26STATIC CONST CHAR16 mEpochVariableName[] = L
"RtcEpochSeconds";
27STATIC CONST CHAR16 mTimeZoneVariableName[] = L
"RtcTimeZone";
28STATIC CONST CHAR16 mDaylightVariableName[] = L
"RtcDaylight";
60 return EFI_INVALID_PARAMETER;
66 return EFI_DEVICE_ERROR;
70 Size =
sizeof (
UINTN);
73 (CHAR16 *)mEpochVariableName,
80 if (EFI_ERROR (Status)) {
81 ASSERT (Status != EFI_INVALID_PARAMETER);
82 ASSERT (Status != EFI_BUFFER_TOO_SMALL);
89 EpochSeconds = BUILD_EPOCH;
92 "LibGetTime: %s non volatile variable was not found - Using compilation time epoch.\n",
97 (CHAR16 *)mEpochVariableName,
100 sizeof (EpochSeconds),
109 Size =
sizeof (TimeZone);
111 (CHAR16 *)mTimeZoneVariableName,
118 if (EFI_ERROR (Status)) {
119 ASSERT (Status != EFI_INVALID_PARAMETER);
120 ASSERT (Status != EFI_BUFFER_TOO_SMALL);
122 if (Status != EFI_NOT_FOUND) {
130 (CHAR16 *)mTimeZoneVariableName,
134 (VOID *)&(Time->TimeZone)
136 if (EFI_ERROR (Status)) {
139 "LibGetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
140 mTimeZoneVariableName,
147 Time->TimeZone = TimeZone;
150 if ( ((Time->TimeZone < -1440) || (Time->TimeZone > 1440))
158 EpochSeconds += Time->TimeZone * SEC_PER_MIN;
163 Size =
sizeof (Daylight);
165 (CHAR16 *)mDaylightVariableName,
172 if (EFI_ERROR (Status)) {
173 ASSERT (Status != EFI_INVALID_PARAMETER);
174 ASSERT (Status != EFI_BUFFER_TOO_SMALL);
176 if (Status != EFI_NOT_FOUND) {
184 (CHAR16 *)mDaylightVariableName,
188 (VOID *)&(Time->Daylight)
190 if (EFI_ERROR (Status)) {
193 "LibGetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
194 mDaylightVariableName,
201 Time->Daylight = Daylight;
204 if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {
206 EpochSeconds += SEC_PER_HOUR;
214 if (Remainder <= 18446744073U) {
215 Time->Nanosecond = (UINT32)(
MultU64x64 (Remainder, 1000000000U) / Freq);
217 DEBUG ((DEBUG_WARN,
"LibGetTime: Nanosecond value not set (64-bit overflow).\n"));
221 Capabilities->Accuracy = 0;
222 Capabilities->Resolution = 1;
223 Capabilities->SetsToZero =
FALSE;
252 return EFI_INVALID_PARAMETER;
259 && (EpochSeconds > Time->TimeZone * SEC_PER_MIN))
261 EpochSeconds -= Time->TimeZone * SEC_PER_MIN;
265 if ( ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT)
266 && (EpochSeconds > SEC_PER_HOUR))
269 EpochSeconds -= SEC_PER_HOUR;
286 (CHAR16 *)mTimeZoneVariableName,
289 sizeof (Time->TimeZone),
290 (VOID *)&(Time->TimeZone)
292 if (EFI_ERROR (Status)) {
295 "LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
296 mTimeZoneVariableName,
304 (CHAR16 *)mDaylightVariableName,
307 sizeof (Time->Daylight),
308 (VOID *)&(Time->Daylight)
310 if (EFI_ERROR (Status)) {
313 "LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
314 mDaylightVariableName,
321 (CHAR16 *)mEpochVariableName,
324 sizeof (EpochSeconds),
327 if (EFI_ERROR (Status)) {
330 "LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",
355 OUT BOOLEAN *Enabled,
356 OUT BOOLEAN *Pending,
360 return EFI_UNSUPPORTED;
383 return EFI_UNSUPPORTED;
UINT64 EFIAPI GetPerformanceCounterProperties(OUT UINT64 *StartValue OPTIONAL, OUT UINT64 *EndValue OPTIONAL)
UINT64 EFIAPI GetPerformanceCounter(VOID)
UINT64 EFIAPI MultU64x64(IN UINT64 Multiplicand, IN UINT64 Multiplier)
UINT64 EFIAPI DivU64x64Remainder(IN UINT64 Dividend, IN UINT64 Divisor, OUT UINT64 *Remainder OPTIONAL)
#define DEBUG(Expression)
UINTN EFIAPI EfiTimeToEpoch(IN EFI_TIME *Time)
VOID EFIAPI EpochToEfiTime(IN UINTN EpochSeconds, OUT EFI_TIME *Time)
BOOLEAN EFIAPI IsTimeValid(IN EFI_TIME *Time)
#define EFI_VARIABLE_NON_VOLATILE
EFI_STATUS EFIAPI EfiGetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, OUT UINT32 *Attributes OPTIONAL, IN OUT UINTN *DataSize, OUT VOID *Data)
EFI_STATUS EFIAPI EfiSetVariable(IN CHAR16 *VariableName, IN EFI_GUID *VendorGuid, IN UINT32 Attributes, IN UINTN DataSize, IN VOID *Data)
#define EFI_UNSPECIFIED_TIMEZONE
EFI_STATUS EFIAPI LibSetWakeupTime(IN BOOLEAN Enabled, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibRtcInitialize(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
EFI_STATUS EFIAPI LibGetWakeupTime(OUT BOOLEAN *Enabled, OUT BOOLEAN *Pending, OUT EFI_TIME *Time)
EFI_STATUS EFIAPI LibSetTime(IN EFI_TIME *Time)
EFI_STATUS EFIAPI LibGetTime(OUT EFI_TIME *Time, OUT EFI_TIME_CAPABILITIES *Capabilities)