]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/Arm/PrePeiCoreEntryPoint.asm
ArmPlatformPkg RVCT: drop dependency on GCC macro library
[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 <AutoGen.h>
15
16 INCLUDE AsmMacroIoLib.inc
17
18 IMPORT CEntryPoint
19 IMPORT ArmPlatformGetCorePosition
20 IMPORT ArmPlatformIsPrimaryCore
21 IMPORT ArmReadMpidr
22 IMPORT ArmPlatformPeiBootAction
23 EXPORT _ModuleEntryPoint
24
25 PRESERVE8
26 AREA PrePeiCoreEntryPoint, CODE, READONLY
27
28 StartupAddr DCD CEntryPoint
29
30 _ModuleEntryPoint
31 // Do early platform specific actions
32 bl ArmPlatformPeiBootAction
33
34 // Identify CPU ID
35 bl ArmReadMpidr
36 // Keep a copy of the MpId register value
37 mov r5, r0
38
39 // Is it the Primary Core ?
40 bl ArmPlatformIsPrimaryCore
41
42 // Get the top of the primary stacks (and the base of the secondary stacks)
43 mov32 r1, FixedPcdGet64(PcdCPUCoresStackBase) + FixedPcdGet32(PcdCPUCorePrimaryStackSize)
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
53 mov r6, r1 // Save base of the secondary stacks
54 mov r0, r5
55 bl ArmPlatformGetCorePosition
56 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
57 add r0, r0, #1
58
59 // StackOffset = CorePos * StackSize
60 mov32 r2, FixedPcdGet32(PcdCPUCoreSecondaryStackSize)
61 mul r0, r0, r2
62 // SP = StackBase + StackOffset
63 add sp, r6, r0
64
65 _PrepareArguments
66 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
67 mov32 r2, FixedPcdGet32(PcdFvBaseAddress)
68 ldr r1, [r2, #4]
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 mov sp, r1
82 b _PrepareArguments
83
84 _NeverReturn
85 b _NeverReturn
86
87 END