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