]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPlatformPkg: Updated the stack setup to have the same geometry between the Secure...
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Feb 2012 17:23:53 +0000 (17:23 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 28 Feb 2012 17:23:53 +0000 (17:23 +0000)
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

ArmPkg/Include/AsmMacroIoLib.h
ArmPkg/Include/AsmMacroIoLib.inc
ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.S
ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.asm
ArmPlatformPkg/PrePi/ModuleEntryPoint.S
ArmPlatformPkg/PrePi/ModuleEntryPoint.asm
ArmPlatformPkg/Sec/SecEntryPoint.S
ArmPlatformPkg/Sec/SecEntryPoint.asm

index 644c65466508df7974fb73f105ceb46986c3ded7..a4ae22dca03e4df6555f27a492f64b4a5f8a2284 100644 (file)
@@ -2,6 +2,7 @@
   Macros to work around lack of Apple support for LDR register, =expr\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
   Macros to work around lack of Apple support for LDR register, =expr\r
 \r
   Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
+  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 \r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   and     Tmp, GlobalSize, #7         ;             \\r
   rsbne   Tmp, Tmp, #8                ;             \\r
   add     GlobalSize, GlobalSize, Tmp ;             \\r
   and     Tmp, GlobalSize, #7         ;             \\r
   rsbne   Tmp, Tmp, #8                ;             \\r
   add     GlobalSize, GlobalSize, Tmp ;             \\r
-  sub     sp, StackTop, GlobalSize\r
+  sub     sp, StackTop, GlobalSize    ;             \\r
+                                      ;             \\r
+  mov     Tmp, sp                     ;             \\r
+  mov     GlobalSize, #0x0            ;             \\r
+_SetPrimaryStackInitGlobals:          ;             \\r
+  cmp     Tmp, StackTop               ;             \\r
+  beq     _SetPrimaryStackEnd         ;             \\r
+  str     GlobalSize, [Tmp], #4       ;             \\r
+  b       _SetPrimaryStackInitGlobals ;             \\r
+_SetPrimaryStackEnd:\r
 \r
 \r
 #elif defined (__GNUC__)\r
 \r
 \r
 #elif defined (__GNUC__)\r
   and     Tmp, GlobalSize, #7         ;             \\r
   rsbne   Tmp, Tmp, #8                ;             \\r
   add     GlobalSize, GlobalSize, Tmp ;             \\r
   and     Tmp, GlobalSize, #7         ;             \\r
   rsbne   Tmp, Tmp, #8                ;             \\r
   add     GlobalSize, GlobalSize, Tmp ;             \\r
-  sub     sp, StackTop, GlobalSize\r
+  sub     sp, StackTop, GlobalSize    ;             \\r
+                                      ;             \\r
+  mov     Tmp, sp                     ;             \\r
+  mov     GlobalSize, #0x0            ;             \\r
+_SetPrimaryStackInitGlobals:          ;             \\r
+  cmp     Tmp, StackTop               ;             \\r
+  beq     _SetPrimaryStackEnd         ;             \\r
+  str     GlobalSize, [Tmp], #4       ;             \\r
+  b       _SetPrimaryStackInitGlobals ;             \\r
+_SetPrimaryStackEnd:\r
 \r
 #else\r
 \r
 \r
 #else\r
 \r
index 5644bf9b3076f02ae16fd4ddb7ccd8bcd1d3f36d..a847579a37b5dd0681ae8aba4f72f59109b83b86 100644 (file)
@@ -3,6 +3,8 @@
 ;  Macros to work around lack of Apple support for LDR register, =expr\r
 ;\r
 ;  Copyright (c) 2009, Apple Inc. All rights reserved.<BR>\r
 ;  Macros to work around lack of Apple support for LDR register, =expr\r
 ;\r
 ;  Copyright (c) 2009, Apple Inc. All rights reserved.<BR>\r
+;  Copyright (c) 2011-2012, ARM Ltd. All rights reserved.<BR>\r
+;\r
 ;  This program and the accompanying materials                          \r
 ;  are licensed and made available under the terms and conditions of the BSD License         \r
 ;  which accompanies this distribution.  The full text of the license may be found at        \r
 ;  This program and the accompanying materials                          \r
 ;  are licensed and made available under the terms and conditions of the BSD License         \r
 ;  which accompanies this distribution.  The full text of the license may be found at        \r
   MEND\r
   \r
   ; The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack\r
   MEND\r
   \r
   ; The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack\r
+  ; Note: Global Size will be modified\r
   MACRO\r
   SetPrimaryStack $StackTop, $GlobalSize, $Tmp\r
   and     $Tmp, $GlobalSize, #7\r
   rsbne   $Tmp, $Tmp, #8\r
   add     $GlobalSize, $GlobalSize, $Tmp\r
   sub     sp, $StackTop, $GlobalSize\r
   MACRO\r
   SetPrimaryStack $StackTop, $GlobalSize, $Tmp\r
   and     $Tmp, $GlobalSize, #7\r
   rsbne   $Tmp, $Tmp, #8\r
   add     $GlobalSize, $GlobalSize, $Tmp\r
   sub     sp, $StackTop, $GlobalSize\r
+\r
+  ; Set all the global variables to 0\r
+  mov     $Tmp, sp\r
+  mov     $GlobalSize, #0x0\r
+_SetPrimaryStackInitGlobals\r
+  cmp     $Tmp, $StackTop\r
+  beq     _SetPrimaryStackEnd\r
+  str     $GlobalSize, [$Tmp], #4\r
+  b       _SetPrimaryStackInitGlobals\r
+\r
+_SetPrimaryStackEnd\r
   MEND\r
 \r
   END\r
   MEND\r
 \r
   END\r
index 261f6e554a83d9dfb6365d0c76cbe47dfc46829a..737b6ac19d5d2b5311499bfb389c50c7a7f6e39c 100644 (file)
@@ -30,50 +30,31 @@ ASM_PFX(_ModuleEntryPoint):
   bl    ASM_PFX(ArmReadMpidr)\r
   // Get ID of this CPU in Multicore system\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
   bl    ASM_PFX(ArmReadMpidr)\r
   // Get ID of this CPU in Multicore system\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
-  and   r0, r0, r1\r
-\r
-  // Calculate the top of the primary stack\r
+  and   r5, r0, r1\r
+  \r
+  // Get the top of the primary stacks (and the base of the secondary stacks)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
-  add   r2, r2, r1\r
+  add   r1, r1, r2\r
 \r
   // Is it the Primary Core ?\r
 \r
   // Is it the Primary Core ?\r
-  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r
-  cmp   r0, r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)\r
+  cmp   r5, r3\r
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack:\r
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack:\r
-  // r2 = Top of the primary stack = Base of the Secondary Stacks\r
+  // r1 contains the base of the secondary stacks\r
 \r
 \r
