]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg/PrePi: Make dynamic the top of the System Memory
authorOlivier Martin <Olivier.Martin@arm.com>
Mon, 6 Jul 2015 16:56:31 +0000 (16:56 +0000)
committeroliviermartin <oliviermartin@Edk2>
Mon, 6 Jul 2015 16:56:31 +0000 (16:56 +0000)
This change allows to change the top of the System Memory that
was hardcoded by:
FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet64 (PcdSystemMemorySize)

It allows to add support when the Trusted Firmware reserves the
top of the System Memory as Trusted. The size of this region
might not be known in advance.

Note: The reason why the start of the System Memory has not been
made dynamic is because the early code calculates where to place
the stack from the top of the System Memory.
So there is no need to make the start of the System Memory a
dynamic value at the early stage of the boot phase.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <Olivier.Martin@arm.com>
Reviewed-by: Ronald Cron <Ronald.Cron@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17835 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.c
ArmPlatformPkg/Library/ArmPlatformGlobalVariableLib/PrePi/PrePiArmPlatformGlobalVariableLib.inf
ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
ArmPlatformPkg/PrePi/PrePi.c
ArmPlatformPkg/PrePi/PrePi.h

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
index 37de35e7d00e9286e8f26ed2479e555170d0f517..1b5b8fcbee0ea883c39996c50f8636aab47d9997 100644 (file)
@@ -1,6 +1,6 @@
 #/** @file\r
 #\r
-#  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r
+#  Copyright (c) 2011-2015, 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
@@ -41,6 +41,4 @@
 \r
 [Pcd]\r
   gArmTokenSpaceGuid.PcdSystemMemoryBase\r
-  gArmTokenSpaceGuid.PcdSystemMemorySize\r
   gArmTokenSpaceGuid.PcdFdBaseAddress\r
-\r
index fcea9496cbd53ffad6159cc5275c7beaebbc392b..2c4a7e5324e97b17a17262404ac39cf01fb05fb7 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//  Copyright (c) 2011-2013, 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
@@ -24,8 +24,10 @@ GCC_ASM_IMPORT(ArmReadMpidr)
 GCC_ASM_IMPORT(ArmPlatformPeiBootAction)\r
 GCC_ASM_IMPORT(ArmPlatformStackSet)\r
 GCC_ASM_EXPORT(_ModuleEntryPoint)\r
+GCC_ASM_EXPORT(mSystemMemoryEnd)\r
 \r
-StartupAddr:        .8byte ASM_PFX(CEntryPoint)\r
+StartupAddr:       .8byte ASM_PFX(CEntryPoint)\r
+mSystemMemoryEnd:  .8byte 0\r
 \r
 ASM_PFX(_ModuleEntryPoint):\r
   // Do early platform specific actions\r
@@ -40,12 +42,23 @@ _SetSVCMode:
 // Check if we can install the stack at the top of the System Memory or if we need\r
 // to install the stacks at the bottom of the Firmware Device (case the FD is located\r
 // at the top of the DRAM)\r
-_SetupStackPosition:\r
-  // Compute Top of System Memory\r
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), x1)\r
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), x2)\r
+_SystemMemoryEndInit:\r
+  ldr   x1, mSystemMemoryEnd\r
+\r
+  // Is mSystemMemoryEnd initialized?\r
+  cmp   x1, #0\r
+  bne   _SetupStackPosition\r
+\r
+  LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), x1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), x2)\r
   sub   x2, x2, #1\r
-  add   x1, x1, x2      // x1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize\r
+  add   x1, x1, x2\r
+  // Update the global variable\r
+  adr   x2, mSystemMemoryEnd\r
+  str   x1, [x2]\r
+\r
+_SetupStackPosition:\r
+  // r1 = SystemMemoryTop\r
 \r
   // Calculate Top of the Firmware Device\r
   LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2)\r
index f00960f1669081aea69f7e17ca7e879eb42b9e8e..f64934480ff4fabc6c43a02c30e06a0ac27cc5ac 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//  Copyright (c) 2011-2014, 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
@@ -27,8 +27,10 @@ GCC_ASM_IMPORT(ArmReadMpidr)
 GCC_ASM_IMPORT(ArmPlatformPeiBootAction)\r
 GCC_ASM_IMPORT(ArmPlatformStackSet)\r
 GCC_ASM_EXPORT(_ModuleEntryPoint)\r
+GCC_ASM_EXPORT(mSystemMemoryEnd)\r
 \r
-StartupAddr: .word    CEntryPoint\r
+StartupAddr:       .word  CEntryPoint\r
+mSystemMemoryEnd:  .8byte 0\r
 \r
 \r
 ASM_PFX(_ModuleEntryPoint):\r
