]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/ArmPlatformGlobalVariableLib: Added new function ArmPlatformGetGlobalV...
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 2 May 2012 19:51:08 +0000 (19:51 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 2 May 2012 19:51:08 +0000 (19:51 +0000)
This function returns the address of a Global Variable in the Global Variable Region.

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

ArmPlatformPkg/Include/Library/ArmPlatformGlobalVariableLib.h
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.c
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Dxe/DxeArmPlatformGlobalVariableLib.inf
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Pei/PeiArmPlatformGlobalVariableLib.c
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/Sec/SecArmPlatformGlobalVariableLib.c

index c0264c24bd9abf6b01201066d16d76d5429e912a..02ef1ea8326bd5ee3714403ceedf6250b77c35e1 100644 (file)
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2011, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD License
@@ -29,5 +29,10 @@ ArmPlatformSetGlobalVariable (
   OUT VOID*     Variable
   );
 
+VOID*
+ArmPlatformGetGlobalVariableAddress (
+  IN  UINTN     VariableOffset
+  );
+
 #endif
 
index aebc91293502bafae1ee7d8a78c95351578fe736..278138759f376e68548c3422afd2a1bb3ec890d8 100644 (file)
@@ -1,6 +1,6 @@
 /** @file
 *
-*  Copyright (c) 2011, ARM Limited. All rights reserved.
+*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.
 *
 *  This program and the accompanying materials
 *  are licensed and made available under the terms and conditions of the BSD License
@@ -67,3 +67,10 @@ ArmPlatformSetGlobalVariable (
   CopyMem ((VOID*)(mGlobalVariableBase + VariableOffset), Variable, VariableSize);
 }
 
+VOID*
+ArmPlatformGetGlobalVariableAddress (
+  IN  UINTN     VariableOffset
+  )
+{
+  return (VOID*)(mGlobalVariableBase + VariableOffset);
+}
index 2b1c7aaf53f27986b1fda8c1be68964dbcb4216e..f2284ce4ca58f35e2b21acf6e15f505160996619 100644 (file)
@@ -3,6 +3,7 @@
 #  
 #  
 #  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>
+#
 #  This program and the accompanying materials
 #  are licensed and made available under the terms and conditions of the BSD License
 #  which accompanies this distribution.  The full text of the license may be found at
index f82b6b1c5d6477e511bf1f0761503500a51e26f8..78563acae929ac9fc5fa60fd3fbf12234d180d28 100644 (file)
@@ -43,8 +43,6 @@ ArmPlatformGetGlobalVariable (
   } else {
     CopyMem (Variable, (VOID*)(GlobalVariableBase + VariableOffset), VariableSize);
   }
-
-  //DEBUG((EFI_D_ERROR,"++ GET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
 }
 
 VOID
@@ -68,7 +66,19 @@ ArmPlatformSetGlobalVariable (
   } else {
     CopyMem ((VOID*)(GlobalVariableBase + VariableOffset), Variable, VariableSize);
   }
-
-  //DEBUG((EFI_D_ERROR,"++ SET Offset[%d] = 0x%x\n",VariableOffset,*(UINTN*)Variable));
 }
 
+VOID*
+ArmPlatformGetGlobalVariableAddress (
+  IN  UINTN     VariableOffset
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  // Ensure the Global Variable Size have been initialized
+  ASSERT (VariableOffset < PcdGet32 (PcdPeiGlobalVariableSize));
+
+  GlobalVariableBase = PcdGet32 (PcdCPUCoresStackBase) + PcdGet32 (PcdCPUCorePrimaryStackSize) - PcdGet32 (PcdPeiGlobalVariableSize);
+
+  return (VOID*)(GlobalVariableBase + VariableOffset);
+}
index b2474e693438ef5f6365a44e0b317a4459fc1062..563e405f664ad2582c2aef3c7330e35ef04e0293 100644 (file)
@@ -83,3 +83,23 @@ ArmPlatformSetGlobalVariable (
   }
 }
 
+VOID*
+ArmPlatformGetGlobalVariableAddress (
+  IN  UINTN     VariableOffset
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  // Ensure the Global Variable Size have been initialized
+  ASSERT (VariableOffset < PcdGet32 (PcdPeiGlobalVariableSize));
+
+  if (IS_XIP()) {
+    // In Case of XIP, we expect the Primary Stack at the top of the System Memory
+    // The size must be 64bit aligned to allow 64bit variable to be aligned
+    GlobalVariableBase = PcdGet32 (PcdSystemMemoryBase) + PcdGet32 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);
+  } else {
+    GlobalVariableBase = mGlobalVariableBase;
+  }
+
+  return (VOID*)(GlobalVariableBase + VariableOffset);
+}
index 847d2b7e816f55d6a626c9f6c34501af4d8f623c..f5d7bb54a3574091416ee8b4a5955fd9f33b101a 100644 (file)
@@ -65,3 +65,17 @@ ArmPlatformSetGlobalVariable (
   }
 }
 
+VOID*
+ArmPlatformGetGlobalVariableAddress (
+  IN  UINTN     VariableOffset
+  )
+{
+  UINTN  GlobalVariableBase;
+
+  // Ensure the Global Variable Size have been initialized
+  ASSERT (VariableOffset < PcdGet32 (PcdSecGlobalVariableSize));
+
+  GlobalVariableBase = PcdGet32 (PcdCPUCoresSecStackBase) + PcdGet32 (PcdCPUCoreSecPrimaryStackSize) - PcdGet32 (PcdSecGlobalVariableSize);
+
+  return (VOID*)(GlobalVariableBase + VariableOffset);
+}