]>
Commit | Line | Data |
---|---|---|
90d6a1bb | 1 | //\r |
1377db63 | 2 | // Copyright (c) 2011-2012, ARM Limited. All rights reserved.\r |
90d6a1bb | 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 ArmPlatformSecBootAction\r | |
22 | IMPORT ArmPlatformInitializeBootMemory\r | |
23 | IMPORT ArmDisableInterrupts\r | |
24 | IMPORT ArmDisableCachesAndMmu\r | |
25 | IMPORT ArmWriteVBar\r | |
26 | IMPORT ArmReadMpidr\r | |
27 | IMPORT SecVectorTable\r | |
28 | IMPORT ArmCpuSynchronizeWait\r | |
29 | EXPORT _ModuleEntryPoint\r | |
30 | \r | |
31 | PRESERVE8\r | |
32 | AREA SecEntryPoint, CODE, READONLY\r | |
33 | \r | |
34 | StartupAddr DCD CEntryPoint\r | |
35 | \r | |
36 | _ModuleEntryPoint\r | |
37 | // First ensure all interrupts are disabled\r | |
38 | blx ArmDisableInterrupts\r | |
39 | \r | |
40 | // Ensure that the MMU and caches are off\r | |
41 | blx ArmDisableCachesAndMmu\r | |
42 | \r | |
43 | // Jump to Platform Specific Boot Action function\r | |
44 | blx ArmPlatformSecBootAction\r | |
45 | \r | |
46 | // Set VBAR to the start of the exception vectors in Secure Mode\r | |
47 | ldr r0, =SecVectorTable\r | |
48 | blx ArmWriteVBar\r | |
49 | \r | |
50 | _IdentifyCpu \r | |
51 | // Identify CPU ID\r | |
52 | bl ArmReadMpidr\r | |
53 | // Get ID of this CPU in Multicore system\r | |
54 | LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r | |
55 | and r5, r0, r1\r | |
56 | \r | |
57 | // Is it the Primary Core ?\r | |
1377db63 | 58 | LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)\r |
59 | cmp r5, r3\r | |
90d6a1bb | 60 | // Only the primary core initialize the memory (SMC)\r |
61 | beq _InitMem\r | |
62 | \r | |
63 | _WaitInitMem\r | |
64 | mov r0, #ARM_CPU_EVENT_BOOT_MEM_INIT\r | |
65 | bl ArmCpuSynchronizeWait\r | |
66 | // Now the Init Mem is initialized, we setup the secondary core stacks\r | |
67 | b _SetupSecondaryCoreStack\r | |
68 | \r | |
69 | _InitMem\r | |
70 | // Initialize Init Boot Memory\r | |
71 | bl ArmPlatformInitializeBootMemory\r | |
72 | \r | |
73 | // Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)\r | |
74 | LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r | |
75 | \r | |
76 | _SetupPrimaryCoreStack\r | |
1377db63 | 77 | // Get the top of the primary stacks (and the base of the secondary stacks)\r |
78 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r | |
79 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r | |
80 | add r1, r1, r2\r | |
81 | \r | |
82 | LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)\r | |
90d6a1bb | 83 | \r |
84 | // The reserved space for global variable must be 8-bytes aligned for pushing\r | |
85 | // 64-bit variable on the stack\r | |
1377db63 | 86 | SetPrimaryStack (r1, r2, r3)\r |
87 | b _PrepareArguments\r | |
90d6a1bb | 88 | \r |
89 | _SetupSecondaryCoreStack\r | |
1377db63 | 90 | // Get the top of the primary stacks (and the base of the secondary stacks)\r |
91 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r | |
92 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r | |
93 | add r1, r1, r2\r | |
94 | \r | |
90d6a1bb | 95 | // Get the Core Position (ClusterId * 4) + CoreId\r |
1377db63 | 96 | GetCorePositionInStack(r0, r5, r2)\r |
90d6a1bb | 97 | // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r |
98 | add r0, r0, #1\r | |
99 | \r | |
90d6a1bb | 100 | // StackOffset = CorePos * StackSize\r |
1377db63 | 101 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r |
90d6a1bb | 102 | mul r0, r0, r2\r |
103 | // SP = StackBase + StackOffset\r | |
104 | add sp, r1, r0\r | |
105 | \r | |
90d6a1bb | 106 | _PrepareArguments\r |
107 | // Move sec startup address into a data register\r | |
108 | // Ensure we're jumping to FV version of the code (not boot remapped alias)\r | |
109 | ldr r3, StartupAddr\r | |
110 | \r | |
111 | // Jump to SEC C code\r | |
112 | // r0 = mp_id\r | |
113 | mov r0, r5\r | |
114 | blx r3\r | |
115 | \r | |
116 | _NeverReturn\r | |
117 | b _NeverReturn\r | |
118 | END\r |