/** @file\r
Provides Set/Get time operations.\r
\r
-Copyright (c) 2006 - 2007, Intel Corporation\r
+Copyright (c) 2006 - 2008, Intel Corporation\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
\r
PC_RTC_MODULE_GLOBALS mModuleGlobal;\r
\r
-EFI_STATUS\r
-EFIAPI\r
-PcRtcEfiGetTime (\r
- OUT EFI_TIME *Time,\r
- OUT EFI_TIME_CAPABILITIES *Capabilities\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
+EFI_HANDLE mHandle = NULL;\r
\r
-Arguments:\r
\r
- Time - GC_TODO: add argument description\r
- Capabilities - GC_TODO: add argument description\r
+/**\r
+ Returns the current time and date information, and the time-keeping capabilities\r
+ of the hardware platform.\r
\r
-Returns:\r
+ @param Time A pointer to storage to receive a snapshot of the current time.\r
+ @param Capabilities An optional pointer to a buffer to receive the real time\r
+ clock device's capabilities.\r
\r
- GC_TODO: add return values\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER Time is NULL.\r
+ @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.\r
\r
---*/\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+PcRtcEfiGetTime (\r
+ OUT EFI_TIME *Time,\r
+ OUT EFI_TIME_CAPABILITIES *Capabilities OPTIONAL\r
+ )\r
{\r
return PcRtcGetTime (Time, Capabilities, &mModuleGlobal);\r
}\r
\r
+/**\r
+ Sets the current local time and date information.\r
+\r
+ @param Time A pointer to the current time.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+ @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
PcRtcEfiSetTime (\r
IN EFI_TIME *Time\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
{\r
return PcRtcSetTime (Time, &mModuleGlobal);\r
}\r
\r
+/**\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 Time The current alarm setting.\r
+\r
+ @retval EFI_SUCCESS The alarm settings were returned.\r
+ @retval EFI_INVALID_PARAMETER Enabled is NULL.\r
+ @retval EFI_INVALID_PARAMETER Pending is NULL.\r
+ @retval EFI_INVALID_PARAMETER Time is NULL.\r
+ @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
+\r
+**/\r
EFI_STATUS\r
EFIAPI\r
PcRtcEfiGetWakeupTime (\r
OUT BOOLEAN *Pending,\r
OUT EFI_TIME *Time\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
+{\r
+ return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
+}\r
\r
- Enabled - GC_TODO: add argument description\r
- Pending - GC_TODO: add argument description\r
- Time - GC_TODO: add argument description\r
\r
-Returns:\r
+/**\r
+ Sets the system wakeup alarm clock time.\r
\r
- GC_TODO: add return values\r
+ @param Enabled Enable or disable the wakeup alarm.\r
+ @param Time If Enable is TRUE, the time to set the wakeup alarm for.\r
+ If Enable is FALSE, then this parameter is optional, and may be NULL.\r
\r
---*/\r
-{\r
- return PcRtcGetWakeupTime (Enabled, Pending, Time, &mModuleGlobal);\r
-}\r
+ @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r
+ If Enable is FALSE, then the wakeup alarm was disabled.\r
+ @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+ @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
PcRtcEfiSetWakeupTime (\r
IN BOOLEAN Enabled,\r
- OUT EFI_TIME *Time\r
+ IN EFI_TIME *Time OPTIONAL\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
+{\r
+ return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
+}\r
\r
- Enabled - GC_TODO: add argument description\r
- Time - GC_TODO: add argument description\r
+/**\r
+ The user Entry Point for PcRTC module.\r
\r
-Returns:\r
+ This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
+ including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
\r
- GC_TODO: add return values\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
\r
---*/\r
-{\r
- return PcRtcSetWakeupTime (Enabled, Time, &mModuleGlobal);\r
-}\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval Others Some error occurs when executing this entry point.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
InitializePcRtc (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
-\r
-\r
-Returns:\r
---*/\r
-// GC_TODO: ImageHandle - add argument and description to function comment\r
-// GC_TODO: SystemTable - add argument and description to function comment\r
{\r
EFI_STATUS Status;\r
- EFI_HANDLE NewHandle;\r
\r
EfiInitializeLock (&mModuleGlobal.RtcLock, TPL_HIGH_LEVEL);\r
\r
gRT->GetWakeupTime = PcRtcEfiGetWakeupTime;\r
gRT->SetWakeupTime = PcRtcEfiSetWakeupTime;\r
\r
- NewHandle = NULL;\r
Status = gBS->InstallMultipleProtocolInterfaces (\r
- &NewHandle,\r
+ &mHandle,\r
&gEfiRealTimeClockArchProtocolGuid,\r
NULL,\r
NULL\r
);\r
+ ASSERT_EFI_ERROR (Status);\r
\r
return Status;\r
}\r
\r
#include "PcRtc.h"\r
\r
+/**\r
+ Compare the Hour, Minute and Second of the From time and the To time.\r
+ \r
+ Only compare H/M/S in EFI_TIME and ignore other fields here.\r
+\r
+ @param From the first time\r
+ @param To the second time\r
+\r
+ @return >0 The H/M/S of the From time is later than those of To time\r
+ @return ==0 The H/M/S of the From time is same as those of To time\r
+ @return <0 The H/M/S of the From time is earlier than those of To time\r
+**/\r
INTN\r
CompareHMS (\r
IN EFI_TIME *From,\r
IN EFI_TIME *To\r
);\r
\r
+/**\r
+ To check if second date is later than first date within 24 hours.\r
+\r
+ @param From the first date\r
+ @param To the second date\r
+\r
+ @retval TRUE From is previous to To within 24 hours.\r
+ @retval FALSE From is later, or it is previous to To more than 24 hours.\r
+**/\r
BOOLEAN\r
IsWithinOneDay (\r
IN EFI_TIME *From,\r
IN EFI_TIME *To\r
);\r
\r
+/**\r
+ Read RTC content through its registers.\r
+\r
+ @param Address Address offset of RTC. It is recommended to use macros such as\r
+ RTC_ADDRESS_SECONDS.\r
+\r
+ @return The data of UINT8 type read from RTC.\r
+**/\r
UINT8\r
RtcRead (\r
IN UINT8 Address\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Address - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
{\r
IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));\r
return IoRead8 (PCAT_RTC_DATA_REGISTER);\r
}\r
\r
+/**\r
+ Write RTC through its registers.\r
+\r
+ @param Address Address offset of RTC. It is recommended to use macros such as\r
+ RTC_ADDRESS_SECONDS.\r
+ @param Data The content you want to write into RTC.\r
+\r
+**/\r
VOID\r
RtcWrite (\r
IN UINT8 Address,\r
IN UINT8 Data\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Address - GC_TODO: add argument description\r
- Data - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
{\r
IoWrite8 (PCAT_RTC_ADDRESS_REGISTER, (UINT8) (Address | (UINT8) (IoRead8 (PCAT_RTC_ADDRESS_REGISTER) & 0x80)));\r
IoWrite8 (PCAT_RTC_DATA_REGISTER, Data);\r
}\r
\r
+/**\r
+ Initialize RTC.\r
+\r
+ @param Global For global use inside this module.\r
+\r
+ @retval EFI_DEVICE_ERROR Initialization failed due to device error.\r
+ @retval EFI_SUCCESS Initialization successful.\r
+\r
+**/\r
EFI_STATUS\r
PcRtcInit (\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Global - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- EFI_DEVICE_ERROR - GC_TODO: Add description for return value\r
- EFI_SUCCESS - GC_TODO: Add description for return value\r
-\r
---*/\r
{\r
EFI_STATUS Status;\r
RTC_REGISTER_A RegisterA;\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
if (!EfiAtRuntime ()) {\r
- EfiAcquireLock (&Global->RtcLock);\r
+ EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
// Initialize RTC Register\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
return EFI_DEVICE_ERROR;\r
}\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
//\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
\r
//\r
return EFI_SUCCESS;\r
}\r
\r
-EFI_STATUS\r
-PcRtcGetTime (\r
- OUT EFI_TIME *Time,\r
- IN EFI_TIME_CAPABILITIES *Capabilities,\r
- IN PC_RTC_MODULE_GLOBALS *Global\r
- )\r
-/*++\r
+/**\r
+ Returns the current time and date information, and the time-keeping capabilities\r
+ of the hardware platform.\r
\r
-Routine Description:\r
+ @param Time A pointer to storage to receive a snapshot of the current time.\r
+ @param Capabilities An optional pointer to a buffer to receive the real time clock\r
+ device's capabilities.\r
+ @param Global For global use inside this module.\r
\r
- Arguments:\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER Time is NULL.\r
+ @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.\r
\r
- Returns:\r
---*/\r
-// GC_TODO: Time - add argument and description to function comment\r
-// GC_TODO: Capabilities - add argument and description to function comment\r
-// GC_TODO: Global - add argument and description to function comment\r
-// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
+**/\r
+EFI_STATUS\r
+PcRtcGetTime (\r
+ OUT EFI_TIME *Time,\r
+ OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL\r
+ IN PC_RTC_MODULE_GLOBALS *Global\r
+ )\r
{\r
EFI_STATUS Status;\r
RTC_REGISTER_B RegisterB;\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
if (!EfiAtRuntime ()) {\r
- EfiAcquireLock (&Global->RtcLock);\r
+ EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
// Wait for up to 0.1 seconds for the RTC to be updated\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
// provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
return Status;\r
}\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
// provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Get the variable that containts the TimeZone and Daylight fields\r
//\r
// Fill in Capabilities if it was passed in\r
//\r
- if (Capabilities) {\r
+ if (Capabilities != NULL) {\r
Capabilities->Resolution = 1;\r
//\r
// 1 hertz\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Sets the current local time and date information.\r
+\r
+ @param Time A pointer to the current time.\r
+ @param Global For global use inside this module.\r
+\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+ @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.\r
+\r
+**/\r
EFI_STATUS\r
PcRtcSetTime (\r
IN EFI_TIME *Time,\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
- Returns:\r
---*/\r
-// GC_TODO: Time - add argument and description to function comment\r
-// GC_TODO: Global - add argument and description to function comment\r
-// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
{\r
EFI_STATUS Status;\r
EFI_TIME RtcTime;\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
if (!EfiAtRuntime ()) {\r
- EfiAcquireLock (&Global->RtcLock);\r
+ EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
// Wait for up to 0.1 seconds for the RTC to be updated\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
// provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Set the variable that containts the TimeZone and Daylight fields\r
return EFI_SUCCESS;\r
}\r
\r
+/**\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 Time The current alarm setting.\r
+ @param Global For global use inside this module.\r
+\r
+ @retval EFI_SUCCESS The alarm settings were returned.\r
+ @retval EFI_INVALID_PARAMETER Enabled is NULL.\r
+ @retval EFI_INVALID_PARAMETER Pending is NULL.\r
+ @retval EFI_INVALID_PARAMETER Time is NULL.\r
+ @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
+\r
+**/\r
EFI_STATUS\r
PcRtcGetWakeupTime (\r
OUT BOOLEAN *Enabled,\r
OUT BOOLEAN *Pending,\r
OUT EFI_TIME *Time,\r
- IN PC_RTC_MODULE_GLOBALS *Global\r
+ IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
-\r
-\r
-Returns:\r
---*/\r
-// GC_TODO: Enabled - add argument and description to function comment\r
-// GC_TODO: Pending - add argument and description to function comment\r
-// GC_TODO: Time - add argument and description to function comment\r
-// GC_TODO: Global - add argument and description to function comment\r
-// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
{\r
EFI_STATUS Status;\r
RTC_REGISTER_B RegisterB;\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
if (!EfiAtRuntime ()) {\r
- EfiAcquireLock (&Global->RtcLock);\r
+ EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
// Wait for up to 0.1 seconds for the RTC to be updated\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
// provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
//\r
// Make sure all field values are in correct range\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Sets the system wakeup alarm clock time.\r
+\r
+ @param Enabled Enable or disable the wakeup alarm.\r
+ @param Time If Enable is TRUE, the time to set the wakeup alarm for.\r
+ If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+ @param Global For global use inside this module.\r
+\r
+ @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r
+ If Enable is FALSE, then the wakeup alarm was disabled.\r
+ @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+ @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
+\r
+**/\r
EFI_STATUS\r
PcRtcSetWakeupTime (\r
IN BOOLEAN Enable,\r
- OUT EFI_TIME *Time,\r
+ IN EFI_TIME *Time, OPTIONAL\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
-\r
-\r
-Returns:\r
---*/\r
-// GC_TODO: Enable - add argument and description to function comment\r
-// GC_TODO: Time - add argument and description to function comment\r
-// GC_TODO: Global - add argument and description to function comment\r
-// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
-// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
-// GC_TODO: EFI_UNSUPPORTED - add return value to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
{\r
EFI_STATUS Status;\r
EFI_TIME RtcTime;\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiAcquireLock or\r
// provide a new instance for EfiAcquireLock, say, RtEfiAcquireLock\r
if (!EfiAtRuntime ()) {\r
- EfiAcquireLock (&Global->RtcLock);\r
+ EfiAcquireLock (&Global->RtcLock);\r
}\r
//\r
// Wait for up to 0.1 seconds for the RTC to be updated\r
//BugBug: the EfiAtRuntime should be encapsulated in EfiReleaseLock or\r
// provide a new instance for EfiReleaseLock, say, RtEfiReleaseLock\r
if (!EfiAtRuntime ()) {\r
- EfiReleaseLock (&Global->RtcLock);\r
+ EfiReleaseLock (&Global->RtcLock);\r
}\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ See if centry 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
+**/\r
EFI_STATUS\r
RtcTestCenturyRegister (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
-\r
-\r
-Returns:\r
---*/\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
{\r
UINT8 Century;\r
UINT8 Temp;\r
\r
Century = RtcRead (RTC_ADDRESS_CENTURY);\r
- //\r
- // RtcWrite (RTC_ADDRESS_CENTURY, 0x00);\r
- //\r
Temp = (UINT8) (RtcRead (RTC_ADDRESS_CENTURY) & 0x7f);\r
RtcWrite (RTC_ADDRESS_CENTURY, Century);\r
if (Temp == 0x19 || Temp == 0x20) {\r
If valid, the function converts it to an 8-bit value and returns it.\r
Otherwise, return 0xff.\r
\r
- @param Value The 8-bit BCD value to check and convert\r
+ @param Value The 8-bit BCD value to check and convert\r
\r
- @return The 8-bit value converted.\r
- 0xff if Value is invalid.\r
+ @return The 8-bit value converted. Or 0xff if Value is invalid.\r
\r
**/\r
UINT8\r
@param RegisterB Value of Register B of RTC, indicating data mode\r
and hour format.\r
\r
+ @retval EFI_INVALID_PARAMETER Parameters passed in are invalid.\r
+ @retval EFI_SUCCESS Convert RTC time to EFI time successfully.\r
+\r
**/\r
EFI_STATUS\r
ConvertRtcTimeToEfiTime (\r
IN RTC_REGISTER_B RegisterB\r
)\r
{\r
- BOOLEAN PM;\r
+ BOOLEAN IsPM;\r
\r
if ((Time->Hour) & 0x80) {\r
- PM = TRUE;\r
+ IsPM = TRUE;\r
} else {\r
- PM = FALSE;\r
+ IsPM = FALSE;\r
}\r
\r
Time->Hour = (UINT8) (Time->Hour & 0x7f);\r
// If time is in 12 hour format, convert it to 24 hour format\r
//\r
if (RegisterB.Bits.MIL == 0) {\r
- if (PM && Time->Hour < 12) {\r
+ if (IsPM && Time->Hour < 12) {\r
Time->Hour = (UINT8) (Time->Hour + 12);\r
}\r
\r
- if (!PM && Time->Hour == 12) {\r
+ if (!IsPM && Time->Hour == 12) {\r
Time->Hour = 0;\r
}\r
}\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ Wait for a period for the RTC to be ready.\r
+\r
+ @param Timeout Tell how long it should take to wait.\r
+\r
+ @retval EFI_DEVICE_ERROR RTC device error.\r
+ @retval EFI_SUCCESS RTC is updated and ready. \r
+**/\r
EFI_STATUS\r
RtcWaitToUpdate (\r
UINTN Timeout\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
-\r
-Returns:\r
---*/\r
-// GC_TODO: Timeout - add argument and description to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO: EFI_DEVICE_ERROR - add return value to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
{\r
RTC_REGISTER_A RegisterA;\r
RTC_REGISTER_D RegisterD;\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ See if all fields of a variable of EFI_TIME type is correct.\r
+\r
+ @param Time The time to be checked.\r
+\r
+ @retval EFI_INVALID_PARAMETER Some fields of Time are not correct.\r
+ @retval EFI_SUCCESS Time is a valid EFI_TIME variable.\r
+\r
+**/\r
EFI_STATUS\r
RtcTimeFieldsValid (\r
IN EFI_TIME *Time\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Arguments:\r
-\r
- Returns:\r
---*/\r
-// GC_TODO: Time - add argument and description to function comment\r
-// GC_TODO: EFI_INVALID_PARAMETER - add return value to function comment\r
-// GC_TODO: EFI_SUCCESS - add return value to function comment\r
{\r
if (Time->Year < 1998 ||\r
Time->Year > 2099 ||\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+ See if field Day of an EFI_TIME is correct.\r
+\r
+ @param Time Its Day field is to be checked.\r
+\r
+ @retval TRUE Day field of Time is correct.\r
+ @retval FALSE Day field of Time is NOT correct.\r
+**/\r
BOOLEAN\r
DayValid (\r
IN EFI_TIME *Time\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
{\r
INTN DayOfMonth[12];\r
\r
return TRUE;\r
}\r
\r
+/**\r
+ Check if it is a leapyear.\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
+**/\r
BOOLEAN\r
IsLeapYear (\r
IN EFI_TIME *Time\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
{\r
if (Time->Year % 4 == 0) {\r
if (Time->Year % 100 == 0) {\r
}\r
}\r
\r
-VOID\r
-ConvertEfiTimeToRtcTime (\r
- IN EFI_TIME *Time,\r
- IN RTC_REGISTER_B RegisterB,\r
- IN UINT8 *Century\r
- )\r
-/*++\r
-\r
-Routine Description:\r
+/**\r
+ Converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
\r
- Arguments:\r
+ This function converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
+ If data mode of RTC is BCD, then converts EFI_TIME to it.\r
+ If RTC is in 12-hour format, then converts EFI_TIME to it.\r
\r
+ @param Time On input, the time data read from UEFI to convert\r
+ On output, the time converted to RTC format\r
+ @param RegisterB Value of Register B of RTC, indicating data mode\r
+ @param Century It is set according to EFI_TIME Time.\r
\r
-Returns:\r
---*/\r
-// GC_TODO: Time - add argument and description to function comment\r
-// GC_TODO: RegisterB - add argument and description to function comment\r
-// GC_TODO: Century - add argument and description to function comment\r
+**/\r
+VOID\r
+ConvertEfiTimeToRtcTime (\r
+ IN OUT EFI_TIME *Time,\r
+ IN RTC_REGISTER_B RegisterB,\r
+ OUT UINT8 *Century\r
+ )\r
{\r
- BOOLEAN PM;\r
+ BOOLEAN IsPM;\r
\r
- PM = TRUE;\r
+ IsPM = TRUE;\r
//\r
- // Adjust hour field if RTC in in 12 hour mode\r
+ // Adjust hour field if RTC is in 12 hour mode\r
//\r
if (RegisterB.Bits.MIL == 0) {\r
if (Time->Hour < 12) {\r
- PM = FALSE;\r
+ IsPM = FALSE;\r
}\r
\r
if (Time->Hour >= 13) {\r
//\r
// If we are in 12 hour mode and PM is set, then set bit 7 of the Hour field.\r
//\r
- if (RegisterB.Bits.MIL == 0 && PM) {\r
+ if (RegisterB.Bits.MIL == 0 && IsPM) {\r
Time->Hour = (UINT8) (Time->Hour | 0x80);\r
}\r
}\r
\r
+/**\r
+ Compare the Hour, Minute and Second of the From time and the To time.\r
+ \r
+ Only compare H/M/S in EFI_TIME and ignore other fields here.\r
+\r
+ @param From the first time\r
+ @param To the second time\r
+\r
+ @return >0 The H/M/S of the From time is later than those of To time\r
+ @return ==0 The H/M/S of the From time is same as those of To time\r
+ @return <0 The H/M/S of the From time is earlier than those of To time\r
+**/\r
INTN\r
CompareHMS (\r
IN EFI_TIME *From,\r
IN EFI_TIME *To\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Compare the Hour, Minute and Second of the 'From' time and the 'To' time.\r
- Only compare H/M/S in EFI_TIME and ignore other fields here.\r
-\r
-Arguments:\r
-\r
- From - the first time\r
- To - the second time\r
-\r
-Returns:\r
-\r
- >0 : The H/M/S of the 'From' time is later than those of 'To' time\r
- ==0 : The H/M/S of the 'From' time is same as those of 'To' time\r
- <0 : The H/M/S of the 'From' time is earlier than those of 'To' time\r
-\r
---*/\r
{\r
if ((From->Hour > To->Hour) ||\r
((From->Hour == To->Hour) && (From->Minute > To->Minute)) ||\r
}\r
}\r
\r
+/**\r
+ To check if second date is later than first date within 24 hours.\r
+\r
+ @param From the first date\r
+ @param To the second date\r
+\r
+ @retval TRUE From is previous to To within 24 hours.\r
+ @retval FALSE From is later, or it is previous to To more than 24 hours.\r
+**/\r
BOOLEAN\r
IsWithinOneDay (\r
IN EFI_TIME *From,\r
IN EFI_TIME *To\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- Judge whether two days are adjacent.\r
-\r
-Arguments:\r
-\r
- From - the first day\r
- To - the second day\r
-\r
-Returns:\r
-\r
- TRUE - The interval of two days are within one day.\r
- FALSE - The interval of two days exceed ony day or parameter error.\r
-\r
---*/\r
{\r
UINT8 DayOfMonth[12];\r
BOOLEAN Adjacent;\r
\r
#pragma pack()\r
\r
+/**\r
+ Initialize RTC.\r
+\r
+ @param Global For global use inside this module.\r
+\r
+ @retval EFI_DEVICE_ERROR Initialization failed due to device error.\r
+ @retval EFI_SUCCESS Initialization successful.\r
+\r
+**/\r
EFI_STATUS\r
PcRtcInit (\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Global - GC_TODO: add argument description\r
+;\r
\r
-Returns:\r
+/**\r
+ Sets the current local time and date information.\r
\r
- GC_TODO: add return values\r
+ @param Time A pointer to the current time.\r
+ @param Global For global use inside this module.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+ @retval EFI_DEVICE_ERROR The time could not be set due due to hardware error.\r
\r
+**/\r
EFI_STATUS\r
PcRtcSetTime (\r
IN EFI_TIME *Time,\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
- Global - GC_TODO: add argument description\r
+;\r
\r
-Returns:\r
+/**\r
+ Returns the current time and date information, and the time-keeping capabilities\r
+ of the hardware platform.\r
\r
- GC_TODO: add return values\r
+ @param Time A pointer to storage to receive a snapshot of the current time.\r
+ @param Capabilities An optional pointer to a buffer to receive the real time clock\r
+ device's capabilities.\r
+ @param Global For global use inside this module.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS The operation completed successfully.\r
+ @retval EFI_INVALID_PARAMETER Time is NULL.\r
+ @retval EFI_DEVICE_ERROR The time could not be retrieved due to hardware error.\r
\r
+**/\r
EFI_STATUS\r
PcRtcGetTime (\r
OUT EFI_TIME *Time,\r
- IN EFI_TIME_CAPABILITIES *Capabilities,\r
+ OUT EFI_TIME_CAPABILITIES *Capabilities, OPTIONAL\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
- Capabilities - GC_TODO: add argument description\r
- Global - GC_TODO: add argument description\r
+;\r
\r
-Returns:\r
+/**\r
+ Sets the system wakeup alarm clock time.\r
\r
- GC_TODO: add return values\r
+ @param Enabled Enable or disable the wakeup alarm.\r
+ @param Time If Enable is TRUE, the time to set the wakeup alarm for.\r
+ If Enable is FALSE, then this parameter is optional, and may be NULL.\r
+ @param Global For global use inside this module.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS If Enable is TRUE, then the wakeup alarm was enabled.\r
+ If Enable is FALSE, then the wakeup alarm was disabled.\r
+ @retval EFI_INVALID_PARAMETER A time field is out of range.\r
+ @retval EFI_DEVICE_ERROR The wakeup time could not be set due to a hardware error.\r
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
\r
+**/\r
EFI_STATUS\r
PcRtcSetWakeupTime (\r
IN BOOLEAN Enable,\r
- OUT EFI_TIME *Time,\r
- IN PC_RTC_MODULE_GLOBALS *Global\r
+ IN EFI_TIME *Time, OPTIONAL\r
+ IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Enable - GC_TODO: add argument description\r
- Time - GC_TODO: add argument description\r
- Global - GC_TODO: add argument description\r
+;\r
\r
-Returns:\r
+/**\r
+ Returns the current wakeup alarm clock setting.\r
\r
- GC_TODO: add return values\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 Time The current alarm setting.\r
+ @param Global For global use inside this module.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS The alarm settings were returned.\r
+ @retval EFI_INVALID_PARAMETER Enabled is NULL.\r
+ @retval EFI_INVALID_PARAMETER Pending is NULL.\r
+ @retval EFI_INVALID_PARAMETER Time is NULL.\r
+ @retval EFI_DEVICE_ERROR The wakeup time could not be retrieved due to a hardware error.\r
+ @retval EFI_UNSUPPORTED A wakeup timer is not supported on this platform.\r
\r
+**/\r
EFI_STATUS\r
PcRtcGetWakeupTime (\r
OUT BOOLEAN *Enabled,\r
OUT EFI_TIME *Time,\r
IN PC_RTC_MODULE_GLOBALS *Global\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
+;\r
\r
- Enabled - GC_TODO: add argument description\r
- Pending - GC_TODO: add argument description\r
- Time - GC_TODO: add argument description\r
- Global - GC_TODO: add argument description\r
+/**\r
+ The user Entry Point for PcRTC module.\r
\r
-Returns:\r
+ This is the entrhy point for PcRTC module. It installs the UEFI runtime service\r
+ including GetTime(),SetTime(),GetWakeupTime(),and SetWakeupTime().\r
\r
- GC_TODO: add return values\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
\r
---*/\r
-;\r
+ @retval EFI_SUCCESS The entry point is executed successfully.\r
+ @retval Others Some error occurs when executing this entry point.\r
\r
+**/\r
EFI_STATUS\r
EFIAPI\r
InitializePcRtc (\r
IN EFI_HANDLE ImageHandle,\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- ImageHandle - GC_TODO: add argument description\r
- SystemTable - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
-UINT8\r
-BcdToDecimal (\r
- IN UINT8 BcdValue\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- BcdValue - GC_TODO: add argument description\r
-\r
-Returns:\r
+/**\r
+ See if all fields of a variable of EFI_TIME type is correct.\r
\r
- GC_TODO: add return values\r
+ @param Time The time to be checked.\r
\r
---*/\r
-;\r
+ @retval EFI_INVALID_PARAMETER Some fields of Time are not correct.\r
+ @retval EFI_SUCCESS Time is a valid EFI_TIME variable.\r
\r
+**/\r
EFI_STATUS\r
RtcTimeFieldsValid (\r
IN EFI_TIME *Time\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
-UINT8\r
-DecimaltoBcd (\r
- IN UINT8 DecValue\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- DecValue - GC_TODO: add argument description\r
-\r
-Returns:\r
+/**\r
+ Converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
\r
- GC_TODO: add return values\r
+ This function converts time from EFI_TIME format defined by UEFI spec to RTC's.\r
+ If data mode of RTC is BCD, then converts EFI_TIME to it.\r
+ If RTC is in 12-hour format, then converts EFI_TIME to it.\r
\r
---*/\r
-;\r
+ @param Time On input, the time data read from UEFI to convert\r
+ On output, the time converted to RTC format\r
+ @param RegisterB Value of Register B of RTC, indicating data mode\r
+ @param Century It is set according to EFI_TIME Time.\r
\r
+**/\r
VOID\r
ConvertEfiTimeToRtcTime (\r
- IN EFI_TIME *Time,\r
- IN RTC_REGISTER_B RegisterB,\r
- IN UINT8 *Century\r
+ IN OUT EFI_TIME *Time,\r
+ IN RTC_REGISTER_B RegisterB,\r
+ OUT UINT8 *Century\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Time - GC_TODO: add argument description\r
- RegisterB - GC_TODO: add argument description\r
- Century - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
+/**\r
+ See if centry 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
+**/\r
EFI_STATUS\r
RtcTestCenturyRegister (\r
VOID\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- None\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
/**\r
@param RegisterB Value of Register B of RTC, indicating data mode\r
and hour format.\r
\r
+ @retval EFI_INVALID_PARAMETER Parameters passed in are invalid.\r
+ @retval EFI_SUCCESS Convert RTC time to EFI time successfully.\r
+\r
**/\r
EFI_STATUS\r
ConvertRtcTimeToEfiTime (\r
IN RTC_REGISTER_B RegisterB\r
);\r
\r
+/**\r
+ Wait for a period for the RTC to be ready.\r
+\r
+ @param Timeout Tell how long it should take to wait.\r
+\r
+ @retval EFI_DEVICE_ERROR RTC device error.\r
+ @retval EFI_SUCCESS RTC is updated and ready. \r
+**/\r
EFI_STATUS\r
RtcWaitToUpdate (\r
UINTN Timeout\r
)\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Timeout - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
-;\r
-\r
-UINT8\r
-RtcSaveContext (\r
- IN PC_RTC_MODULE_GLOBALS *Global\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- Global - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
-\r
---*/\r
;\r
\r
-VOID\r
-RtcRestoreContext (\r
- IN UINT8 SavedAddressRegister,\r
- IN PC_RTC_MODULE_GLOBALS *Global\r
- )\r
-/*++\r
-\r
-Routine Description:\r
-\r
- GC_TODO: Add function description\r
-\r
-Arguments:\r
-\r
- SavedAddressRegister - GC_TODO: add argument description\r
- Global - GC_TODO: add argument description\r
-\r
-Returns:\r
-\r
- GC_TODO: add return values\r
+/**\r
+ See if field Day of an EFI_TIME is correct.\r
\r
---*/\r
-;\r
+ @param Time Its Day field is to be checked.\r
\r
+ @retval TRUE Day field of Time is correct.\r
+ @retval FALSE Day field of Time is NOT correct.\r
+**/\r
BOOLEAN\r
DayValid (\r
IN EFI_TIME *Time\r
);\r
\r
+/**\r
+ Check if it is a leapyear.\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
+**/\r
BOOLEAN\r
IsLeapYear (\r
IN EFI_TIME *Time\r