]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/PrePi/AArch64/ModuleEntryPoint.S
ArmPlatformPkg: use correct ASM decoration for non-function global symbols
[mirror_edk2.git] / ArmPlatformPkg / PrePi / AArch64 / ModuleEntryPoint.S
CommitLineData
1bc83266 1//\r
5dbacdb2 2// Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r
1bc83266
HL
3//\r
4// This program and the accompanying materials\r
5// are licensed and made available under the terms and conditions of the BSD License\r
6// which accompanies this distribution. The full text of the license may be found at\r
7// http://opensource.org/licenses/bsd-license.php\r
8//\r
9// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11//\r
12//\r
13\r
14#include <AsmMacroIoLibV8.h>\r
15#include <Base.h>\r
16#include <Library/PcdLib.h>\r
17#include <AutoGen.h>\r
18\r
1bc83266
HL
19.text\r
20.align 3\r
21\r
22GCC_ASM_IMPORT(ArmPlatformIsPrimaryCore)\r
23GCC_ASM_IMPORT(ArmReadMpidr)\r
24GCC_ASM_IMPORT(ArmPlatformPeiBootAction)\r
25GCC_ASM_IMPORT(ArmPlatformStackSet)\r
26GCC_ASM_EXPORT(_ModuleEntryPoint)\r
7afaa6de 27ASM_GLOBAL ASM_PFX(mSystemMemoryEnd)\r
1bc83266 28\r
7afaa6de
AB
29StartupAddr: .8byte ASM_PFX(CEntryPoint)\r
30ASM_PFX(mSystemMemoryEnd): .8byte 0\r
1bc83266
HL
31\r
32ASM_PFX(_ModuleEntryPoint):\r
33 // Do early platform specific actions\r
34 bl ASM_PFX(ArmPlatformPeiBootAction)\r
35\r
36 // Get ID of this CPU in Multicore system\r
37 bl ASM_PFX(ArmReadMpidr)\r
38 // Keep a copy of the MpId register value\r
39 mov x10, x0\r
40\r
41_SetSVCMode:\r
42// Check if we can install the stack at the top of the System Memory or if we need\r
43// to install the stacks at the bottom of the Firmware Device (case the FD is located\r
44// at the top of the DRAM)\r
5dbacdb2
OM
45_SystemMemoryEndInit:\r
46 ldr x1, mSystemMemoryEnd\r
47\r
48 // Is mSystemMemoryEnd initialized?\r
49 cmp x1, #0\r
50 bne _SetupStackPosition\r
51\r
52 LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), x1)\r
53 LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), x2)\r
1bc83266 54 sub x2, x2, #1\r
5dbacdb2
OM
55 add x1, x1, x2\r
56 // Update the global variable\r
57 adr x2, mSystemMemoryEnd\r
58 str x1, [x2]\r
59\r
60_SetupStackPosition:\r
61 // r1 = SystemMemoryTop\r
1bc83266
HL
62\r
63 // Calculate Top of the Firmware Device\r
64 LoadConstantToReg (FixedPcdGet32(PcdFdBaseAddress), x2)\r
65 LoadConstantToReg (FixedPcdGet32(PcdFdSize), x3)\r
66 sub x3, x3, #1\r
67 add x3, x3, x2 // x3 = FdTop = PcdFdBaseAddress + PcdFdSize\r
68\r
69 // UEFI Memory Size (stacks are allocated in this region)\r
70 LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), x4)\r
71\r
72 //\r
73 // Reserve the memory for the UEFI region (contain stacks on its top)\r
74 //\r
75\r
76 // Calculate how much space there is between the top of the Firmware and the Top of the System Memory\r
77 subs x0, x1, x3 // x0 = SystemMemoryTop - FdTop\r
78 b.mi _SetupStack // Jump if negative (FdTop > SystemMemoryTop). Case when the PrePi is in XIP memory outside of the DRAM\r
79 cmp x0, x4\r
80 b.ge _SetupStack\r
81\r
82 // Case the top of stacks is the FdBaseAddress\r
83 mov x1, x2\r
84\r
85_SetupStack:\r
86 // x1 contains the top of the stack (and the UEFI Memory)\r
87\r
88 // Because the 'push' instruction is equivalent to 'stmdb' (decrement before), we need to increment\r
89 // one to the top of the stack. We check if incrementing one does not overflow (case of DRAM at the\r
90 // top of the memory space)\r
91 adds x11, x1, #1\r
92 b.cs _SetupOverflowStack\r
93\r
94_SetupAlignedStack:\r
95 mov x1, x11\r
96 b _GetBaseUefiMemory\r
97\r
98_SetupOverflowStack:\r
99 // Case memory at the top of the address space. Ensure the top of the stack is EFI_PAGE_SIZE\r
100 // aligned (4KB)\r
101 LoadConstantToReg (EFI_PAGE_MASK, x11)\r
102 and x11, x11, x1\r
103 sub x1, x1, x11\r
104\r
105_GetBaseUefiMemory:\r
106 // Calculate the Base of the UEFI Memory\r
107 sub x11, x1, x4\r
108\r
109_GetStackBase:\r
110 // r1 = The top of the Mpcore Stacks\r
111 // Stack for the primary core = PrimaryCoreStack\r
112 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
113 sub x12, x1, x2\r
114\r
115 // Stack for the secondary core = Number of Cores - 1\r
116 LoadConstantToReg (FixedPcdGet32(PcdCoreCount), x0)\r
117 sub x0, x0, #1\r
118 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x1)\r
119 mul x1, x1, x0\r
120 sub x12, x12, x1\r
121\r
122 // x12 = The base of the MpCore Stacks (primary stack & secondary stacks)\r
123 mov x0, x12\r
124 mov x1, x10\r
125 //ArmPlatformStackSet(StackBase, MpId, PrimaryStackSize, SecondaryStackSize)\r
126 LoadConstantToReg (FixedPcdGet32(PcdCPUCorePrimaryStackSize), x2)\r
127 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecondaryStackSize), x3)\r
128 bl ASM_PFX(ArmPlatformStackSet)\r
129\r
130 // Is it the Primary Core ?\r
131 mov x0, x10\r
132 bl ASM_PFX(ArmPlatformIsPrimaryCore)\r
133 cmp x0, #1\r
134 bne _PrepareArguments\r
135\r
136_ReserveGlobalVariable:\r
137 LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), x0)\r
138 // InitializePrimaryStack($GlobalVariableSize, $Tmp1, $Tmp2)\r
139 InitializePrimaryStack(x0, x1, x2)\r
140\r
141_PrepareArguments:\r
142 mov x0, x10\r
143 mov x1, x11\r
144 mov x2, x12\r
145 mov x3, sp\r
146\r
147 // Move sec startup address into a data register\r
148 // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
149 ldr x4, StartupAddr\r
150\r
151 // Jump to PrePiCore C code\r
152 // x0 = MpId\r
153 // x1 = UefiMemoryBase\r
154 // x2 = StacksBase\r
155 // x3 = GlobalVariableBase\r
156 blr x4\r
157\r
158_NeverReturn:\r
159 b _NeverReturn\r