-  // Get the position of the cores (ClusterId * 4) + CoreId\r
-  GetCorePositionInStack(r3, r0, r1)\r
+  // Get the Core Position (ClusterId * 4) + CoreId\r
+  GetCorePositionInStack(r0, r5, r2)\r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
-  add   r3, r3, #1\r
+  add   r0, r0, #1\r
 \r
 \r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)\r
   // StackOffset = CorePos * StackSize\r
   // StackOffset = CorePos * StackSize\r
-  mul   r3, r3, r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)\r
+  mul   r0, r0, r2\r
   // SP = StackBase + StackOffset\r
   // SP = StackBase + StackOffset\r
-  add   sp, r2, r3\r
-\r
-  b     _PrepareArguments\r
-\r
-_SetupPrimaryCoreStack:\r
-  // r2 = Top of the primary stack\r
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), 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 (r2, r3, r1)\r
-\r
-  // Set all the PEI global variables to 0\r
-  mov   r3, sp\r
-  mov   r1, #0x0\r
-_InitGlobals:\r
-  cmp   r3, r2\r
-  beq   _PrepareArguments\r
-  str   r1, [r3], #4\r
-  b     _InitGlobals\r
+  add   sp, r1, r0\r
 \r
 _PrepareArguments:\r
   // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
 \r
 _PrepareArguments:\r
   // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
@@ -81,14 +62,24 @@ _PrepareArguments:
   add   r2, r2, #4\r
   ldr   r1, [r2]\r
 \r
   add   r2, r2, #4\r
   ldr   r1, [r2]\r
 \r
-  // move sec startup address into a data register\r
-  // ensure we're jumping to FV version of the code (not boot remapped alias)\r
-  ldr   r2, StartupAddr\r
-\r
-  // jump to PrePeiCore C code\r
+  // Move sec startup address into a data register\r
+  // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
+  ldr   r3, StartupAddr\r
+  \r
+  // Jump to PrePeiCore C code\r
   //    r0 = mp_id\r
   //    r1 = pei_core_address\r
   //    r0 = mp_id\r
   //    r1 = pei_core_address\r
