//\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
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
// 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