diff options
author | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-07-06 16:27:21 +0000 |
---|---|---|
committer | oliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524> | 2011-07-06 16:27:21 +0000 |
commit | d269095b712ba45fd4aca55331b5e6f3045ce1ad (patch) | |
tree | 45ee937196347b33f6eeddf11cd3fa29c431a1f0 /ArmPlatformPkg/PrePi/ModuleEntryPoint.S | |
parent | a6caee65ac3bba2ac649f20bf1c63f0a87050f17 (diff) | |
download | edk2-platforms-d269095b712ba45fd4aca55331b5e6f3045ce1ad.tar.xz |
ArmPlatformPkg: Change the memory model for the ARM Platform components
In the former memory model, the UEFI firmware was expected to be located
at the top of the system memory. Stacks & Pi memory regions were set below
the firmware.
On some platform, the UEFI firmware could be shadowed by the ROM firmware
(case of the BeagleBoard) and in some cases the firmware is copied at the
beginning of the system memory.
With this new memory model, stack and Pi/DXE memory regions are set at the
top of the system memory wherever the UEFI firmware is located in the memory
map.
Because DXE core does not support shadowed firmwares, the system memory covered
by the UEFI firmware is marked as 'Non Present' to avoid to be overlapped by
DXE allocations.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11992 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/PrePi/ModuleEntryPoint.S')
-rwxr-xr-x | ArmPlatformPkg/PrePi/ModuleEntryPoint.S | 68 |
1 files changed, 42 insertions, 26 deletions
diff --git a/ArmPlatformPkg/PrePi/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/ModuleEntryPoint.S index 0857024a27..a8c779fba9 100755 --- a/ArmPlatformPkg/PrePi/ModuleEntryPoint.S +++ b/ArmPlatformPkg/PrePi/ModuleEntryPoint.S @@ -16,50 +16,70 @@ #include <Library/PcdLib.h>
#include <AutoGen.h>
-#start of the code section
.text
.align 3
-#global symbols referenced by this module
+# Global symbols referenced by this module
GCC_ASM_IMPORT(CEntryPoint)
+GCC_ASM_EXPORT(_ModuleEntryPoint)
StartupAddr: .word CEntryPoint
-#make _ModuleEntryPoint as global
-GCC_ASM_EXPORT(_ModuleEntryPoint)
-
ASM_PFX(_ModuleEntryPoint):
// Identify CPU ID
mrc p15, 0, r0, c0, c0, 5
and r0, #0xf
-_UefiMemoryBase:
-#if FixedPcdGet32(PcdStandalone)
+_SetSVCMode:
+ // Enter SVC mode
+ mov r1, #0x13|0x80|0x40
+ msr CPSR_c, r1
+
+// Check if we can install the size 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 (FixedPcdGet32(PcdSystemMemoryBase), r1)
LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)
add r1, r1, r2 // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize
-#else
- // If it is not a Standalone, we must compute the top of the UEFI memory with the base of the FD
- LoadConstantToReg (FixedPcdGet32(PcdNormalFdBaseAddress), r1)
-#endif
- // Compute Base of UEFI Memory
- LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), r2)
- sub r1, r1, r2 // r1 = SystemMemoryTop - PcdSystemMemoryUefiRegionSize = UefiMemoryBase
+ // Calculate Top of the Firmware Device
+ LoadConstantToReg (FixedPcdGet32(PcdNormalFdBaseAddress), r2)
+ LoadConstantToReg (FixedPcdGet32(PcdNormalFdSize), r3)
+ add r3, r3, r2 // r4 = FdTop = PcdNormalFdBaseAddress + PcdNormalFdSize
+
+ // UEFI Memory Size (stacks are allocated in this region)
+ LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), r4)
+
+ //
+ // Reserve the memory for the UEFI region (contain stacks on its top)
+ //
+
+ // Calculate how much space there is between the top of the Firmware and the Top of the System Memory
+ subs r5, r1, r3 // r5 = SystemMemoryTop - FdTop
+ bmi _SetupStack // Jump if negative (FdTop > SystemMemoryTop)
+ cmp r5, r4
+ bge _SetupStack
+
+ // Case the top of stacks is the FdBaseAddress
+ mov r1, r2
_SetupStack:
// Compute Base of Normal stacks for CPU Cores
- LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackSize), r2)
- mul r3, r0, r2 // r3 = core_id * stack_size = offset from the stack base
- sub sp, r1, r3 // r3 = UefiMemoryBase - StackOffset = TopOfStack
+ LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackSize), r5)
+ mul r3, r0, r5 // r3 = core_id * stack_size = offset from the stack base
+ sub sp, r1, r3 // r3 = (SystemMemoryTop|FdBaseAddress) - StackOffset = TopOfStack
+
+ // Calculate the Base of the UEFI Memory
+ sub r1, r1, r4
- // Only allocate memory in top of the primary core stack
+ // Only allocate memory for global variables at top of the primary core stack
cmp r0, #0
bne _PrepareArguments
-_AllocateGlobalPeiVariables:
+_AllocateGlobalPrePiVariables:
// Reserve top of the stack for Global PEI Variables (eg: PeiServicesTablePointer)
LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r4)
// The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack
@@ -69,16 +89,12 @@ _AllocateGlobalPeiVariables: sub sp, sp, r4
_PrepareArguments:
- // Pass the StackBase to the C Entrypoint (UefiMemoryBase - StackSize - StackOffset)
- sub r2, r1, r2
- sub r2, r3
// Move sec startup address into a data register
// Ensure we're jumping to FV version of the code (not boot remapped alias)
- ldr r3, StartupAddr
+ ldr r2, StartupAddr
- // jump to PrePiCore C code
+ // Jump to PrePiCore C code
// r0 = core_id
// r1 = UefiMemoryBase
- // r2 = StackBase
- blx r3
+ blx r2
|