]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.S
ARM Packages: Rename PcdNormal* into Pcd* PCDs
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / 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 r0, r0, r1
34
35 // Calculate the top of the primary stack
36 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
37 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
38 add r2, r2, r1
39
40 // Is it the Primary Core ?
41 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)
42 cmp r0, r1
43 beq _SetupPrimaryCoreStack
44
45 _SetupSecondaryCoreStack:
46 // r2 = Top of the primary stack = Base of the Secondary Stacks
47
48 // Get the position of the cores (ClusterId * 4) + CoreId
49 GetCorePositionInStack(r3, r0, r1)
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 r3, r3, #1
52
53 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)
54 // StackOffset = CorePos * StackSize
55 mul r3, r3, r1
56 // SP = StackBase + StackOffset
57 add sp, r2, r3
58
59 b _PrepareArguments
60
61 _SetupPrimaryCoreStack:
62 // r2 = Top of the primary stack
63 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r3)
64
65 // The reserved space for global variable must be 8-bytes aligned for pushing
66 // 64-bit variable on the stack
67 SetPrimaryStack (r2, r3, r1)
68
69 // Set all the PEI global variables to 0
70 mov r3, sp
71 mov r1, #0x0
72 _InitGlobals:
73 str r1, [r3], #4
74 cmp r3, r2
75 blt _InitGlobals
76
77 _PrepareArguments:
78 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
79 LoadConstantToReg (FixedPcdGet32(PcdFvBaseAddress), r2)
80 add r2, r2, #4
81 ldr r1, [r2]
82
83 // move sec startup address into a data register
84 // ensure we're jumping to FV version of the code (not boot remapped alias)
85 ldr r2, StartupAddr
86
87 // jump to PrePeiCore C code
88 // r0 = mp_id
89 // r1 = pei_core_address
90 blx r2
91
92 _NeverReturn:
93 b _NeverReturn