-  blx   r2\r
+  mov   r0, r5\r
+  blx   r3\r
+\r
+_SetupPrimaryCoreStack:\r
+  // r1 contains the top of the primary stack\r
+  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)\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
+  b     _PrepareArguments\r
 \r
 _NeverReturn:\r
   b _NeverReturn\r
 \r
 _NeverReturn:\r
   b _NeverReturn\r
index ce3be2772ba44a88dc80050751abcbfdd6822965..60f6051b90bb2c456f554f0bfd61efbe1eb620d4 100644 (file)
@@ -32,50 +32,31 @@ _ModuleEntryPoint
   bl    ArmReadMpidr\r
   // Get ID of this CPU in Multicore system\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
   bl    ArmReadMpidr\r
   // Get ID of this CPU in Multicore system\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
-  and   r0, r0, r1\r
-\r
-  // Calculate the top of the primary stack\r
+  and   r5, r0, r1\r
+  \r
+  // Get the top of the primary stacks (and the base of the secondary stacks)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
-  add   r2, r2, r1\r
+  add   r1, r1, r2\r
 \r
   // Is it the Primary Core ?\r
 \r
   // Is it the Primary Core ?\r
-  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r
-  cmp   r0, r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)\r
+  cmp   r5, r3\r
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack\r
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack\r
-  // r2 = Top of the primary stack = Base of the Secondary Stacks\r
+  // r1 contains the base of the secondary stacks\r
 \r
 \r
-  // Get the position of the cores (ClusterId * 4) + CoreId\r
-  GetCorePositionInStack(r3, r0, r1)\r
+  // Get the Core Position (ClusterId * 4) + CoreId\r
+  GetCorePositionInStack(r0, r5, r2)\r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
-  add   r3, r3, #1\r
+  add   r0, r0, #1\r
 \r
 \r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)\r
   // StackOffset = CorePos * StackSize\r
   // StackOffset = CorePos * StackSize\r
-  mul   r3, r3, r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)\r
+  mul   r0, r0, r2\r
   // SP = StackBase + StackOffset\r
   // SP = StackBase + StackOffset\r
-  add   sp, r2, r3\r
-\r
-  b     _PrepareArguments\r
-\r
-_SetupPrimaryCoreStack\r
-  // r2 = Top of the primary stack\r
-  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), 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 (r2, r3, r1)\r
-\r
-  // Set all the PEI global variables to 0\r
-  mov   r3, sp\r
-  mov   r1, #0x0\r
-_InitGlobals\r
-  cmp   r3, r2\r
-  beq   _PrepareArguments\r
-  str   r1, [r3], #4\r
-  b     _InitGlobals\r
+  add   sp, r1, r0\r
 \r
 _PrepareArguments\r
   // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
 \r
 _PrepareArguments\r
   // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
@@ -83,14 +64,24 @@ _PrepareArguments
   add   r2, r2, #4\r
   ldr   r1, [r2]\r
 \r
   add   r2, r2, #4\r
   ldr   r1, [r2]\r
 \r
-  // move sec startup address into a data register\r
-  // ensure we're jumping to FV version of the code (not boot remapped alias)\r
-  ldr   r2, StartupAddr\r
-\r
-  // jump to PrePeiCore C code\r
+  // Move sec startup address into a data register\r
+  // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
+  ldr   r3, StartupAddr\r
+  \r
+  // Jump to PrePeiCore C code\r
   //    r0 = mp_id\r
   //    r1 = pei_core_address\r
   //    r0 = mp_id\r
   //    r1 = pei_core_address\r
-  blx   r2\r
+  mov   r0, r5\r
+  blx   r3\r
+\r
+_SetupPrimaryCoreStack\r
+  // r1 contains the top of the primary stack\r
+  LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)\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
+  b     _PrepareArguments\r
 \r
 _NeverReturn\r
   b _NeverReturn\r
 \r
 _NeverReturn\r
   b _NeverReturn\r
index fe9117218a6c1fb279358ce0f8813a7cdfdabf8a..52e50921b8ca6e7a7bfa6f01b2bf707bcc77b817 100755 (executable)
@@ -103,6 +103,7 @@ _GetStackBase:
   beq   _SetupUnicoreStack\r
 \r
 _GetStackBaseMpCore:\r
   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
   // 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
   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
 \r
   // Is it the Primary Core ?\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)\r
