]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPlatformPkg/PrePeiCore/PrePeiCoreEntryPoint.asm
ArmPlatformPkg/PrePi: Fixed stack setup when System Memory is mapped upto 0xFFFFFFFF
[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 // Calculate the top of the primary stack
38 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresStackBase), r1)
39 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), r2)
40 add r2, r2, r1
41
42 // Is it the Primary Core ?
43 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)
44 cmp r0, r1
45 beq _SetupPrimaryCoreStack
46
47 _SetupSecondaryCoreStack
48 // r2 = Top of the primary stack = Base of the Secondary Stacks
49
50 // Get the position of the cores (ClusterId * 4) + CoreId
51 GetCorePositionInStack(r3, r0, r1)
52 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack
53 add r3, r3, #1
54
55 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), r1)
56 // StackOffset = CorePos * StackSize
57 mul r3, r3, r1
58 // SP = StackBase + StackOffset
59 add sp, r2, r3
60
61 b _PrepareArguments
62
63 _SetupPrimaryCoreStack
64 // r2 = Top of the primary stack
65 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r3)
66
67 // The reserved space for global variable must be 8-bytes aligned for pushing
68 // 64-bit variable on the stack
69 SetPrimaryStack (r2, r3, r1)
70
71 // Set all the PEI global variables to 0
72 mov r3, sp
73 mov r1, #0x0
74 _InitGlobals
75 cmp r3, r2
76 beq _PrepareArguments
77 str r1, [r3], #4
78 b _InitGlobals
79
80 _PrepareArguments
81 // The PEI Core Entry Point has been computed by GenFV and stored in the second entry of the Reset Vector
82 LoadConstantToReg (FixedPcdGet32(PcdFvBaseAddress), r2)
83 add r2, r2, #4
84 ldr r1, [r2]
85
86 // move sec startup address into a data register
87 // ensure we're jumping to FV version of the code (not boot remapped alias)
88 ldr r2, StartupAddr
89
90 // jump to PrePeiCore C code
91 // r0 = mp_id
92 // r1 = pei_core_address
93 blx r2
94
95 _NeverReturn
96 b _NeverReturn
97
98 END