]>
Commit | Line | Data |
---|---|---|
93deac7e HL |
1 | #------------------------------------------------------------------------------\r |
2 | #\r | |
3 | # Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r | |
eaa84fd5 | 4 | # Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r |
93deac7e HL |
5 | #\r |
6 | # This program and the accompanying materials\r | |
7 | # are licensed and made available under the terms and conditions of the BSD License\r | |
8 | # which accompanies this distribution. The full text of the license may be found at\r | |
9 | # http://opensource.org/licenses/bsd-license.php\r | |
10 | #\r | |
11 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | #\r | |
14 | #------------------------------------------------------------------------------\r | |
15 | \r | |
16 | #include <AsmMacroIoLibV8.h>\r | |
17 | \r | |
18 | .text\r | |
19 | .align 3\r | |
20 | GCC_ASM_EXPORT (ArmMainIdCode)\r | |
21 | GCC_ASM_EXPORT (ArmCacheInfo)\r | |
22 | GCC_ASM_EXPORT (ArmGetInterruptState)\r | |
23 | GCC_ASM_EXPORT (ArmGetFiqState)\r | |
24 | GCC_ASM_EXPORT (ArmGetTTBR0BaseAddress)\r | |
25 | GCC_ASM_EXPORT (ArmSetTTBR0)\r | |
26 | GCC_ASM_EXPORT (ArmGetTCR)\r | |
27 | GCC_ASM_EXPORT (ArmSetTCR)\r | |
28 | GCC_ASM_EXPORT (ArmGetMAIR)\r | |
29 | GCC_ASM_EXPORT (ArmSetMAIR)\r | |
30 | GCC_ASM_EXPORT (ArmWriteCpacr)\r | |
31 | GCC_ASM_EXPORT (ArmWriteAuxCr)\r | |
32 | GCC_ASM_EXPORT (ArmReadAuxCr)\r | |
33 | GCC_ASM_EXPORT (ArmInvalidateTlb)\r | |
34 | GCC_ASM_EXPORT (ArmUpdateTranslationTableEntry)\r | |
d6dc67ba | 35 | GCC_ASM_EXPORT (ArmWriteCptr)\r |
93deac7e HL |
36 | GCC_ASM_EXPORT (ArmWriteScr)\r |
37 | GCC_ASM_EXPORT (ArmWriteMVBar)\r | |
38 | GCC_ASM_EXPORT (ArmCallWFE)\r | |
39 | GCC_ASM_EXPORT (ArmCallSEV)\r | |
40 | \r | |
41 | #------------------------------------------------------------------------------\r | |
42 | \r | |
43 | .set DAIF_FIQ_BIT, (1 << 0)\r | |
44 | .set DAIF_IRQ_BIT, (1 << 1)\r | |
45 | \r | |
46 | ASM_PFX(ArmiMainIdCode):\r | |
47 | mrs x0, midr_el1 // Read from Main ID Register (MIDR)\r | |
48 | ret\r | |
49 | \r | |
50 | ASM_PFX(ArmCacheInfo):\r | |
51 | mrs x0, ctr_el0 // Read from Cache Type Regiter (CTR)\r | |
52 | ret\r | |
53 | \r | |
54 | ASM_PFX(ArmGetInterruptState):\r | |
55 | mrs x0, daif\r | |
56 | tst w0, #DAIF_IRQ_BIT // Check if IRQ is enabled. Enabled if 0.\r | |
57 | mov w0, #0\r | |
58 | mov w1, #1\r | |
59 | csel w0, w1, w0, ne\r | |
60 | ret\r | |
61 | \r | |
62 | ASM_PFX(ArmGetFiqState):\r | |
63 | mrs x0, daif\r | |
64 | tst w0, #DAIF_FIQ_BIT // Check if FIQ is enabled. Enabled if 0.\r | |
65 | mov w0, #0\r | |
66 | mov w1, #1\r | |
67 | csel w0, w1, w0, ne\r | |
68 | ret\r | |
69 | \r | |
70 | ASM_PFX(ArmWriteCpacr):\r | |
71 | msr cpacr_el1, x0 // Coprocessor Access Control Reg (CPACR)\r | |
72 | ret\r | |
73 | \r | |
74 | ASM_PFX(ArmWriteAuxCr):\r | |
75 | EL1_OR_EL2(x1)\r | |
76 | 1:msr actlr_el1, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r | |
77 | b 3f\r | |
78 | 2:msr actlr_el2, x0 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r | |
79 | 3:ret\r | |
80 | \r | |
81 | ASM_PFX(ArmReadAuxCr):\r | |
82 | EL1_OR_EL2(x1)\r | |
83 | 1:mrs x0, actlr_el1 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r | |
84 | b 3f\r | |
85 | 2:mrs x0, actlr_el2 // Aux Control Reg (ACTLR) at EL1. Also available in EL2 and EL3\r | |
86 | 3:ret\r | |
87 | \r | |
88 | ASM_PFX(ArmSetTTBR0):\r | |
89 | EL1_OR_EL2_OR_EL3(x1)\r | |
90 | 1:msr ttbr0_el1, x0 // Translation Table Base Reg 0 (TTBR0)\r | |
91 | b 4f\r | |
92 | 2:msr ttbr0_el2, x0 // Translation Table Base Reg 0 (TTBR0)\r | |
93 | b 4f\r | |
94 | 3:msr ttbr0_el3, x0 // Translation Table Base Reg 0 (TTBR0)\r | |
95 | 4:isb\r | |
96 | ret\r | |
97 | \r | |
98 | ASM_PFX(ArmGetTTBR0BaseAddress):\r | |
99 | EL1_OR_EL2(x1)\r | |
100 | 1:mrs x0, ttbr0_el1\r | |
101 | b 3f\r | |
102 | 2:mrs x0, ttbr0_el2\r | |
103 | 3:LoadConstantToReg(0xFFFFFFFFFFFF, x1) /* Look at bottom 48 bits */\r | |
104 | and x0, x0, x1\r | |
105 | isb\r | |
106 | ret\r | |
107 | \r | |
108 | ASM_PFX(ArmGetTCR):\r | |
109 | EL1_OR_EL2_OR_EL3(x1)\r | |
110 | 1:mrs x0, tcr_el1\r | |
111 | b 4f\r | |
112 | 2:mrs x0, tcr_el2\r | |
113 | b 4f\r | |
114 | 3:mrs x0, tcr_el3\r | |
115 | 4:isb\r | |
116 | ret\r | |
117 | \r | |
118 | ASM_PFX(ArmSetTCR):\r | |
119 | EL1_OR_EL2_OR_EL3(x1)\r | |
120 | 1:msr tcr_el1, x0\r | |
121 | b 4f\r | |
122 | 2:msr tcr_el2, x0\r | |
123 | b 4f\r | |
124 | 3:msr tcr_el3, x0\r | |
125 | 4:isb\r | |
126 | ret\r | |
127 | \r | |
128 | ASM_PFX(ArmGetMAIR):\r | |
129 | EL1_OR_EL2_OR_EL3(x1)\r | |
130 | 1:mrs x0, mair_el1\r | |
131 | b 4f\r | |
132 | 2:mrs x0, mair_el2\r | |
133 | b 4f\r | |
134 | 3:mrs x0, mair_el3\r | |
135 | 4:isb\r | |
136 | ret\r | |
137 | \r | |
138 | ASM_PFX(ArmSetMAIR):\r | |
139 | EL1_OR_EL2_OR_EL3(x1)\r | |
140 | 1:msr mair_el1, x0\r | |
141 | b 4f\r | |
142 | 2:msr mair_el2, x0\r | |
143 | b 4f\r | |
144 | 3:msr mair_el3, x0\r | |
145 | 4:isb\r | |
146 | ret\r | |
147 | \r | |
148 | \r | |
149 | //\r | |
150 | //VOID\r | |
151 | //ArmUpdateTranslationTableEntry (\r | |
152 | // IN VOID *TranslationTableEntry // X0\r | |
153 | // IN VOID *MVA // X1\r | |
154 | // );\r | |
155 | ASM_PFX(ArmUpdateTranslationTableEntry):\r | |
156 | dc civac, x0 // Clean and invalidate data line\r | |
157 | dsb sy\r | |
158 | EL1_OR_EL2_OR_EL3(x0)\r | |
159 | 1: tlbi vaae1, x1 // TLB Invalidate VA , EL1\r | |
160 | b 4f\r | |
161 | 2: tlbi vae2, x1 // TLB Invalidate VA , EL2\r | |
162 | b 4f\r | |
163 | 3: tlbi vae3, x1 // TLB Invalidate VA , EL3\r | |
164 | 4: dsb sy\r | |
165 | isb\r | |
166 | ret\r | |
167 | \r | |
168 | ASM_PFX(ArmInvalidateTlb):\r | |
169 | EL1_OR_EL2_OR_EL3(x0)\r | |
70f89c0b | 170 | 1: tlbi vmalle1\r |
93deac7e HL |
171 | b 4f\r |
172 | 2: tlbi alle2\r | |
173 | b 4f\r | |
174 | 3: tlbi alle3\r | |
175 | 4: dsb sy\r | |
176 | isb\r | |
177 | ret\r | |
178 | \r | |
d6dc67ba | 179 | ASM_PFX(ArmWriteCptr):\r |
93deac7e | 180 | msr cptr_el3, x0 // EL3 Coprocessor Trap Reg (CPTR)\r |
d6dc67ba | 181 | ret\r |
93deac7e HL |
182 | \r |
183 | ASM_PFX(ArmWriteScr):\r | |
184 | msr scr_el3, x0 // Secure configuration register EL3\r | |
185 | ret\r | |
186 | \r | |
187 | ASM_PFX(ArmWriteMVBar):\r | |
188 | msr vbar_el3, x0 // Excpetion Vector Base address for Monitor on EL3\r | |
189 | ret\r | |
190 | \r | |
191 | ASM_PFX(ArmCallWFE):\r | |
192 | wfe\r | |
193 | ret\r | |
194 | \r | |
195 | ASM_PFX(ArmCallSEV):\r | |
196 | sev\r | |
197 | ret\r | |
198 | \r | |
93deac7e HL |
199 | \r |
200 | ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r |