@@ -122,7 +127,7 @@ _GetStackBaseMpCore:
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack:\r
   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
 \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   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
 \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
   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
 \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
   // 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
 _PrepareArguments:\r
   mov   r0, r5\r
   mov   r1, r6\r
@@ -172,17 +177,3 @@ _PrepareArguments:
 _NeverReturn:\r
   b _NeverReturn\r
 \r
 _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
index d62efb2414b85f8407639be74ef98a795a1b2a48..e6b2d71361aee107d6514f50a1645ceb466b9c31 100644 (file)
@@ -104,6 +104,7 @@ _GetStackBase
   beq   _SetupUnicoreStack\r
 \r
 _GetStackBaseMpCore\r
   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
   // Stack for the primary core = PrimaryCoreStack\r
   LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
   sub   r7, r1, r2\r
@@ -114,8 +115,12 @@ _GetStackBaseMpCore
   mul   r2, r2, r3\r
   sub   r7, r7, r2\r
 \r
   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
 \r
   // Is it the Primary Core ?\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r4)\r
@@ -123,7 +128,7 @@ _GetStackBaseMpCore
   beq   _SetupPrimaryCoreStack\r
 \r
 _SetupSecondaryCoreStack\r
   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
 \r
   // Get the position of the cores (ClusterId * 4) + CoreId\r
   GetCorePositionInStack(r0, r5, r4)\r
@@ -131,28 +136,28 @@ _SetupSecondaryCoreStack
   add   r0, r0, #1\r
   // Get the offset for the Secondary Stack\r
   mul   r0, r0, r3\r
   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
 \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
   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
 \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
   // 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
 _PrepareArguments\r
   mov   r0, r5\r
   mov   r1, r6\r
@@ -173,18 +178,4 @@ _PrepareArguments
 _NeverReturn\r
   b _NeverReturn\r
 \r
 _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
   END\r
   END\r
index 6d3eb365319a8a9085c70ffb2517d463bf5510e9..42b18c40de3075c587c01e6326be1e58cd91d30c 100644 (file)
@@ -1,5 +1,5 @@
 //\r
 //\r
-//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+//  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
 //  \r
 //  This program and the accompanying materials                          \r
 //  are licensed and made available under the terms and conditions of the BSD License         \r
 //  \r
 //  This program and the accompanying materials                          \r
 //  are licensed and made available under the terms and conditions of the BSD License         \r
@@ -53,8 +53,8 @@ _IdentifyCpu:
   and   r5, r0, r1\r
   \r
   // Is it the Primary Core ?\r
   and   r5, r0, r1\r
   \r
   // Is it the Primary Core ?\r
-  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r
-  cmp   r5, r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)\r
+  cmp   r5, r3\r
   // Only the primary core initialize the memory (SMC)\r
   beq   _InitMem\r
   \r
   // Only the primary core initialize the memory (SMC)\r
   beq   _InitMem\r
   \r
@@ -72,42 +72,35 @@ _InitMem:
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r
 \r
 _SetupPrimaryCoreStack:\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r
 \r
 _SetupPrimaryCoreStack:\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r2)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r3)\r
-  // Calculate the Top of the Stack\r
-  add   r2, r2, r3\r
-  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r3)\r
+  // Get the top of the primary stacks (and the base of the secondary stacks)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
+  add   r1, r1, r2\r
+\r
+  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)\r
 \r
   // The reserved space for global variable must be 8-bytes aligned for pushing\r
   // 64-bit variable on the stack\r
 \r
   // The reserved space for global variable must be 8-bytes aligned for pushing\r
   // 64-bit variable on the stack\r
-  SetPrimaryStack (r2, r3, r1)\r
-\r
-  // Set all the SEC global variables to 0\r
-  mov     r3, sp\r
-  mov     r1, #0x0\r
-_InitGlobals:\r
-  cmp     r3, r2\r
-  beq     _PrepareArguments\r
-  str     r1, [r3], #4\r
-  b       _InitGlobals\r
+  SetPrimaryStack (r1, r2, r3)\r
+  b     _PrepareArguments\r
 \r
 _SetupSecondaryCoreStack:\r
 \r
 _SetupSecondaryCoreStack:\r
+  // Get the top of the primary stacks (and the base of the secondary stacks)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
+  add   r1, r1, r2\r
+\r
   // Get the Core Position (ClusterId * 4) + CoreId\r
   // Get the Core Position (ClusterId * 4) + CoreId\r
