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