]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPlatformPkg/Sec/SecEntryPoint.S
ArmPkg: Renamed library 'PL390GicLib' into 'ArmGicLib'
[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
33GCC_ASM_IMPORT(ArmPlatformIsMemoryInitialized)\r
34GCC_ASM_IMPORT(ArmPlatformInitializeBootMemory)\r
35GCC_ASM_IMPORT(ArmDisableInterrupts)\r
36GCC_ASM_IMPORT(ArmDisableCachesAndMmu)\r
37GCC_ASM_IMPORT(ArmWriteVBar)\r
38GCC_ASM_IMPORT(SecVectorTable)\r
39\r
40#if (FixedPcdGet32(PcdMPCoreSupport))\r
41GCC_ASM_IMPORT(ArmIsScuEnable)\r
42#endif\r
43\r
44StartupAddr: .word ASM_PFX(CEntryPoint)\r
45SecVectorTableAddr: .word ASM_PFX(SecVectorTable)\r
46\r
47ASM_PFX(_ModuleEntryPoint):\r
48 #Set VBAR to the start of the exception vectors in Secure Mode\r
49 ldr r0, SecVectorTableAddr\r
50 bl ASM_PFX(ArmWriteVBar)\r
51\r
52 # First ensure all interrupts are disabled\r
53 bl ASM_PFX(ArmDisableInterrupts)\r
54\r
55 # Ensure that the MMU and caches are off\r
56 bl ASM_PFX(ArmDisableCachesAndMmu)\r
57\r
58_IdentifyCpu: \r
59 # Identify CPU ID\r
60 bl ASM_PFX(ArmReadMpidr)\r
61 and r5, r0, #0xf\r
62 \r
63 #get ID of this CPU in Multicore system\r
64 cmp r5, #0\r
65 # Only the primary core initialize the memory (SMC)\r
66 beq _InitMem\r
67 \r
68#if (FixedPcdGet32(PcdMPCoreSupport))\r
69 # ... The secondary cores wait for SCU to be enabled\r
70_WaitForEnabledScu:\r
71 bl ASM_PFX(ArmIsScuEnable)\r
72 tst r1, #1\r
73 beq _WaitForEnabledScu\r
74 b _SetupStack\r
75#endif\r
76 \r
77_InitMem:\r
78 bl ASM_PFX(ArmPlatformIsMemoryInitialized)\r
79 bne _SetupStack\r
80 \r
81 # Initialize Init Memory\r
82 bl ASM_PFX(ArmPlatformInitializeBootMemory)\r
83\r
84 # Only Primary CPU could run this line (the secondary cores have jumped from _IdentifyCpu to _SetupStack)\r
85 mov r5, #0\r
86 \r
87_SetupStack:\r
88 # Setup Stack for the 4 CPU cores\r
89 #Read Stack Base address from PCD\r
90 LoadConstantToReg (FixedPcdGet32(PcdCPUCoresSecStackBase), r1)\r
91\r
92 #read Stack size from PCD\r
93 LoadConstantToReg (FixedPcdGet32(PcdCPUCoreSecStackSize), r2)\r
94\r
95 #calcuate Stack Pointer reg value using Stack size and CPU ID.\r
96 mov r3,r5 @ r3 = core_id\r
97 mul r3,r3,r2 @ r3 = core_id * stack_size = offset from the stack base\r
98 add r3,r3,r1 @ r3 ldr= stack_base + offset\r
99 mov sp, r3\r
100 \r
101 # move sec startup address into a data register\r
102 # ensure we're jumping to FV version of the code (not boot remapped alias)\r
103 ldr r3, StartupAddr\r
104 \r
105 # Move the CoreId in r0 to be the first argument of the SEC Entry Point\r
106 mov r0, r5\r
107\r
108 # jump to SEC C code\r
109 # r0 = core_id\r
110 blx r3\r
111\r
112\r