armreg.h revision 1.45 1 /* $NetBSD: armreg.h,v 1.45 2020/05/23 18:08:59 ryo Exp $ */
2
3 /*-
4 * Copyright (c) 2014 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Matt Thomas of 3am Software Foundry.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
30 */
31
32 #ifndef _AARCH64_ARMREG_H_
33 #define _AARCH64_ARMREG_H_
34
35 #include <arm/cputypes.h>
36 #include <sys/types.h>
37
38 #ifdef __clang__
39 #define ATTR_ARCH(arch) ".arch " arch ";"
40 #define ATTR_TARGET_ARCH(x)
41 #define ASM_ARCH(x) x
42 #else
43 #define ATTR_ARCH(arch) __attribute__((target("arch=" arch)))
44 #define ATTR_TARGET_ARCH(x) x
45 #define ASM_ARCH(x)
46 #endif
47
48 #define AARCH64REG_READ_INLINE3(regname, regdesc, arch) \
49 static __inline uint64_t ATTR_TARGET_ARCH(arch) \
50 reg_##regname##_read(void) \
51 { \
52 uint64_t __rv; \
53 __asm __volatile( \
54 ASM_ARCH(arch) \
55 "mrs %0, " #regdesc : "=r"(__rv) \
56 ); \
57 return __rv; \
58 }
59
60 #define AARCH64REG_READ_INLINE2(regname, regdesc) \
61 AARCH64REG_READ_INLINE3(regname, regdesc, )
62
63 #define AARCH64REG_WRITE_INLINE3(regname, regdesc, arch) \
64 static __inline void ATTR_TARGET_ARCH(arch) \
65 reg_##regname##_write(uint64_t __val) \
66 { \
67 __asm __volatile( \
68 ASM_ARCH(arch) \
69 "msr " #regdesc ", %0" :: "r"(__val) \
70 ); \
71 }
72
73 #define AARCH64REG_WRITE_INLINE2(regname, regdesc) \
74 AARCH64REG_WRITE_INLINE3(regname, regdesc, )
75
76 #define AARCH64REG_WRITEIMM_INLINE2(regname, regdesc) \
77 static __inline void \
78 reg_##regname##_write(uint64_t __val) \
79 { \
80 __asm __volatile("msr " #regdesc ", %0" :: "n"(__val)); \
81 }
82
83 #define AARCH64REG_READ_INLINE(regname) \
84 AARCH64REG_READ_INLINE2(regname, regname)
85
86 #define AARCH64REG_WRITE_INLINE(regname) \
87 AARCH64REG_WRITE_INLINE2(regname, regname)
88
89 #define AARCH64REG_WRITEIMM_INLINE(regname) \
90 AARCH64REG_WRITEIMM_INLINE2(regname, regname)
91
92 #define AARCH64REG_READWRITE_INLINE2(regname, regdesc) \
93 AARCH64REG_READ_INLINE2(regname, regdesc) \
94 AARCH64REG_WRITE_INLINE2(regname, regdesc)
95
96 #define AARCH64REG_ATWRITE_INLINE2(regname, regdesc) \
97 static __inline void \
98 reg_##regname##_write(uint64_t __val) \
99 { \
100 __asm __volatile("at " #regdesc ", %0" :: "r"(__val)); \
101 }
102
103 #define AARCH64REG_ATWRITE_INLINE(regname) \
104 AARCH64REG_ATWRITE_INLINE2(regname, regname)
105
106 /*
107 * System registers available at EL0 (user)
108 */
109 AARCH64REG_READ_INLINE(ctr_el0) // Cache Type Register
110
111 #define CTR_EL0_CWG_LINE __BITS(27,24) // Cacheback Writeback Granule
112 #define CTR_EL0_ERG_LINE __BITS(23,20) // Exclusives Reservation Granule
113 #define CTR_EL0_DMIN_LINE __BITS(19,16) // Dcache MIN LINE size (log2 - 2)
114 #define CTR_EL0_L1IP_MASK __BITS(15,14)
115 #define CTR_EL0_L1IP_VPIPT 0 // VMID-aware Physical Index, Physical Tag
116 #define CTR_EL0_L1IP_AIVIVT 1 // ASID-tagged Virtual Index, Virtual Tag
117 #define CTR_EL0_L1IP_VIPT 2 // Virtual Index, Physical Tag
118 #define CTR_EL0_L1IP_PIPT 3 // Physical Index, Physical Tag
119 #define CTR_EL0_IMIN_LINE __BITS(3,0) // Icache MIN LINE size (log2 - 2)
120
121 AARCH64REG_READ_INLINE(dczid_el0) // Data Cache Zero ID Register
122
123 #define DCZID_DZP __BIT(4) // Data Zero Prohibited
124 #define DCZID_BS __BITS(3,0) // Block Size (log2 - 2)
125
126 AARCH64REG_READ_INLINE(fpcr) // Floating Point Control Register
127 AARCH64REG_WRITE_INLINE(fpcr)
128
129 #define FPCR_AHP __BIT(26) // Alternative Half Precision
130 #define FPCR_DN __BIT(25) // Default Nan Control
131 #define FPCR_FZ __BIT(24) // Flush-To-Zero
132 #define FPCR_RMODE __BITS(23,22) // Rounding Mode
133 #define FPCR_RN 0 // Round Nearest
134 #define FPCR_RP 1 // Round towards Plus infinity
135 #define FPCR_RM 2 // Round towards Minus infinity
136 #define FPCR_RZ 3 // Round towards Zero
137 #define FPCR_STRIDE __BITS(21,20)
138 #define FPCR_FZ16 __BIT(19) // Flush-To-Zero for FP16
139 #define FPCR_LEN __BITS(18,16)
140 #define FPCR_IDE __BIT(15) // Input Denormal Exception enable
141 #define FPCR_IXE __BIT(12) // IneXact Exception enable
142 #define FPCR_UFE __BIT(11) // UnderFlow Exception enable
143 #define FPCR_OFE __BIT(10) // OverFlow Exception enable
144 #define FPCR_DZE __BIT(9) // Divide by Zero Exception enable
145 #define FPCR_IOE __BIT(8) // Invalid Operation Exception enable
146 #define FPCR_ESUM 0x1F00
147
148 AARCH64REG_READ_INLINE(fpsr) // Floating Point Status Register
149 AARCH64REG_WRITE_INLINE(fpsr)
150
151 #define FPSR_N32 __BIT(31) // AARCH32 Negative
152 #define FPSR_Z32 __BIT(30) // AARCH32 Zero
153 #define FPSR_C32 __BIT(29) // AARCH32 Carry
154 #define FPSR_V32 __BIT(28) // AARCH32 Overflow
155 #define FPSR_QC __BIT(27) // SIMD Saturation
156 #define FPSR_IDC __BIT(7) // Input Denormal Cumulative status
157 #define FPSR_IXC __BIT(4) // IneXact Cumulative status
158 #define FPSR_UFC __BIT(3) // UnderFlow Cumulative status
159 #define FPSR_OFC __BIT(2) // OverFlow Cumulative status
160 #define FPSR_DZC __BIT(1) // Divide by Zero Cumulative status
161 #define FPSR_IOC __BIT(0) // Invalid Operation Cumulative status
162 #define FPSR_CSUM 0x1F
163
164 AARCH64REG_READ_INLINE(nzcv) // condition codes
165 AARCH64REG_WRITE_INLINE(nzcv)
166
167 #define NZCV_N __BIT(31) // Negative
168 #define NZCV_Z __BIT(30) // Zero
169 #define NZCV_C __BIT(29) // Carry
170 #define NZCV_V __BIT(28) // Overflow
171
172 AARCH64REG_READ_INLINE(tpidr_el0) // Thread Pointer ID Register (RW)
173 AARCH64REG_WRITE_INLINE(tpidr_el0)
174
175 AARCH64REG_READ_INLINE(tpidrro_el0) // Thread Pointer ID Register (RO)
176
177 /*
178 * From here on, these can only be accessed at EL1 (kernel)
179 */
180
181 /*
182 * These are readonly registers
183 */
184 AARCH64REG_READ_INLINE(aidr_el1)
185
186 AARCH64REG_READ_INLINE2(cbar_el1, s3_1_c15_c3_0) // Cortex-A57
187
188 #define CBAR_PA __BITS(47,18)
189
190 AARCH64REG_READ_INLINE(ccsidr_el1)
191
192 #define CCSIDR_WT __BIT(31) // OBSOLETE: Write-through supported
193 #define CCSIDR_WB __BIT(30) // OBSOLETE: Write-back supported
194 #define CCSIDR_RA __BIT(29) // OBSOLETE: Read-allocation supported
195 #define CCSIDR_WA __BIT(28) // OBSOLETE: Write-allocation supported
196 #define CCSIDR_NUMSET __BITS(27,13) // (Number of sets in cache) - 1
197 #define CCSIDR_ASSOC __BITS(12,3) // (Associativity of cache) - 1
198 #define CCSIDR_LINESIZE __BITS(2,0) // Number of bytes in cache line
199
200 AARCH64REG_READ_INLINE(clidr_el1)
201
202 #define CLIDR_ICB __BITS(32,30) // Inner cache boundary
203 #define CLIDR_LOUU __BITS(29,27) // Level of Unification Uniprocessor
204 #define CLIDR_LOC __BITS(26,24) // Level of Coherency
205 #define CLIDR_LOUIS __BITS(23,21) // Level of Unification InnerShareable*/
206 #define CLIDR_CTYPE7 __BITS(20,18) // Cache Type field for level7
207 #define CLIDR_CTYPE6 __BITS(17,15) // Cache Type field for level6
208 #define CLIDR_CTYPE5 __BITS(14,12) // Cache Type field for level5
209 #define CLIDR_CTYPE4 __BITS(11,9) // Cache Type field for level4
210 #define CLIDR_CTYPE3 __BITS(8,6) // Cache Type field for level3
211 #define CLIDR_CTYPE2 __BITS(5,3) // Cache Type field for level2
212 #define CLIDR_CTYPE1 __BITS(2,0) // Cache Type field for level1
213 #define CLIDR_TYPE_NOCACHE 0 // No cache
214 #define CLIDR_TYPE_ICACHE 1 // Instruction cache only
215 #define CLIDR_TYPE_DCACHE 2 // Data cache only
216 #define CLIDR_TYPE_IDCACHE 3 // Separate inst and data caches
217 #define CLIDR_TYPE_UNIFIEDCACHE 4 // Unified cache
218
219 AARCH64REG_READ_INLINE(currentel)
220 AARCH64REG_READ_INLINE(id_aa64afr0_el1)
221 AARCH64REG_READ_INLINE(id_aa64afr1_el1)
222 AARCH64REG_READ_INLINE(id_aa64dfr0_el1)
223
224 #define ID_AA64DFR0_EL1_TRACEFILT __BITS(43,40)
225 #define ID_AA64DFR0_EL1_TRACEFILT_NONE 0
226 #define ID_AA64DFR0_EL1_TRACEFILT_IMPL 1
227 #define ID_AA64DFR0_EL1_DBLLOCK __BITS(39,36)
228 #define ID_AA64DFR0_EL1_DBLLOCK_IMPL 0
229 #define ID_AA64DFR0_EL1_DBLLOCK_NONE 15
230 #define ID_AA64DFR0_EL1_PMSVER __BITS(35,32)
231 #define ID_AA64DFR0_EL1_CTX_CMPS __BITS(31,28)
232 #define ID_AA64DFR0_EL1_WRPS __BITS(20,23)
233 #define ID_AA64DFR0_EL1_BRPS __BITS(12,15)
234 #define ID_AA64DFR0_EL1_PMUVER __BITS(8,11)
235 #define ID_AA64DFR0_EL1_PMUVER_NONE 0
236 #define ID_AA64DFR0_EL1_PMUVER_V3 1
237 #define ID_AA64DFR0_EL1_PMUVER_NOV3 2
238 #define ID_AA64DFR0_EL1_TRACEVER __BITS(4,7)
239 #define ID_AA64DFR0_EL1_TRACEVER_NONE 0
240 #define ID_AA64DFR0_EL1_TRACEVER_IMPL 1
241 #define ID_AA64DFR0_EL1_DEBUGVER __BITS(0,3)
242 #define ID_AA64DFR0_EL1_DEBUGVER_V8A 6
243
244 AARCH64REG_READ_INLINE(id_aa64dfr1_el1)
245
246 AARCH64REG_READ_INLINE(id_aa64isar0_el1)
247
248 #define ID_AA64ISAR0_EL1_RNDR __BITS(63,60)
249 #define ID_AA64ISAR0_EL1_RNDR_NONE 0
250 #define ID_AA64ISAR0_EL1_RNDR_RNDRRS 1
251 #define ID_AA64ISAR0_EL1_TLB __BITS(59,56)
252 #define ID_AA64ISAR0_EL1_TLB_NONE 0
253 #define ID_AA64ISAR0_EL1_TLB_OS 1
254 #define ID_AA64ISAR0_EL1_TLB_OS_TLB 2
255 #define ID_AA64ISAR0_EL1_TS __BITS(55,52)
256 #define ID_AA64ISAR0_EL1_TS_NONE 0
257 #define ID_AA64ISAR0_EL1_TS_CFINV 1
258 #define ID_AA64ISAR0_EL1_TS_AXFLAG 2
259 #define ID_AA64ISAR0_EL1_FHM __BITS(51,48)
260 #define ID_AA64ISAR0_EL1_FHM_NONE 0
261 #define ID_AA64ISAR0_EL1_FHM_FMLAL 1
262 #define ID_AA64ISAR0_EL1_DP __BITS(47,44)
263 #define ID_AA64ISAR0_EL1_DP_NONE 0
264 #define ID_AA64ISAR0_EL1_DP_UDOT 1
265 #define ID_AA64ISAR0_EL1_SM4 __BITS(43,40)
266 #define ID_AA64ISAR0_EL1_SM4_NONE 0
267 #define ID_AA64ISAR0_EL1_SM4_SM4 1
268 #define ID_AA64ISAR0_EL1_SM3 __BITS(39,36)
269 #define ID_AA64ISAR0_EL1_SM3_NONE 0
270 #define ID_AA64ISAR0_EL1_SM3_SM3 1
271 #define ID_AA64ISAR0_EL1_SHA3 __BITS(35,32)
272 #define ID_AA64ISAR0_EL1_SHA3_NONE 0
273 #define ID_AA64ISAR0_EL1_SHA3_EOR3 1
274 #define ID_AA64ISAR0_EL1_RDM __BITS(31,28)
275 #define ID_AA64ISAR0_EL1_RDM_NONE 0
276 #define ID_AA64ISAR0_EL1_RDM_SQRDML 1
277 #define ID_AA64ISAR0_EL1_ATOMIC __BITS(23,20)
278 #define ID_AA64ISAR0_EL1_ATOMIC_NONE 0
279 #define ID_AA64ISAR0_EL1_ATOMIC_SWP 1
280 #define ID_AA64ISAR0_EL1_CRC32 __BITS(19,16)
281 #define ID_AA64ISAR0_EL1_CRC32_NONE 0
282 #define ID_AA64ISAR0_EL1_CRC32_CRC32X 1
283 #define ID_AA64ISAR0_EL1_SHA2 __BITS(15,12)
284 #define ID_AA64ISAR0_EL1_SHA2_NONE 0
285 #define ID_AA64ISAR0_EL1_SHA2_SHA256HSU 1
286 #define ID_AA64ISAR0_EL1_SHA2_SHA512HSU 2
287 #define ID_AA64ISAR0_EL1_SHA1 __BITS(11,8)
288 #define ID_AA64ISAR0_EL1_SHA1_NONE 0
289 #define ID_AA64ISAR0_EL1_SHA1_SHA1CPMHSU 1
290 #define ID_AA64ISAR0_EL1_AES __BITS(7,4)
291 #define ID_AA64ISAR0_EL1_AES_NONE 0
292 #define ID_AA64ISAR0_EL1_AES_AES 1
293 #define ID_AA64ISAR0_EL1_AES_PMUL 2
294
295 AARCH64REG_READ_INLINE(id_aa64isar1_el1)
296
297 #define ID_AA64ISAR1_EL1_SPECRES __BITS(43,40)
298 #define ID_AA64ISAR1_EL1_SPECRES_NONE 0
299 #define ID_AA64ISAR1_EL1_SPECRES_SUPPORTED 1
300 #define ID_AA64ISAR1_EL1_SB __BITS(39,36)
301 #define ID_AA64ISAR1_EL1_SB_NONE 0
302 #define ID_AA64ISAR1_EL1_SB_SUPPORTED 1
303 #define ID_AA64ISAR1_EL1_FRINTTS __BITS(35,32)
304 #define ID_AA64ISAR1_EL1_FRINTTS_NONE 0
305 #define ID_AA64ISAR1_EL1_FRINTTS_SUPPORTED 1
306 #define ID_AA64ISAR1_EL1_GPI __BITS(31,28)
307 #define ID_AA64ISAR1_EL1_GPI_NONE 0
308 #define ID_AA64ISAR1_EL1_GPI_SUPPORTED 1
309 #define ID_AA64ISAR1_EL1_GPA __BITS(27,24)
310 #define ID_AA64ISAR1_EL1_GPA_NONE 0
311 #define ID_AA64ISAR1_EL1_GPA_QARMA 1
312 #define ID_AA64ISAR1_EL1_LRCPC __BITS(23,20)
313 #define ID_AA64ISAR1_EL1_LRCPC_NONE 0
314 #define ID_AA64ISAR1_EL1_LRCPC_PR 1
315 #define ID_AA64ISAR1_EL1_LRCPC_PR_UR 2
316 #define ID_AA64ISAR1_EL1_FCMA __BITS(19,16)
317 #define ID_AA64ISAR1_EL1_FCMA_NONE 0
318 #define ID_AA64ISAR1_EL1_FCMA_SUPPORTED 1
319 #define ID_AA64ISAR1_EL1_JSCVT __BITS(15,12)
320 #define ID_AA64ISAR1_EL1_JSCVT_NONE 0
321 #define ID_AA64ISAR1_EL1_JSCVT_SUPPORTED 1
322 #define ID_AA64ISAR1_EL1_API __BITS(11,8)
323 #define ID_AA64ISAR1_EL1_API_NONE 0
324 #define ID_AA64ISAR1_EL1_API_SUPPORTED 1
325 #define ID_AA64ISAR1_EL1_API_ENHANCED 2
326 #define ID_AA64ISAR1_EL1_APA __BITS(7,4)
327 #define ID_AA64ISAR1_EL1_APA_NONE 0
328 #define ID_AA64ISAR1_EL1_APA_QARMA 1
329 #define ID_AA64ISAR1_EL1_APA_QARMA_ENH 2
330 #define ID_AA64ISAR1_EL1_DPB __BITS(3,0)
331 #define ID_AA64ISAR1_EL1_DPB_NONE 0
332 #define ID_AA64ISAR1_EL1_DPB_CVAP 1
333 #define ID_AA64ISAR1_EL1_DPB_CVAP_CVADP 2
334
335 AARCH64REG_READ_INLINE(id_aa64mmfr0_el1)
336
337 #define ID_AA64MMFR0_EL1_EXS __BITS(43,40)
338 #define ID_AA64MMFR0_EL1_TGRAN4 __BITS(31,28)
339 #define ID_AA64MMFR0_EL1_TGRAN4_4KB 0
340 #define ID_AA64MMFR0_EL1_TGRAN4_NONE 15
341 #define ID_AA64MMFR0_EL1_TGRAN64 __BITS(24,27)
342 #define ID_AA64MMFR0_EL1_TGRAN64_64KB 0
343 #define ID_AA64MMFR0_EL1_TGRAN64_NONE 15
344 #define ID_AA64MMFR0_EL1_TGRAN16 __BITS(20,23)
345 #define ID_AA64MMFR0_EL1_TGRAN16_NONE 0
346 #define ID_AA64MMFR0_EL1_TGRAN16_16KB 1
347 #define ID_AA64MMFR0_EL1_BIGENDEL0 __BITS(16,19)
348 #define ID_AA64MMFR0_EL1_BIGENDEL0_NONE 0
349 #define ID_AA64MMFR0_EL1_BIGENDEL0_MIX 1
350 #define ID_AA64MMFR0_EL1_SNSMEM __BITS(12,15)
351 #define ID_AA64MMFR0_EL1_SNSMEM_NONE 0
352 #define ID_AA64MMFR0_EL1_SNSMEM_SNSMEM 1
353 #define ID_AA64MMFR0_EL1_BIGEND __BITS(8,11)
354 #define ID_AA64MMFR0_EL1_BIGEND_NONE 0
355 #define ID_AA64MMFR0_EL1_BIGEND_MIX 1
356 #define ID_AA64MMFR0_EL1_ASIDBITS __BITS(4,7)
357 #define ID_AA64MMFR0_EL1_ASIDBITS_8BIT 0
358 #define ID_AA64MMFR0_EL1_ASIDBITS_16BIT 2
359 #define ID_AA64MMFR0_EL1_PARANGE __BITS(0,3)
360 #define ID_AA64MMFR0_EL1_PARANGE_4G 0
361 #define ID_AA64MMFR0_EL1_PARANGE_64G 1
362 #define ID_AA64MMFR0_EL1_PARANGE_1T 2
363 #define ID_AA64MMFR0_EL1_PARANGE_4T 3
364 #define ID_AA64MMFR0_EL1_PARANGE_16T 4
365 #define ID_AA64MMFR0_EL1_PARANGE_256T 5
366 #define ID_AA64MMFR0_EL1_PARANGE_4P 6
367
368 AARCH64REG_READ_INLINE(id_aa64mmfr1_el1)
369
370 #define ID_AA64MMFR1_EL1_XNX __BITS(31,28)
371 #define ID_AA64MMFR1_EL1_XNX_NONE 0
372 #define ID_AA64MMFR1_EL1_XNX_SUPPORTED 1
373 #define ID_AA64MMFR1_EL1_SPECSEI __BITS(27,24)
374 #define ID_AA64MMFR1_EL1_SPECSEI_NONE 0
375 #define ID_AA64MMFR1_EL1_SPECSEI_EXTINT 1
376 #define ID_AA64MMFR1_EL1_PAN __BITS(23,20)
377 #define ID_AA64MMFR1_EL1_PAN_NONE 0
378 #define ID_AA64MMFR1_EL1_PAN_SUPPORTED 1
379 #define ID_AA64MMFR1_EL1_PAN_S1E1 2
380 #define ID_AA64MMFR1_EL1_LO __BITS(19,16)
381 #define ID_AA64MMFR1_EL1_LO_NONE 0
382 #define ID_AA64MMFR1_EL1_LO_SUPPORTED 1
383 #define ID_AA64MMFR1_EL1_HPDS __BITS(15,12)
384 #define ID_AA64MMFR1_EL1_HPDS_NONE 0
385 #define ID_AA64MMFR1_EL1_HPDS_SUPPORTED 1
386 #define ID_AA64MMFR1_EL1_HPDS_EXTRA_PTD 2
387 #define ID_AA64MMFR1_EL1_VH __BITS(11,8)
388 #define ID_AA64MMFR1_EL1_VH_NONE 0
389 #define ID_AA64MMFR1_EL1_VH_SUPPORTED 1
390 #define ID_AA64MMFR1_EL1_VMIDBITS __BITS(7,4)
391 #define ID_AA64MMFR1_EL1_VMIDBITS_8BIT 0
392 #define ID_AA64MMFR1_EL1_VMIDBITS_16BIT 2
393 #define ID_AA64MMFR1_EL1_HAFDBS __BITS(3,0)
394 #define ID_AA64MMFR1_EL1_HAFDBS_NONE 0
395 #define ID_AA64MMFR1_EL1_HAFDBS_A 1
396 #define ID_AA64MMFR1_EL1_HAFDBS_AD 2
397
398 AARCH64REG_READ_INLINE3(id_aa64mmfr2_el1, id_aa64mmfr2_el1,
399 ATTR_ARCH("armv8.2-a"))
400
401 #define ID_AA64MMFR2_EL1_E0PD __BITS(63,60)
402 #define ID_AA64MMFR2_EL1_E0PD_NONE 0
403 #define ID_AA64MMFR2_EL1_E0PD_SUPPORTED 1
404 #define ID_AA64MMFR2_EL1_EVT __BITS(59,56)
405 #define ID_AA64MMFR2_EL1_EVT_NONE 0
406 #define ID_AA64MMFR2_EL1_EVT_TO_TI 1
407 #define ID_AA64MMFR2_EL1_EVT_TO_TI_TTL 2
408 #define ID_AA64MMFR2_EL1_BBM __BITS(55,52)
409 #define ID_AA64MMFR2_EL1_BBM_L0 0
410 #define ID_AA64MMFR2_EL1_BBM_L1 1
411 #define ID_AA64MMFR2_EL1_BBM_L2 2
412 #define ID_AA64MMFR2_EL1_TTL __BITS(51,48)
413 #define ID_AA64MMFR2_EL1_TTL_NONE 0
414 #define ID_AA64MMFR2_EL1_TTL_SUPPORTED 1
415 #define ID_AA64MMFR2_EL1_FWB __BITS(43,40)
416 #define ID_AA64MMFR2_EL1_FWB_NONE 0
417 #define ID_AA64MMFR2_EL1_FWB_SUPPORTED 1
418 #define ID_AA64MMFR2_EL1_IDS __BITS(39,36)
419 #define ID_AA64MMFR2_EL1_IDS_0X0 0
420 #define ID_AA64MMFR2_EL1_IDS_0X18 1
421 #define ID_AA64MMFR2_EL1_AT __BITS(35,32)
422 #define ID_AA64MMFR2_EL1_AT_NONE 0
423 #define ID_AA64MMFR2_EL1_AT_16BIT 1
424 #define ID_AA64MMFR2_EL1_ST __BITS(31,28)
425 #define ID_AA64MMFR2_EL1_ST_39 0
426 #define ID_AA64MMFR2_EL1_ST_48 1
427 #define ID_AA64MMFR2_EL1_NV __BITS(27,24)
428 #define ID_AA64MMFR2_EL1_NV_NONE 0
429 #define ID_AA64MMFR2_EL1_NV_HCR 1
430 #define ID_AA64MMFR2_EL1_NV_HCR_VNCR 2
431 #define ID_AA64MMFR2_EL1_CCIDX __BITS(23,20)
432 #define ID_AA64MMFR2_EL1_CCIDX_32BIT 0
433 #define ID_AA64MMFR2_EL1_CCIDX_64BIT 1
434 #define ID_AA64MMFR2_EL1_VARANGE __BITS(19,16)
435 #define ID_AA64MMFR2_EL1_VARANGE_48BIT 0
436 #define ID_AA64MMFR2_EL1_VARANGE_52BIT 1
437 #define ID_AA64MMFR2_EL1_IESB __BITS(15,12)
438 #define ID_AA64MMFR2_EL1_IESB_NONE 0
439 #define ID_AA64MMFR2_EL1_IESB_SUPPORTED 1
440 #define ID_AA64MMFR2_EL1_LSM __BITS(11,8)
441 #define ID_AA64MMFR2_EL1_LSM_NONE 0
442 #define ID_AA64MMFR2_EL1_LSM_SUPPORTED 1
443 #define ID_AA64MMFR2_EL1_UAO __BITS(7,4)
444 #define ID_AA64MMFR2_EL1_UAO_NONE 0
445 #define ID_AA64MMFR2_EL1_UAO_SUPPORTED 1
446 #define ID_AA64MMFR2_EL1_CNP __BITS(3,0)
447 #define ID_AA64MMFR2_EL1_CNP_NONE 0
448 #define ID_AA64MMFR2_EL1_CNP_SUPPORTED 1
449
450 AARCH64REG_READ_INLINE2(a72_cpuactlr_el1, s3_1_c15_c2_0)
451 AARCH64REG_READ_INLINE(id_aa64pfr0_el1)
452 AARCH64REG_READ_INLINE(id_aa64pfr1_el1)
453
454 #define ID_AA64PFR1_EL1_RASFRAC __BITS(15,12)
455 #define ID_AA64PFR1_EL1_RASFRAC_NORMAL 0
456 #define ID_AA64PFR1_EL1_RASFRAC_EXTRA 1
457 #define ID_AA64PFR1_EL1_MTE __BITS(11,8)
458 #define ID_AA64PFR1_EL1_MTE_NONE 0
459 #define ID_AA64PFR1_EL1_MTE_PARTIAL 1
460 #define ID_AA64PFR1_EL1_MTE_SUPPORTED 2
461 #define ID_AA64PFR1_EL1_SSBS __BITS(7,4)
462 #define ID_AA64PFR1_EL1_SSBS_NONE 0
463 #define ID_AA64PFR1_EL1_SSBS_SUPPORTED 1
464 #define ID_AA64PFR1_EL1_SSBS_MSR_MRS 2
465 #define ID_AA64PFR1_EL1_BT __BITS(3,0)
466 #define ID_AA64PFR1_EL1_BT_NONE 0
467 #define ID_AA64PFR1_EL1_BT_SUPPORTED 1
468
469 AARCH64REG_READ_INLINE(id_aa64zfr0_el1)
470 AARCH64REG_READ_INLINE(id_pfr1_el1)
471 AARCH64REG_READ_INLINE(isr_el1)
472 AARCH64REG_READ_INLINE(midr_el1)
473 AARCH64REG_READ_INLINE(mpidr_el1)
474
475 #define MIDR_EL1_IMPL __BITS(31,24) // Implementor
476 #define MIDR_EL1_VARIANT __BITS(23,20) // CPU Variant
477 #define MIDR_EL1_ARCH __BITS(19,16) // Architecture
478 #define MIDR_EL1_PARTNUM __BITS(15,4) // PartNum
479 #define MIDR_EL1_REVISION __BITS(3,0) // Revision
480
481 #define MPIDR_AFF3 __BITS(32,39)
482 #define MPIDR_U __BIT(30) // 1 = Uni-Processor System
483 #define MPIDR_MT __BIT(24) // 1 = SMT(AFF0 is logical)
484 #define MPIDR_AFF2 __BITS(16,23)
485 #define MPIDR_AFF1 __BITS(8,15)
486 #define MPIDR_AFF0 __BITS(0,7)
487
488 AARCH64REG_READ_INLINE(mvfr0_el1)
489
490 #define MVFR0_FPROUND __BITS(31,28)
491 #define MVFR0_FPROUND_NEAREST 0
492 #define MVFR0_FPROUND_ALL 1
493 #define MVFR0_FPSHVEC __BITS(27,24)
494 #define MVFR0_FPSHVEC_NONE 0
495 #define MVFR0_FPSHVEC_SHVEC 1
496 #define MVFR0_FPSQRT __BITS(23,20)
497 #define MVFR0_FPSQRT_NONE 0
498 #define MVFR0_FPSQRT_VSQRT 1
499 #define MVFR0_FPDIVIDE __BITS(19,16)
500 #define MVFR0_FPDIVIDE_NONE 0
501 #define MVFR0_FPDIVIDE_VDIV 1
502 #define MVFR0_FPTRAP __BITS(15,12)
503 #define MVFR0_FPTRAP_NONE 0
504 #define MVFR0_FPTRAP_TRAP 1
505 #define MVFR0_FPDP __BITS(11,8)
506 #define MVFR0_FPDP_NONE 0
507 #define MVFR0_FPDP_VFPV2 1
508 #define MVFR0_FPDP_VFPV3 2
509 #define MVFR0_FPSP __BITS(7,4)
510 #define MVFR0_FPSP_NONE 0
511 #define MVFR0_FPSP_VFPV2 1
512 #define MVFR0_FPSP_VFPV3 2
513 #define MVFR0_SIMDREG __BITS(3,0)
514 #define MVFR0_SIMDREG_NONE 0
515 #define MVFR0_SIMDREG_16x64 1
516 #define MVFR0_SIMDREG_32x64 2
517
518 AARCH64REG_READ_INLINE(mvfr1_el1)
519
520 #define MVFR1_SIMDFMAC __BITS(31,28)
521 #define MVFR1_SIMDFMAC_NONE 0
522 #define MVFR1_SIMDFMAC_FMAC 1
523 #define MVFR1_FPHP __BITS(27,24)
524 #define MVFR1_FPHP_NONE 0
525 #define MVFR1_FPHP_HALF_SINGLE 1
526 #define MVFR1_FPHP_HALF_DOUBLE 2
527 #define MVFR1_FPHP_HALF_ARITH 3
528 #define MVFR1_SIMDHP __BITS(23,20)
529 #define MVFR1_SIMDHP_NONE 0
530 #define MVFR1_SIMDHP_HALF 1
531 #define MVFR1_SIMDHP_HALF_ARITH 3
532 #define MVFR1_SIMDSP __BITS(19,16)
533 #define MVFR1_SIMDSP_NONE 0
534 #define MVFR1_SIMDSP_SINGLE 1
535 #define MVFR1_SIMDINT __BITS(15,12)
536 #define MVFR1_SIMDINT_NONE 0
537 #define MVFR1_SIMDINT_INTEGER 1
538 #define MVFR1_SIMDLS __BITS(11,8)
539 #define MVFR1_SIMDLS_NONE 0
540 #define MVFR1_SIMDLS_LOADSTORE 1
541 #define MVFR1_FPDNAN __BITS(7,4)
542 #define MVFR1_FPDNAN_NONE 0
543 #define MVFR1_FPDNAN_NAN 1
544 #define MVFR1_FPFTZ __BITS(3,0)
545 #define MVFR1_FPFTZ_NONE 0
546 #define MVFR1_FPFTZ_DENORMAL 1
547
548 AARCH64REG_READ_INLINE(mvfr2_el1)
549
550 #define MVFR2_FPMISC __BITS(7,4)
551 #define MVFR2_FPMISC_NONE 0
552 #define MVFR2_FPMISC_SEL 1
553 #define MVFR2_FPMISC_DROUND 2
554 #define MVFR2_FPMISC_ROUNDINT 3
555 #define MVFR2_FPMISC_MAXMIN 4
556 #define MVFR2_SIMDMISC __BITS(3,0)
557 #define MVFR2_SIMDMISC_NONE 0
558 #define MVFR2_SIMDMISC_DROUND 1
559 #define MVFR2_SIMDMISC_ROUNDINT 2
560 #define MVFR2_SIMDMISC_MAXMIN 3
561
562 AARCH64REG_READ_INLINE(revidr_el1)
563
564 /*
565 * These are read/write registers
566 */
567 AARCH64REG_READ_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a"))
568 AARCH64REG_WRITE_INLINE3(APIAKeyLo_EL1, apiakeylo_el1, ATTR_ARCH("armv8.3-a"))
569 AARCH64REG_READ_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a"))
570 AARCH64REG_WRITE_INLINE3(APIAKeyHi_EL1, apiakeyhi_el1, ATTR_ARCH("armv8.3-a"))
571
572 AARCH64REG_READ_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a"))
573 AARCH64REG_WRITE_INLINE3(APIBKeyLo_EL1, apibkeylo_el1, ATTR_ARCH("armv8.3-a"))
574 AARCH64REG_READ_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a"))
575 AARCH64REG_WRITE_INLINE3(APIBKeyHi_EL1, apibkeyhi_el1, ATTR_ARCH("armv8.3-a"))
576
577 AARCH64REG_READ_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a"))
578 AARCH64REG_WRITE_INLINE3(APDAKeyLo_EL1, apdakeylo_el1, ATTR_ARCH("armv8.3-a"))
579 AARCH64REG_READ_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a"))
580 AARCH64REG_WRITE_INLINE3(APDAKeyHi_EL1, apdakeyhi_el1, ATTR_ARCH("armv8.3-a"))
581
582 AARCH64REG_READ_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a"))
583 AARCH64REG_WRITE_INLINE3(APDBKeyLo_EL1, apdbkeylo_el1, ATTR_ARCH("armv8.3-a"))
584 AARCH64REG_READ_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a"))
585 AARCH64REG_WRITE_INLINE3(APDBKeyHi_EL1, apdbkeyhi_el1, ATTR_ARCH("armv8.3-a"))
586
587 AARCH64REG_READ_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a"))
588 AARCH64REG_WRITE_INLINE3(APGAKeyLo_EL1, apgakeylo_el1, ATTR_ARCH("armv8.3-a"))
589 AARCH64REG_READ_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a"))
590 AARCH64REG_WRITE_INLINE3(APGAKeyHi_EL1, apgakeyhi_el1, ATTR_ARCH("armv8.3-a"))
591
592 AARCH64REG_READ_INLINE(cpacr_el1) // Coprocessor Access Control Regiser
593 AARCH64REG_WRITE_INLINE(cpacr_el1)
594
595 #define CPACR_TTA __BIT(28) // System Register Access Traps
596 #define CPACR_FPEN __BITS(21,20)
597 #define CPACR_FPEN_NONE __SHIFTIN(0, CPACR_FPEN)
598 #define CPACR_FPEN_EL1 __SHIFTIN(1, CPACR_FPEN)
599 #define CPACR_FPEN_NONE_2 __SHIFTIN(2, CPACR_FPEN)
600 #define CPACR_FPEN_ALL __SHIFTIN(3, CPACR_FPEN)
601
602 AARCH64REG_READ_INLINE(csselr_el1) // Cache Size Selection Register
603 AARCH64REG_WRITE_INLINE(csselr_el1)
604
605 #define CSSELR_LEVEL __BITS(3,1) // Cache level of required cache
606 #define CSSELR_IND __BIT(0) // Instruction not Data bit
607
608 AARCH64REG_READ_INLINE(daif) // Debug Async Irq Fiq mask register
609 AARCH64REG_WRITE_INLINE(daif)
610 AARCH64REG_WRITEIMM_INLINE(daifclr)
611 AARCH64REG_WRITEIMM_INLINE(daifset)
612
613 #define DAIF_D __BIT(9) // Debug Exception Mask
614 #define DAIF_A __BIT(8) // SError Abort Mask
615 #define DAIF_I __BIT(7) // IRQ Mask
616 #define DAIF_F __BIT(6) // FIQ Mask
617 #define DAIF_SETCLR_SHIFT 6 // for daifset/daifclr #imm shift
618
619 AARCH64REG_READ_INLINE(elr_el1) // Exception Link Register
620 AARCH64REG_WRITE_INLINE(elr_el1)
621
622 AARCH64REG_READ_INLINE(esr_el1) // Exception Symdrone Register
623 AARCH64REG_WRITE_INLINE(esr_el1)
624
625 #define ESR_EC __BITS(31,26) // Exception Cause
626 #define ESR_EC_UNKNOWN 0x00 // AXX: Unknown Reason
627 #define ESR_EC_WFX 0x01 // AXX: WFI or WFE instruction execution
628 #define ESR_EC_CP15_RT 0x03 // A32: MCR/MRC access to CP15 !EC=0
629 #define ESR_EC_CP15_RRT 0x04 // A32: MCRR/MRRC access to CP15 !EC=0
630 #define ESR_EC_CP14_RT 0x05 // A32: MCR/MRC access to CP14
631 #define ESR_EC_CP14_DT 0x06 // A32: LDC/STC access to CP14
632 #define ESR_EC_FP_ACCESS 0x07 // AXX: Access to SIMD/FP Registers
633 #define ESR_EC_FPID 0x08 // A32: MCR/MRC access to CP10 !EC=7
634 #define ESR_EC_CP14_RRT 0x0c // A32: MRRC access to CP14
635 #define ESR_EC_BTE_A64 0x0d // A64: Branch Target Exception (V8.5)
636 #define ESR_EC_ILL_STATE 0x0e // AXX: Illegal Execution State
637 #define ESR_EC_SVC_A32 0x11 // A32: SVC Instruction Execution
638 #define ESR_EC_HVC_A32 0x12 // A32: HVC Instruction Execution
639 #define ESR_EC_SMC_A32 0x13 // A32: SMC Instruction Execution
640 #define ESR_EC_SVC_A64 0x15 // A64: SVC Instruction Execution
641 #define ESR_EC_HVC_A64 0x16 // A64: HVC Instruction Execution
642 #define ESR_EC_SMC_A64 0x17 // A64: SMC Instruction Execution
643 #define ESR_EC_SYS_REG 0x18 // A64: MSR/MRS/SYS instruction (!EC0/1/7)
644 #define ESR_EC_INSN_ABT_EL0 0x20 // AXX: Instruction Abort (EL0)
645 #define ESR_EC_INSN_ABT_EL1 0x21 // AXX: Instruction Abort (EL1)
646 #define ESR_EC_PC_ALIGNMENT 0x22 // AXX: Misaligned PC
647 #define ESR_EC_DATA_ABT_EL0 0x24 // AXX: Data Abort (EL0)
648 #define ESR_EC_DATA_ABT_EL1 0x25 // AXX: Data Abort (EL1)
649 #define ESR_EC_SP_ALIGNMENT 0x26 // AXX: Misaligned SP
650 #define ESR_EC_FP_TRAP_A32 0x28 // A32: FP Exception
651 #define ESR_EC_FP_TRAP_A64 0x2c // A64: FP Exception
652 #define ESR_EC_SERROR 0x2f // AXX: SError Interrupt
653 #define ESR_EC_BRKPNT_EL0 0x30 // AXX: Breakpoint Exception (EL0)
654 #define ESR_EC_BRKPNT_EL1 0x31 // AXX: Breakpoint Exception (EL1)
655 #define ESR_EC_SW_STEP_EL0 0x32 // AXX: Software Step (EL0)
656 #define ESR_EC_SW_STEP_EL1 0x33 // AXX: Software Step (EL1)
657 #define ESR_EC_WTCHPNT_EL0 0x34 // AXX: Watchpoint (EL0)
658 #define ESR_EC_WTCHPNT_EL1 0x35 // AXX: Watchpoint (EL1)
659 #define ESR_EC_BKPT_INSN_A32 0x38 // A32: BKPT Instruction Execution
660 #define ESR_EC_VECTOR_CATCH 0x3a // A32: Vector Catch Exception
661 #define ESR_EC_BKPT_INSN_A64 0x3c // A64: BKPT Instruction Execution
662 #define ESR_IL __BIT(25) // Instruction Length (1=32-bit)
663 #define ESR_ISS __BITS(24,0) // Instruction Specific Syndrome
664 #define ESR_ISS_CV __BIT(24) // common
665 #define ESR_ISS_COND __BITS(23,20) // common
666 #define ESR_ISS_WFX_TRAP_INSN __BIT(0) // for ESR_EC_WFX
667 #define ESR_ISS_MRC_OPC2 __BITS(19,17) // for ESR_EC_CP15_RT
668 #define ESR_ISS_MRC_OPC1 __BITS(16,14) // for ESR_EC_CP15_RT
669 #define ESR_ISS_MRC_CRN __BITS(13,10) // for ESR_EC_CP15_RT
670 #define ESR_ISS_MRC_RT __BITS(9,5) // for ESR_EC_CP15_RT
671 #define ESR_ISS_MRC_CRM __BITS(4,1) // for ESR_EC_CP15_RT
672 #define ESR_ISS_MRC_DIRECTION __BIT(0) // for ESR_EC_CP15_RT
673 #define ESR_ISS_MCRR_OPC1 __BITS(19,16) // for ESR_EC_CP15_RRT
674 #define ESR_ISS_MCRR_RT2 __BITS(14,10) // for ESR_EC_CP15_RRT
675 #define ESR_ISS_MCRR_RT __BITS(9,5) // for ESR_EC_CP15_RRT
676 #define ESR_ISS_MCRR_CRM __BITS(4,1) // for ESR_EC_CP15_RRT
677 #define ESR_ISS_MCRR_DIRECTION __BIT(0) // for ESR_EC_CP15_RRT
678 #define ESR_ISS_HVC_IMM16 __BITS(15,0) // for ESR_EC_{SVC,HVC}
679 // ...
680 #define ESR_ISS_INSNABORT_EA __BIT(9) // for ESC_RC_INSN_ABT_EL[01]
681 #define ESR_ISS_INSNABORT_S1PTW __BIT(7) // for ESC_RC_INSN_ABT_EL[01]
682 #define ESR_ISS_INSNABORT_IFSC __BITS(0,5) // for ESC_RC_INSN_ABT_EL[01]
683 #define ESR_ISS_DATAABORT_ISV __BIT(24) // for ESC_RC_DATA_ABT_EL[01]
684 #define ESR_ISS_DATAABORT_SAS __BITS(23,22) // for ESC_RC_DATA_ABT_EL[01]
685 #define ESR_ISS_DATAABORT_SSE __BIT(21) // for ESC_RC_DATA_ABT_EL[01]
686 #define ESR_ISS_DATAABORT_SRT __BITS(19,16) // for ESC_RC_DATA_ABT_EL[01]
687 #define ESR_ISS_DATAABORT_SF __BIT(15) // for ESC_RC_DATA_ABT_EL[01]
688 #define ESR_ISS_DATAABORT_AR __BIT(14) // for ESC_RC_DATA_ABT_EL[01]
689 #define ESR_ISS_DATAABORT_EA __BIT(9) // for ESC_RC_DATA_ABT_EL[01]
690 #define ESR_ISS_DATAABORT_CM __BIT(8) // for ESC_RC_DATA_ABT_EL[01]
691 #define ESR_ISS_DATAABORT_S1PTW __BIT(7) // for ESC_RC_DATA_ABT_EL[01]
692 #define ESR_ISS_DATAABORT_WnR __BIT(6) // for ESC_RC_DATA_ABT_EL[01]
693 #define ESR_ISS_DATAABORT_DFSC __BITS(0,5) // for ESC_RC_DATA_ABT_EL[01]
694
695 #define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_0 0x00
696 #define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_1 0x01
697 #define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_2 0x02
698 #define ESR_ISS_FSC_ADDRESS_SIZE_FAULT_3 0x03
699 #define ESR_ISS_FSC_TRANSLATION_FAULT_0 0x04
700 #define ESR_ISS_FSC_TRANSLATION_FAULT_1 0x05
701 #define ESR_ISS_FSC_TRANSLATION_FAULT_2 0x06
702 #define ESR_ISS_FSC_TRANSLATION_FAULT_3 0x07
703 #define ESR_ISS_FSC_ACCESS_FAULT_0 0x08
704 #define ESR_ISS_FSC_ACCESS_FAULT_1 0x09
705 #define ESR_ISS_FSC_ACCESS_FAULT_2 0x0a
706 #define ESR_ISS_FSC_ACCESS_FAULT_3 0x0b
707 #define ESR_ISS_FSC_PERM_FAULT_0 0x0c
708 #define ESR_ISS_FSC_PERM_FAULT_1 0x0d
709 #define ESR_ISS_FSC_PERM_FAULT_2 0x0e
710 #define ESR_ISS_FSC_PERM_FAULT_3 0x0f
711 #define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT 0x10
712 #define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_0 0x14
713 #define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_1 0x15
714 #define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_2 0x16
715 #define ESR_ISS_FSC_SYNC_EXTERNAL_ABORT_TTWALK_3 0x17
716 #define ESR_ISS_FSC_SYNC_PARITY_ERROR 0x18
717 #define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_0 0x1c
718 #define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_1 0x1d
719 #define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_2 0x1e
720 #define ESR_ISS_FSC_SYNC_PARITY_ERROR_ON_TTWALK_3 0x1f
721 #define ESR_ISS_FSC_ALIGNMENT_FAULT 0x21
722 #define ESR_ISS_FSC_TLB_CONFLICT_FAULT 0x30
723 #define ESR_ISS_FSC_LOCKDOWN_ABORT 0x34
724 #define ESR_ISS_FSC_UNSUPPORTED_EXCLUSIVE 0x35
725 #define ESR_ISS_FSC_FIRST_LEVEL_DOMAIN_FAULT 0x3d
726 #define ESR_ISS_FSC_SECOND_LEVEL_DOMAIN_FAULT 0x3e
727
728
729 AARCH64REG_READ_INLINE(far_el1) // Fault Address Register
730 AARCH64REG_WRITE_INLINE(far_el1)
731
732 AARCH64REG_READ_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73
733 AARCH64REG_WRITE_INLINE2(l2ctlr_el1, s3_1_c11_c0_2) // Cortex-A53,57,72,73
734
735 #define L2CTLR_NUMOFCORE __BITS(25,24) // Number of cores
736 #define L2CTLR_CPUCACHEPROT __BIT(22) // CPU Cache Protection
737 #define L2CTLR_SCUL2CACHEPROT __BIT(21) // SCU-L2 Cache Protection
738 #define L2CTLR_L2_INPUT_LATENCY __BIT(5) // L2 Data RAM input latency
739 #define L2CTLR_L2_OUTPUT_LATENCY __BIT(0) // L2 Data RAM output latency
740
741 AARCH64REG_READ_INLINE(mair_el1) // Memory Attribute Indirection Register
742 AARCH64REG_WRITE_INLINE(mair_el1)
743
744 #define MAIR_ATTR0 __BITS(7,0)
745 #define MAIR_ATTR1 __BITS(15,8)
746 #define MAIR_ATTR2 __BITS(23,16)
747 #define MAIR_ATTR3 __BITS(31,24)
748 #define MAIR_ATTR4 __BITS(39,32)
749 #define MAIR_ATTR5 __BITS(47,40)
750 #define MAIR_ATTR6 __BITS(55,48)
751 #define MAIR_ATTR7 __BITS(63,56)
752 #define MAIR_DEVICE_nGnRnE 0x00 // NoGathering,NoReordering,NoEarlyWriteAck.
753 #define MAIR_DEVICE_nGnRE 0x04 // NoGathering,NoReordering,EarlyWriteAck.
754 #define MAIR_NORMAL_NC 0x44
755 #define MAIR_NORMAL_WT 0xbb
756 #define MAIR_NORMAL_WB 0xff
757
758 AARCH64REG_READ_INLINE(par_el1) // Physical Address Register
759 AARCH64REG_WRITE_INLINE(par_el1)
760
761 #define PAR_ATTR __BITS(63,56) // F=0 memory attributes
762 #define PAR_PA __BITS(51,12) // F=0 physical address
763 #define PAR_PA_SHIFT 12
764 #define PAR_NS __BIT(9) // F=0 non-secure
765 #define PAR_S __BIT(9) // F=1 failure stage
766 #define PAR_SHA __BITS(8,7) // F=0 shareability attribute
767 #define PAR_SHA_NONE 0
768 #define PAR_SHA_OUTER 2
769 #define PAR_SHA_INNER 3
770 #define PAR_PTW __BIT(8) // F=1 partial table walk
771 #define PAR_FST __BITS(6,1) // F=1 fault status code
772 #define PAR_F __BIT(0) // translation failed
773
774 AARCH64REG_READ_INLINE(rmr_el1) // Reset Management Register
775 AARCH64REG_WRITE_INLINE(rmr_el1)
776
777 AARCH64REG_READ_INLINE(rvbar_el1) // Reset Vector Base Address Register
778 AARCH64REG_WRITE_INLINE(rvbar_el1)
779
780 AARCH64REG_ATWRITE_INLINE(s1e0r); // Address Translate Stages 1
781 AARCH64REG_ATWRITE_INLINE(s1e0w);
782 AARCH64REG_ATWRITE_INLINE(s1e1r);
783 AARCH64REG_ATWRITE_INLINE(s1e1w);
784
785 AARCH64REG_READ_INLINE(sctlr_el1) // System Control Register
786 AARCH64REG_WRITE_INLINE(sctlr_el1)
787
788 #define SCTLR_RES0 0xc8222400 // Reserved ARMv8.0, write 0
789 #define SCTLR_RES1 0x30d00800 // Reserved ARMv8.0, write 1
790 #define SCTLR_M __BIT(0)
791 #define SCTLR_A __BIT(1)
792 #define SCTLR_C __BIT(2)
793 #define SCTLR_SA __BIT(3)
794 #define SCTLR_SA0 __BIT(4)
795 #define SCTLR_CP15BEN __BIT(5)
796 #define SCTLR_nAA __BIT(6)
797 #define SCTLR_ITD __BIT(7)
798 #define SCTLR_SED __BIT(8)
799 #define SCTLR_UMA __BIT(9)
800 #define SCTLR_EnRCTX __BIT(10)
801 #define SCTLR_EOS __BIT(11)
802 #define SCTLR_I __BIT(12)
803 #define SCTLR_EnDB __BIT(13)
804 #define SCTLR_DZE __BIT(14)
805 #define SCTLR_UCT __BIT(15)
806 #define SCTLR_nTWI __BIT(16)
807 #define SCTLR_nTWE __BIT(18)
808 #define SCTLR_WXN __BIT(19)
809 #define SCTLR_TSCXT __BIT(20)
810 #define SCTLR_IESB __BIT(21)
811 #define SCTLR_EIS __BIT(22)
812 #define SCTLR_SPAN __BIT(23)
813 #define SCTLR_EOE __BIT(24)
814 #define SCTLR_EE __BIT(25)
815 #define SCTLR_UCI __BIT(26)
816 #define SCTLR_EnDA __BIT(27)
817 #define SCTLR_nTLSMD __BIT(28)
818 #define SCTLR_LSMAOE __BIT(29)
819 #define SCTLR_EnIB __BIT(30)
820 #define SCTLR_EnIA __BIT(31)
821 #define SCTLR_BT0 __BIT(35)
822 #define SCTLR_BT1 __BIT(36)
823 #define SCTLR_ITFSB __BIT(37)
824 #define SCTLR_TCF0 __BITS(39,38)
825 #define SCTLR_TCF __BITS(41,40)
826 #define SCTLR_ATA0 __BIT(42)
827 #define SCTLR_ATA __BIT(43)
828 #define SCTLR_DSSBS __BIT(44)
829
830 // current EL stack pointer
831 static __inline uint64_t
832 reg_sp_read(void)
833 {
834 uint64_t __rv;
835 __asm __volatile ("mov %0, sp" : "=r"(__rv));
836 return __rv;
837 }
838
839 AARCH64REG_READ_INLINE(sp_el0) // EL0 Stack Pointer
840 AARCH64REG_WRITE_INLINE(sp_el0)
841
842 AARCH64REG_READ_INLINE(spsel) // Stack Pointer Select
843 AARCH64REG_WRITE_INLINE(spsel)
844
845 #define SPSEL_SP __BIT(0); // use SP_EL0 at all exception levels
846
847 AARCH64REG_READ_INLINE(spsr_el1) // Saved Program Status Register
848 AARCH64REG_WRITE_INLINE(spsr_el1)
849
850 #define SPSR_NZCV __BITS(31,28) // mask of N Z C V
851 #define SPSR_N __BIT(31) // Negative
852 #define SPSR_Z __BIT(30) // Zero
853 #define SPSR_C __BIT(29) // Carry
854 #define SPSR_V __BIT(28) // oVerflow
855 #define SPSR_A32_Q __BIT(27) // A32: Overflow
856 #define SPSR_A32_IT1 __BIT(26) // A32: IT[1]
857 #define SPSR_A32_IT0 __BIT(25) // A32: IT[0]
858 #define SPSR_SS __BIT(21) // Software Step
859 #define SPSR_SS_SHIFT 21
860 #define SPSR_IL __BIT(20) // Instruction Length
861 #define SPSR_GE __BITS(19,16) // A32: SIMD GE
862 #define SPSR_IT7 __BIT(15) // A32: IT[7]
863 #define SPSR_IT6 __BIT(14) // A32: IT[6]
864 #define SPSR_IT5 __BIT(13) // A32: IT[5]
865 #define SPSR_IT4 __BIT(12) // A32: IT[4]
866 #define SPSR_IT3 __BIT(11) // A32: IT[3]
867 #define SPSR_IT2 __BIT(10) // A32: IT[2]
868 #define SPSR_A64_BTYPE __BITS(11,10) // A64: BTYPE
869 #define SPSR_A64_D __BIT(9) // A64: Debug Exception Mask
870 #define SPSR_A32_E __BIT(9) // A32: BE Endian Mode
871 #define SPSR_A __BIT(8) // Async abort (SError) Mask
872 #define SPSR_I __BIT(7) // IRQ Mask
873 #define SPSR_F __BIT(6) // FIQ Mask
874 #define SPSR_A32_T __BIT(5) // A32 Thumb Mode
875 #define SPSR_A32 __BIT(4) // A32 Mode (a part of SPSR_M)
876 #define SPSR_M __BITS(4,0) // Execution State
877 #define SPSR_M_EL3H 0x0d
878 #define SPSR_M_EL3T 0x0c
879 #define SPSR_M_EL2H 0x09
880 #define SPSR_M_EL2T 0x08
881 #define SPSR_M_EL1H 0x05
882 #define SPSR_M_EL1T 0x04
883 #define SPSR_M_EL0T 0x00
884 #define SPSR_M_SYS32 0x1f
885 #define SPSR_M_UND32 0x1b
886 #define SPSR_M_ABT32 0x17
887 #define SPSR_M_SVC32 0x13
888 #define SPSR_M_IRQ32 0x12
889 #define SPSR_M_FIQ32 0x11
890 #define SPSR_M_USR32 0x10
891
892 AARCH64REG_READ_INLINE(tcr_el1) // Translation Control Register
893 AARCH64REG_WRITE_INLINE(tcr_el1)
894
895
896 /* TCR_EL1 - Translation Control Register */
897 #define TCR_TBI1 __BIT(38) /* ignore Top Byte TTBR1_EL1 */
898 #define TCR_TBI0 __BIT(37) /* ignore Top Byte TTBR0_EL1 */
899 #define TCR_AS64K __BIT(36) /* Use 64K ASIDs */
900 #define TCR_IPS __BITS(34,32) /* Intermediate PhysAdr Size */
901 #define TCR_IPS_4PB __SHIFTIN(6,TCR_IPS) /* 52 bits ( 4 PB) */
902 #define TCR_IPS_256TB __SHIFTIN(5,TCR_IPS) /* 48 bits (256 TB) */
903 #define TCR_IPS_16TB __SHIFTIN(4,TCR_IPS) /* 44 bits (16 TB) */
904 #define TCR_IPS_4TB __SHIFTIN(3,TCR_IPS) /* 42 bits ( 4 TB) */
905 #define TCR_IPS_1TB __SHIFTIN(2,TCR_IPS) /* 40 bits ( 1 TB) */
906 #define TCR_IPS_64GB __SHIFTIN(1,TCR_IPS) /* 36 bits (64 GB) */
907 #define TCR_IPS_4GB __SHIFTIN(0,TCR_IPS) /* 32 bits (4 GB) */
908 #define TCR_TG1 __BITS(31,30) /* TTBR1 Page Granule Size */
909 #define TCR_TG1_16KB __SHIFTIN(1,TCR_TG1) /* 16KB page size */
910 #define TCR_TG1_4KB __SHIFTIN(2,TCR_TG1) /* 4KB page size */
911 #define TCR_TG1_64KB __SHIFTIN(3,TCR_TG1) /* 64KB page size */
912 #define TCR_SH1 __BITS(29,28)
913 #define TCR_SH1_NONE __SHIFTIN(0,TCR_SH1)
914 #define TCR_SH1_OUTER __SHIFTIN(2,TCR_SH1)
915 #define TCR_SH1_INNER __SHIFTIN(3,TCR_SH1)
916 #define TCR_ORGN1 __BITS(27,26) /* TTBR1 Outer cacheability */
917 #define TCR_ORGN1_NC __SHIFTIN(0,TCR_ORGN1) /* Non Cacheable */
918 #define TCR_ORGN1_WB_WA __SHIFTIN(1,TCR_ORGN1) /* WriteBack WriteAllocate */
919 #define TCR_ORGN1_WT __SHIFTIN(2,TCR_ORGN1) /* WriteThrough */
920 #define TCR_ORGN1_WB __SHIFTIN(3,TCR_ORGN1) /* WriteBack */
921 #define TCR_IRGN1 __BITS(25,24) /* TTBR1 Inner cacheability */
922 #define TCR_IRGN1_NC __SHIFTIN(0,TCR_IRGN1) /* Non Cacheable */
923 #define TCR_IRGN1_WB_WA __SHIFTIN(1,TCR_IRGN1) /* WriteBack WriteAllocate */
924 #define TCR_IRGN1_WT __SHIFTIN(2,TCR_IRGN1) /* WriteThrough */
925 #define TCR_IRGN1_WB __SHIFTIN(3,TCR_IRGN1) /* WriteBack */
926 #define TCR_EPD1 __BIT(23) /* Walk Disable for TTBR1_EL1 */
927 #define TCR_A1 __BIT(22) /* ASID is in TTBR1_EL1 */
928 #define TCR_T1SZ __BITS(21,16) /* Size offset for TTBR1_EL1 */
929 #define TCR_TG0 __BITS(15,14) /* TTBR0 Page Granule Size */
930 #define TCR_TG0_4KB __SHIFTIN(0,TCR_TG0) /* 4KB page size */
931 #define TCR_TG0_64KB __SHIFTIN(1,TCR_TG0) /* 64KB page size */
932 #define TCR_TG0_16KB __SHIFTIN(2,TCR_TG0) /* 16KB page size */
933 #define TCR_SH0 __BITS(13,12)
934 #define TCR_SH0_NONE __SHIFTIN(0,TCR_SH0)
935 #define TCR_SH0_OUTER __SHIFTIN(2,TCR_SH0)
936 #define TCR_SH0_INNER __SHIFTIN(3,TCR_SH0)
937 #define TCR_ORGN0 __BITS(11,10) /* TTBR0 Outer cacheability */
938 #define TCR_ORGN0_NC __SHIFTIN(0,TCR_ORGN0) /* Non Cacheable */
939 #define TCR_ORGN0_WB_WA __SHIFTIN(1,TCR_ORGN0) /* WriteBack WriteAllocate */
940 #define TCR_ORGN0_WT __SHIFTIN(2,TCR_ORGN0) /* WriteThrough */
941 #define TCR_ORGN0_WB __SHIFTIN(3,TCR_ORGN0) /* WriteBack */
942 #define TCR_IRGN0 __BITS(9,8) /* TTBR0 Inner cacheability */
943 #define TCR_IRGN0_NC __SHIFTIN(0,TCR_IRGN0) /* Non Cacheable */
944 #define TCR_IRGN0_WB_WA __SHIFTIN(1,TCR_IRGN0) /* WriteBack WriteAllocate */
945 #define TCR_IRGN0_WT __SHIFTIN(2,TCR_IRGN0) /* WriteThrough */
946 #define TCR_IRGN0_WB __SHIFTIN(3,TCR_IRGN0) /* WriteBack */
947 #define TCR_EPD0 __BIT(7) /* Walk Disable for TTBR0 */
948 #define TCR_T0SZ __BITS(5,0) /* Size offset for TTBR0_EL1 */
949
950 AARCH64REG_READ_INLINE(tpidr_el1) // Thread ID Register (EL1)
951 AARCH64REG_WRITE_INLINE(tpidr_el1)
952
953 AARCH64REG_WRITE_INLINE(tpidrro_el0) // Thread ID Register (RO for EL0)
954
955 AARCH64REG_READ_INLINE(ttbr0_el1) // Translation Table Base Register 0 EL1
956 AARCH64REG_WRITE_INLINE(ttbr0_el1)
957
958 AARCH64REG_READ_INLINE(ttbr1_el1) // Translation Table Base Register 1 EL1
959 AARCH64REG_WRITE_INLINE(ttbr1_el1)
960
961 #define TTBR_ASID __BITS(63,48)
962 #define TTBR_BADDR __BITS(47,0)
963
964 AARCH64REG_READ_INLINE(vbar_el1) // Vector Base Address Register
965 AARCH64REG_WRITE_INLINE(vbar_el1)
966
967 /*
968 * From here on, these are DEBUG registers
969 */
970 AARCH64REG_READ_INLINE(dbgbcr0_el1) // Debug Breakpoint Control Register 0
971 AARCH64REG_WRITE_INLINE(dbgbcr0_el1)
972 AARCH64REG_READ_INLINE(dbgbcr1_el1) // Debug Breakpoint Control Register 1
973 AARCH64REG_WRITE_INLINE(dbgbcr1_el1)
974 AARCH64REG_READ_INLINE(dbgbcr2_el1) // Debug Breakpoint Control Register 2
975 AARCH64REG_WRITE_INLINE(dbgbcr2_el1)
976 AARCH64REG_READ_INLINE(dbgbcr3_el1) // Debug Breakpoint Control Register 3
977 AARCH64REG_WRITE_INLINE(dbgbcr3_el1)
978 AARCH64REG_READ_INLINE(dbgbcr4_el1) // Debug Breakpoint Control Register 4
979 AARCH64REG_WRITE_INLINE(dbgbcr4_el1)
980 AARCH64REG_READ_INLINE(dbgbcr5_el1) // Debug Breakpoint Control Register 5
981 AARCH64REG_WRITE_INLINE(dbgbcr5_el1)
982 AARCH64REG_READ_INLINE(dbgbcr6_el1) // Debug Breakpoint Control Register 6
983 AARCH64REG_WRITE_INLINE(dbgbcr6_el1)
984 AARCH64REG_READ_INLINE(dbgbcr7_el1) // Debug Breakpoint Control Register 7
985 AARCH64REG_WRITE_INLINE(dbgbcr7_el1)
986 AARCH64REG_READ_INLINE(dbgbcr8_el1) // Debug Breakpoint Control Register 8
987 AARCH64REG_WRITE_INLINE(dbgbcr8_el1)
988 AARCH64REG_READ_INLINE(dbgbcr9_el1) // Debug Breakpoint Control Register 9
989 AARCH64REG_WRITE_INLINE(dbgbcr9_el1)
990 AARCH64REG_READ_INLINE(dbgbcr10_el1) // Debug Breakpoint Control Register 10
991 AARCH64REG_WRITE_INLINE(dbgbcr10_el1)
992 AARCH64REG_READ_INLINE(dbgbcr11_el1) // Debug Breakpoint Control Register 11
993 AARCH64REG_WRITE_INLINE(dbgbcr11_el1)
994 AARCH64REG_READ_INLINE(dbgbcr12_el1) // Debug Breakpoint Control Register 12
995 AARCH64REG_WRITE_INLINE(dbgbcr12_el1)
996 AARCH64REG_READ_INLINE(dbgbcr13_el1) // Debug Breakpoint Control Register 13
997 AARCH64REG_WRITE_INLINE(dbgbcr13_el1)
998 AARCH64REG_READ_INLINE(dbgbcr14_el1) // Debug Breakpoint Control Register 14
999 AARCH64REG_WRITE_INLINE(dbgbcr14_el1)
1000 AARCH64REG_READ_INLINE(dbgbcr15_el1) // Debug Breakpoint Control Register 15
1001 AARCH64REG_WRITE_INLINE(dbgbcr15_el1)
1002
1003 #define DBGBCR_BT __BITS(23,20)
1004 #define DBGBCR_LBN __BITS(19,16)
1005 #define DBGBCR_SSC __BITS(15,14)
1006 #define DBGBCR_HMC __BIT(13)
1007 #define DBGBCR_BAS __BITS(8,5)
1008 #define DBGBCR_PMC __BITS(2,1)
1009 #define DBGBCR_E __BIT(0)
1010
1011 AARCH64REG_READ_INLINE(dbgbvr0_el1) // Debug Breakpoint Value Register 0
1012 AARCH64REG_WRITE_INLINE(dbgbvr0_el1)
1013 AARCH64REG_READ_INLINE(dbgbvr1_el1) // Debug Breakpoint Value Register 1
1014 AARCH64REG_WRITE_INLINE(dbgbvr1_el1)
1015 AARCH64REG_READ_INLINE(dbgbvr2_el1) // Debug Breakpoint Value Register 2
1016 AARCH64REG_WRITE_INLINE(dbgbvr2_el1)
1017 AARCH64REG_READ_INLINE(dbgbvr3_el1) // Debug Breakpoint Value Register 3
1018 AARCH64REG_WRITE_INLINE(dbgbvr3_el1)
1019 AARCH64REG_READ_INLINE(dbgbvr4_el1) // Debug Breakpoint Value Register 4
1020 AARCH64REG_WRITE_INLINE(dbgbvr4_el1)
1021 AARCH64REG_READ_INLINE(dbgbvr5_el1) // Debug Breakpoint Value Register 5
1022 AARCH64REG_WRITE_INLINE(dbgbvr5_el1)
1023 AARCH64REG_READ_INLINE(dbgbvr6_el1) // Debug Breakpoint Value Register 6
1024 AARCH64REG_WRITE_INLINE(dbgbvr6_el1)
1025 AARCH64REG_READ_INLINE(dbgbvr7_el1) // Debug Breakpoint Value Register 7
1026 AARCH64REG_WRITE_INLINE(dbgbvr7_el1)
1027 AARCH64REG_READ_INLINE(dbgbvr8_el1) // Debug Breakpoint Value Register 8
1028 AARCH64REG_WRITE_INLINE(dbgbvr8_el1)
1029 AARCH64REG_READ_INLINE(dbgbvr9_el1) // Debug Breakpoint Value Register 9
1030 AARCH64REG_WRITE_INLINE(dbgbvr9_el1)
1031 AARCH64REG_READ_INLINE(dbgbvr10_el1) // Debug Breakpoint Value Register 10
1032 AARCH64REG_WRITE_INLINE(dbgbvr10_el1)
1033 AARCH64REG_READ_INLINE(dbgbvr11_el1) // Debug Breakpoint Value Register 11
1034 AARCH64REG_WRITE_INLINE(dbgbvr11_el1)
1035 AARCH64REG_READ_INLINE(dbgbvr12_el1) // Debug Breakpoint Value Register 12
1036 AARCH64REG_WRITE_INLINE(dbgbvr12_el1)
1037 AARCH64REG_READ_INLINE(dbgbvr13_el1) // Debug Breakpoint Value Register 13
1038 AARCH64REG_WRITE_INLINE(dbgbvr13_el1)
1039 AARCH64REG_READ_INLINE(dbgbvr14_el1) // Debug Breakpoint Value Register 14
1040 AARCH64REG_WRITE_INLINE(dbgbvr14_el1)
1041 AARCH64REG_READ_INLINE(dbgbvr15_el1) // Debug Breakpoint Value Register 15
1042 AARCH64REG_WRITE_INLINE(dbgbvr15_el1)
1043
1044 AARCH64REG_READ_INLINE(dbgwcr0_el1) // Debug Watchpoint Control Register 0
1045 AARCH64REG_WRITE_INLINE(dbgwcr0_el1)
1046 AARCH64REG_READ_INLINE(dbgwcr1_el1) // Debug Watchpoint Control Register 1
1047 AARCH64REG_WRITE_INLINE(dbgwcr1_el1)
1048 AARCH64REG_READ_INLINE(dbgwcr2_el1) // Debug Watchpoint Control Register 2
1049 AARCH64REG_WRITE_INLINE(dbgwcr2_el1)
1050 AARCH64REG_READ_INLINE(dbgwcr3_el1) // Debug Watchpoint Control Register 3
1051 AARCH64REG_WRITE_INLINE(dbgwcr3_el1)
1052 AARCH64REG_READ_INLINE(dbgwcr4_el1) // Debug Watchpoint Control Register 4
1053 AARCH64REG_WRITE_INLINE(dbgwcr4_el1)
1054 AARCH64REG_READ_INLINE(dbgwcr5_el1) // Debug Watchpoint Control Register 5
1055 AARCH64REG_WRITE_INLINE(dbgwcr5_el1)
1056 AARCH64REG_READ_INLINE(dbgwcr6_el1) // Debug Watchpoint Control Register 6
1057 AARCH64REG_WRITE_INLINE(dbgwcr6_el1)
1058 AARCH64REG_READ_INLINE(dbgwcr7_el1) // Debug Watchpoint Control Register 7
1059 AARCH64REG_WRITE_INLINE(dbgwcr7_el1)
1060 AARCH64REG_READ_INLINE(dbgwcr8_el1) // Debug Watchpoint Control Register 8
1061 AARCH64REG_WRITE_INLINE(dbgwcr8_el1)
1062 AARCH64REG_READ_INLINE(dbgwcr9_el1) // Debug Watchpoint Control Register 9
1063 AARCH64REG_WRITE_INLINE(dbgwcr9_el1)
1064 AARCH64REG_READ_INLINE(dbgwcr10_el1) // Debug Watchpoint Control Register 10
1065 AARCH64REG_WRITE_INLINE(dbgwcr10_el1)
1066 AARCH64REG_READ_INLINE(dbgwcr11_el1) // Debug Watchpoint Control Register 11
1067 AARCH64REG_WRITE_INLINE(dbgwcr11_el1)
1068 AARCH64REG_READ_INLINE(dbgwcr12_el1) // Debug Watchpoint Control Register 12
1069 AARCH64REG_WRITE_INLINE(dbgwcr12_el1)
1070 AARCH64REG_READ_INLINE(dbgwcr13_el1) // Debug Watchpoint Control Register 13
1071 AARCH64REG_WRITE_INLINE(dbgwcr13_el1)
1072 AARCH64REG_READ_INLINE(dbgwcr14_el1) // Debug Watchpoint Control Register 14
1073 AARCH64REG_WRITE_INLINE(dbgwcr14_el1)
1074 AARCH64REG_READ_INLINE(dbgwcr15_el1) // Debug Watchpoint Control Register 15
1075 AARCH64REG_WRITE_INLINE(dbgwcr15_el1)
1076
1077 #define DBGWCR_MASK __BITS(28,24)
1078 #define DBGWCR_WT __BIT(20)
1079 #define DBGWCR_LBN __BITS(19,16)
1080 #define DBGWCR_SSC __BITS(15,14)
1081 #define DBGWCR_HMC __BIT(13)
1082 #define DBGWCR_BAS __BITS(12,5)
1083 #define DBGWCR_LSC __BITS(4,3)
1084 #define DBGWCR_PAC __BITS(2,1)
1085 #define DBGWCR_E __BIT(0)
1086
1087 AARCH64REG_READ_INLINE(dbgwvr0_el1) // Debug Watchpoint Value Register 0
1088 AARCH64REG_WRITE_INLINE(dbgwvr0_el1)
1089 AARCH64REG_READ_INLINE(dbgwvr1_el1) // Debug Watchpoint Value Register 1
1090 AARCH64REG_WRITE_INLINE(dbgwvr1_el1)
1091 AARCH64REG_READ_INLINE(dbgwvr2_el1) // Debug Watchpoint Value Register 2
1092 AARCH64REG_WRITE_INLINE(dbgwvr2_el1)
1093 AARCH64REG_READ_INLINE(dbgwvr3_el1) // Debug Watchpoint Value Register 3
1094 AARCH64REG_WRITE_INLINE(dbgwvr3_el1)
1095 AARCH64REG_READ_INLINE(dbgwvr4_el1) // Debug Watchpoint Value Register 4
1096 AARCH64REG_WRITE_INLINE(dbgwvr4_el1)
1097 AARCH64REG_READ_INLINE(dbgwvr5_el1) // Debug Watchpoint Value Register 5
1098 AARCH64REG_WRITE_INLINE(dbgwvr5_el1)
1099 AARCH64REG_READ_INLINE(dbgwvr6_el1) // Debug Watchpoint Value Register 6
1100 AARCH64REG_WRITE_INLINE(dbgwvr6_el1)
1101 AARCH64REG_READ_INLINE(dbgwvr7_el1) // Debug Watchpoint Value Register 7
1102 AARCH64REG_WRITE_INLINE(dbgwvr7_el1)
1103 AARCH64REG_READ_INLINE(dbgwvr8_el1) // Debug Watchpoint Value Register 8
1104 AARCH64REG_WRITE_INLINE(dbgwvr8_el1)
1105 AARCH64REG_READ_INLINE(dbgwvr9_el1) // Debug Watchpoint Value Register 9
1106 AARCH64REG_WRITE_INLINE(dbgwvr9_el1)
1107 AARCH64REG_READ_INLINE(dbgwvr10_el1) // Debug Watchpoint Value Register 10
1108 AARCH64REG_WRITE_INLINE(dbgwvr10_el1)
1109 AARCH64REG_READ_INLINE(dbgwvr11_el1) // Debug Watchpoint Value Register 11
1110 AARCH64REG_WRITE_INLINE(dbgwvr11_el1)
1111 AARCH64REG_READ_INLINE(dbgwvr12_el1) // Debug Watchpoint Value Register 12
1112 AARCH64REG_WRITE_INLINE(dbgwvr12_el1)
1113 AARCH64REG_READ_INLINE(dbgwvr13_el1) // Debug Watchpoint Value Register 13
1114 AARCH64REG_WRITE_INLINE(dbgwvr13_el1)
1115 AARCH64REG_READ_INLINE(dbgwvr14_el1) // Debug Watchpoint Value Register 14
1116 AARCH64REG_WRITE_INLINE(dbgwvr14_el1)
1117 AARCH64REG_READ_INLINE(dbgwvr15_el1) // Debug Watchpoint Value Register 15
1118 AARCH64REG_WRITE_INLINE(dbgwvr15_el1)
1119
1120 #define DBGWVR_MASK __BITS(64,3)
1121
1122
1123 AARCH64REG_READ_INLINE(mdscr_el1) // Monitor Debug System Control Register
1124 AARCH64REG_WRITE_INLINE(mdscr_el1)
1125
1126 #define MDSCR_RXFULL __BIT(30) // for EDSCR.RXfull
1127 #define MDSCR_TXFULL __BIT(29) // for EDSCR.TXfull
1128 #define MDSCR_RXO __BIT(27) // for EDSCR.RXO
1129 #define MDSCR_TXU __BIT(26) // for EDSCR.TXU
1130 #define MDSCR_INTDIS __BITS(32,22) // for EDSCR.INTdis
1131 #define MDSCR_TDA __BIT(21) // for EDSCR.TDA
1132 #define MDSCR_MDE __BIT(15) // Monitor debug events
1133 #define MDSCR_HDE __BIT(14) // for EDSCR.HDE
1134 #define MDSCR_KDE __BIT(13) // Local debug enable
1135 #define MDSCR_TDCC __BIT(12) // Trap Debug CommCh access
1136 #define MDSCR_ERR __BIT(6) // for EDSCR.ERR
1137 #define MDSCR_SS __BIT(0) // Software step
1138
1139 AARCH64REG_WRITE_INLINE(oslar_el1) // OS Lock Access Register
1140
1141 AARCH64REG_READ_INLINE(oslsr_el1) // OS Lock Status Register
1142
1143 /*
1144 * From here on, these are PMC registers
1145 */
1146
1147 AARCH64REG_READ_INLINE(pmccfiltr_el0)
1148 AARCH64REG_WRITE_INLINE(pmccfiltr_el0)
1149
1150 #define PMCCFILTR_P __BIT(31) // Don't count cycles in EL1
1151 #define PMCCFILTR_U __BIT(30) // Don't count cycles in EL0
1152 #define PMCCFILTR_NSK __BIT(29) // Don't count cycles in NS EL1
1153 #define PMCCFILTR_NSU __BIT(28) // Don't count cycles in NS EL0
1154 #define PMCCFILTR_NSH __BIT(27) // Don't count cycles in NS EL2
1155 #define PMCCFILTR_M __BIT(26) // Don't count cycles in EL3
1156
1157 AARCH64REG_READ_INLINE(pmccntr_el0)
1158
1159 AARCH64REG_READ_INLINE(pmceid0_el0)
1160 AARCH64REG_READ_INLINE(pmceid1_el0)
1161
1162 AARCH64REG_WRITE_INLINE(pmcntenclr_el0)
1163 AARCH64REG_WRITE_INLINE(pmcntenset_el0)
1164
1165 #define PMCNTEN_C __BIT(31) // Enable the cycle counter
1166 #define PMCNTEN_P __BITS(30,0) // Enable event counter bits
1167
1168 AARCH64REG_READ_INLINE(pmcr_el0)
1169 AARCH64REG_WRITE_INLINE(pmcr_el0)
1170
1171 #define PMCR_IMP __BITS(31,24) // Implementor code
1172 #define PMCR_IDCODE __BITS(23,16) // Identification code
1173 #define PMCR_N __BITS(15,11) // Number of event counters
1174 #define PMCR_LC __BIT(6) // Long cycle counter enable
1175 #define PMCR_DP __BIT(5) // Disable cycle counter when event
1176 // counting is prohibited
1177 #define PMCR_X __BIT(4) // Enable export of events
1178 #define PMCR_D __BIT(3) // Clock divider
1179 #define PMCR_C __BIT(2) // Cycle counter reset
1180 #define PMCR_P __BIT(1) // Event counter reset
1181 #define PMCR_E __BIT(0) // Enable
1182
1183
1184 AARCH64REG_READ_INLINE(pmevcntr1_el0)
1185 AARCH64REG_WRITE_INLINE(pmevcntr1_el0)
1186
1187 AARCH64REG_READ_INLINE(pmevtyper1_el0)
1188 AARCH64REG_WRITE_INLINE(pmevtyper1_el0)
1189
1190 #define PMEVTYPER_P __BIT(31) // Don't count events in EL1
1191 #define PMEVTYPER_U __BIT(30) // Don't count events in EL0
1192 #define PMEVTYPER_NSK __BIT(29) // Don't count events in NS EL1
1193 #define PMEVTYPER_NSU __BIT(28) // Don't count events in NS EL0
1194 #define PMEVTYPER_NSH __BIT(27) // Count events in NS EL2
1195 #define PMEVTYPER_M __BIT(26) // Don't count events in EL3
1196 #define PMEVTYPER_MT __BIT(25) // Count events on all CPUs with same
1197 // aff1 level
1198 #define PMEVTYPER_EVTCOUNT __BITS(15,0) // Event to count
1199
1200 AARCH64REG_WRITE_INLINE(pmintenclr_el1)
1201 AARCH64REG_WRITE_INLINE(pmintenset_el1)
1202
1203 AARCH64REG_WRITE_INLINE(pmovsclr_el0)
1204 AARCH64REG_READ_INLINE(pmovsset_el0)
1205 AARCH64REG_WRITE_INLINE(pmovsset_el0)
1206
1207 AARCH64REG_WRITE_INLINE(pmselr_el0)
1208
1209 AARCH64REG_WRITE_INLINE(pmswinc_el0)
1210
1211 AARCH64REG_READ_INLINE(pmuserenr_el0)
1212 AARCH64REG_WRITE_INLINE(pmuserenr_el0)
1213
1214 AARCH64REG_READ_INLINE(pmxevcntr_el0)
1215 AARCH64REG_WRITE_INLINE(pmxevcntr_el0)
1216
1217 AARCH64REG_READ_INLINE(pmxevtyper_el0)
1218 AARCH64REG_WRITE_INLINE(pmxevtyper_el0)
1219
1220 /*
1221 * Generic timer registers
1222 */
1223
1224 AARCH64REG_READ_INLINE(cntfrq_el0)
1225
1226 AARCH64REG_READ_INLINE(cnthctl_el2)
1227 AARCH64REG_WRITE_INLINE(cnthctl_el2)
1228
1229 #define CNTHCTL_EVNTDIR __BIT(3)
1230 #define CNTHCTL_EVNTEN __BIT(2)
1231 #define CNTHCTL_EL1PCEN __BIT(1)
1232 #define CNTHCTL_EL1PCTEN __BIT(0)
1233
1234 AARCH64REG_READ_INLINE(cntkctl_el1)
1235 AARCH64REG_WRITE_INLINE(cntkctl_el1)
1236
1237 #define CNTKCTL_EL0PTEN __BIT(9) // EL0 access for CNTP CVAL/TVAL/CTL
1238 #define CNTKCTL_PL0PTEN CNTKCTL_EL0PTEN
1239 #define CNTKCTL_EL0VTEN __BIT(8) // EL0 access for CNTV CVAL/TVAL/CTL
1240 #define CNTKCTL_PL0VTEN CNTKCTL_EL0VTEN
1241 #define CNTKCTL_ELNTI __BITS(7,4)
1242 #define CNTKCTL_EVNTDIR __BIT(3)
1243 #define CNTKCTL_EVNTEN __BIT(2)
1244 #define CNTKCTL_EL0VCTEN __BIT(1) // EL0 access for CNTVCT and CNTFRQ
1245 #define CNTKCTL_PL0VCTEN CNTKCTL_EL0VCTEN
1246 #define CNTKCTL_EL0PCTEN __BIT(0) // EL0 access for CNTPCT and CNTFRQ
1247 #define CNTKCTL_PL0PCTEN CNTKCTL_EL0PCTEN
1248
1249 AARCH64REG_READ_INLINE(cntp_ctl_el0)
1250 AARCH64REG_WRITE_INLINE(cntp_ctl_el0)
1251 AARCH64REG_READ_INLINE(cntp_cval_el0)
1252 AARCH64REG_WRITE_INLINE(cntp_cval_el0)
1253 AARCH64REG_READ_INLINE(cntp_tval_el0)
1254 AARCH64REG_WRITE_INLINE(cntp_tval_el0)
1255 AARCH64REG_READ_INLINE(cntpct_el0)
1256 AARCH64REG_WRITE_INLINE(cntpct_el0)
1257
1258 AARCH64REG_READ_INLINE(cntps_ctl_el1)
1259 AARCH64REG_WRITE_INLINE(cntps_ctl_el1)
1260 AARCH64REG_READ_INLINE(cntps_cval_el1)
1261 AARCH64REG_WRITE_INLINE(cntps_cval_el1)
1262 AARCH64REG_READ_INLINE(cntps_tval_el1)
1263 AARCH64REG_WRITE_INLINE(cntps_tval_el1)
1264
1265 AARCH64REG_READ_INLINE(cntv_ctl_el0)
1266 AARCH64REG_WRITE_INLINE(cntv_ctl_el0)
1267 AARCH64REG_READ_INLINE(cntv_cval_el0)
1268 AARCH64REG_WRITE_INLINE(cntv_cval_el0)
1269 AARCH64REG_READ_INLINE(cntv_tval_el0)
1270 AARCH64REG_WRITE_INLINE(cntv_tval_el0)
1271 AARCH64REG_READ_INLINE(cntvct_el0)
1272 AARCH64REG_WRITE_INLINE(cntvct_el0)
1273
1274 #define CNTCTL_ISTATUS __BIT(2) // Interrupt Asserted
1275 #define CNTCTL_IMASK __BIT(1) // Timer Interrupt is Masked
1276 #define CNTCTL_ENABLE __BIT(0) // Timer Enabled
1277
1278 // ID_AA64PFR0_EL1: AArch64 Processor Feature Register 0
1279 #define ID_AA64PFR0_EL1_SVE __BITS(35,32) // Scalable Vector
1280 #define ID_AA64PFR0_EL1_SVE_NONE 0
1281 #define ID_AA64PFR0_EL1_SVE_IMPL 1
1282 #define ID_AA64PFR0_EL1_RAS __BITS(31,28) // RAS Extension
1283 #define ID_AA64PFR0_EL1_RAS_NONE 0
1284 #define ID_AA64PFR0_EL1_RAS_IMPL 1
1285 #define ID_AA64PFR0_EL1_RAS_ERX 2
1286 #define ID_AA64PFR0_EL1_GIC __BITS(24,27) // GIC CPU IF
1287 #define ID_AA64PFR0_EL1_GIC_SHIFT 24
1288 #define ID_AA64PFR0_EL1_GIC_CPUIF_EN 1
1289 #define ID_AA64PFR0_EL1_GIC_CPUIF_NONE 0
1290 #define ID_AA64PFR0_EL1_ADVSIMD __BITS(23,20) // SIMD
1291 #define ID_AA64PFR0_EL1_ADV_SIMD_IMPL 0x0
1292 #define ID_AA64PFR0_EL1_ADV_SIMD_HP 0x1
1293 #define ID_AA64PFR0_EL1_ADV_SIMD_NONE 0xf
1294 #define ID_AA64PFR0_EL1_FP __BITS(19,16) // FP
1295 #define ID_AA64PFR0_EL1_FP_IMPL 0x0
1296 #define ID_AA64PFR0_EL1_FP_HP 0x1
1297 #define ID_AA64PFR0_EL1_FP_NONE 0xf
1298 #define ID_AA64PFR0_EL1_EL3 __BITS(15,12) // EL3 handling
1299 #define ID_AA64PFR0_EL1_EL3_NONE 0
1300 #define ID_AA64PFR0_EL1_EL3_64 1
1301 #define ID_AA64PFR0_EL1_EL3_64_32 2
1302 #define ID_AA64PFR0_EL1_EL2 __BITS(11,8) // EL2 handling
1303 #define ID_AA64PFR0_EL1_EL2_NONE 0
1304 #define ID_AA64PFR0_EL1_EL2_64 1
1305 #define ID_AA64PFR0_EL1_EL2_64_32 2
1306 #define ID_AA64PFR0_EL1_EL1 __BITS(7,4) // EL1 handling
1307 #define ID_AA64PFR0_EL1_EL1_64 1
1308 #define ID_AA64PFR0_EL1_EL1_64_32 2
1309 #define ID_AA64PFR0_EL1_EL0 __BITS(3,0) // EL0 handling
1310 #define ID_AA64PFR0_EL1_EL0_64 1
1311 #define ID_AA64PFR0_EL1_EL0_64_32 2
1312
1313 /*
1314 * GICv3 system registers
1315 */
1316 AARCH64REG_READWRITE_INLINE2(icc_sre_el1, s3_0_c12_c12_5)
1317 AARCH64REG_READWRITE_INLINE2(icc_ctlr_el1, s3_0_c12_c12_4)
1318 AARCH64REG_READWRITE_INLINE2(icc_pmr_el1, s3_0_c4_c6_0)
1319 AARCH64REG_READWRITE_INLINE2(icc_bpr0_el1, s3_0_c12_c8_3)
1320 AARCH64REG_READWRITE_INLINE2(icc_bpr1_el1, s3_0_c12_c12_3)
1321 AARCH64REG_READWRITE_INLINE2(icc_igrpen0_el1, s3_0_c12_c12_6)
1322 AARCH64REG_READWRITE_INLINE2(icc_igrpen1_el1, s3_0_c12_c12_7)
1323 AARCH64REG_READWRITE_INLINE2(icc_eoir0_el1, s3_0_c12_c8_1)
1324 AARCH64REG_READWRITE_INLINE2(icc_eoir1_el1, s3_0_c12_c12_1)
1325 AARCH64REG_READWRITE_INLINE2(icc_sgi1r_el1, s3_0_c12_c11_5)
1326 AARCH64REG_READ_INLINE2(icc_iar1_el1, s3_0_c12_c12_0)
1327
1328 // ICC_SRE_EL1: Interrupt Controller System Register Enable register
1329 #define ICC_SRE_EL1_DIB __BIT(2)
1330 #define ICC_SRE_EL1_DFB __BIT(1)
1331 #define ICC_SRE_EL1_SRE __BIT(0)
1332
1333 // ICC_SRE_EL2: Interrupt Controller System Register Enable register
1334 #define ICC_SRE_EL2_EN __BIT(3)
1335 #define ICC_SRE_EL2_DIB __BIT(2)
1336 #define ICC_SRE_EL2_DFB __BIT(1)
1337 #define ICC_SRE_EL2_SRE __BIT(0)
1338
1339 // ICC_BPR[01]_EL1: Interrupt Controller Binary Point Register 0/1
1340 #define ICC_BPR_EL1_BinaryPoint __BITS(2,0)
1341
1342 // ICC_CTLR_EL1: Interrupt Controller Control Register
1343 #define ICC_CTLR_EL1_A3V __BIT(15)
1344 #define ICC_CTLR_EL1_SEIS __BIT(14)
1345 #define ICC_CTLR_EL1_IDbits __BITS(13,11)
1346 #define ICC_CTLR_EL1_PRIbits __BITS(10,8)
1347 #define ICC_CTLR_EL1_PMHE __BIT(6)
1348 #define ICC_CTLR_EL1_EOImode __BIT(1)
1349 #define ICC_CTLR_EL1_CBPR __BIT(0)
1350
1351 // ICC_IGRPEN[01]_EL1: Interrupt Controller Interrupt Group 0/1 Enable register
1352 #define ICC_IGRPEN_EL1_Enable __BIT(0)
1353
1354 // ICC_SGI[01]R_EL1: Interrupt Controller Software Generated Interrupt Group 0/1 Register
1355 #define ICC_SGIR_EL1_Aff3 __BITS(55,48)
1356 #define ICC_SGIR_EL1_IRM __BIT(40)
1357 #define ICC_SGIR_EL1_Aff2 __BITS(39,32)
1358 #define ICC_SGIR_EL1_INTID __BITS(27,24)
1359 #define ICC_SGIR_EL1_Aff1 __BITS(23,16)
1360 #define ICC_SGIR_EL1_TargetList __BITS(15,0)
1361 #define ICC_SGIR_EL1_Aff (ICC_SGIR_EL1_Aff3|ICC_SGIR_EL1_Aff2|ICC_SGIR_EL1_Aff1)
1362
1363 // ICC_IAR[01]_EL1: Interrupt Controller Interrupt Acknowledge Register 0/1
1364 #define ICC_IAR_INTID __BITS(23,0)
1365 #define ICC_IAR_INTID_SPURIOUS 1023
1366
1367 /*
1368 * GICv3 REGISTER ACCESS
1369 */
1370
1371 #define icc_sre_read reg_icc_sre_el1_read
1372 #define icc_sre_write reg_icc_sre_el1_write
1373 #define icc_pmr_read reg_icc_pmr_el1_read
1374 #define icc_pmr_write reg_icc_pmr_el1_write
1375 #define icc_bpr0_write reg_icc_bpr0_el1_write
1376 #define icc_bpr1_write reg_icc_bpr1_el1_write
1377 #define icc_ctlr_read reg_icc_ctlr_el1_read
1378 #define icc_ctlr_write reg_icc_ctlr_el1_write
1379 #define icc_igrpen1_write reg_icc_igrpen1_el1_write
1380 #define icc_sgi1r_write reg_icc_sgi1r_el1_write
1381 #define icc_iar1_read reg_icc_iar1_el1_read
1382 #define icc_eoi1r_write reg_icc_eoir1_el1_write
1383
1384 #if defined(_KERNEL)
1385
1386 /*
1387 * CPU REGISTER ACCESS
1388 */
1389 static __inline register_t
1390 cpu_mpidr_aff_read(void)
1391 {
1392
1393 return reg_mpidr_el1_read() &
1394 (MPIDR_AFF3|MPIDR_AFF2|MPIDR_AFF1|MPIDR_AFF0);
1395 }
1396
1397 /*
1398 * GENERIC TIMER REGISTER ACCESS
1399 */
1400 static __inline uint32_t
1401 gtmr_cntfrq_read(void)
1402 {
1403
1404 return reg_cntfrq_el0_read();
1405 }
1406
1407 static __inline uint32_t
1408 gtmr_cntk_ctl_read(void)
1409 {
1410
1411 return reg_cntkctl_el1_read();
1412 }
1413
1414 static __inline void
1415 gtmr_cntk_ctl_write(uint32_t val)
1416 {
1417
1418 reg_cntkctl_el1_write(val);
1419 }
1420
1421 /*
1422 * Counter-timer Virtual Count timer
1423 */
1424 static __inline uint64_t
1425 gtmr_cntpct_read(void)
1426 {
1427
1428 return reg_cntpct_el0_read();
1429 }
1430
1431 static __inline uint64_t
1432 gtmr_cntvct_read(void)
1433 {
1434
1435 return reg_cntvct_el0_read();
1436 }
1437
1438 /*
1439 * Counter-timer Virtual Timer Control register
1440 */
1441 static __inline uint32_t
1442 gtmr_cntv_ctl_read(void)
1443 {
1444
1445 return reg_cntv_ctl_el0_read();
1446 }
1447
1448 static __inline void
1449 gtmr_cntv_ctl_write(uint32_t val)
1450 {
1451
1452 reg_cntv_ctl_el0_write(val);
1453 }
1454
1455 /*
1456 * Counter-timer Physical Timer Control register
1457 */
1458 static __inline uint32_t
1459 gtmr_cntp_ctl_read(void)
1460 {
1461
1462 return reg_cntp_ctl_el0_read();
1463 }
1464
1465 static __inline void
1466 gtmr_cntp_ctl_write(uint32_t val)
1467 {
1468
1469 reg_cntp_ctl_el0_write(val);
1470 }
1471
1472 /*
1473 * Counter-timer Physical Timer TimerValue register
1474 */
1475 static __inline uint32_t
1476 gtmr_cntp_tval_read(void)
1477 {
1478
1479 return reg_cntp_tval_el0_read();
1480 }
1481
1482 static __inline void
1483 gtmr_cntp_tval_write(uint32_t val)
1484 {
1485
1486 reg_cntp_tval_el0_write(val);
1487 }
1488
1489 /*
1490 * Counter-timer Virtual Timer TimerValue register
1491 */
1492 static __inline uint32_t
1493 gtmr_cntv_tval_read(void)
1494 {
1495
1496 return reg_cntv_tval_el0_read();
1497 }
1498
1499 static __inline void
1500 gtmr_cntv_tval_write(uint32_t val)
1501 {
1502
1503 reg_cntv_tval_el0_write(val);
1504 }
1505
1506 /*
1507 * Counter-timer Physical Timer CompareValue register
1508 */
1509 static __inline uint64_t
1510 gtmr_cntp_cval_read(void)
1511 {
1512
1513 return reg_cntp_cval_el0_read();
1514 }
1515
1516 static __inline void
1517 gtmr_cntp_cval_write(uint64_t val)
1518 {
1519
1520 reg_cntp_cval_el0_write(val);
1521 }
1522
1523 /*
1524 * Counter-timer Virtual Timer CompareValue register
1525 */
1526 static __inline uint64_t
1527 gtmr_cntv_cval_read(void)
1528 {
1529
1530 return reg_cntv_cval_el0_read();
1531 }
1532
1533 static __inline void
1534 gtmr_cntv_cval_write(uint64_t val)
1535 {
1536
1537 reg_cntv_cval_el0_write(val);
1538 }
1539 #endif /* _KERNEL */
1540
1541 /*
1542 * Structure attached to machdep.cpuN.cpu_id sysctl node.
1543 * Always add new members to the end, and avoid arrays.
1544 */
1545 struct aarch64_sysctl_cpu_id {
1546 uint64_t ac_midr; /* Main ID Register */
1547 uint64_t ac_revidr; /* Revision ID Register */
1548 uint64_t ac_mpidr; /* Multiprocessor Affinity Register */
1549
1550 uint64_t ac_aa64dfr0; /* A64 Debug Feature Register 0 */
1551 uint64_t ac_aa64dfr1; /* A64 Debug Feature Register 1 */
1552
1553 uint64_t ac_aa64isar0; /* A64 Instruction Set Attribute Register 0 */
1554 uint64_t ac_aa64isar1; /* A64 Instruction Set Attribute Register 1 */
1555
1556 uint64_t ac_aa64mmfr0; /* A64 Memory Model Feature Register 0 */
1557 uint64_t ac_aa64mmfr1; /* A64 Memory Model Feature Register 1 */
1558 uint64_t ac_aa64mmfr2; /* A64 Memory Model Feature Register 2 */
1559
1560 uint64_t ac_aa64pfr0; /* A64 Processor Feature Register 0 */
1561 uint64_t ac_aa64pfr1; /* A64 Processor Feature Register 1 */
1562
1563 uint64_t ac_aa64zfr0; /* A64 SVE Feature ID Register 0 */
1564
1565 uint32_t ac_mvfr0; /* Media and VFP Feature Register 0 */
1566 uint32_t ac_mvfr1; /* Media and VFP Feature Register 1 */
1567 uint32_t ac_mvfr2; /* Media and VFP Feature Register 2 */
1568 };
1569
1570 #endif /* _AARCH64_ARMREG_H_ */
1571