]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmPlatformPkg/Sec/Arm/SecEntryPoint.asm
ArmPlatformPkg/ArmPlatformLib: Added support for ArmPlatformIsPrimaryCore()
[mirror_edk2.git] / ArmPlatformPkg / Sec / Arm / SecEntryPoint.asm
... / ...
CommitLineData
1//\r
2// Copyright (c) 2011-2013, 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 <AutoGen.h>\r
15#include <AsmMacroIoLib.h>\r
16#include "SecInternal.h"\r
17\r
18 INCLUDE AsmMacroIoLib.inc\r
19 \r
20 IMPORT CEntryPoint\r
21 IMPORT ArmPlatformIsPrimaryCore\r
22 IMPORT ArmPlatformSecBootAction\r
23 IMPORT ArmPlatformSecBootMemoryInit\r
24 IMPORT ArmDisableInterrupts\r
25 IMPORT ArmDisableCachesAndMmu\r
26 IMPORT ArmReadMpidr\r
27 IMPORT ArmCallWFE\r
28 EXPORT _ModuleEntryPoint\r
29\r
30 PRESERVE8\r
31 AREA SecEntryPoint, CODE, READONLY\r
32 \r
33StartupAddr DCD CEntryPoint\r
34\r
35_ModuleEntryPoint FUNCTION\r
36 // First ensure all interrupts are disabled\r
37 bl ArmDisableInterrupts\r
38\r
39 // Ensure that the MMU and caches are off\r
40 bl ArmDisableCachesAndMmu\r
41\r
42 // By default, we are doing a cold boot\r
43 mov r10, #ARM_SEC_COLD_BOOT\r
44\r
45 // Jump to Platform Specific Boot Action function\r
46 blx ArmPlatformSecBootAction\r
47\r
48_IdentifyCpu \r
49 // Identify CPU ID\r
50 bl ArmReadMpidr\r
51 // Keep a copy of the MpId register value\r
52 mov r9, r0\r
53 \r
54 // Is it the Primary Core ?\r
55 bl ArmPlatformIsPrimaryCore\r
56 cmp r0, #1\r
57 // Only the primary core initialize the memory (SMC)\r
58 beq _InitMem\r
59 \r
60_WaitInitMem\r
61 // If we are not doing a cold boot in this case we should assume the Initial Memory to be already initialized\r
62 // Otherwise we have to wait the Primary Core to finish the initialization\r
63 cmp r10, #ARM_SEC_COLD_BOOT\r
64 bne _SetupSecondaryCoreStack\r
65\r
66 // Wait for the primary core to initialize the initial memory (event: BOOT_MEM_INIT)\r
67 bl ArmCallWFE\r
68 // Now the Init Mem is initialized, we setup the secondary core stacks\r
69 b _SetupSecondaryCoreStack\r
70 \r
71_InitMem\r
72 // If we are not doing a cold boot in this case we should assume the Initial Memory to be already initialized\r
73 cmp r10, #ARM_SEC_COLD_BOOT\r
74 bne _SetupPrimaryCoreStack\r
75\r
76 // Initialize Init Boot Memory\r
77 bl ArmPlatformSecBootMemoryInit\r
78 \r
79_SetupPrimaryCoreStack\r
80 // Get the top of the primary stacks (and the base of the secondary stacks)\r
81 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
82 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
83 add r1, r1, r2\r
84\r
85 LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)\r
86\r
87 // The reserved space for global variable must be 8-bytes aligned for pushing\r
88 // 64-bit variable on the stack\r
89 SetPrimaryStack (r1, r2, r3)\r
90 b _PrepareArguments\r
91\r
92_SetupSecondaryCoreStack\r
93 // Get the top of the primary stacks (and the base of the secondary stacks)\r
94 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
95 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
96 add r1, r1, r2\r
97\r
98 // Get the Core Position (ClusterId * 4) + CoreId\r
99 GetCorePositionFromMpId(r0, r9, r2)\r
100 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
101 add r0, r0, #1\r
102\r
103 // StackOffset = CorePos * StackSize\r
104 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r
105 mul r0, r0, r2\r
106 // SP = StackBase + StackOffset\r
107 add sp, r1, r0\r
108\r
109_PrepareArguments\r
110 // Move sec startup address into a data register\r
111 // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
112 ldr r3, StartupAddr\r
113 \r
114 // Jump to SEC C code\r
115 // r0 = mp_id\r
116 // r1 = Boot Mode\r
117 mov r0, r9\r
118 mov r1, r10\r
119 blx r3\r
120 ENDFUNC\r
121 \r
122_NeverReturn\r
123 b _NeverReturn\r
124 END\r