summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/PrePi
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-28 17:22:13 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-28 17:22:13 +0000
commit2569b068685b126c64753c280f339e1e6869d068 (patch)
treef851fcc5ee23beaa716e632c3f255e9067125956 /ArmPlatformPkg/PrePi
parent5ed2368498307ee0f635012fefb58c51feb98bd5 (diff)
downloadedk2-2569b068685b126c64753c280f339e1e6869d068.tar.gz
edk2-2569b068685b126c64753c280f339e1e6869d068.tar.bz2
edk2-2569b068685b126c64753c280f339e1e6869d068.zip
ArmPlatformPkg/PrePi: Fixed stack setup when System Memory is mapped upto 0xFFFFFFFF
The stacks must be 32-bit aligned (which is not the case of 0xFFFFFFFF). This change ensures the stacks are setup properperly in case the system memory is available at 0xFFFFFFFF. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13057 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/PrePi')
-rwxr-xr-xArmPlatformPkg/PrePi/ModuleEntryPoint.S22
-rw-r--r--ArmPlatformPkg/PrePi/ModuleEntryPoint.asm22
2 files changed, 42 insertions, 2 deletions
diff --git a/ArmPlatformPkg/PrePi/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/ModuleEntryPoint.S
index 75728c983f..fe9117218a 100755
--- a/ArmPlatformPkg/PrePi/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/ModuleEntryPoint.S
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2012, 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
@@ -45,11 +45,13 @@ _SetupStackPosition:
// Compute Top of System Memory
LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)
+ sub r2, r2, #1
add r1, r1, r2 // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize
// Calculate Top of the Firmware Device
LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)
LoadConstantToReg (FixedPcdGet32(PcdFdSize), r3)
+ sub r3, r3, #1
add r3, r3, r2 // r4 = FdTop = PcdFdBaseAddress + PcdFdSize
// UEFI Memory Size (stacks are allocated in this region)
@@ -71,6 +73,24 @@ _SetupStackPosition:
_SetupStack:
// r1 contains the top of the stack (and the UEFI Memory)
+ // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment
+ // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the
+ // top of the memory space)
+ adds r6, r1, #1
+ bcs _SetupOverflowStack
+
+_SetupAlignedStack:
+ mov r1, r6
+ b _GetBaseUefiMemory
+
+_SetupOverflowStack:
+ // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE
+ // aligned (4KB)
+ LoadConstantToReg (EFI_PAGE_MASK, r6)
+ and r6, r6, r1
+ sub r1, r1, r6
+
+_GetBaseUefiMemory:
// Calculate the Base of the UEFI Memory
sub r6, r1, r4
diff --git a/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm b/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
index 5392e80925..d62efb2414 100644
--- a/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
+++ b/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
@@ -1,5 +1,5 @@
//
-// Copyright (c) 2011, ARM Limited. All rights reserved.
+// Copyright (c) 2011-2012, 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
@@ -46,11 +46,13 @@ _SetupStackPosition
// Compute Top of System Memory
LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)
+ sub r2, r2, #1
add r1, r1, r2 // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize
// Calculate Top of the Firmware Device
LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), r2)
LoadConstantToReg (FixedPcdGet32(PcdFdSize), r3)
+ sub r3, r3, #1
add r3, r3, r2 // r4 = FdTop = PcdFdBaseAddress + PcdFdSize
// UEFI Memory Size (stacks are allocated in this region)
@@ -72,6 +74,24 @@ _SetupStackPosition
_SetupStack
// r1 contains the top of the stack (and the UEFI Memory)
+ // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment
+ // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the
+ // top of the memory space)
+ adds r6, r1, #1
+ bcs _SetupOverflowStack
+
+_SetupAlignedStack
+ mov r1, r6
+ b _GetBaseUefiMemory
+
+_SetupOverflowStack
+ // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE
+ // aligned (4KB)
+ LoadConstantToReg (EFI_PAGE_MASK, r6)
+ and r6, r6, r1
+ sub r1, r1, r6
+
+_GetBaseUefiMemory
// Calculate the Base of the UEFI Memory
sub r6, r1, r4