]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.S
ArmPlatformPkg: Introduce Primary core macros
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / PrePeiCoreEntryPoint.S
CommitLineData
11c20f4e 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.text\r
20.align 3\r
21\r
11c20f4e 22GCC_ASM_IMPORT(CEntryPoint)\r
0787bc61 23GCC_ASM_IMPORT(ArmReadMpidr)\r
11c20f4e 24GCC_ASM_EXPORT(_ModuleEntryPoint)\r
25\r
0787bc61 26StartupAddr: .word CEntryPoint\r
11c20f4e 27\r
28ASM_PFX(_ModuleEntryPoint):\r
29 # Identify CPU ID\r
0787bc61 30 bl ASM_PFX(ArmReadMpidr)\r
31 // Get ID of this CPU in Multicore system\r
32 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
33 and r0, r0, r1\r
11c20f4e 34\r
35_SetupStack:\r
36 # Setup Stack for the 4 CPU cores\r
37 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackBase), r1)\r
38 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackSize), r2)\r
39 \r
40 mov r3,r0 @ r3 = core_id\r
41 mul r3,r3,r2 @ r3 = core_id * stack_size = offset from the stack base\r
42 add r3,r3,r1 @ r3 = stack_base + offset\r
43 add r3,r3,r2,LSR #1 @ r3 = stack_offset + (stack_size/2) <-- the top half is for the heap\r
44 mov sp, r3\r
45\r
46 # Only allocate memory in top of the primary core stack\r
47 cmp r0, #0\r
48 bne _PrepareArguments\r
49\r
50_AllocateGlobalPeiVariables:\r
51 # Reserve top of the stack for Global PEI Variables (eg: PeiServicesTablePointer)\r
52 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r1)\r
53 sub sp, sp, r1\r
54\r
55_PrepareArguments:\r
56 # The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector\r
57 LoadConstantToReg (FixedPcdGet32(PcdNormalFvBaseAddress), r2)\r
58 add r2, r2, #4\r
59 ldr r1, [r2]\r
60\r
61 # move sec startup address into a data register\r
62 # ensure we're jumping to FV version of the code (not boot remapped alias)\r
63 ldr r2, StartupAddr\r
64\r
65 # jump to PrePeiCore C code\r
66 # r0 = core_id\r
67 # r1 = pei_core_address\r
68 blx r2\r