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