summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/PrePi/Arm
diff options
context:
space:
mode:
authorOlivier Martin <Olivier.Martin@arm.com>2015-07-06 16:56:31 +0000
committeroliviermartin <oliviermartin@Edk2>2015-07-06 16:56:31 +0000
commit5dbacdb21b59748e885c2eccae370b81271ab795 (patch)
tree69f477c94ae7e754ab9214a222134e9d07c4ae89 /ArmPlatformPkg/PrePi/Arm
parent40a3f38f67cee7046feb5a5666883cc75a6962ff (diff)
downloadedk2-5dbacdb21b59748e885c2eccae370b81271ab795.tar.gz
edk2-5dbacdb21b59748e885c2eccae370b81271ab795.tar.bz2
edk2-5dbacdb21b59748e885c2eccae370b81271ab795.zip
ArmPlatformPkg/PrePi: Make dynamic the top of the System Memory
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
Diffstat (limited to 'ArmPlatformPkg/PrePi/Arm')
-rw-r--r--ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S27
-rw-r--r--ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm25
2 files changed, 39 insertions, 13 deletions
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
index f00960f166..f64934480f 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.S
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2015, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -27,8 +27,10 @@ GCC_ASM_IMPORT(ArmReadMpidr)
GCC_ASM_IMPORT(ArmPlatformPeiBootAction)
GCC_ASM_IMPORT(ArmPlatformStackSet)
GCC_ASM_EXPORT(_ModuleEntryPoint)
+GCC_ASM_EXPORT(mSystemMemoryEnd)
-StartupAddr: .word CEntryPoint
+StartupAddr: .word CEntryPoint
+mSystemMemoryEnd: .8byte 0
ASM_PFX(_ModuleEntryPoint):
@@ -48,12 +50,23 @@ _SetSVCMode:
// Check if we can install the stack at the top of the System Memory or if we need
// to install the stacks at the bottom of the Firmware Device (case the FD is located
// at the top of the DRAM)
-_SetupStackPosition:
- // Compute Top of System Memory
- LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), r1)
- LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), r2)
+_SystemMemoryEndInit:
+ ldr r1, mSystemMemoryEnd
+
+ // Is mSystemMemoryEnd initialized?
+ cmp r1, #0
+ bne _SetupStackPosition
+
+ LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)
+ LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)
sub r2, r2, #1
- add r1, r1, r2 // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize
+ add r1, r1, r2
+ // Update the global variable
+ adr r2, mSystemMemoryEnd
+ str r1, [r2]
+
+_SetupStackPosition:
+ // r1 = SystemMemoryTop
// Calculate Top of the Firmware Device
LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)
diff --git a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
index cbb3a08008..f73c56850d 100644
--- a/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
+++ b/ArmPlatformPkg/PrePi/Arm/ModuleEntryPoint.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2015, ARM Limited. All rights reserved.
//
// This program and the accompanying materials
// are licensed and made available under the terms and conditions of the BSD License
@@ -27,11 +27,13 @@
IMPORT ArmPlatformStackSet
EXPORT _ModuleEntryPoint
+ EXPORT mSystemMemoryEnd
PRESERVE8
AREA PrePiCoreEntryPoint, CODE, READONLY
StartupAddr DCD CEntryPoint
+mSystemMemoryEnd DCQ 0
_ModuleEntryPoint
// Do early platform specific actions
@@ -50,12 +52,23 @@ _SetSVCMode
// Check if we can install the stack at the top of the System Memory or if we need
// to install the stacks at the bottom of the Firmware Device (case the FD is located
// at the top of the DRAM)
-_SetupStackPosition
- // Compute Top of System Memory
- LoadConstantToReg (FixedPcdGet64 (PcdSystemMemoryBase), r1)
- LoadConstantToReg (FixedPcdGet64 (PcdSystemMemorySize), r2)
+_SystemMemoryEndInit
+ ldr r1, mSystemMemoryEnd
+
+ // Is mSystemMemoryEnd initialized?
+ cmp r1, #0
+ bne _SetupStackPosition
+
+ LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)
+ LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)
sub r2, r2, #1
- add r1, r1, r2 // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize
+ add r1, r1, r2
+ // Update the global variable
+ adr r2, mSystemMemoryEnd
+ str r1, [r2]
+
+_SetupStackPosition
+ // r1 = SystemMemoryTop
// Calculate Top of the Firmware Device
LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)