]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmPlatformPkg/PrePi/ModuleEntryPoint.S
ArmPlatformPkg: Updated the stack setup to have the same geometry between the Secure...
[mirror_edk2.git] / ArmPlatformPkg / PrePi / ModuleEntryPoint.S
index fe9117218a6c1fb279358ce0f8813a7cdfdabf8a..52e50921b8ca6e7a7bfa6f01b2bf707bcc77b817 100755 (executable)
@@ -103,6 +103,7 @@ _GetStackBase:
   beq   _SetupUnicoreStack\r
 \r
 _GetStackBaseMpCore:\r
+  // r1 = The top of the Mpcore Stacks\r
   // Stack for the primary core = PrimaryCoreStack\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
   sub   r7, r1, r2\r
@@ -113,8 +114,12 @@ _GetStackBaseMpCore:
   mul   r2, r2, r3\r
   sub   r7, r7, r2\r
 \r
-  // The top of the Mpcore Stacks is in r1\r
-  // The base of the MpCore Stacks is in r7\r
+  // The base of the secondary Stacks = Top of Primary stack\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
+  add   r1, r7, r2\r
+\r
+  // r7 = The base of the MpCore Stacks\r
+  // r1 = The base of the secondary Stacks = Top of the Primary stack\r
 \r
   // Is it the Primary Core ?\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)\r
@@ -122,7 +127,7 @@ _GetStackBaseMpCore:
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack:\r
-  // Base of the stack for the secondary cores is in r7\r
+  // r1 = The base of the secondary Stacks\r
 \r
   // Get the position of the cores (ClusterId * 4) + CoreId\r
   GetCorePositionInStack(r0, r5, r4)\r
@@ -130,28 +135,28 @@ _SetupSecondaryCoreStack:
   add   r0, r0, #1\r
   // Get the offset for the Secondary Stack\r
   mul   r0, r0, r3\r
-  add   sp, r7, r0\r
+  add   sp, r1, r0\r
 \r
   bne   _PrepareArguments\r
 \r
 _SetupPrimaryCoreStack:\r
-  // The top of the Mpcore Stacks is in r1\r
+  // r1 = Top of the primary stack\r
   LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)\r
+  b     _PreparePrimaryStack\r
+\r
+_SetupUnicoreStack:\r
+  // The top of the Unicore Stack is in r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r3)\r
 \r
+  // Calculate the bottom of the primary stack (StackBase)\r
+  sub   r7, r1, r3\r
+\r
+_PreparePrimaryStack:\r
   // The reserved space for global variable must be 8-bytes aligned for pushing\r
   // 64-bit variable on the stack\r
   SetPrimaryStack (r1, r2, r3)\r
 \r
-_SetGlobals:\r
-  // Set all the PrePi global variables to 0\r
-  mov   r3, sp\r
-  mov   r2, #0x0\r
-_InitGlobals:\r
-  cmp   r3, r1\r
-  beq   _PrepareArguments\r
-  str   r2, [r3], #4\r
-  b     _InitGlobals\r
-\r
 _PrepareArguments:\r
   mov   r0, r5\r
   mov   r1, r6\r
@@ -172,17 +177,3 @@ _PrepareArguments:
 _NeverReturn:\r
   b _NeverReturn\r
 \r
-_SetupUnicoreStack:\r
-  // The top of the Unicore Stack is in r1\r
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r3)\r
-\r
-  // Calculate the bottom of the primary stack (StackBase)\r
-  sub   r7, r1, r3\r
-\r
-  // The reserved space for global variable must be 8-bytes aligned for pushing\r
-  // 64-bit variable on the stack\r
-  SetPrimaryStack (r1, r2, r3)\r
-\r
-  b _SetGlobals\r
-\r