]>
Commit | Line | Data |
---|---|---|
cd872e40 | 1 | //\r |
2 | // Copyright (c) 2011, ARM Limited. All rights reserved.\r | |
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 <AsmMacroIoLib.h>\r | |
15 | #include <Base.h>\r | |
16 | #include <Library/PcdLib.h>\r | |
17 | #include <AutoGen.h>\r | |
18 | \r | |
19 | INCLUDE AsmMacroIoLib.inc\r | |
20 | \r | |
21 | IMPORT CEntryPoint\r | |
22 | EXPORT _ModuleEntryPoint\r | |
23 | \r | |
24 | PRESERVE8\r | |
25 | AREA PrePiCoreEntryPoint, CODE, READONLY\r | |
26 | \r | |
27 | StartupAddr DCD CEntryPoint\r | |
28 | \r | |
29 | _ModuleEntryPoint\r | |
30 | // Identify CPU ID\r | |
31 | mrc p15, 0, r0, c0, c0, 5\r | |
32 | and r0, #0xf\r | |
33 | \r | |
34 | _UefiMemoryBase\r | |
35 | #if FixedPcdGet32(PcdStandalone)\r | |
36 | // Compute Top of System Memory\r | |
37 | LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryBase), r1)\r | |
38 | LoadConstantToReg (FixedPcdGet32(PcdSystemMemorySize), r2)\r | |
39 | add r1, r1, r2 // r1 = SystemMemoryTop = PcdSystemMemoryBase + PcdSystemMemorySize\r | |
40 | #else\r | |
41 | // If it is not a Standalone, we must compute the top of the UEFI memory with the base of the FD\r | |
42 | LoadConstantToReg (FixedPcdGet32(PcdNormalFdBaseAddress), r1)\r | |
43 | #endif\r | |
44 | \r | |
45 | // Compute Base of UEFI Memory\r | |
46 | LoadConstantToReg (FixedPcdGet32(PcdSystemMemoryUefiRegionSize), r2)\r | |
47 | sub r1, r1, r2 // r1 = SystemMemoryTop - PcdSystemMemoryUefiRegionSize = UefiMemoryBase\r | |
48 | \r | |
49 | _SetupStack\r | |
50 | // Compute Base of Normal stacks for CPU Cores\r | |
51 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoresNonSecStackSize), r2)\r | |
52 | mul r3, r0, r2 // r3 = core_id * stack_size = offset from the stack base\r | |
53 | sub sp, r1, r3 // r3 = UefiMemoryBase - StackOffset = TopOfStack\r | |
54 | \r | |
55 | // Only allocate memory in top of the primary core stack\r | |
56 | cmp r0, #0\r | |
57 | bne _PrepareArguments\r | |
58 | \r | |
59 | _AllocateGlobalPrePiVariables\r | |
60 | // Reserve top of the stack for Global PEI Variables (eg: PeiServicesTablePointer)\r | |
61 | LoadConstantToReg (FixedPcdGet32(PcdPeiGlobalVariableSize), r4)\r | |
62 | // The reserved place must be 8-bytes aligned for pushing 64-bit variable on the stack\r | |
63 | and r5, r4, #7\r | |
64 | rsb r5, r5, #8\r | |
65 | add r4, r4, r5\r | |
66 | sub sp, sp, r4\r | |
67 | \r | |
68 | _PrepareArguments\r | |
69 | // Pass the StackBase to the C Entrypoint (UefiMemoryBase - StackSize - StackOffset)\r | |
70 | sub r2, r1, r2\r | |
71 | sub r2, r3\r | |
72 | // Move sec startup address into a data register\r | |
73 | // Ensure we're jumping to FV version of the code (not boot remapped alias)\r | |
74 | ldr r3, StartupAddr\r | |
75 | \r | |
76 | // jump to PrePiCore C code\r | |
77 | // r0 = core_id\r | |
78 | // r1 = UefiMemoryBase\r | |
79 | // r2 = StackBase\r | |
80 | blx r3\r | |
81 | \r | |
82 | END\r |