]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
ArmPlatformPkg/PrePi: Make dynamic the top of the System Memory
[mirror_edk2.git] / ArmPlatformPkg / PrePi / AArch64 / ModuleEntryPoint.S
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