]>
Commit | Line | Data |
---|---|---|
2dbcb8f0 | 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 | |
11c20f4e | 13 | \r |
2dbcb8f0 | 14 | #include <AutoGen.h>\r |
11c20f4e | 15 | #include <AsmMacroIoLib.h>\r |
16 | #include <Base.h>\r | |
17 | #include <Library/PcdLib.h>\r | |
18 | #include <Library/ArmPlatformLib.h>\r | |
11c20f4e | 19 | \r |
11c20f4e | 20 | .text\r |
21 | .align 3\r | |
22 | \r | |
11c20f4e | 23 | GCC_ASM_EXPORT(_ModuleEntryPoint)\r |
24 | \r | |
11c20f4e | 25 | GCC_ASM_IMPORT(CEntryPoint)\r |
44e272fd | 26 | GCC_ASM_IMPORT(ArmPlatformSecBootAction)\r |
11c20f4e | 27 | GCC_ASM_IMPORT(ArmPlatformInitializeBootMemory)\r |
28 | GCC_ASM_IMPORT(ArmDisableInterrupts)\r | |
29 | GCC_ASM_IMPORT(ArmDisableCachesAndMmu)\r | |
30 | GCC_ASM_IMPORT(ArmWriteVBar)\r | |
0787bc61 | 31 | GCC_ASM_IMPORT(ArmReadMpidr)\r |
11c20f4e | 32 | GCC_ASM_IMPORT(SecVectorTable)\r |
33 | \r | |
34 | #if (FixedPcdGet32(PcdMPCoreSupport))\r | |
35 | GCC_ASM_IMPORT(ArmIsScuEnable)\r | |
36 | #endif\r | |
37 | \r | |
2dbcb8f0 | 38 | StartupAddr: .word ASM_PFX(CEntryPoint)\r |
39 | SecVectorTableAddr: .word ASM_PFX(SecVectorTable)\r | |
11c20f4e | 40 | \r |
41 | ASM_PFX(_ModuleEntryPoint):\r | |
2dbcb8f0 | 42 | // First ensure all interrupts are disabled\r |
43 | bl ASM_PFX(ArmDisableInterrupts)\r | |
11c20f4e | 44 | \r |
2dbcb8f0 | 45 | // Ensure that the MMU and caches are off\r |
46 | bl ASM_PFX(ArmDisableCachesAndMmu)\r | |
11c20f4e | 47 | \r |
2dbcb8f0 | 48 | // Jump to Platform Specific Boot Action function\r |
44e272fd | 49 | blx ASM_PFX(ArmPlatformSecBootAction)\r |
50 | \r | |
2dbcb8f0 | 51 | // Set VBAR to the start of the exception vectors in Secure Mode\r |
44e272fd | 52 | ldr r0, =SecVectorTable\r |
53 | bl ASM_PFX(ArmWriteVBar)\r | |
54 | \r | |
2dbcb8f0 | 55 | _IdentifyCpu:\r |
56 | // Identify CPU ID\r | |
11c20f4e | 57 | bl ASM_PFX(ArmReadMpidr)\r |
0787bc61 | 58 | // Get ID of this CPU in Multicore system\r |
59 | LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r | |
60 | and r5, r0, r1\r | |
11c20f4e | 61 | \r |
2dbcb8f0 | 62 | // Is it the Primary Core ?\r |
0787bc61 | 63 | LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r |
64 | cmp r5, r1\r | |
2dbcb8f0 | 65 | // Only the primary core initialize the memory (SMC)\r |
11c20f4e | 66 | beq _InitMem\r |
67 | \r | |
68 | #if (FixedPcdGet32(PcdMPCoreSupport))\r | |
2dbcb8f0 | 69 | // ... The secondary cores wait for SCU to be enabled\r |
11c20f4e | 70 | _WaitForEnabledScu:\r |
71 | bl ASM_PFX(ArmIsScuEnable)\r | |
72 | tst r1, #1\r | |
73 | beq _WaitForEnabledScu\r | |
2dbcb8f0 | 74 | b _SetupSecondaryCoreStack\r |
11c20f4e | 75 | #endif\r |
76 | \r | |
77 | _InitMem:\r | |
f156d5b4 | 78 | // Initialize Init Boot Memory\r |
11c20f4e | 79 | bl ASM_PFX(ArmPlatformInitializeBootMemory)\r |
2dbcb8f0 | 80 | \r |
81 | // Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)\r | |
82 | LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r | |
83 | \r | |
84 | _SetupPrimaryCoreStack:\r | |
85 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r2)\r | |
86 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r3)\r | |
87 | // Calculate the Top of the Stack\r | |
88 | add r2, r2, r3\r | |
89 | LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r3)\r | |
90 | \r | |
91 | // The reserved space for global variable must be 8-bytes aligned for pushing\r | |
92 | // 64-bit variable on the stack\r | |
93 | SetPrimaryStack (r2, r3, r1)\r | |
94 | \r | |
95 | // Set all the SEC global variables to 0\r | |
96 | mov r3, sp\r | |
97 | mov r1, #0x0\r | |
98 | _InitGlobals:\r | |
99 | str r1, [r3], #4\r | |
100 | cmp r3, r2\r | |
101 | blt _InitGlobals\r | |
102 | \r | |
103 | b _PrepareArguments\r | |
104 | \r | |
105 | _SetupSecondaryCoreStack:\r | |
106 | // Get the Core Position (ClusterId * 4) + CoreId\r | |
107 | GetCorePositionInStack(r0, r5, r1)\r | |
108 | // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r | |
109 | add r0, r0, #1\r | |
110 | \r | |
111 | // Get the base of the stack for the secondary cores\r | |
11c20f4e | 112 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r |
2dbcb8f0 | 113 | LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r |
114 | add r1, r1, r2\r | |
11c20f4e | 115 | \r |
2dbcb8f0 | 116 | // StackOffset = CorePos * StackSize\r |
117 | mul r0, r0, r2\r | |
118 | // SP = StackBase + StackOffset\r | |
119 | add sp, r1, r0\r | |
11c20f4e | 120 | \r |
2dbcb8f0 | 121 | \r |
122 | _PrepareArguments:\r | |
123 | // Move sec startup address into a data register\r | |
124 | // Ensure we're jumping to FV version of the code (not boot remapped alias)\r | |
11c20f4e | 125 | ldr r3, StartupAddr\r |
126 | \r | |
2dbcb8f0 | 127 | // Jump to SEC C code\r |
128 | // r0 = mp_id\r | |
11c20f4e | 129 | mov r0, r5\r |
2dbcb8f0 | 130 | blx r3\r |
131 | \r | |
132 | _NeverReturn:\r | |
133 | b _NeverReturn\r |