]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c
ArmPlatformPkg/PrePi: Make dynamic the top of the System Memory
[mirror_edk2.git] / ArmPlatformPkg / Library / ArmPlatformGlobalVariableLib / PrePi / PrePiArmPlatformGlobalVariableLib.c
index 41af1836e16f305274c001a23929a49405c3899c..db69ba047dbdcae3805dbfb5284b347725731bc6 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
+*  Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r
 *\r
 *  This program and the accompanying materials\r
 *  are licensed and made available under the terms and conditions of the BSD License\r
@@ -19,7 +19,9 @@
 #include <Library/PcdLib.h>\r
 #include <Library/DebugLib.h>\r
 \r
-#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > (UINT32)(PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize))) || \\r
+extern UINT64 mSystemMemoryEnd;\r
+\r
+#define IS_XIP() (((UINT32)PcdGet64 (PcdFdBaseAddress) > (UINT32)(mSystemMemoryEnd)) || \\r
                   ((PcdGet64 (PcdFdBaseAddress) + PcdGet32 (PcdFdSize)) < PcdGet64 (PcdSystemMemoryBase)))\r
 \r
 // Declared by ArmPlatformPkg/PrePi Module\r
@@ -40,7 +42,7 @@ ArmPlatformGetGlobalVariable (
   if (IS_XIP()) {\r
     // In Case of XIP, we expect the Primary Stack at the top of the System Memory\r
     // The size must be 64bit aligned to allow 64bit variable to be aligned\r
-    GlobalVariableBase = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);\r
+    GlobalVariableBase = mSystemMemoryEnd + 1 - ALIGN_VALUE (PcdGet32 (PcdPeiGlobalVariableSize), 0x8);\r
   } else {\r
     GlobalVariableBase = mGlobalVariableBase;\r
   }\r
@@ -69,7 +71,7 @@ ArmPlatformSetGlobalVariable (
   if (IS_XIP()) {\r
     // In Case of XIP, we expect the Primary Stack at the top of the System Memory\r
     // The size must be 64bit aligned to allow 64bit variable to be aligned\r
-    GlobalVariableBase = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);\r
+    GlobalVariableBase = mSystemMemoryEnd + 1 - ALIGN_VALUE (PcdGet32 (PcdPeiGlobalVariableSize), 0x8);\r
   } else {\r
     GlobalVariableBase = mGlobalVariableBase;\r
   }\r
@@ -96,7 +98,7 @@ ArmPlatformGetGlobalVariableAddress (
   if (IS_XIP()) {\r
     // In Case of XIP, we expect the Primary Stack at the top of the System Memory\r
     // The size must be 64bit aligned to allow 64bit variable to be aligned\r
-    GlobalVariableBase = PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize) - ALIGN_VALUE(PcdGet32 (PcdPeiGlobalVariableSize),0x8);\r
+    GlobalVariableBase = mSystemMemoryEnd + 1 - ALIGN_VALUE (PcdGet32 (PcdPeiGlobalVariableSize), 0x8);\r
   } else {\r
     GlobalVariableBase = mGlobalVariableBase;\r
   }\r