iPXE
efi_time.c File Reference

EFI time source. More...

#include <string.h>
#include <errno.h>
#include <time.h>
#include <ipxe/time.h>
#include <ipxe/efi/efi.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER_OR_UBDL)
 FILE_SECBOOT (PERMITTED)
static time_t efi_get_time (void)
 Get current time in seconds.
 PROVIDE_TIME (efi, time_now, efi_get_time)

Detailed Description

EFI time source.

Definition in file efi_time.c.

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL )

◆ FILE_SECBOOT()

FILE_SECBOOT ( PERMITTED )

◆ efi_get_time()

time_t efi_get_time ( void )
static

Get current time in seconds.

Return values
timeTime, in seconds

Definition at line 44 of file efi_time.c.

44 {
45 EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices;
46 EFI_TIME time;
47 struct tm tm;
48 EFI_STATUS efirc;
49 int rc;
50
51 /* Get current time and date */
52 if ( ( efirc = rs->GetTime ( &time, NULL ) ) != 0 ) {
53 rc = -EEFI ( efirc );
54 DBGC ( rs, "EFITIME could not get system time: %s\n",
55 strerror ( rc ) );
56 /* Nothing meaningful we can return */
57 return 0;
58 }
59
60 /* Construct broken-down time */
61 memset ( &tm, 0, sizeof ( tm ) );
62 tm.tm_sec = time.Second;
63 tm.tm_min = time.Minute;
64 tm.tm_hour = time.Hour;
65 tm.tm_mday = time.Day;
66 tm.tm_mon = ( time.Month - 1 );
67 tm.tm_year = ( time.Year - 1900 );
68 DBGC ( rs, "EFITIME is %04d-%02d-%02d %02d:%02d:%02d\n",
69 ( tm.tm_year + 1900 ), ( tm.tm_mon + 1 ),
71
72 /* Convert to seconds since the Epoch */
73 return mktime ( &tm );
74}
#define NULL
NULL pointer (VOID *)
Definition Base.h:322
RETURN_STATUS EFI_STATUS
Function return status for EFI API.
struct arbelprm_rc_send_wqe rc
Definition arbel.h:3
#define DBGC(...)
Definition compiler.h:505
#define EEFI(efirc)
Convert an EFI status code to an iPXE status code.
Definition efi.h:175
EFI_SYSTEM_TABLE * efi_systab
void * memset(void *dest, int character, size_t len) __nonnull
char * strerror(int errno)
Retrieve string representation of error number.
Definition strerror.c:79
EFI Runtime Services Table.
Definition UefiSpec.h:1880
EFI_GET_TIME GetTime
Definition UefiSpec.h:1889
EFI Time Abstraction: Year: 1900 - 9999 Month: 1 - 12 Day: 1 - 31 Hour: 0 - 23 Minute: 0 - 59 Second:...
UINT8 Second
UINT8 Hour
UINT8 Minute
UINT8 Day
UINT16 Year
UINT8 Month
Broken-down time.
Definition time.h:16
int tm_mon
Month of year [0,11].
Definition time.h:26
int tm_year
Years since 1900.
Definition time.h:28
int tm_hour
Hour [0,23].
Definition time.h:22
int tm_sec
Seconds [0,60].
Definition time.h:18
int tm_mday
Day of month [1,31].
Definition time.h:24
int tm_min
Minutes [0,59].
Definition time.h:20
time_t mktime(struct tm *tm)
Calculate seconds since the Epoch.
Definition time.c:118

References EFI_TIME::Day, DBGC, EEFI, efi_systab, EFI_RUNTIME_SERVICES::GetTime, EFI_TIME::Hour, memset(), EFI_TIME::Minute, mktime(), EFI_TIME::Month, NULL, rc, EFI_TIME::Second, strerror(), tm::tm_hour, tm::tm_mday, tm::tm_min, tm::tm_mon, tm::tm_sec, tm::tm_year, and EFI_TIME::Year.

Referenced by PROVIDE_TIME().

◆ PROVIDE_TIME()

PROVIDE_TIME ( efi ,
time_now ,
efi_get_time  )

References efi_get_time(), and time_now().