//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));\r
if (EFI_ERROR (Status)) {\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
\r
+ //\r
+ // Get the data of Daylight saving and time zone, if they have been\r
+ // stored in NV variable during previous boot.\r
+ //\r
+ DataSize = sizeof (UINT32);\r
+ Status = EfiGetVariable (\r
+ L"RTC",\r
+ &gEfiCallerIdGuid,\r
+ NULL,\r
+ &DataSize,\r
+ (VOID *) &TimerVar\r
+ );\r
+ if (!EFI_ERROR (Status)) {\r
+ Time.TimeZone = (INT16) TimerVar;\r
+ Time.Daylight = (UINT8) (TimerVar >> 16);\r
+ } else {\r
+ Time.TimeZone = EFI_UNSPECIFIED_TIMEZONE;\r
+ Time.Daylight = 0; \r
+ }\r
+\r
//\r
// Validate time fields\r
//\r
Time.Day = RTC_INIT_DAY;\r
Time.Month = RTC_INIT_MONTH;\r
Time.Year = RTC_INIT_YEAR;\r
+ Time.Nanosecond = 0;\r
}\r
- //\r
- // Get the data of Daylight saving and time zone, if they have been\r
- // stored in NV variable during previous boot.\r
- //\r
- DataSize = sizeof (UINT32);\r
- Status = EfiGetVariable (\r
- L"RTC",\r
- &gEfiCallerIdGuid,\r
- NULL,\r
- &DataSize,\r
- (VOID *) &TimerVar\r
- );\r
- if (!EFI_ERROR (Status)) {\r
- Global->SavedTimeZone = (INT16) TimerVar;\r
- Global->Daylight = (UINT8) (TimerVar >> 16);\r
\r
- Time.TimeZone = Global->SavedTimeZone;\r
- Time.Daylight = Global->Daylight;\r
- }\r
//\r
// Reset time value according to new RTC configuration\r
//\r
- PcRtcSetTime (&Time, Global);\r
-\r
- return EFI_SUCCESS;\r
+ Status = PcRtcSetTime (&Time, Global);\r
+ if(!EFI_ERROR (Status)) {\r
+ return EFI_SUCCESS;\r
+ } else {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
}\r
\r
/**\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));\r
if (EFI_ERROR (Status)) {\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
+\r
//\r
// Get the variable that contains the TimeZone and Daylight fields\r
//\r
if (EFI_ERROR (Status)) {\r
return EFI_DEVICE_ERROR;\r
}\r
+\r
//\r
// Fill in Capabilities if it was passed in\r
//\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));\r
if (EFI_ERROR (Status)) {\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));\r
if (EFI_ERROR (Status)) {\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
+\r
+ //\r
+ // Get the variable that contains the TimeZone and Daylight fields\r
+ //\r
+ Time->TimeZone = Global->SavedTimeZone;\r
+ Time->Daylight = Global->Daylight;\r
+\r
//\r
// Make sure all field values are in correct range\r
//\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
Status = RtcWaitToUpdate (PcdGet32 (PcdRealTimeClockUpdateTimeout));\r
if (EFI_ERROR (Status)) {\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
}\r
\r
Time->Nanosecond = 0;\r
- Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;\r
- Time->Daylight = 0;\r
\r
return EFI_SUCCESS;\r
}\r
Time->Year > 2099 ||\r
Time->Month < 1 ||\r
Time->Month > 12 ||\r
+ (!DayValid (Time)) ||\r
Time->Hour > 23 ||\r
Time->Minute > 59 ||\r
Time->Second > 59 ||\r
Time->Nanosecond > 999999999 ||\r
(!(Time->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||\r
- ((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)\r
- ) {\r
- if (!DayValid (Time)) {\r
- return EFI_INVALID_PARAMETER;\r
- }\r
+ ((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)) {\r
+ return EFI_INVALID_PARAMETER;\r
}\r
\r
return EFI_SUCCESS;\r