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