//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\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
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
- //\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
DataSize = sizeof (UINT32);\r
Status = EfiGetVariable (\r
- L"TimerVar",\r
- &gEfiGenericPlatformVariableGuid,\r
+ L"RTC",\r
+ &gEfiCallerIdGuid,\r
NULL,\r
&DataSize,\r
(VOID *) &TimerVar\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\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
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\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
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\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
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
TimerVar = Time->Daylight;\r
TimerVar = (UINT32) ((TimerVar << 16) | Time->TimeZone);\r
Status = EfiSetVariable (\r
- L"TimerVar",\r
- &gEfiGenericPlatformVariableGuid,\r
+ L"RTC",\r
+ &gEfiCallerIdGuid,\r
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,\r
sizeof (TimerVar),\r
&TimerVar\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\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
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
// Just support set alarm time within 24 hours\r
//\r
PcRtcGetTime (&RtcTime, &Capabilities, Global);\r
+ Status = RtcTimeFieldsValid (&RtcTime);\r
+ if (EFI_ERROR (Status)) {\r
+ return EFI_DEVICE_ERROR;\r
+ }\r
if (!IsWithinOneDay (&RtcTime, Time)) {\r
return EFI_UNSUPPORTED;\r
}\r
//\r
// Acquire RTC Lock to make access to RTC atomic\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
- // provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\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
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Release RTC Lock.\r
//\r
- //BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
- // provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
+ //Code here doesn't consider the runtime environment.\r
if (!EfiAtRuntime ()) {\r
EfiReleaseLock (&Global->RtcLock);\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->TimeZone == EFI_UNSPECIFIED_TIMEZONE || (Time->TimeZone >= -1440 && Time->TimeZone <= 1440))) ||\r
((Time->Daylight & (~(EFI_TIME_ADJUST_DAYLIGHT | EFI_TIME_IN_DAYLIGHT))) != 0)\r
) {\r
- return EFI_INVALID_PARAMETER;\r
+ if (!DayValid (Time)) {\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
}\r
\r
return EFI_SUCCESS;\r
DayOfMonth[10] = 30;\r
DayOfMonth[11] = 31;\r
\r
+ //\r
+ // The validity of Time->Month field should be checked before\r
+ //\r
+ ASSERT (Time->Month >=1);\r
+ ASSERT (Time->Month <=12);\r
if (Time->Day < 1 ||\r
Time->Day > DayOfMonth[Time->Month - 1] ||\r
(Time->Month == 2 && (!IsLeapYear (Time) && Time->Day > 28))\r
\r
Adjacent = FALSE;\r
\r
+ //\r
+ // The validity of From->Month field should be checked before\r
+ //\r
+ ASSERT (From->Month >=1);\r
+ ASSERT (From->Month <=12);\r
+ \r
if (From->Year == To->Year) {\r
if (From->Month == To->Month) {\r
if ((From->Day + 1) == To->Day) {\r