]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
f902a251c22c57f69183bbbfd5ee6936d9d1a9c7
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / Arm / PrePeiCoreEntryPoint.S
1 //
2 // Copyright (c) 2011, ARM Limited. All rights reserved.
3 //
4 // This program and the accompanying materials
5 // are licensed and made available under the terms and conditions of the BSD License
6 // which accompanies this distribution. The full text of the license may be found at
7 // http://opensource.org/licenses/bsd-license.php
8 //
9 // THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11 //
12 //
13
14 #include <AsmMacroIoLib.h>
15 #include <Base.h>
16 #include <Library/PcdLib.h>
17 #include <AutoGen.h>
18
19 .text
20 .align 3
21
22 GCC_ASM_IMPORT(CEntryPoint)
23 GCC_ASM_IMPORT(ArmReadMpidr)
24 GCC_ASM_EXPORT(_ModuleEntryPoint)
25
26 StartupAddr: .word CEntryPoint
27
28 ASM_PFX(_ModuleEntryPoint):
29 // Identify CPU ID
30 bl ASM_PFX(ArmReadMpidr)
31 // Get ID of this CPU in Multicore system
32 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)
33 and r5, r0, r1
34
35 // Get the top of the primary stacks (and the base of the secondary stacks)
36 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
37 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
38 add r1, r1, r2
39
40 // Is it the Primary Core ?
41 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)
42 cmp r5, r3
43 beq _SetupPrimaryCoreStack
44
45 _SetupSecondaryCoreStack:
46 // r1 contains the base of the secondary stacks
47
48 // Get the Core Position (ClusterId * 4) + CoreId
49 GetCorePositionFromMpId(r0, r5, r2)
50 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
51 add r0, r0, #1
52
53 // StackOffset = CorePos * StackSize
54 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)
55 mul r0, r0, r2
56 // SP = StackBase + StackOffset
57 add sp, r1, r0
58
59 _PrepareArguments:
60 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
61 LoadConstantToReg (FixedPcdGet32(PcdFvBaseAddress), r2)
62 add r2, r2, #4
63 ldr r1, [r2]
64
65 // Move sec startup address into a data register
66 // Ensure we're jumping to FV version of the code (not boot remapped alias)
67 ldr r3, StartupAddr
68
69 // Jump to PrePeiCore C code
70 // r0 = mp_id
71 // r1 = pei_core_address
72 mov r0, r5
73 blx r3
74
75 _SetupPrimaryCoreStack:
76 // r1 contains the top of the primary stack
77 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
78
79 // The reserved space for global variable must be 8-bytes aligned for pushing
80 // 64-bit variable on the stack
81 SetPrimaryStack (r1, r2, r3)
82 b _PrepareArguments
83
84 _NeverReturn:
85 b _NeverReturn