]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PL031RealTimeClockLib: Set PL031_{TimeZone,Daylight} UEFI variables...
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Jan 2013 11:59:37 +0000 (11:59 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 28 Jan 2013 11:59:37 +0000 (11:59 +0000)
PL031_TimeZone and PL031_Daylight are not global variables as defined by UEFI specification

Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14107 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c
ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.inf

index 44a1eee7a44c33c44632e521ab36c9ba67457be8..b7dba087fcae3232b3b386345b3ae2a4d744bfdc 100644 (file)
@@ -34,9 +34,9 @@
 \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
@@ -129,10 +129,6 @@ EpochToEfiTime (
   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
@@ -234,13 +230,14 @@ DayValid (
   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
@@ -252,8 +249,9 @@ LibGetTime (
 {\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
@@ -287,27 +285,44 @@ LibGetTime (
   }\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
@@ -322,27 +337,44 @@ LibGetTime (
   }\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
@@ -457,27 +489,37 @@ LibSetTime (
 \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
index 24c74d2d112582a2bdf726e3c0379f177b330bf6..add982ce8e4b442819ccbaddc3eeba00d51c5b4c 100644 (file)
@@ -1,8 +1,7 @@
 #/** @file\r
-# Memory Status Code Library for UEFI drivers\r
 #\r
-# Lib to provide memory journal status code reporting Routines\r
 # Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011-2013, ARM Ltd. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -25,7 +24,6 @@
 [Sources.common]\r
   PL031RealTimeClockLib.c\r
 \r
-\r
 [Packages]\r
   MdePkg/MdePkg.dec\r
   EmbeddedPkg/EmbeddedPkg.dec\r
@@ -37,7 +35,7 @@
   DebugLib\r
   PcdLib\r
   ArmPlatformSysConfigLib\r
-  \r
+\r
 [Pcd]\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcBase\r
   gArmPlatformTokenSpaceGuid.PcdPL031RtcPpmAccuracy\r