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