]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Sec/SecEntryPoint.asm
ArmPkg: Fixed unsigned type to be architecture independent
[mirror_edk2.git] / ArmPlatformPkg / Sec / SecEntryPoint.asm
CommitLineData
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
e314d564 22 IMPORT ArmPlatformSecBootMemoryInit\r
90d6a1bb 23 IMPORT ArmDisableInterrupts\r
24 IMPORT ArmDisableCachesAndMmu\r
90d6a1bb 25 IMPORT ArmReadMpidr\r
b1d41be7 26 IMPORT ArmCallWFE\r
90d6a1bb 27 EXPORT _ModuleEntryPoint\r
28\r
29 PRESERVE8\r
30 AREA SecEntryPoint, CODE, READONLY\r
31 \r
32StartupAddr DCD CEntryPoint\r
33\r
a75568e9 34_ModuleEntryPoint FUNCTION\r
90d6a1bb 35 // First ensure all interrupts are disabled\r
36 blx ArmDisableInterrupts\r
37\r
38 // Ensure that the MMU and caches are off\r
39 blx ArmDisableCachesAndMmu\r
40\r
a75568e9 41 // By default, we are doing a cold boot\r
42 mov r10, #ARM_SEC_COLD_BOOT\r
43\r
90d6a1bb 44 // Jump to Platform Specific Boot Action function\r
45 blx ArmPlatformSecBootAction\r
46\r
90d6a1bb 47_IdentifyCpu \r
48 // Identify CPU ID\r
49 bl ArmReadMpidr\r
50 // Get ID of this CPU in Multicore system\r
51 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
52 and r5, r0, r1\r
53 \r
54 // Is it the Primary Core ?\r
1377db63 55 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r3)\r
56 cmp r5, r3\r
90d6a1bb 57 // Only the primary core initialize the memory (SMC)\r
58 beq _InitMem\r
59 \r
60_WaitInitMem\r
a75568e9 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
b1d41be7 66 // Wait for the primary core to initialize the initial memory (event: BOOT_MEM_INIT)\r
67 bl ArmCallWFE\r
90d6a1bb 68 // Now the Init Mem is initialized, we setup the secondary core stacks\r
69 b _SetupSecondaryCoreStack\r
70 \r
71_InitMem\r
8cfd2e24 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
90d6a1bb 76 // Initialize Init Boot Memory\r
e314d564 77 bl ArmPlatformSecBootMemoryInit\r
90d6a1bb 78 \r
79 // Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)\r
80 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r5)\r
81\r
82_SetupPrimaryCoreStack\r
1377db63 83 // Get the top of the primary stacks (and the base of the secondary stacks)\r
84 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
85 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
86 add r1, r1, r2\r
87\r
88 LoadConstantToReg (FixedPcdGet32(PcdSecGlobalVariableSize), r2)\r
90d6a1bb 89\r
90 // The reserved space for global variable must be 8-bytes aligned for pushing\r
91 // 64-bit variable on the stack\r
1377db63 92 SetPrimaryStack (r1, r2, r3)\r
93 b _PrepareArguments\r
90d6a1bb 94\r
95_SetupSecondaryCoreStack\r
1377db63 96 // Get the top of the primary stacks (and the base of the secondary stacks)\r
97 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
98 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecPrimaryStackSize), r2)\r
99 add r1, r1, r2\r
100\r
90d6a1bb 101 // Get the Core Position (ClusterId * 4) + CoreId\r
a32dae48 102 GetCorePositionFromMpId(r0, r5, r2)\r
90d6a1bb 103 // The stack starts at the top of the stack region. Add '1' to the Core Position to get the top of the stack\r
104 add r0, r0, #1\r
105\r
90d6a1bb 106 // StackOffset = CorePos * StackSize\r
1377db63 107 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecSecondaryStackSize), r2)\r
90d6a1bb 108 mul r0, r0, r2\r
109 // SP = StackBase + StackOffset\r
110 add sp, r1, r0\r
111\r
90d6a1bb 112_PrepareArguments\r
113 // Move sec startup address into a data register\r
114 // Ensure we're jumping to FV version of the code (not boot remapped alias)\r
115 ldr r3, StartupAddr\r
116 \r
117 // Jump to SEC C code\r
118 // r0 = mp_id\r
a75568e9 119 // r1 = Boot Mode\r
90d6a1bb 120 mov r0, r5\r
a75568e9 121 mov r1, r10\r
90d6a1bb 122 blx r3\r
a75568e9 123 ENDFUNC\r
90d6a1bb 124 \r
125_NeverReturn\r
126 b _NeverReturn\r
127 END\r