-  GetCorePositionInStack(r0, r5, r1)\r
+  GetCorePositionInStack(r0, r5, r2)\r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
   add   r0, r0, #1\r
 \r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
   add   r0, r0, #1\r
 \r
-  // Get the base of the stack for the secondary cores\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r
-  add   r1, r1, r2\r
-\r
   // StackOffset = CorePos * StackSize\r
   // StackOffset = CorePos * StackSize\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r
   mul   r0, r0, r2\r
   // SP = StackBase + StackOffset\r
   add   sp, r1, r0\r
 \r
   mul   r0, r0, r2\r
   // SP = StackBase + StackOffset\r
   add   sp, r1, r0\r
 \r
-\r
 _PrepareArguments:\r
   // Move sec startup address into a data register\r
   // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
 _PrepareArguments:\r
   // Move sec startup address into a data register\r
   // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
index fe362883607e1b5b85700d681f67410c9228fcf1..df443d055d1c9fd1373d5bc7bce0e2141d3a9410 100644 (file)
@@ -1,5 +1,5 @@
 //\r
 //\r
-//  Copyright (c) 2011, ARM Limited. All rights reserved.\r
+//  Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r
 //  \r
 //  This program and the accompanying materials                          \r
 //  are licensed and made available under the terms and conditions of the BSD License         \r
 //  \r
 //  This program and the accompanying materials                          \r
 //  are licensed and made available under the terms and conditions of the BSD License         \r
@@ -55,8 +55,8 @@ _IdentifyCpu
   and   r5, r0, r1\r
   \r
   // Is it the Primary Core ?\r
   and   r5, r0, r1\r
   \r
   // Is it the Primary Core ?\r
-  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r
-  cmp   r5, r1\r
+  LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)\r
+  cmp   r5, r3\r
   // Only the primary core initialize the memory (SMC)\r
   beq   _InitMem\r
   \r
   // Only the primary core initialize the memory (SMC)\r
   beq   _InitMem\r
   \r
@@ -74,42 +74,35 @@ _InitMem
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r
 \r
 _SetupPrimaryCoreStack\r
   LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r
 \r
 _SetupPrimaryCoreStack\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r2)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r3)\r
-  // Calculate the Top of the Stack\r
-  add   r2, r2, r3\r
-  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r3)\r
+  // Get the top of the primary stacks (and the base of the secondary stacks)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
+  add   r1, r1, r2\r
+\r
+  LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)\r
 \r
   // The reserved space for global variable must be 8-bytes aligned for pushing\r
   // 64-bit variable on the stack\r
 \r
   // The reserved space for global variable must be 8-bytes aligned for pushing\r
   // 64-bit variable on the stack\r
-  SetPrimaryStack (r2, r3, r1)\r
-\r
-  // Set all the SEC global variables to 0\r
-  mov     r3, sp\r
-  mov     r1, #0x0\r
-_InitGlobals\r
-  cmp     r3, r2\r
-  beq     _PrepareArguments\r
-  str     r1, [r3], #4\r
-  b       _InitGlobals\r
+  SetPrimaryStack (r1, r2, r3)\r
+  b     _PrepareArguments\r
 \r
 _SetupSecondaryCoreStack\r
 \r
 _SetupSecondaryCoreStack\r
+  // Get the top of the primary stacks (and the base of the secondary stacks)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
+  add   r1, r1, r2\r
+\r
   // Get the Core Position (ClusterId * 4) + CoreId\r
   // Get the Core Position (ClusterId * 4) + CoreId\r
-  GetCorePositionInStack(r0, r5, r1)\r
+  GetCorePositionInStack(r0, r5, r2)\r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
   add   r0, r0, #1\r
 \r
   // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
   add   r0, r0, #1\r
 \r
-  // Get the base of the stack for the secondary cores\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
-  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r
-  add   r1, r1, r2\r
-\r
   // StackOffset = CorePos * StackSize\r
   // StackOffset = CorePos * StackSize\r
+  LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r
   mul   r0, r0, r2\r
   // SP = StackBase + StackOffset\r
   add   sp, r1, r0\r
 \r
   mul   r0, r0, r2\r
   // SP = StackBase + StackOffset\r
   add   sp, r1, r0\r
 \r
-\r
 _PrepareArguments\r
   // Move sec startup address into a data register\r
   // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
 _PrepareArguments\r
   // Move sec startup address into a data register\r
   // Ensure we're jumping to FV version of the code (not boot remapped alias)\r