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