\r
#include <ArmPlatform.h>\r
\r
-CHAR16 mTimeZoneVariableName[] = L"PL031_TimeZone";\r
-CHAR16 mDaylightVariableName[] = L"PL031_Daylight";\r
-BOOLEAN mPL031Initialized = FALSE;\r
+STATIC CONST CHAR16 mTimeZoneVariableName[] = L"PL031RtcTimeZone";\r
+STATIC CONST CHAR16 mDaylightVariableName[] = L"PL031RtcDaylight";\r
+STATIC BOOLEAN mPL031Initialized = FALSE;\r
\r
EFI_STATUS\r
IdentifyPL031 (\r
UINTN ss;\r
UINTN J;\r
\r
- if (Time->Daylight == TRUE) {\r
-\r
- }\r
-\r
J = (EpochSeconds / 86400) + 2440588;\r
j = J + 32044;\r
g = j / 146097;\r
Returns the current time and date information, and the time-keeping capabilities\r
of the hardware platform.\r
\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 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
\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
+ @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
+ @retval EFI_SECURITY_VIOLATION The time could not be retrieved due to an authentication failure.\r
\r
**/\r
EFI_STATUS\r
{\r
EFI_STATUS Status = EFI_SUCCESS;\r
UINT32 EpochSeconds;\r
- INT16 *TimeZone = 0;\r
- UINTN *Daylight = 0;\r
+ INT16 TimeZone;\r
+ UINT8 Daylight;\r
+ UINTN Size;\r
\r
// Initialize the hardware if not already done\r
if (!mPL031Initialized) {\r
}\r
\r
// Get the current time zone information from non-volatile storage\r
- TimeZone = (INT16 *)GetVariable(mTimeZoneVariableName, &gEfiGlobalVariableGuid);\r
+ Size = sizeof (TimeZone);\r
+ Status = gRT->GetVariable (\r
+ (CHAR16 *)mTimeZoneVariableName,\r
+ &gEfiCallerIdGuid,\r
+ NULL,\r
+ &Size,\r
+ (VOID *)&TimeZone\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ ASSERT(Status != EFI_INVALID_PARAMETER);\r
+ ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
+\r
+ if (Status != EFI_NOT_FOUND)\r
+ goto EXIT;\r
\r
- if (TimeZone == NULL) {\r
// The time zone variable does not exist in non-volatile storage, so create it.\r
Time->TimeZone = EFI_UNSPECIFIED_TIMEZONE;\r
// Store it\r
Status = gRT->SetVariable (\r
- mTimeZoneVariableName,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof(Time->TimeZone),\r
- &(Time->TimeZone)\r
- );\r
+ (CHAR16 *)mTimeZoneVariableName,\r
+ &gEfiCallerIdGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ Size,\r
+ (VOID *)&(Time->TimeZone)\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG((EFI_D_ERROR,"LibGetTime: ERROR: TimeZone\n"));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ "LibGetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",\r
+ mTimeZoneVariableName,\r
+ Status\r
+ ));\r
goto EXIT;\r
}\r
} else {\r
// Got the time zone\r
- Time->TimeZone = *TimeZone;\r
- FreePool(TimeZone);\r
+ Time->TimeZone = TimeZone;\r
\r
// Check TimeZone bounds: -1440 to 1440 or 2047\r
if (((Time->TimeZone < -1440) || (Time->TimeZone > 1440))\r
}\r
\r
// Get the current daylight information from non-volatile storage\r
- Daylight = (UINTN *)GetVariable(mDaylightVariableName, &gEfiGlobalVariableGuid);\r
+ Size = sizeof (Daylight);\r
+ Status = gRT->GetVariable (\r
+ (CHAR16 *)mDaylightVariableName,\r
+ &gEfiCallerIdGuid,\r
+ NULL,\r
+ &Size,\r
+ (VOID *)&Daylight\r
+ );\r
+\r
+ if (EFI_ERROR (Status)) {\r
+ ASSERT(Status != EFI_INVALID_PARAMETER);\r
+ ASSERT(Status != EFI_BUFFER_TOO_SMALL);\r
+\r
+ if (Status != EFI_NOT_FOUND)\r
+ goto EXIT;\r
\r
- if (Daylight == NULL) {\r
// The daylight variable does not exist in non-volatile storage, so create it.\r
Time->Daylight = 0;\r
// Store it\r
Status = gRT->SetVariable (\r
- mDaylightVariableName,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof(Time->Daylight),\r
- &(Time->Daylight)\r
- );\r
+ (CHAR16 *)mDaylightVariableName,\r
+ &gEfiCallerIdGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ Size,\r
+ (VOID *)&(Time->Daylight)\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG((EFI_D_ERROR,"LibGetTime: ERROR: Daylight\n"));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ "LibGetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",\r
+ mDaylightVariableName,\r
+ Status\r
+ ));\r
goto EXIT;\r
}\r
} else {\r
// Got the daylight information\r
- Time->Daylight = *Daylight;\r
- FreePool(Daylight);\r
+ Time->Daylight = Daylight;\r
\r
// Adjust for the correct period\r
if ((Time->Daylight & EFI_TIME_IN_DAYLIGHT) == EFI_TIME_IN_DAYLIGHT) {\r
\r
// Save the current time zone information into non-volatile storage\r
Status = gRT->SetVariable (\r
- mTimeZoneVariableName,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof(Time->TimeZone),\r
- &(Time->TimeZone)\r
- );\r
+ (CHAR16 *)mTimeZoneVariableName,\r
+ &gEfiCallerIdGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof (Time->TimeZone),\r
+ (VOID *)&(Time->TimeZone)\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG((EFI_D_ERROR,"LibSetTime: ERROR: TimeZone\n"));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ "LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",\r
+ mTimeZoneVariableName,\r
+ Status\r
+ ));\r
goto EXIT;\r
}\r
\r
// Save the current daylight information into non-volatile storage\r
Status = gRT->SetVariable (\r
- mDaylightVariableName,\r
- &gEfiGlobalVariableGuid,\r
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
- sizeof(Time->Daylight),\r
- &(Time->Daylight)\r
- );\r
+ (CHAR16 *)mDaylightVariableName,\r
+ &gEfiCallerIdGuid,\r
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
+ sizeof(Time->Daylight),\r
+ (VOID *)&(Time->Daylight)\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG((EFI_D_ERROR,"LibSetTime: ERROR: Daylight\n"));\r
+ DEBUG ((\r
+ EFI_D_ERROR,\r
+ "LibSetTime: Failed to save %s variable to non-volatile storage, Status = %r\n",\r
+ mDaylightVariableName,\r
+ Status\r
+ ));\r
goto EXIT;\r
}\r
\r