]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.S
ARM Packages: Replaced the macro GetCorePositionFromMpId() by the ArmPlatformGetCoreP...
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / Arm / PrePeiCoreEntryPoint.S
1 //
2 // Copyright (c) 2011-2013, 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(ArmPlatformGetCorePosition)
24 GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)
25 GCC_ASM_IMPORT(ArmReadMpidr)
26 GCC_ASM_EXPORT(_ModuleEntryPoint)
27
28 StartupAddr: .word CEntryPoint
29
30 ASM_PFX(_ModuleEntryPoint):
31 // Identify CPU ID
32 bl ASM_PFX(ArmReadMpidr)
33 // Keep a copy of the MpId register value
34 mov r5, r0
35
36 // Is it the Primary Core ?
37 bl ASM_PFX(ArmPlatformIsPrimaryCore)
38
39 // Get the top of the primary stacks (and the base of the secondary stacks)
40 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
41 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
42 add r1, r1, r2
43
44 // r0 is equal to 1 if I am the primary core
45 cmp r0, #1
46 beq _SetupPrimaryCoreStack
47
48 _SetupSecondaryCoreStack:
49 // r1 contains the base of the secondary stacks
50
51 // Get the Core Position
52 mov r6, r1 // Save base of the secondary stacks
53 mov r0, r5
54 bl ASM_PFX(ArmPlatformGetCorePosition)
55 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
56 add r0, r0, #1
57
58 // StackOffset = CorePos * StackSize
59 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r2)
60 mul r0, r0, r2
61 // SP = StackBase + StackOffset
62 add sp, r6, r0
63
64 _PrepareArguments:
65 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
66 LoadConstantToReg (FixedPcdGet32(PcdFvBaseAddress), r2)
67 add r2, r2, #4
68 ldr r1, [r2]
69
70 // Move sec startup address into a data register
71 // Ensure we're jumping to FV version of the code (not boot remapped alias)
72 ldr r3, StartupAddr
73
74 // Jump to PrePeiCore C code
75 // r0 = mp_id
76 // r1 = pei_core_address
77 mov r0, r5
78 blx r3
79
80 _SetupPrimaryCoreStack:
81 // r1 contains the top of the primary stack
82 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r2)
83
84 // The reserved space for global variable must be 8-bytes aligned for pushing
85 // 64-bit variable on the stack
86 SetPrimaryStack (r1, r2, r3)
87 b _PrepareArguments
88
89 _NeverReturn:
90 b _NeverReturn