@@ -48,12 +50,23 @@ _SetSVCMode:
 // Check if we can install the stack at the top of the System Memory or if we need\r
 // to install the stacks at the bottom of the Firmware Device (case the FD is located\r
 // at the top of the DRAM)\r
-_SetupStackPosition:\r
-  // Compute Top of System Memory\r
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), r1)\r
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), r2)\r
+_SystemMemoryEndInit:\r
+  ldr   r1, mSystemMemoryEnd\r
+\r
+  // Is mSystemMemoryEnd initialized?\r
+  cmp   r1, #0\r
+  bne   _SetupStackPosition\r
+\r
+  LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)\r
   sub   r2, r2, #1\r
-  add   r1, r1, r2      // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize\r
+  add   r1, r1, r2\r
+  // Update the global variable\r
+  adr   r2, mSystemMemoryEnd\r
+  str   r1, [r2]\r
+\r
+_SetupStackPosition:\r
+  // r1 = SystemMemoryTop\r
 \r
   // Calculate Top of the Firmware Device\r
   LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)\r
index cbb3a08008696c3410f839b506ebf363bd5c3536..f73c56850d99b455848f97d5741beb7253a22d91 100644 (file)
@@ -1,5 +1,5 @@
 //\r
-//  Copyright (c) 2011-2014, 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
   IMPORT  ArmPlatformStackSet\r
 \r
   EXPORT  _ModuleEntryPoint\r
+  EXPORT  mSystemMemoryEnd\r
 \r
   PRESERVE8\r
   AREA    PrePiCoreEntryPoint, CODE, READONLY\r
 \r
 StartupAddr        DCD      CEntryPoint\r
+mSystemMemoryEnd   DCQ      0\r
 \r
 _ModuleEntryPoint\r
   // Do early platform specific actions\r
@@ -50,12 +52,23 @@ _SetSVCMode
 // Check if we can install the stack at the top of the System Memory or if we need\r
 // to install the stacks at the bottom of the Firmware Device (case the FD is located\r
 // at the top of the DRAM)\r
-_SetupStackPosition\r
-  // Compute Top of System Memory\r
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), r1)\r
-  LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), r2)\r
+_SystemMemoryEndInit\r
+  ldr   r1, mSystemMemoryEnd\r
+\r
+  // Is mSystemMemoryEnd initialized?\r
+  cmp   r1, #0\r
+  bne   _SetupStackPosition\r
+\r
+  LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)\r
   sub   r2, r2, #1\r
-  add   r1, r1, r2      // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize\r
+  add   r1, r1, r2\r
+  // Update the global variable\r
+  adr   r2, mSystemMemoryEnd\r
+  str   r1, [r2]\r
+\r
+_SetupStackPosition\r
+  // r1 = SystemMemoryTop\r
 \r
   // Calculate Top of the Firmware Device\r
   LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)\r
index 9a5e067ef537aeaf8fc26341989427bf431139b2..99afe6fa9064b6b2dc055ff168277c7560757e15 100755 (executable)
@@ -30,7 +30,7 @@
 #include "PrePi.h"\r
 #include "LzmaDecompress.h"\r
 \r
-#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet32 (PcdSystemMemorySize))) || \\r
+#define IS_XIP() (((UINT32)FixedPcdGet32 (PcdFdBaseAddress) > mSystemMemoryEnd) || \\r
                   ((FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) < FixedPcdGet64 (PcdSystemMemoryBase)))\r
 \r
 // Not used when PrePi in run in XIP mode\r
@@ -109,7 +109,7 @@ PrePiMain (
   // If ensure the FD is either part of the System Memory or totally outside of the System Memory (XIP)\r
   ASSERT (IS_XIP() ||\r
           ((FixedPcdGet32 (PcdFdBaseAddress) >= FixedPcdGet64 (PcdSystemMemoryBase)) &&\r
-           ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT32)(FixedPcdGet64 (PcdSystemMemoryBase) + FixedPcdGet64 (PcdSystemMemorySize)))));\r
+           ((UINT32)(FixedPcdGet32 (PcdFdBaseAddress) + FixedPcdGet32 (PcdFdSize)) <= (UINT32)mSystemMemoryEnd)));\r
 \r
   // Initialize the architecture specific bits\r
   ArchInitialize ();\r
index e67795f4490aa9e22b55e4e15b8d8e3b1ab987cc..6e90c2afc89a8bd407adfee63b98b4740e8f1b86 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
@@ -29,6 +29,8 @@
 \r
 #define SerialPrint(txt)  SerialPortWrite (txt, AsciiStrLen(txt)+1);\r
 \r
+extern UINT64 mSystemMemoryEnd;\r
+\r
 RETURN_STATUS\r
 EFIAPI\r
 TimerConstructor (\r