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
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
; 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
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
\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
- // 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
- LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)\r
// StackOffset = CorePos * StackSize\r
// StackOffset = CorePos * StackSize\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
\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
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
+ 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
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
\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
- // 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
- LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)\r
// StackOffset = CorePos * StackSize\r
// StackOffset = CorePos * StackSize\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
\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
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
+ 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
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
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
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
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
\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
+ // 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
_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
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
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
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
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
\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
+ // 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
_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
-// 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
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
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
_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
-// 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
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
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
_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