summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/PrePi
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-28 17:23:53 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2012-02-28 17:23:53 +0000
commit1377db63ff80bbb28da572c7b276ba56faea5f94 (patch)
tree40938c5d1960667bed42eb0e87da13a120fc8420 /ArmPlatformPkg/PrePi
parent2569b068685b126c64753c280f339e1e6869d068 (diff)
ArmPlatformPkg: Updated the stack setup to have the same geometry between the Secure and Normal World
Having a similar setup reduces the error during the MPCore stack setup. The stack setup is described on this wikipage: https://sourceforge.net/apps/mediawiki/tianocore/index.php?title=ArmPlatformPkg/Stack git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13058 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/PrePi')
-rwxr-xr-xArmPlatformPkg/PrePi/ModuleEntryPoint.S49
-rw-r--r--ArmPlatformPkg/PrePi/ModuleEntryPoint.asm49
2 files changed, 40 insertions, 58 deletions
diff --git a/ArmPlatformPkg/PrePi/ModuleEntryPoint.S b/ArmPlatformPkg/PrePi/ModuleEntryPoint.S
index fe9117218..52e50921b 100755
--- a/ArmPlatformPkg/PrePi/ModuleEntryPoint.S
+++ b/ArmPlatformPkg/PrePi/ModuleEntryPoint.S
@@ -103,6 +103,7 @@ _GetStackBase:
beq _SetupUnicoreStack
_GetStackBaseMpCore:
+ // r1 = The top of the Mpcore Stacks
// Stack for the primary core = PrimaryCoreStack
LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
sub r7, r1, r2
@@ -113,8 +114,12 @@ _GetStackBaseMpCore:
mul r2, r2, r3
sub r7, r7, r2
- // The top of the Mpcore Stacks is in r1
- // The base of the MpCore Stacks is in r7
+ // The base of the secondary Stacks = Top of Primary stack
+ LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
+ add r1, r7, r2
+
+ // r7 = The base of the MpCore Stacks
+ // r1 = The base of the secondary Stacks = Top of the Primary stack
// Is it the Primary Core ?
LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)
@@ -122,7 +127,7 @@ _GetStackBaseMpCore:
beq _SetupPrimaryCoreStack
_SetupSecondaryCoreStack:
- // Base of the stack for the secondary cores is in r7
+ // r1 = The base of the secondary Stacks
// Get the position of the cores (ClusterId * 4) + CoreId
GetCorePositionInStack(r0, r5, r4)
@@ -130,28 +135,28 @@ _SetupSecondaryCoreStack:
add r0, r0, #1
// Get the offset for the Secondary Stack
mul r0, r0, r3
- add sp, r7, r0
+ add sp, r1, r0
bne _PrepareArguments
_SetupPrimaryCoreStack:
- // The top of the Mpcore Stacks is in r1
+ // r1 = Top of the primary stack
LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
+ b _PreparePrimaryStack
+
+_SetupUnicoreStack:
+ // The top of the Unicore Stack is in r1
+ LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
+ LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r3)
+ // Calculate the bottom of the primary stack (StackBase)
+ sub r7, r1, r3
+
+_PreparePrimaryStack:
// The reserved space for global variable must be 8-bytes aligned for pushing
// 64-bit variable on the stack
SetPrimaryStack (r1, r2, r3)
-_SetGlobals:
- // Set all the PrePi global variables to 0
- mov r3, sp
- mov r2, #0x0
-_InitGlobals:
- cmp r3, r1
- beq _PrepareArguments
- str r2, [r3], #4
- b _InitGlobals
-
_PrepareArguments:
mov r0, r5
mov r1, r6
@@ -172,17 +177,3 @@ _PrepareArguments:
_NeverReturn:
b _NeverReturn
-_SetupUnicoreStack:
- // The top of the Unicore Stack is in r1
- LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
- LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r3)
-
- // Calculate the bottom of the primary stack (StackBase)
- sub r7, r1, r3
-
- // The reserved space for global variable must be 8-bytes aligned for pushing
- // 64-bit variable on the stack
- SetPrimaryStack (r1, r2, r3)
-
- b _SetGlobals
-
diff --git a/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm b/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
index d62efb241..e6b2d7136 100644
--- a/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
+++ b/ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
@@ -104,6 +104,7 @@ _GetStackBase
beq _SetupUnicoreStack
_GetStackBaseMpCore
+ // r1 = The top of the Mpcore Stacks
// Stack for the primary core = PrimaryCoreStack
LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
sub r7, r1, r2
@@ -114,8 +115,12 @@ _GetStackBaseMpCore
mul r2, r2, r3
sub r7, r7, r2
- // The top of the Mpcore Stacks is in r1
- // The base of the MpCore Stacks is in r7
+ // The base of the secondary Stacks = Top of Primary stack
+ LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
+ add r1, r7, r2
+
+ // r7 = The base of the MpCore Stacks
+ // r1 = The base of the secondary Stacks = Top of the Primary stack
// Is it the Primary Core ?
LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)
@@ -123,7 +128,7 @@ _GetStackBaseMpCore
beq _SetupPrimaryCoreStack
_SetupSecondaryCoreStack
- // Base of the stack for the secondary cores is in r7
+ // r1 = The base of the secondary Stacks
// Get the position of the cores (ClusterId * 4) + CoreId
GetCorePositionInStack(r0, r5, r4)
@@ -131,28 +136,28 @@ _SetupSecondaryCoreStack
add r0, r0, #1
// Get the offset for the Secondary Stack
mul r0, r0, r3
- add sp, r7, r0
+ add sp, r1, r0
bne _PrepareArguments
_SetupPrimaryCoreStack
- // The top of the Mpcore Stacks is in r1
+ // r1 = Top of the primary stack
LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
+ b _PreparePrimaryStack
+
+_SetupUnicoreStack
+ // The top of the Unicore Stack is in r1
+ LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
+ LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r3)
+ // Calculate the bottom of the primary stack (StackBase)
+ sub r7, r1, r3
+
+_PreparePrimaryStack
// The reserved space for global variable must be 8-bytes aligned for pushing
// 64-bit variable on the stack
SetPrimaryStack (r1, r2, r3)
-_SetGlobals
- // Set all the PrePi global variables to 0
- mov r3, sp
- mov r2, #0x0
-_InitGlobals
- cmp r3, r1
- beq _PrepareArguments
- str r2, [r3], #4
- b _InitGlobals
-
_PrepareArguments
mov r0, r5
mov r1, r6
@@ -173,18 +178,4 @@ _PrepareArguments
_NeverReturn
b _NeverReturn
-_SetupUnicoreStack
- // The top of the Unicore Stack is in r1
- LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
- LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r3)
-
- // Calculate the bottom of the primary stack (StackBase)
- sub r7, r1, r3
-
- // The reserved space for global variable must be 8-bytes aligned for pushing
- // 64-bit variable on the stack
- SetPrimaryStack (r1, r2, r3)
-
- b _SetGlobals
-
END