]>
Commit | Line | Data |
---|---|---|
25402f5d HL |
1 | #------------------------------------------------------------------------------\r |
2 | #\r | |
3 | # Copyright (c) 2008 - 2010, Apple Inc. All rights reserved.<BR>\r | |
9401d6f4 | 4 | # Copyright (c) 2011 - 2014, ARM Limited. All rights reserved.\r |
25402f5d 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 <Chipset/AArch64.h>\r | |
17 | #include <AsmMacroIoLibV8.h>\r | |
18 | \r | |
19 | .text\r | |
20 | .align 3\r | |
21 | \r | |
22 | GCC_ASM_EXPORT (ArmInvalidateInstructionCache)\r | |
23 | GCC_ASM_EXPORT (ArmInvalidateDataCacheEntryByMVA)\r | |
24 | GCC_ASM_EXPORT (ArmCleanDataCacheEntryByMVA)\r | |
25 | GCC_ASM_EXPORT (ArmCleanInvalidateDataCacheEntryByMVA)\r | |
26 | GCC_ASM_EXPORT (ArmInvalidateDataCacheEntryBySetWay)\r | |
27 | GCC_ASM_EXPORT (ArmCleanDataCacheEntryBySetWay)\r | |
28 | GCC_ASM_EXPORT (ArmCleanInvalidateDataCacheEntryBySetWay)\r | |
29 | GCC_ASM_EXPORT (ArmDrainWriteBuffer)\r | |
30 | GCC_ASM_EXPORT (ArmEnableMmu)\r | |
31 | GCC_ASM_EXPORT (ArmDisableMmu)\r | |
32 | GCC_ASM_EXPORT (ArmDisableCachesAndMmu)\r | |
33 | GCC_ASM_EXPORT (ArmMmuEnabled)\r | |
34 | GCC_ASM_EXPORT (ArmEnableDataCache)\r | |
35 | GCC_ASM_EXPORT (ArmDisableDataCache)\r | |
36 | GCC_ASM_EXPORT (ArmEnableInstructionCache)\r | |
37 | GCC_ASM_EXPORT (ArmDisableInstructionCache)\r | |
38 | GCC_ASM_EXPORT (ArmDisableAlignmentCheck)\r | |
39 | GCC_ASM_EXPORT (ArmEnableAlignmentCheck)\r | |
40 | GCC_ASM_EXPORT (ArmEnableBranchPrediction)\r | |
41 | GCC_ASM_EXPORT (ArmDisableBranchPrediction)\r | |
42 | GCC_ASM_EXPORT (AArch64AllDataCachesOperation)\r | |
43 | GCC_ASM_EXPORT (AArch64PerformPoUDataCacheOperation)\r | |
44 | GCC_ASM_EXPORT (ArmDataMemoryBarrier)\r | |
45 | GCC_ASM_EXPORT (ArmDataSyncronizationBarrier)\r | |
46 | GCC_ASM_EXPORT (ArmInstructionSynchronizationBarrier)\r | |
47 | GCC_ASM_EXPORT (ArmWriteVBar)\r | |
f0247796 | 48 | GCC_ASM_EXPORT (ArmReadVBar)\r |
25402f5d HL |
49 | GCC_ASM_EXPORT (ArmEnableVFP)\r |
50 | GCC_ASM_EXPORT (ArmCallWFI)\r | |
25402f5d HL |
51 | GCC_ASM_EXPORT (ArmReadMpidr)\r |
52 | GCC_ASM_EXPORT (ArmReadTpidrurw)\r | |
53 | GCC_ASM_EXPORT (ArmWriteTpidrurw)\r | |
54 | GCC_ASM_EXPORT (ArmIsArchTimerImplemented)\r | |
55 | GCC_ASM_EXPORT (ArmReadIdPfr0)\r | |
56 | GCC_ASM_EXPORT (ArmReadIdPfr1)\r | |
57 | GCC_ASM_EXPORT (ArmWriteHcr)\r | |
58 | GCC_ASM_EXPORT (ArmReadCurrentEL)\r | |
59 | \r | |
60 | .set CTRL_M_BIT, (1 << 0)\r | |
61 | .set CTRL_A_BIT, (1 << 1)\r | |
62 | .set CTRL_C_BIT, (1 << 2)\r | |
63 | .set CTRL_I_BIT, (1 << 12)\r | |
64 | .set CTRL_V_BIT, (1 << 12)\r | |
65 | .set CPACR_VFP_BITS, (3 << 20)\r | |
66 | \r | |
67 | ASM_PFX(ArmInvalidateDataCacheEntryByMVA):\r | |
68 | dc ivac, x0 // Invalidate single data cache line\r | |
69 | dsb sy\r | |
70 | isb\r | |
71 | ret\r | |
72 | \r | |
73 | \r | |
74 | ASM_PFX(ArmCleanDataCacheEntryByMVA):\r | |
75 | dc cvac, x0 // Clean single data cache line\r | |
76 | dsb sy\r | |
77 | isb\r | |
78 | ret\r | |
79 | \r | |
80 | \r | |
81 | ASM_PFX(ArmCleanInvalidateDataCacheEntryByMVA):\r | |
82 | dc civac, x0 // Clean and invalidate single data cache line\r | |
83 | dsb sy\r | |
84 | isb\r | |
85 | ret\r | |
86 | \r | |
87 | \r | |
88 | ASM_PFX(ArmInvalidateDataCacheEntryBySetWay):\r | |
89 | dc isw, x0 // Invalidate this line\r | |
90 | dsb sy\r | |
91 | isb\r | |
92 | ret\r | |
93 | \r | |
94 | \r | |
95 | ASM_PFX(ArmCleanInvalidateDataCacheEntryBySetWay):\r | |
96 | dc cisw, x0 // Clean and Invalidate this line\r | |
97 | dsb sy\r | |
98 | isb\r | |
99 | ret\r | |
100 | \r | |
101 | \r | |
102 | ASM_PFX(ArmCleanDataCacheEntryBySetWay):\r | |
103 | dc csw, x0 // Clean this line\r | |
104 | dsb sy\r | |
105 | isb\r | |
106 | ret\r | |
107 | \r | |
108 | \r | |
109 | ASM_PFX(ArmInvalidateInstructionCache):\r | |
110 | ic iallu // Invalidate entire instruction cache\r | |
111 | dsb sy\r | |
112 | isb\r | |
113 | ret\r | |
114 | \r | |
115 | \r | |
116 | ASM_PFX(ArmEnableMmu):\r | |
117 | EL1_OR_EL2_OR_EL3(x1)\r | |
118 | 1: mrs x0, sctlr_el1 // Read System control register EL1\r | |
119 | b 4f\r | |
120 | 2: mrs x0, sctlr_el2 // Read System control register EL2\r | |
121 | b 4f\r | |
122 | 3: mrs x0, sctlr_el3 // Read System control register EL3\r | |
123 | 4: orr x0, x0, #CTRL_M_BIT // Set MMU enable bit\r | |
124 | EL1_OR_EL2_OR_EL3(x1)\r | |
70f89c0b | 125 | 1: tlbi vmalle1\r |
25402f5d HL |
126 | isb\r |
127 | msr sctlr_el1, x0 // Write back\r | |
128 | b 4f\r | |
129 | 2: tlbi alle2\r | |
130 | isb\r | |
131 | msr sctlr_el2, x0 // Write back\r | |
132 | b 4f\r | |
133 | 3: tlbi alle3\r | |
134 | isb\r | |
135 | msr sctlr_el3, x0 // Write back\r | |
136 | 4: dsb sy\r | |
137 | isb\r | |
138 | ret\r | |
139 | \r | |
140 | \r | |
141 | ASM_PFX(ArmDisableMmu):\r | |
142 | EL1_OR_EL2_OR_EL3(x1)\r | |
143 | 1: mrs x0, sctlr_el1 // Read System Control Register EL1\r | |
144 | b 4f\r | |
145 | 2: mrs x0, sctlr_el2 // Read System Control Register EL2\r | |
146 | b 4f\r | |
147 | 3: mrs x0, sctlr_el3 // Read System Control Register EL3\r | |
73ca5009 | 148 | 4: and x0, x0, #~CTRL_M_BIT // Clear MMU enable bit\r |
25402f5d HL |
149 | EL1_OR_EL2_OR_EL3(x1)\r |
150 | 1: msr sctlr_el1, x0 // Write back\r | |
70f89c0b | 151 | tlbi vmalle1\r |
25402f5d HL |
152 | b 4f\r |
153 | 2: msr sctlr_el2, x0 // Write back\r | |
154 | tlbi alle2\r | |
155 | b 4f\r | |
156 | 3: msr sctlr_el3, x0 // Write back\r | |
157 | tlbi alle3\r | |
158 | 4: dsb sy\r | |
159 | isb\r | |
160 | ret\r | |
161 | \r | |
162 | \r | |
163 | ASM_PFX(ArmDisableCachesAndMmu):\r | |
164 | EL1_OR_EL2_OR_EL3(x1)\r | |
165 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
166 | b 4f\r | |
167 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
168 | b 4f\r | |
169 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
73ca5009 BJ |
170 | 4: mov x1, #~(CTRL_M_BIT | CTRL_C_BIT | CTRL_I_BIT) // Disable MMU, D & I caches\r |
171 | and x0, x0, x1\r | |
25402f5d HL |
172 | EL1_OR_EL2_OR_EL3(x1)\r |
173 | 1: msr sctlr_el1, x0 // Write back control register\r | |
174 | b 4f\r | |
175 | 2: msr sctlr_el2, x0 // Write back control register\r | |
176 | b 4f\r | |
177 | 3: msr sctlr_el3, x0 // Write back control register\r | |
178 | 4: dsb sy\r | |
179 | isb\r | |
180 | ret\r | |
181 | \r | |
182 | \r | |
183 | ASM_PFX(ArmMmuEnabled):\r | |
184 | EL1_OR_EL2_OR_EL3(x1)\r | |
185 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
186 | b 4f\r | |
187 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
188 | b 4f\r | |
189 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
190 | 4: and x0, x0, #CTRL_M_BIT\r | |
191 | ret\r | |
192 | \r | |
193 | \r | |
194 | ASM_PFX(ArmEnableDataCache):\r | |
195 | EL1_OR_EL2_OR_EL3(x1)\r | |
196 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
197 | b 4f\r | |
198 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
199 | b 4f\r | |
200 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
201 | 4: orr x0, x0, #CTRL_C_BIT // Set C bit\r | |
202 | EL1_OR_EL2_OR_EL3(x1)\r | |
203 | 1: msr sctlr_el1, x0 // Write back control register\r | |
204 | b 4f\r | |
205 | 2: msr sctlr_el2, x0 // Write back control register\r | |
206 | b 4f\r | |
207 | 3: msr sctlr_el3, x0 // Write back control register\r | |
208 | 4: dsb sy\r | |
209 | isb\r | |
210 | ret\r | |
211 | \r | |
212 | \r | |
213 | ASM_PFX(ArmDisableDataCache):\r | |
214 | EL1_OR_EL2_OR_EL3(x1)\r | |
215 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
216 | b 4f\r | |
217 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
218 | b 4f\r | |
219 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
73ca5009 | 220 | 4: and x0, x0, #~CTRL_C_BIT // Clear C bit\r |
25402f5d HL |
221 | EL1_OR_EL2_OR_EL3(x1)\r |
222 | 1: msr sctlr_el1, x0 // Write back control register\r | |
223 | b 4f\r | |
224 | 2: msr sctlr_el2, x0 // Write back control register\r | |
225 | b 4f\r | |
226 | 3: msr sctlr_el3, x0 // Write back control register\r | |
227 | 4: dsb sy\r | |
228 | isb\r | |
229 | ret\r | |
230 | \r | |
231 | \r | |
232 | ASM_PFX(ArmEnableInstructionCache):\r | |
233 | EL1_OR_EL2_OR_EL3(x1)\r | |
234 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
235 | b 4f\r | |
236 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
237 | b 4f\r | |
238 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
239 | 4: orr x0, x0, #CTRL_I_BIT // Set I bit\r | |
240 | EL1_OR_EL2_OR_EL3(x1)\r | |
241 | 1: msr sctlr_el1, x0 // Write back control register\r | |
242 | b 4f\r | |
243 | 2: msr sctlr_el2, x0 // Write back control register\r | |
244 | b 4f\r | |
245 | 3: msr sctlr_el3, x0 // Write back control register\r | |
246 | 4: dsb sy\r | |
247 | isb\r | |
248 | ret\r | |
249 | \r | |
250 | \r | |
251 | ASM_PFX(ArmDisableInstructionCache):\r | |
252 | EL1_OR_EL2_OR_EL3(x1)\r | |
253 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
254 | b 4f\r | |
255 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
256 | b 4f\r | |
257 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
73ca5009 | 258 | 4: and x0, x0, #~CTRL_I_BIT // Clear I bit\r |
25402f5d HL |
259 | EL1_OR_EL2_OR_EL3(x1)\r |
260 | 1: msr sctlr_el1, x0 // Write back control register\r | |
261 | b 4f\r | |
262 | 2: msr sctlr_el2, x0 // Write back control register\r | |
263 | b 4f\r | |
264 | 3: msr sctlr_el3, x0 // Write back control register\r | |
265 | 4: dsb sy\r | |
266 | isb\r | |
267 | ret\r | |
268 | \r | |
269 | \r | |
270 | ASM_PFX(ArmEnableAlignmentCheck):\r | |
271 | EL1_OR_EL2(x1)\r | |
272 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
273 | b 3f\r | |
274 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
275 | 3: orr x0, x0, #CTRL_A_BIT // Set A (alignment check) bit\r | |
276 | EL1_OR_EL2(x1)\r | |
277 | 1: msr sctlr_el1, x0 // Write back control register\r | |
278 | b 3f\r | |
279 | 2: msr sctlr_el2, x0 // Write back control register\r | |
280 | 3: dsb sy\r | |
281 | isb\r | |
282 | ret\r | |
283 | \r | |
284 | \r | |
285 | ASM_PFX(ArmDisableAlignmentCheck):\r | |
286 | EL1_OR_EL2_OR_EL3(x1)\r | |
287 | 1: mrs x0, sctlr_el1 // Get control register EL1\r | |
288 | b 4f\r | |
289 | 2: mrs x0, sctlr_el2 // Get control register EL2\r | |
290 | b 4f\r | |
291 | 3: mrs x0, sctlr_el3 // Get control register EL3\r | |
73ca5009 | 292 | 4: and x0, x0, #~CTRL_A_BIT // Clear A (alignment check) bit\r |
25402f5d HL |
293 | EL1_OR_EL2_OR_EL3(x1)\r |
294 | 1: msr sctlr_el1, x0 // Write back control register\r | |
295 | b 4f\r | |
296 | 2: msr sctlr_el2, x0 // Write back control register\r | |
297 | b 4f\r | |
298 | 3: msr sctlr_el3, x0 // Write back control register\r | |
299 | 4: dsb sy\r | |
300 | isb\r | |
301 | ret\r | |
302 | \r | |
303 | \r | |
304 | // Always turned on in AArch64. Else implementation specific. Leave in for C compatibility for now\r | |
305 | ASM_PFX(ArmEnableBranchPrediction):\r | |
306 | ret\r | |
307 | \r | |
308 | \r | |
309 | // Always turned on in AArch64. Else implementation specific. Leave in for C compatibility for now.\r | |
310 | ASM_PFX(ArmDisableBranchPrediction):\r | |
311 | ret\r | |
312 | \r | |
313 | \r | |
314 | ASM_PFX(AArch64AllDataCachesOperation):\r | |
315 | // We can use regs 0-7 and 9-15 without having to save/restore.\r | |
316 | // Save our link register on the stack.\r | |
317 | str x30, [sp, #-0x10]!\r | |
318 | mov x1, x0 // Save Function call in x1\r | |
319 | mrs x6, clidr_el1 // Read EL1 CLIDR\r | |
320 | and x3, x6, #0x7000000 // Mask out all but Level of Coherency (LoC)\r | |
433a49a0 OM |
321 | lsr x3, x3, #23 // Left align cache level value - the level is shifted by 1 to the\r |
322 | // right to ease the access to CSSELR and the Set/Way operation.\r | |
25402f5d HL |
323 | cbz x3, L_Finished // No need to clean if LoC is 0\r |
324 | mov x10, #0 // Start clean at cache level 0\r | |
325 | b Loop1\r | |
326 | \r | |
327 | ASM_PFX(AArch64PerformPoUDataCacheOperation):\r | |
328 | // We can use regs 0-7 and 9-15 without having to save/restore.\r | |
329 | // Save our link register on the stack.\r | |
330 | str x30, [sp, #-0x10]!\r | |
331 | mov x1, x0 // Save Function call in x1\r | |
332 | mrs x6, clidr_el1 // Read EL1 CLIDR\r | |
333 | and x3, x6, #0x38000000 // Mask out all but Point of Unification (PoU)\r | |
433a49a0 OM |
334 | lsr x3, x3, #26 // Left align cache level value - the level is shifted by 1 to the\r |
335 | // right to ease the access to CSSELR and the Set/Way operation.\r | |
25402f5d HL |
336 | cbz x3, L_Finished // No need to clean if LoC is 0\r |
337 | mov x10, #0 // Start clean at cache level 0\r | |
338 | \r | |
339 | Loop1:\r | |
340 | add x2, x10, x10, lsr #1 // Work out 3x cachelevel for cache info\r | |
341 | lsr x12, x6, x2 // bottom 3 bits are the Cache type for this level\r | |
342 | and x12, x12, #7 // get those 3 bits alone\r | |
343 | cmp x12, #2 // what cache at this level?\r | |
344 | b.lt L_Skip // no cache or only instruction cache at this level\r | |
345 | msr csselr_el1, x10 // write the Cache Size selection register with current level (CSSELR)\r | |
346 | isb // isb to sync the change to the CacheSizeID reg\r | |
347 | mrs x12, ccsidr_el1 // reads current Cache Size ID register (CCSIDR)\r | |
348 | and x2, x12, #0x7 // extract the line length field\r | |
349 | add x2, x2, #4 // add 4 for the line length offset (log2 16 bytes)\r | |
350 | mov x4, #0x400\r | |
351 | sub x4, x4, #1\r | |
352 | and x4, x4, x12, lsr #3 // x4 is the max number on the way size (right aligned)\r | |
353 | clz w5, w4 // w5 is the bit position of the way size increment\r | |
354 | mov x7, #0x00008000\r | |
355 | sub x7, x7, #1\r | |
356 | and x7, x7, x12, lsr #13 // x7 is the max number of the index size (right aligned)\r | |
357 | \r | |
358 | Loop2:\r | |
359 | mov x9, x4 // x9 working copy of the max way size (right aligned)\r | |
360 | \r | |
361 | Loop3:\r | |
362 | lsl x11, x9, x5\r | |
363 | orr x0, x10, x11 // factor in the way number and cache number\r | |
364 | lsl x11, x7, x2\r | |
365 | orr x0, x0, x11 // factor in the index number\r | |
366 | \r | |
367 | blr x1 // Goto requested cache operation\r | |
368 | \r | |
369 | subs x9, x9, #1 // decrement the way number\r | |
370 | b.ge Loop3\r | |
371 | subs x7, x7, #1 // decrement the index\r | |
372 | b.ge Loop2\r | |
373 | L_Skip:\r | |
374 | add x10, x10, #2 // increment the cache number\r | |
375 | cmp x3, x10\r | |
376 | b.gt Loop1\r | |
377 | \r | |
378 | L_Finished:\r | |
379 | dsb sy\r | |
380 | isb\r | |
381 | ldr x30, [sp], #0x10\r | |
382 | ret\r | |
383 | \r | |
384 | \r | |
385 | ASM_PFX(ArmDataMemoryBarrier):\r | |
386 | dmb sy\r | |
387 | ret\r | |
388 | \r | |
389 | \r | |
390 | ASM_PFX(ArmDataSyncronizationBarrier):\r | |
391 | ASM_PFX(ArmDrainWriteBuffer):\r | |
392 | dsb sy\r | |
393 | ret\r | |
394 | \r | |
395 | \r | |
396 | ASM_PFX(ArmInstructionSynchronizationBarrier):\r | |
397 | isb\r | |
398 | ret\r | |
399 | \r | |
400 | \r | |
401 | ASM_PFX(ArmWriteVBar):\r | |
402 | EL1_OR_EL2_OR_EL3(x1)\r | |
403 | 1: msr vbar_el1, x0 // Set the Address of the EL1 Vector Table in the VBAR register\r | |
404 | b 4f\r | |
405 | 2: msr vbar_el2, x0 // Set the Address of the EL2 Vector Table in the VBAR register\r | |
406 | b 4f\r | |
407 | 3: msr vbar_el3, x0 // Set the Address of the EL3 Vector Table in the VBAR register\r | |
408 | 4: isb\r | |
409 | ret\r | |
410 | \r | |
f0247796 OM |
411 | ASM_PFX(ArmReadVBar):\r |
412 | EL1_OR_EL2_OR_EL3(x1)\r | |
413 | 1: mrs x0, vbar_el1 // Set the Address of the EL1 Vector Table in the VBAR register\r | |
414 | ret\r | |
415 | 2: mrs x0, vbar_el2 // Set the Address of the EL2 Vector Table in the VBAR register\r | |
416 | ret\r | |
417 | 3: mrs x0, vbar_el3 // Set the Address of the EL3 Vector Table in the VBAR register\r | |
418 | ret\r | |
419 | \r | |
420 | \r | |
25402f5d HL |
421 | ASM_PFX(ArmEnableVFP):\r |
422 | // Check whether floating-point is implemented in the processor.\r | |
423 | mov x1, x30 // Save LR\r | |
424 | bl ArmReadIdPfr0 // Read EL1 Processor Feature Register (PFR0)\r | |
425 | mov x30, x1 // Restore LR\r | |
426 | ands x0, x0, #AARCH64_PFR0_FP// Extract bits indicating VFP implementation\r | |
427 | cmp x0, #0 // VFP is implemented if '0'.\r | |
428 | b.ne 4f // Exit if VFP not implemented.\r | |
429 | // FVP is implemented.\r | |
430 | // Make sure VFP exceptions are not trapped (to any exception level).\r | |
431 | mrs x0, cpacr_el1 // Read EL1 Coprocessor Access Control Register (CPACR)\r | |
432 | orr x0, x0, #CPACR_VFP_BITS // Disable FVP traps to EL1\r | |
433 | msr cpacr_el1, x0 // Write back EL1 Coprocessor Access Control Register (CPACR)\r | |
434 | mov x1, #AARCH64_CPTR_TFP // TFP Bit for trapping VFP Exceptions\r | |
435 | EL1_OR_EL2_OR_EL3(x2)\r | |
436 | 1:ret // Not configurable in EL1\r | |
437 | 2:mrs x0, cptr_el2 // Disable VFP traps to EL2\r | |
438 | bic x0, x0, x1\r | |
439 | msr cptr_el2, x0\r | |
440 | ret\r | |
441 | 3:mrs x0, cptr_el3 // Disable VFP traps to EL3\r | |
442 | bic x0, x0, x1\r | |
443 | msr cptr_el3, x0\r | |
444 | 4:ret\r | |
445 | \r | |
446 | \r | |
447 | ASM_PFX(ArmCallWFI):\r | |
448 | wfi\r | |
449 | ret\r | |
450 | \r | |
451 | \r | |
25402f5d HL |
452 | ASM_PFX(ArmReadMpidr):\r |
453 | mrs x0, mpidr_el1 // read EL1 MPIDR\r | |
454 | ret\r | |
455 | \r | |
456 | \r | |
457 | // Keep old function names for C compatibilty for now. Change later?\r | |
458 | ASM_PFX(ArmReadTpidrurw):\r | |
459 | mrs x0, tpidr_el0 // read tpidr_el0 (v7 TPIDRURW) -> (v8 TPIDR_EL0)\r | |
460 | ret\r | |
461 | \r | |
462 | \r | |
463 | // Keep old function names for C compatibilty for now. Change later?\r | |
464 | ASM_PFX(ArmWriteTpidrurw):\r | |
465 | msr tpidr_el0, x0 // write tpidr_el0 (v7 TPIDRURW) -> (v8 TPIDR_EL0)\r | |
466 | ret\r | |
467 | \r | |
468 | \r | |
469 | // Arch timers are mandatory on AArch64\r | |
470 | ASM_PFX(ArmIsArchTimerImplemented):\r | |
471 | mov x0, #1\r | |
472 | ret\r | |
473 | \r | |
474 | \r | |
475 | ASM_PFX(ArmReadIdPfr0):\r | |
476 | mrs x0, id_aa64pfr0_el1 // Read ID_AA64PFR0 Register\r | |
477 | ret\r | |
478 | \r | |
479 | \r | |
480 | // Q: id_aa64pfr1_el1 not defined yet. What does this funtion want to access?\r | |
481 | // A: used to setup arch timer. Check if we have security extensions, permissions to set stuff.\r | |
482 | // See: ArmPkg/Library/ArmArchTimerLib/AArch64/ArmArchTimerLib.c\r | |
483 | // Not defined yet, but stick in here for now, should read all zeros.\r | |
484 | ASM_PFX(ArmReadIdPfr1):\r | |
485 | mrs x0, id_aa64pfr1_el1 // Read ID_PFR1 Register\r | |
486 | ret\r | |
487 | \r | |
488 | // VOID ArmWriteHcr(UINTN Hcr)\r | |
489 | ASM_PFX(ArmWriteHcr):\r | |
490 | msr hcr_el2, x0 // Write the passed HCR value\r | |
491 | ret\r | |
492 | \r | |
493 | // UINTN ArmReadCurrentEL(VOID)\r | |
494 | ASM_PFX(ArmReadCurrentEL):\r | |
495 | mrs x0, CurrentEL\r | |
496 | ret\r | |
497 | \r | |
25402f5d | 498 | ASM_FUNCTION_REMOVE_IF_UNREFERENCED\r |