//\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
- // Get the variable that containts the TimeZone and Daylight fields\r
+ // Get the variable that contains the TimeZone and Daylight fields\r
//\r
Time->TimeZone = Global->SavedTimeZone;\r
Time->Daylight = Global->Daylight;\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
- // Set the variable that containts the TimeZone and Daylight fields\r
+ // Set the variable that contains the TimeZone and Daylight fields\r
//\r
Global->SavedTimeZone = Time->TimeZone;\r
Global->Daylight = Time->Daylight;\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
Returns the current wakeup alarm clock setting.\r
\r
@param Enabled Indicates if the alarm is currently enabled or disabled.\r
- @param Pending Indicates if the alarm signal is pending and requires acknowledgement.\r
+ @param Pending Indicates if the alarm signal is pending and requires acknowledgment.\r
@param Time The current alarm setting.\r
@param Global For global use inside this module.\r
\r
UINT8 Century;\r
\r
//\r
- // Check paramters for null pointers\r
+ // Check parameters for null pointers\r
//\r
if ((Enabled == NULL) || (Pending == NULL) || (Time == NULL)) {\r
return EFI_INVALID_PARAMETER;\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
}\r
\r
/**\r
- See if centry register of RTC is valid.\r
+ See if century register of RTC is valid.\r
\r
@retval EFI_SUCCESS Century register is valid.\r
@retval EFI_DEVICE_ERROR Century register is NOT valid.\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
\r
/**\r
- Check if it is a leapyear.\r
+ Check if it is a leap year.\r
\r
@param Time The time to be checked.\r
\r
- @retval TRUE It is a leapyear.\r
- @retval FALSE It is NOT a leapyear.\r
+ @retval TRUE It is a leap year.\r
+ @retval FALSE It is NOT a leap year.\r
**/\r
BOOLEAN\r
IsLeapYear (\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