]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Sec/SecEntryPoint.S
ArmPlatformPkg/ArmPlatformLib: Introduce ArmPlatformSecBootAction function
[mirror_edk2.git] / ArmPlatformPkg / Sec / SecEntryPoint.S
CommitLineData
11c20f4e 1#------------------------------------------------------------------------------ \r
2#\r
3# ARM VE Entry point. Reset vector in FV header will brach to\r
4# _ModuleEntryPoint. \r
5#\r
6# Copyright (c) 2011, ARM Limited. All rights reserved.\r
7# \r
8# This program and the accompanying materials \r
9# are licensed and made available under the terms and conditions of the BSD License \r
10# which accompanies this distribution. The full text of the license may be found at \r
11# http://opensource.org/licenses/bsd-license.php \r
12#\r
13# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
14# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
15#\r
16#------------------------------------------------------------------------------\r
17\r
18#include <AsmMacroIoLib.h>\r
19#include <Base.h>\r
20#include <Library/PcdLib.h>\r
21#include <Library/ArmPlatformLib.h>\r
22#include <AutoGen.h>\r
23\r
24#Start of Code section\r
25.text\r
26.align 3\r
27\r
28#make _ModuleEntryPoint as global\r
29GCC_ASM_EXPORT(_ModuleEntryPoint)\r
30\r
31#global functions referenced by this module\r
32GCC_ASM_IMPORT(CEntryPoint)\r
44e272fd 33GCC_ASM_IMPORT(ArmPlatformSecBootAction)\r
11c20f4e 34GCC_ASM_IMPORT(ArmPlatformIsMemoryInitialized)\r
35GCC_ASM_IMPORT(ArmPlatformInitializeBootMemory)\r
36GCC_ASM_IMPORT(ArmDisableInterrupts)\r
37GCC_ASM_IMPORT(ArmDisableCachesAndMmu)\r
38GCC_ASM_IMPORT(ArmWriteVBar)\r
0787bc61 39GCC_ASM_IMPORT(ArmReadMpidr)\r
11c20f4e 40GCC_ASM_IMPORT(SecVectorTable)\r
41\r
42#if (FixedPcdGet32(PcdMPCoreSupport))\r
43GCC_ASM_IMPORT(ArmIsScuEnable)\r
44#endif\r
45\r
46StartupAddr: .word ASM_PFX(CEntryPoint)\r
47SecVectorTableAddr: .word ASM_PFX(SecVectorTable)\r
48\r
49ASM_PFX(_ModuleEntryPoint):\r
11c20f4e 50 # First ensure all interrupts are disabled\r
51 bl ASM_PFX(ArmDisableInterrupts)\r
52\r
53 # Ensure that the MMU and caches are off\r
54 bl ASM_PFX(ArmDisableCachesAndMmu)\r
55\r
44e272fd 56 # Jump to Platform Specific Boot Action function\r
57 blx ASM_PFX(ArmPlatformSecBootAction)\r
58\r
59 # Set VBAR to the start of the exception vectors in Secure Mode\r
60 ldr r0, =SecVectorTable\r
61 bl ASM_PFX(ArmWriteVBar)\r
62\r
11c20f4e 63_IdentifyCpu: \r
64 # Identify CPU ID\r
65 bl ASM_PFX(ArmReadMpidr)\r
0787bc61 66 // Get ID of this CPU in Multicore system\r
67 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCoreMask), r1)\r
68 and r5, r0, r1\r
11c20f4e 69 \r
70 #get ID of this CPU in Multicore system\r
0787bc61 71 LoadConstantToReg (FixedPcdGet32(PcdArmPrimaryCore), r1)\r
72 cmp r5, r1\r
11c20f4e 73 # Only the primary core initialize the memory (SMC)\r
74 beq _InitMem\r
75 \r
76#if (FixedPcdGet32(PcdMPCoreSupport))\r
77 # ... The secondary cores wait for SCU to be enabled\r
78_WaitForEnabledScu:\r
79 bl ASM_PFX(ArmIsScuEnable)\r
80 tst r1, #1\r
81 beq _WaitForEnabledScu\r
82 b _SetupStack\r
83#endif\r
84 \r
85_InitMem:\r
86 bl ASM_PFX(ArmPlatformIsMemoryInitialized)\r
87 bne _SetupStack\r
88 \r
89 # Initialize Init Memory\r
90 bl ASM_PFX(ArmPlatformInitializeBootMemory)\r
91\r
92 # Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)\r
93 mov r5, #0\r
94 \r
95_SetupStack:\r
96 # Setup Stack for the 4 CPU cores\r
97 #Read Stack Base address from PCD\r
98 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
99\r
100 #read Stack size from PCD\r
101 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecStackSize), r2)\r
102\r
103 #calcuate Stack Pointer reg value using Stack size and CPU ID.\r
104 mov r3,r5 @ r3 = core_id\r
105 mul r3,r3,r2 @ r3 = core_id * stack_size = offset from the stack base\r
106 add r3,r3,r1 @ r3 ldr= stack_base + offset\r
107 mov sp, r3\r
108 \r
109 # move sec startup address into a data register\r
110 # ensure we're jumping to FV version of the code (not boot remapped alias)\r
111 ldr r3, StartupAddr\r
112 \r
113 # Move the CoreId in r0 to be the first argument of the SEC Entry Point\r
114 mov r0, r5\r
115\r
116 # jump to SEC C code\r
117 # r0 = core_id\r
118 blx r3\r
119\r
120\r