]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.asm
ArmPkg: Move ARM Platform drivers from ArmPkg/Drivers/ to ArmPlatformPkg/Drivers/
[mirror_edk2.git] / ArmPlatformPkg / PrePeiCore / PrePeiCoreEntryPoint.asm
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 INCLUDE AsmMacroIoLib.inc
20
21 IMPORT CEntryPoint
22 EXPORT _ModuleEntryPoint
23
24 PRESERVE8
25 AREA PrePeiCoreEntryPoint, CODE, READONLY
26
27 StartupAddr DCD CEntryPoint
28
29 _ModuleEntryPoint
30 // Identify CPU ID
31 mrc p15, 0, r0, c0, c0, 5
32 and r0, #0xf
33
34 _SetupStack
35 // Setup Stack for the 4 CPU cores
36 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackBase), r1)
37 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackSize), r2)
38
39 mov r3, r0 // r3 = core_id
40 mul r3, r3, r2 // r3 = core_id * stack_size = offset from the stack base
41 add r3, r3, r1 // r3 = stack_base + offset
42 add r3, r3, r2, LSR #1 // r3 = stack_offset + (stack_size/2) <-- the top half is for the heap
43 mov sp, r3
44
45 // Only allocate memory in top of the primary core stack
46 cmp r0, #0
47 bne _PrepareArguments
48
49 _AllocateGlobalPeiVariables
50 // Reserve top of the stack for Global PEI Variables (eg: PeiServicesTablePointer)
51 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r1)
52 sub sp, sp, r1
53
54 _PrepareArguments
55 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
56 LoadConstantToReg (FixedPcdGet32(PcdNormalFvBaseAddress), r2)
57 add r2, r2, #4
58 ldr r1, [r2]
59
60 // move sec startup address into a data register
61 // ensure we're jumping to FV version of the code (not boot remapped alias)
62 ldr r2, StartupAddr
63
64 // jump to PrePeiCore C code
65 // r0 = core_id
66 // r1 = pei_core_address
67 blx r2
68
69 END