]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PL031RealTimeClockLib: use virtual address of runtime services
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 10 Sep 2014 18:49:43 +0000 (18:49 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 10 Sep 2014 18:49:43 +0000 (18:49 +0000)
This library accesses SystemTable->RuntimeServices at runtime,
which means it should take care to use its updated value after
SetVirtualAddressMap () is called.

Replace references to gRT with mRT, which we initialize to gRT
and update to its virtual value on a virtual address change event.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16091 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Library/PL031RealTimeClockLib/PL031RealTimeClockLib.c

index b43d8dc4ba2fd69dda62aff22e230fbf96849d95..3e4147c58baced9ab6b1ca921b05493ded8c3b2b 100644 (file)
@@ -1,8 +1,6 @@
 /** @file\r
   Implement EFI RealTimeClock runtime services via RTC Lib.\r
 \r
-  Currently this driver does not support runtime virtual calling.\r
-\r
   Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r
   Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>\r
 \r
 \r
 #include <ArmPlatform.h>\r
 \r
-STATIC CONST CHAR16  mTimeZoneVariableName[] = L"PL031RtcTimeZone";\r
-STATIC CONST CHAR16  mDaylightVariableName[] = L"PL031RtcDaylight";\r
-STATIC BOOLEAN       mPL031Initialized = FALSE;\r
-STATIC EFI_EVENT     mRtcVirtualAddrChangeEvent;\r
-STATIC UINTN         mPL031RtcBase;\r
+STATIC CONST CHAR16           mTimeZoneVariableName[] = L"PL031RtcTimeZone";\r
+STATIC CONST CHAR16           mDaylightVariableName[] = L"PL031RtcDaylight";\r
+STATIC BOOLEAN                mPL031Initialized = FALSE;\r
+STATIC EFI_EVENT              mRtcVirtualAddrChangeEvent;\r
+STATIC UINTN                  mPL031RtcBase;\r
+STATIC EFI_RUNTIME_SERVICES   *mRT;\r
 \r
 EFI_STATUS\r
 IdentifyPL031 (\r
@@ -294,7 +293,7 @@ LibGetTime (
 \r
   // Get the current time zone information from non-volatile storage\r
   Size = sizeof (TimeZone);\r
-  Status = gRT->GetVariable (\r
+  Status = mRT->GetVariable (\r
                   (CHAR16 *)mTimeZoneVariableName,\r
                   &gEfiCallerIdGuid,\r
                   NULL,\r
@@ -312,7 +311,7 @@ LibGetTime (
     // 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
+    Status = mRT->SetVariable (\r
                     (CHAR16 *)mTimeZoneVariableName,\r
                     &gEfiCallerIdGuid,\r
                     EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
@@ -346,7 +345,7 @@ LibGetTime (
 \r
   // Get the current daylight information from non-volatile storage\r
   Size = sizeof (Daylight);\r
-  Status = gRT->GetVariable (\r
+  Status = mRT->GetVariable (\r
                   (CHAR16 *)mDaylightVariableName,\r
                   &gEfiCallerIdGuid,\r
                   NULL,\r
@@ -364,7 +363,7 @@ LibGetTime (
     // 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
+    Status = mRT->SetVariable (\r
                     (CHAR16 *)mDaylightVariableName,\r
                     &gEfiCallerIdGuid,\r
                     EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
@@ -498,7 +497,7 @@ LibSetTime (
   // Do this after having set the RTC.\r
 \r
   // Save the current time zone information into non-volatile storage\r
-  Status = gRT->SetVariable (\r
+  Status = mRT->SetVariable (\r
                   (CHAR16 *)mTimeZoneVariableName,\r
                   &gEfiCallerIdGuid,\r
                   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
@@ -516,7 +515,7 @@ LibSetTime (
   }\r
 \r
   // Save the current daylight information into non-volatile storage\r
-  Status = gRT->SetVariable (\r
+  Status = mRT->SetVariable (\r
                   (CHAR16 *)mDaylightVariableName,\r
                   &gEfiCallerIdGuid,\r
                   EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,\r
@@ -609,6 +608,7 @@ LibRtcVirtualNotifyEvent (
   // runtime calls will be made in virtual mode.\r
   //\r
   EfiConvertPointer (0x0, (VOID**)&mPL031RtcBase);\r
+  EfiConvertPointer (0x0, (VOID**)&mRT);\r
   return;\r
 }\r
 \r
@@ -656,6 +656,8 @@ LibRtcInitialize (
   gRT->GetWakeupTime = LibGetWakeupTime;\r
   gRT->SetWakeupTime = LibSetWakeupTime;\r
 \r
+  mRT = gRT;\r
+\r
   // Install the protocol\r
   Handle = NULL;\r
   Status = gBS->InstallMultipleProtocolInterfaces (\r