]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.asm
ArmPlatformPkg: Changed memory model for the stacks
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / PrePeiCoreEntryPoint.asm
CommitLineData
1d5d0ae9 1//\r
2// Copyright (c) 2011, ARM Limited. All rights reserved.\r
3// \r
4// This program and the accompanying materials \r
5// are licensed and made available under the terms and conditions of the BSD License \r
6// which accompanies this distribution. The full text of the license may be found at \r
7// http://opensource.org/licenses/bsd-license.php \r
8//\r
9// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11//\r
12//\r
13\r
14#include <AsmMacroIoLib.h>\r
15#include <Base.h>\r
16#include <Library/PcdLib.h>\r
17#include <AutoGen.h>\r
18\r
19 INCLUDE AsmMacroIoLib.inc\r
20 \r
21 IMPORT CEntryPoint\r
0787bc61 22 IMPORT ArmReadMpidr\r
1d5d0ae9 23 EXPORT _ModuleEntryPoint\r
24 \r
25 PRESERVE8\r
26 AREA PrePeiCoreEntryPoint, CODE, READONLY\r
27 \r
28StartupAddr DCD CEntryPoint\r
29\r
1d5d0ae9 30_ModuleEntryPoint\r
31 // Identify CPU ID\r
0787bc61 32 bl ArmReadMpidr\r
33 // Get ID of this CPU in Multicore system\r
34 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
35 and r0, r0, r1\r
1d5d0ae9 36\r
2dbcb8f0 37 // Calculate the top of the primary stack\r
38 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)\r
39 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)\r
40 add r2, r2, r1\r
41\r
42 // Is it the Primary Core ?\r
43 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r
44 cmp r0, r1\r
45 beq _SetupPrimaryCoreStack\r
46\r
47_SetupSecondaryCoreStack\r
48 // r2 = Top of the primary stack = Base of the Secondary Stacks\r
49\r
50 // Get the position of the cores (ClusterId * 4) + CoreId\r
51 GetCorePositionInStack(r3, r0, r1)\r
52 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
53 add r3, r3, #1\r
1d5d0ae9 54\r
2dbcb8f0 55 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)\r
56 // StackOffset = CorePos * StackSize\r
57 mul r3, r3, r1\r
58 // SP = StackBase + StackOffset\r
59 add sp, r2, r3\r
47a8e12f 60\r
2dbcb8f0 61 b _PrepareArguments\r
62\r
63_SetupPrimaryCoreStack\r
64 // r2 = Top of the primary stack\r
65 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r3)\r
66\r
67 // The reserved space for global variable must be 8-bytes aligned for pushing\r
68 // 64-bit variable on the stack\r
69 SetPrimaryStack (r2, r3, r1)\r
70\r
71 // Set all the PEI global variables to 0\r
72 mov r3, sp\r
73 mov r1, #0x0\r
74_InitGlobals\r
75 str r1, [r3], #4\r
76 cmp r3, r2\r
77 blt _InitGlobals\r
47a8e12f 78\r
79_PrepareArguments\r
1d5d0ae9 80 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
1ad14bc8 81 LoadConstantToReg (FixedPcdGet32(PcdNormalFvBaseAddress), r2)\r
1d5d0ae9 82 add r2, r2, #4\r
83 ldr r1, [r2]\r
84\r
85 // move sec startup address into a data register\r
86 // ensure we're jumping to FV version of the code (not boot remapped alias)\r
87 ldr r2, StartupAddr\r
88\r
262a9b04 89 // jump to PrePeiCore C code\r
0787bc61 90 // r0 = mp_id\r
1d5d0ae9 91 // r1 = pei_core_address\r
92 blx r2\r
93\r
2dbcb8f0 94_NeverReturn\r
95 b _NeverReturn\r
96\r
1d5d0ae9 97 END\r