VirtualBox

source: vbox/trunk/include/iprt/armv8.h

Last change on this file was 106061, checked in by vboxsync, 7 weeks ago

Copyright year updates by scm.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 285.4 KB
Line 
1/** @file
2 * IPRT - ARMv8 (AArch64 and AArch32) Structures and Definitions.
3 */
4
5/*
6 * Copyright (C) 2023-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.virtualbox.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef IPRT_INCLUDED_armv8_h
37#define IPRT_INCLUDED_armv8_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#ifndef VBOX_FOR_DTRACE_LIB
43# include <iprt/cdefs.h>
44# ifndef RT_IN_ASSEMBLER
45# include <iprt/types.h>
46# include <iprt/assert.h>
47# endif
48# include <iprt/assertcompile.h>
49#else
50# pragma D depends_on library vbox-types.d
51#endif
52
53/** @defgroup grp_rt_armv8 ARMv8 Types and Definitions
54 * @ingroup grp_rt
55 * @{
56 */
57
58/** @name The AArch64 register encoding - deprecated.
59 * @deprecated Use ARMV8_A64_REG_XXX instead.
60 * @todo correct code and drop these remaining ones.
61 * @{ */
62#define ARMV8_AARCH64_REG_X0 0
63#define ARMV8_AARCH64_REG_X1 1
64#define ARMV8_AARCH64_REG_X2 2
65#define ARMV8_AARCH64_REG_X3 3
66#define ARMV8_AARCH64_REG_ZR 31
67/** @} */
68
69/** @name The AArch64 general purpose register encoding.
70 * @{ */
71#define ARMV8_A64_REG_X0 0
72#define ARMV8_A64_REG_X1 1
73#define ARMV8_A64_REG_X2 2
74#define ARMV8_A64_REG_X3 3
75#define ARMV8_A64_REG_X4 4
76#define ARMV8_A64_REG_X5 5
77#define ARMV8_A64_REG_X6 6
78#define ARMV8_A64_REG_X7 7
79#define ARMV8_A64_REG_X8 8
80#define ARMV8_A64_REG_X9 9
81#define ARMV8_A64_REG_X10 10
82#define ARMV8_A64_REG_X11 11
83#define ARMV8_A64_REG_X12 12
84#define ARMV8_A64_REG_X13 13
85#define ARMV8_A64_REG_X14 14
86#define ARMV8_A64_REG_X15 15
87#define ARMV8_A64_REG_X16 16
88#define ARMV8_A64_REG_X17 17
89#define ARMV8_A64_REG_X18 18
90#define ARMV8_A64_REG_X19 19
91#define ARMV8_A64_REG_X20 20
92#define ARMV8_A64_REG_X21 21
93#define ARMV8_A64_REG_X22 22
94#define ARMV8_A64_REG_X23 23
95#define ARMV8_A64_REG_X24 24
96#define ARMV8_A64_REG_X25 25
97#define ARMV8_A64_REG_X26 26
98#define ARMV8_A64_REG_X27 27
99#define ARMV8_A64_REG_X28 28
100#define ARMV8_A64_REG_X29 29
101#define ARMV8_A64_REG_X30 30
102/** @} */
103
104/** @name The AArch64 32-bit general purpose register names.
105 * @{ */
106#define ARMV8_A64_REG_W0 ARMV8_A64_REG_X0
107#define ARMV8_A64_REG_W1 ARMV8_A64_REG_X1
108#define ARMV8_A64_REG_W2 ARMV8_A64_REG_X2
109#define ARMV8_A64_REG_W3 ARMV8_A64_REG_X3
110#define ARMV8_A64_REG_W4 ARMV8_A64_REG_X4
111#define ARMV8_A64_REG_W5 ARMV8_A64_REG_X5
112#define ARMV8_A64_REG_W6 ARMV8_A64_REG_X6
113#define ARMV8_A64_REG_W7 ARMV8_A64_REG_X7
114#define ARMV8_A64_REG_W8 ARMV8_A64_REG_X8
115#define ARMV8_A64_REG_W9 ARMV8_A64_REG_X9
116#define ARMV8_A64_REG_W10 ARMV8_A64_REG_X10
117#define ARMV8_A64_REG_W11 ARMV8_A64_REG_X11
118#define ARMV8_A64_REG_W12 ARMV8_A64_REG_X12
119#define ARMV8_A64_REG_W13 ARMV8_A64_REG_X13
120#define ARMV8_A64_REG_W14 ARMV8_A64_REG_X14
121#define ARMV8_A64_REG_W15 ARMV8_A64_REG_X15
122#define ARMV8_A64_REG_W16 ARMV8_A64_REG_X16
123#define ARMV8_A64_REG_W17 ARMV8_A64_REG_X17
124#define ARMV8_A64_REG_W18 ARMV8_A64_REG_X18
125#define ARMV8_A64_REG_W19 ARMV8_A64_REG_X19
126#define ARMV8_A64_REG_W20 ARMV8_A64_REG_X20
127#define ARMV8_A64_REG_W21 ARMV8_A64_REG_X21
128#define ARMV8_A64_REG_W22 ARMV8_A64_REG_X22
129#define ARMV8_A64_REG_W23 ARMV8_A64_REG_X23
130#define ARMV8_A64_REG_W24 ARMV8_A64_REG_X24
131#define ARMV8_A64_REG_W25 ARMV8_A64_REG_X25
132#define ARMV8_A64_REG_W26 ARMV8_A64_REG_X26
133#define ARMV8_A64_REG_W27 ARMV8_A64_REG_X27
134#define ARMV8_A64_REG_W28 ARMV8_A64_REG_X28
135#define ARMV8_A64_REG_W29 ARMV8_A64_REG_X29
136#define ARMV8_A64_REG_W30 ARMV8_A64_REG_X30
137/** @} */
138
139/** @name The AArch64 NEON scalar register encoding.
140 * @{ */
141#define ARMV8_A64_REG_Q0 0
142#define ARMV8_A64_REG_Q1 1
143#define ARMV8_A64_REG_Q2 2
144#define ARMV8_A64_REG_Q3 3
145#define ARMV8_A64_REG_Q4 4
146#define ARMV8_A64_REG_Q5 5
147#define ARMV8_A64_REG_Q6 6
148#define ARMV8_A64_REG_Q7 7
149#define ARMV8_A64_REG_Q8 8
150#define ARMV8_A64_REG_Q9 9
151#define ARMV8_A64_REG_Q10 10
152#define ARMV8_A64_REG_Q11 11
153#define ARMV8_A64_REG_Q12 12
154#define ARMV8_A64_REG_Q13 13
155#define ARMV8_A64_REG_Q14 14
156#define ARMV8_A64_REG_Q15 15
157#define ARMV8_A64_REG_Q16 16
158#define ARMV8_A64_REG_Q17 17
159#define ARMV8_A64_REG_Q18 18
160#define ARMV8_A64_REG_Q19 19
161#define ARMV8_A64_REG_Q20 20
162#define ARMV8_A64_REG_Q21 21
163#define ARMV8_A64_REG_Q22 22
164#define ARMV8_A64_REG_Q23 23
165#define ARMV8_A64_REG_Q24 24
166#define ARMV8_A64_REG_Q25 25
167#define ARMV8_A64_REG_Q26 26
168#define ARMV8_A64_REG_Q27 27
169#define ARMV8_A64_REG_Q28 28
170#define ARMV8_A64_REG_Q29 29
171#define ARMV8_A64_REG_Q30 30
172#define ARMV8_A64_REG_Q31 31
173/** @} */
174
175/** @name The AArch64 NEON vector register encoding.
176 * @{ */
177#define ARMV8_A64_REG_V0 ARMV8_A64_REG_Q0
178#define ARMV8_A64_REG_V1 ARMV8_A64_REG_Q1
179#define ARMV8_A64_REG_V2 ARMV8_A64_REG_Q2
180#define ARMV8_A64_REG_V3 ARMV8_A64_REG_Q3
181#define ARMV8_A64_REG_V4 ARMV8_A64_REG_Q4
182#define ARMV8_A64_REG_V5 ARMV8_A64_REG_Q5
183#define ARMV8_A64_REG_V6 ARMV8_A64_REG_Q6
184#define ARMV8_A64_REG_V7 ARMV8_A64_REG_Q7
185#define ARMV8_A64_REG_V8 ARMV8_A64_REG_Q8
186#define ARMV8_A64_REG_V9 ARMV8_A64_REG_Q9
187#define ARMV8_A64_REG_V10 ARMV8_A64_REG_Q10
188#define ARMV8_A64_REG_V11 ARMV8_A64_REG_Q11
189#define ARMV8_A64_REG_V12 ARMV8_A64_REG_Q12
190#define ARMV8_A64_REG_V13 ARMV8_A64_REG_Q13
191#define ARMV8_A64_REG_V14 ARMV8_A64_REG_Q14
192#define ARMV8_A64_REG_V15 ARMV8_A64_REG_Q15
193#define ARMV8_A64_REG_V16 ARMV8_A64_REG_Q16
194#define ARMV8_A64_REG_V17 ARMV8_A64_REG_Q17
195#define ARMV8_A64_REG_V18 ARMV8_A64_REG_Q18
196#define ARMV8_A64_REG_V19 ARMV8_A64_REG_Q19
197#define ARMV8_A64_REG_V20 ARMV8_A64_REG_Q20
198#define ARMV8_A64_REG_V21 ARMV8_A64_REG_Q21
199#define ARMV8_A64_REG_V22 ARMV8_A64_REG_Q22
200#define ARMV8_A64_REG_V23 ARMV8_A64_REG_Q23
201#define ARMV8_A64_REG_V24 ARMV8_A64_REG_Q24
202#define ARMV8_A64_REG_V25 ARMV8_A64_REG_Q25
203#define ARMV8_A64_REG_V26 ARMV8_A64_REG_Q26
204#define ARMV8_A64_REG_V27 ARMV8_A64_REG_Q27
205#define ARMV8_A64_REG_V28 ARMV8_A64_REG_Q28
206#define ARMV8_A64_REG_V29 ARMV8_A64_REG_Q29
207#define ARMV8_A64_REG_V30 ARMV8_A64_REG_Q30
208#define ARMV8_A64_REG_V31 ARMV8_A64_REG_Q31
209/** @} */
210
211/** @name The AArch64 register 31.
212 * @note Register 31 typically refers to the zero register, but can also in
213 * select case (by instruction and opecode field) refer the to stack
214 * pointer of the current exception level. ARM typically uses \<Xn|SP\>
215 * to indicate that register 31 is taken as SP, if just \<Xn\> is used
216 * 31 will be the zero register.
217 * @{ */
218/** The stack pointer. */
219#define ARMV8_A64_REG_SP 31
220/** The zero register. Reads as zero, writes ignored. */
221#define ARMV8_A64_REG_XZR 31
222/** The zero register, the 32-bit register name. */
223#define ARMV8_A64_REG_WZR ARMV8_A64_REG_XZR
224/** @} */
225
226/** @name AArch64 register aliases
227 * @{ */
228/** The link register is typically mapped to x30 as that's the default pick of
229 * the RET instruction. */
230#define ARMV8_A64_REG_LR ARMV8_A64_REG_X30
231/** Frame base pointer is typically mapped to x29. */
232#define ARMV8_A64_REG_BP ARMV8_A64_REG_X29
233/** @} */
234
235
236/** @name System register encoding.
237 * @{
238 */
239/** Mask for the op0 part of an MSR/MRS instruction */
240#define ARMV8_AARCH64_SYSREG_OP0_MASK (RT_BIT_32(19) | RT_BIT_32(20))
241/** Shift for the op0 part of an MSR/MRS instruction */
242#define ARMV8_AARCH64_SYSREG_OP0_SHIFT 19
243/** Returns the op0 part of the given MRS/MSR instruction. */
244#define ARMV8_AARCH64_SYSREG_OP0_GET(a_MsrMrsInsn) (((a_MsrMrsInsn) & ARMV8_AARCH64_SYSREG_OP0_MASK) >> ARMV8_AARCH64_SYSREG_OP0_SHIFT)
245/** Mask for the op1 part of an MSR/MRS instruction */
246#define ARMV8_AARCH64_SYSREG_OP1_MASK (RT_BIT_32(16) | RT_BIT_32(17) | RT_BIT_32(18))
247/** Shift for the op1 part of an MSR/MRS instruction */
248#define ARMV8_AARCH64_SYSREG_OP1_SHIFT 16
249/** Returns the op1 part of the given MRS/MSR instruction. */
250#define ARMV8_AARCH64_SYSREG_OP1_GET(a_MsrMrsInsn) (((a_MsrMrsInsn) & ARMV8_AARCH64_SYSREG_OP1_MASK) >> ARMV8_AARCH64_SYSREG_OP1_SHIFT)
251/** Mask for the CRn part of an MSR/MRS instruction */
252#define ARMV8_AARCH64_SYSREG_CRN_MASK ( RT_BIT_32(12) | RT_BIT_32(13) | RT_BIT_32(14) \
253 | RT_BIT_32(15) )
254/** Shift for the CRn part of an MSR/MRS instruction */
255#define ARMV8_AARCH64_SYSREG_CRN_SHIFT 12
256/** Returns the CRn part of the given MRS/MSR instruction. */
257#define ARMV8_AARCH64_SYSREG_CRN_GET(a_MsrMrsInsn) (((a_MsrMrsInsn) & ARMV8_AARCH64_SYSREG_CRN_MASK) >> ARMV8_AARCH64_SYSREG_CRN_SHIFT)
258/** Mask for the CRm part of an MSR/MRS instruction */
259#define ARMV8_AARCH64_SYSREG_CRM_MASK ( RT_BIT_32(8) | RT_BIT_32(9) | RT_BIT_32(10) \
260 | RT_BIT_32(11) )
261/** Shift for the CRm part of an MSR/MRS instruction */
262#define ARMV8_AARCH64_SYSREG_CRM_SHIFT 8
263/** Returns the CRn part of the given MRS/MSR instruction. */
264#define ARMV8_AARCH64_SYSREG_CRM_GET(a_MsrMrsInsn) (((a_MsrMrsInsn) & ARMV8_AARCH64_SYSREG_CRM_MASK) >> ARMV8_AARCH64_SYSREG_CRM_SHIFT)
265/** Mask for the op2 part of an MSR/MRS instruction */
266#define ARMV8_AARCH64_SYSREG_OP2_MASK (RT_BIT_32(5) | RT_BIT_32(6) | RT_BIT_32(7))
267/** Shift for the op2 part of an MSR/MRS instruction */
268#define ARMV8_AARCH64_SYSREG_OP2_SHIFT 5
269/** Returns the op2 part of the given MRS/MSR instruction. */
270#define ARMV8_AARCH64_SYSREG_OP2_GET(a_MsrMrsInsn) (((a_MsrMrsInsn) & ARMV8_AARCH64_SYSREG_OP2_MASK) >> ARMV8_AARCH64_SYSREG_OP2_SHIFT)
271/** Mask for all system register encoding relevant fields in an MRS/MSR instruction. */
272#define ARMV8_AARCH64_SYSREG_MASK ( ARMV8_AARCH64_SYSREG_OP0_MASK | ARMV8_AARCH64_SYSREG_OP1_MASK \
273 | ARMV8_AARCH64_SYSREG_CRN_MASK | ARMV8_AARCH64_SYSREG_CRN_MASK \
274 | ARMV8_AARCH64_SYSREG_OP2_MASK)
275/** @} */
276
277/** @name Mapping of op0:op1:CRn:CRm:op2 to a system register ID. This is
278 * IPRT specific and not part of the ARMv8 specification.
279 * @{ */
280#define ARMV8_AARCH64_SYSREG_ID_CREATE(a_Op0, a_Op1, a_CRn, a_CRm, a_Op2) \
281 (uint16_t)( (((a_Op0) & 0x3) << 14) \
282 | (((a_Op1) & 0x7) << 11) \
283 | (((a_CRn) & 0xf) << 7) \
284 | (((a_CRm) & 0xf) << 3) \
285 | ((a_Op2) & 0x7))
286/** Returns the internal system register ID from the given MRS/MSR instruction. */
287#define ARMV8_AARCH64_SYSREG_ID_FROM_MRS_MSR(a_MsrMrsInsn) \
288 ARMV8_AARCH64_SYSREG_ID_CREATE(ARMV8_AARCH64_SYSREG_OP0_GET(a_MsrMrsInsn), \
289 ARMV8_AARCH64_SYSREG_OP1_GET(a_MsrMrsInsn), \
290 ARMV8_AARCH64_SYSREG_CRN_GET(a_MsrMrsInsn), \
291 ARMV8_AARCH64_SYSREG_CRM_GET(a_MsrMrsInsn), \
292 ARMV8_AARCH64_SYSREG_OP2_GET(a_MsrMrsInsn))
293/** Encodes the given system register ID in the given MSR/MRS instruction. */
294#define ARMV8_AARCH64_SYSREG_ID_ENCODE_IN_MRS_MSR(a_MsrMrsInsn, a_SysregId) \
295 ((a_MsrMrsInsn) = ((a_MsrMrsInsn) & ~ARMV8_AARCH64_SYSREG_MASK) | (a_SysregId << ARMV8_AARCH64_SYSREG_OP2_SHIFT))
296/** @} */
297
298
299/** @name System register IDs.
300 * @{ */
301/** OSDTRRX_EL1 register - RW. */
302#define ARMV8_AARCH64_SYSREG_OSDTRRX_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, 0, 2)
303/** MDSCR_EL1 - RW. */
304#define ARMV8_AARCH64_SYSREG_MDSCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, 2, 2)
305/** DBGBVR<0..15>_EL1 register - RW. */
306#define ARMV8_AARCH64_SYSREG_DBGBVRn_EL1(a_Id) ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, (a_Id), 4)
307/** DBGBCR<0..15>_EL1 register - RW. */
308#define ARMV8_AARCH64_SYSREG_DBGBCRn_EL1(a_Id) ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, (a_Id), 5)
309/** DBGWVR<0..15>_EL1 register - RW. */
310#define ARMV8_AARCH64_SYSREG_DBGWVRn_EL1(a_Id) ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, (a_Id), 6)
311/** DBGWCR<0..15>_EL1 register - RW. */
312#define ARMV8_AARCH64_SYSREG_DBGWCRn_EL1(a_Id) ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, (a_Id), 7)
313/** MDCCINT_EL1 register - RW. */
314#define ARMV8_AARCH64_SYSREG_MDCCINT_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, 2, 0)
315/** OSDTRTX_EL1 register - RW. */
316#define ARMV8_AARCH64_SYSREG_OSDTRTX_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, 3, 2)
317/** OSECCR_EL1 register - RW. */
318#define ARMV8_AARCH64_SYSREG_OSECCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 0, 6, 2)
319/** MDRAR_EL1 register - RO. */
320#define ARMV8_AARCH64_SYSREG_MDRAR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 1, 0, 0)
321/** OSLAR_EL1 register - WO. */
322#define ARMV8_AARCH64_SYSREG_OSLAR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 1, 0, 4)
323/** OSLSR_EL1 register - RO. */
324#define ARMV8_AARCH64_SYSREG_OSLSR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 1, 1, 4)
325/** OSDLR_EL1 register - RW. */
326#define ARMV8_AARCH64_SYSREG_OSDLR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(2, 0, 1, 3, 4)
327
328/** MIDR_EL1 register - RO. */
329#define ARMV8_AARCH64_SYSREG_MIDR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 0, 0)
330/** MIPDR_EL1 register - RO. */
331#define ARMV8_AARCH64_SYSREG_MPIDR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 0, 5)
332/** REVIDR_EL1 register - RO. */
333#define ARMV8_AARCH64_SYSREG_REVIDR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 0, 6)
334/** ID_PFR0_EL1 register - RO. */
335#define ARMV8_AARCH64_SYSREG_ID_PFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 0)
336/** ID_PFR1_EL1 register - RO. */
337#define ARMV8_AARCH64_SYSREG_ID_PFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 1)
338/** ID_DFR0_EL1 register - RO. */
339#define ARMV8_AARCH64_SYSREG_ID_DFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 2)
340/** ID_AFR0_EL1 register - RO. */
341#define ARMV8_AARCH64_SYSREG_ID_AFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 3)
342/** ID_MMFR0_EL1 register - RO. */
343#define ARMV8_AARCH64_SYSREG_ID_MMFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 4)
344/** ID_MMFR1_EL1 register - RO. */
345#define ARMV8_AARCH64_SYSREG_ID_MMFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 5)
346/** ID_MMFR2_EL1 register - RO. */
347#define ARMV8_AARCH64_SYSREG_ID_MMFR2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 6)
348/** ID_MMFR3_EL1 register - RO. */
349#define ARMV8_AARCH64_SYSREG_ID_MMFR3_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 1, 7)
350
351/** ID_ISAR0_EL1 register - RO. */
352#define ARMV8_AARCH64_SYSREG_ID_ISAR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 0)
353/** ID_ISAR1_EL1 register - RO. */
354#define ARMV8_AARCH64_SYSREG_ID_ISAR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 1)
355/** ID_ISAR2_EL1 register - RO. */
356#define ARMV8_AARCH64_SYSREG_ID_ISAR2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 2)
357/** ID_ISAR3_EL1 register - RO. */
358#define ARMV8_AARCH64_SYSREG_ID_ISAR3_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 3)
359/** ID_ISAR4_EL1 register - RO. */
360#define ARMV8_AARCH64_SYSREG_ID_ISAR4_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 4)
361/** ID_ISAR5_EL1 register - RO. */
362#define ARMV8_AARCH64_SYSREG_ID_ISAR5_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 5)
363/** ID_MMFR4_EL1 register - RO. */
364#define ARMV8_AARCH64_SYSREG_ID_MMFR4_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 6)
365/** ID_ISAR6_EL1 register - RO. */
366#define ARMV8_AARCH64_SYSREG_ID_ISAR6_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 2, 7)
367
368/** MVFR0_EL1 register - RO. */
369#define ARMV8_AARCH64_SYSREG_MVFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 3, 0)
370/** MVFR1_EL1 register - RO. */
371#define ARMV8_AARCH64_SYSREG_MVFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 3, 1)
372/** MVFR2_EL1 register - RO. */
373#define ARMV8_AARCH64_SYSREG_MVFR2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 3, 2)
374/** ID_PFR2_EL1 register - RO. */
375#define ARMV8_AARCH64_SYSREG_ID_PFR2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 3, 4)
376/** ID_DFR1_EL1 register - RO. */
377#define ARMV8_AARCH64_SYSREG_ID_DFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 3, 5)
378/** ID_MMFR5_EL1 register - RO. */
379#define ARMV8_AARCH64_SYSREG_ID_MMFR5_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 3, 6)
380
381/** ID_AA64PFR0_EL1 register - RO. */
382#define ARMV8_AARCH64_SYSREG_ID_AA64PFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 4, 0)
383/** ID_AA64PFR0_EL1 register - RO. */
384#define ARMV8_AARCH64_SYSREG_ID_AA64PFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 4, 1)
385/** ID_AA64ZFR0_EL1 register - RO. */
386#define ARMV8_AARCH64_SYSREG_ID_AA64ZFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 4, 4)
387/** ID_AA64SMFR0_EL1 register - RO. */
388#define ARMV8_AARCH64_SYSREG_ID_AA64SMFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 4, 5)
389
390/** ID_AA64DFR0_EL1 register - RO. */
391#define ARMV8_AARCH64_SYSREG_ID_AA64DFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 5, 0)
392/** ID_AA64DFR0_EL1 register - RO. */
393#define ARMV8_AARCH64_SYSREG_ID_AA64DFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 5, 1)
394/** ID_AA64AFR0_EL1 register - RO. */
395#define ARMV8_AARCH64_SYSREG_ID_AA64AFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 5, 4)
396/** ID_AA64AFR1_EL1 register - RO. */
397#define ARMV8_AARCH64_SYSREG_ID_AA64AFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 5, 5)
398
399/** ID_AA64ISAR0_EL1 register - RO. */
400#define ARMV8_AARCH64_SYSREG_ID_AA64ISAR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 6, 0)
401/** ID_AA64ISAR1_EL1 register - RO. */
402#define ARMV8_AARCH64_SYSREG_ID_AA64ISAR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 6, 1)
403/** ID_AA64ISAR2_EL1 register - RO. */
404#define ARMV8_AARCH64_SYSREG_ID_AA64ISAR2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 6, 2)
405
406/** ID_AA64MMFR0_EL1 register - RO. */
407#define ARMV8_AARCH64_SYSREG_ID_AA64MMFR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 7, 0)
408/** ID_AA64MMFR1_EL1 register - RO. */
409#define ARMV8_AARCH64_SYSREG_ID_AA64MMFR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 7, 1)
410/** ID_AA64MMFR2_EL1 register - RO. */
411#define ARMV8_AARCH64_SYSREG_ID_AA64MMFR2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 0, 7, 2)
412
413/** SCTRL_EL1 register - RW. */
414#define ARMV8_AARCH64_SYSREG_SCTRL_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 0, 0)
415/** ACTRL_EL1 register - RW. */
416#define ARMV8_AARCH64_SYSREG_ACTRL_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 0, 1)
417/** CPACR_EL1 register - RW. */
418#define ARMV8_AARCH64_SYSREG_CPACR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 0, 2)
419/** RGSR_EL1 register - RW. */
420#define ARMV8_AARCH64_SYSREG_RGSR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 0, 5)
421/** GCR_EL1 register - RW. */
422#define ARMV8_AARCH64_SYSREG_GCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 0, 6)
423
424/** ZCR_EL1 register - RW. */
425#define ARMV8_AARCH64_SYSREG_ZCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 2, 0)
426/** TRFCR_EL1 register - RW. */
427#define ARMV8_AARCH64_SYSREG_TRFCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 2, 1)
428/** SMPRI_EL1 register - RW. */
429#define ARMV8_AARCH64_SYSREG_SMPRI_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 2, 4)
430/** SMCR_EL1 register - RW. */
431#define ARMV8_AARCH64_SYSREG_SMCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 1, 2, 6)
432
433/** TTBR0_EL1 register - RW. */
434#define ARMV8_AARCH64_SYSREG_TTBR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 0, 0)
435/** TTBR1_EL1 register - RW. */
436#define ARMV8_AARCH64_SYSREG_TTBR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 0, 1)
437/** TCR_EL1 register - RW. */
438#define ARMV8_AARCH64_SYSREG_TCR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 0, 2)
439
440/** APIAKeyLo_EL1 register - RW. */
441#define ARMV8_AARCH64_SYSREG_APIAKeyLo_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 1, 0)
442/** APIAKeyHi_EL1 register - RW. */
443#define ARMV8_AARCH64_SYSREG_APIAKeyHi_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 1, 1)
444/** APIBKeyLo_EL1 register - RW. */
445#define ARMV8_AARCH64_SYSREG_APIBKeyLo_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 1, 2)
446/** APIBKeyHi_EL1 register - RW. */
447#define ARMV8_AARCH64_SYSREG_APIBKeyHi_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 1, 3)
448
449/** APDAKeyLo_EL1 register - RW. */
450#define ARMV8_AARCH64_SYSREG_APDAKeyLo_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 2, 0)
451/** APDAKeyHi_EL1 register - RW. */
452#define ARMV8_AARCH64_SYSREG_APDAKeyHi_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 2, 1)
453/** APDBKeyLo_EL1 register - RW. */
454#define ARMV8_AARCH64_SYSREG_APDBKeyLo_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 2, 2)
455/** APDBKeyHi_EL1 register - RW. */
456#define ARMV8_AARCH64_SYSREG_APDBKeyHi_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 2, 3)
457
458/** APGAKeyLo_EL1 register - RW. */
459#define ARMV8_AARCH64_SYSREG_APGAKeyLo_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 3, 0)
460/** APGAKeyHi_EL1 register - RW. */
461#define ARMV8_AARCH64_SYSREG_APGAKeyHi_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 2, 3, 1)
462
463/** SPSR_EL1 register - RW. */
464#define ARMV8_AARCH64_SYSREG_SPSR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 0, 0)
465/** ELR_EL1 register - RW. */
466#define ARMV8_AARCH64_SYSREG_ELR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 0, 1)
467
468/** SP_EL0 register - RW. */
469#define ARMV8_AARCH64_SYSREG_SP_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 1, 0)
470
471/** PSTATE.SPSel value. */
472#define ARMV8_AARCH64_SYSREG_SPSEL ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 2, 0)
473/** PSTATE.CurrentEL value. */
474#define ARMV8_AARCH64_SYSREG_CURRENTEL ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 2, 2)
475/** PSTATE.PAN value. */
476#define ARMV8_AARCH64_SYSREG_PAN ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 2, 3)
477/** PSTATE.UAO value. */
478#define ARMV8_AARCH64_SYSREG_UAO ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 2, 4)
479
480/** PSTATE.ALLINT value. */
481#define ARMV8_AARCH64_SYSREG_ALLINT ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 3, 0)
482
483/** ICC_PMR_EL1 register - RW. */
484#define ARMV8_AARCH64_SYSREG_ICC_PMR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 4, 6, 0)
485
486/** AFSR0_EL1 register - RW. */
487#define ARMV8_AARCH64_SYSREG_AFSR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 5, 1, 0)
488/** AFSR1_EL1 register - RW. */
489#define ARMV8_AARCH64_SYSREG_AFSR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 5, 1, 1)
490
491/** ESR_EL1 register - RW. */
492#define ARMV8_AARCH64_SYSREG_ESR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 5, 2, 0)
493
494/** ERRIDR_EL1 register - RO. */
495#define ARMV8_AARCH64_SYSREG_ERRIDR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 5, 3, 0)
496/** ERRSELR_EL1 register - RW. */
497#define ARMV8_AARCH64_SYSREG_ERRSELR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 5, 3, 1)
498
499/** FAR_EL1 register - RW. */
500#define ARMV8_AARCH64_SYSREG_FAR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 6, 0, 0)
501
502/** PAR_EL1 register - RW. */
503#define ARMV8_AARCH64_SYSREG_PAR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 7, 4, 0)
504
505/** MAIR_EL1 register - RW. */
506#define ARMV8_AARCH64_SYSREG_MAIR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 10, 2, 0)
507
508/** AMAIR_EL1 register - RW. */
509#define ARMV8_AARCH64_SYSREG_AMAIR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 10, 3, 0)
510
511/** VBAR_EL1 register - RW. */
512#define ARMV8_AARCH64_SYSREG_VBAR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 0, 0)
513
514/** ICC_IAR0_EL1 register - RO. */
515#define ARMV8_AARCH64_SYSREG_ICC_IAR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 0)
516/** ICC_EOIR0_EL1 register - WO. */
517#define ARMV8_AARCH64_SYSREG_ICC_EOIR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 1)
518/** ICC_HPPIR0_EL1 register - WO. */
519#define ARMV8_AARCH64_SYSREG_ICC_HPPIR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 2)
520/** ICC_BPR0_EL1 register - RW. */
521#define ARMV8_AARCH64_SYSREG_ICC_BPR0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 3)
522/** ICC_AP0R0_EL1 register - RW. */
523#define ARMV8_AARCH64_SYSREG_ICC_AP0R0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 4)
524/** ICC_AP0R1_EL1 register - RW. */
525#define ARMV8_AARCH64_SYSREG_ICC_AP0R1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 5)
526/** ICC_AP0R2_EL1 register - RW. */
527#define ARMV8_AARCH64_SYSREG_ICC_AP0R2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 6)
528/** ICC_AP0R3_EL1 register - RW. */
529#define ARMV8_AARCH64_SYSREG_ICC_AP0R3_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 8, 7)
530
531/** ICC_AP1R0_EL1 register - RW. */
532#define ARMV8_AARCH64_SYSREG_ICC_AP1R0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 9, 0)
533/** ICC_AP1R1_EL1 register - RW. */
534#define ARMV8_AARCH64_SYSREG_ICC_AP1R1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 9, 1)
535/** ICC_AP1R2_EL1 register - RW. */
536#define ARMV8_AARCH64_SYSREG_ICC_AP1R2_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 9, 2)
537/** ICC_AP1R3_EL1 register - RW. */
538#define ARMV8_AARCH64_SYSREG_ICC_AP1R3_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 9, 3)
539/** ICC_NMIAR1_EL1 register - RO. */
540#define ARMV8_AARCH64_SYSREG_ICC_NMIAR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 9, 5)
541
542/** ICC_DIR_EL1 register - WO. */
543#define ARMV8_AARCH64_SYSREG_ICC_DIR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 11, 1)
544/** ICC_RPR_EL1 register - RO. */
545#define ARMV8_AARCH64_SYSREG_ICC_RPR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 11, 3)
546/** ICC_SGI1R_EL1 register - WO. */
547#define ARMV8_AARCH64_SYSREG_ICC_SGI1R_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 11, 5)
548/** ICC_ASGI1R_EL1 register - WO. */
549#define ARMV8_AARCH64_SYSREG_ICC_ASGI1R_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 11, 6)
550/** ICC_SGI0R_EL1 register - WO. */
551#define ARMV8_AARCH64_SYSREG_ICC_SGI0R_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 11, 7)
552
553/** ICC_IAR1_EL1 register - RO. */
554#define ARMV8_AARCH64_SYSREG_ICC_IAR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 0)
555/** ICC_EOIR1_EL1 register - WO. */
556#define ARMV8_AARCH64_SYSREG_ICC_EOIR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 1)
557/** ICC_HPPIR1_EL1 register - RO. */
558#define ARMV8_AARCH64_SYSREG_ICC_HPPIR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 2)
559/** ICC_BPR1_EL1 register - RW. */
560#define ARMV8_AARCH64_SYSREG_ICC_BPR1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 3)
561/** ICC_CTLR_EL1 register - RW. */
562#define ARMV8_AARCH64_SYSREG_ICC_CTLR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 4)
563/** ICC_SRE_EL1 register - RW. */
564#define ARMV8_AARCH64_SYSREG_ICC_SRE_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 5)
565/** ICC_IGRPEN0_EL1 register - RW. */
566#define ARMV8_AARCH64_SYSREG_ICC_IGRPEN0_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 6)
567/** ICC_IGRPEN1_EL1 register - RW. */
568#define ARMV8_AARCH64_SYSREG_ICC_IGRPEN1_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 12, 12, 7)
569
570/** CONTEXTIDR_EL1 register - RW. */
571#define ARMV8_AARCH64_SYSREG_CONTEXTIDR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 13, 0, 1)
572/** TPIDR_EL1 register - RW. */
573#define ARMV8_AARCH64_SYSREG_TPIDR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 13, 0, 4)
574
575/** CNTKCTL_EL1 register - RW. */
576#define ARMV8_AARCH64_SYSREG_CNTKCTL_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 0, 14, 1, 0)
577
578/** CSSELR_EL1 register - RW. */
579#define ARMV8_AARCH64_SYSREG_CSSELR_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 2, 0, 0, 0)
580
581/** NZCV - Status Flags - ??. */
582#define ARMV8_AARCH64_SYSREG_NZCV ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 2, 0)
583/** DAIF - Interrupt Mask Bits - ??. */
584#define ARMV8_AARCH64_SYSREG_DAIF ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 2, 1)
585/** SVCR - Streaming Vector Control Register - ??. */
586#define ARMV8_AARCH64_SYSREG_SVCR ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 2, 2)
587/** DIT - Data Independent Timing - ??. */
588#define ARMV8_AARCH64_SYSREG_DIT ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 2, 5)
589/** SSBS - Speculative Store Bypass Safe - ??. */
590#define ARMV8_AARCH64_SYSREG_SSBS ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 2, 6)
591/** TCO - Tag Check Override - ??. */
592#define ARMV8_AARCH64_SYSREG_TCO ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 2, 7)
593
594/** FPCR register - RW. */
595#define ARMV8_AARCH64_SYSREG_FPCR ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 4, 0)
596/** FPSR register - RW. */
597#define ARMV8_AARCH64_SYSREG_FPSR ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 4, 4, 1)
598
599/** ICC_SRE_EL2 register - RW. */
600#define ARMV8_AARCH64_SYSREG_ICC_SRE_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 12, 9, 5)
601
602/** TPIDR_EL0 register - RW. */
603#define ARMV8_AARCH64_SYSREG_TPIDR_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 13, 0, 2)
604/** TPIDRRO_EL0 register - RO. */
605#define ARMV8_AARCH64_SYSREG_TPIDRRO_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 13, 0, 3)
606
607/** CNTFRQ_EL0 register - RW. */
608#define ARMV8_AARCH64_SYSREG_CNTFRQ_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 14, 0, 0)
609/** CNTVCT_EL0 register - RW. */
610#define ARMV8_AARCH64_SYSREG_CNTVCT_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 14, 0, 2)
611
612/** CNTP_TVAL_EL0 register - RW. */
613#define ARMV8_AARCH64_SYSREG_CNTP_TVAL_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 14, 2, 0)
614/** CNTP_CTL_EL0 register - RW. */
615#define ARMV8_AARCH64_SYSREG_CNTP_CTL_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 14, 2, 1)
616/** CNTP_CVAL_EL0 register - RW. */
617#define ARMV8_AARCH64_SYSREG_CNTP_CVAL_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 14, 2, 2)
618
619/** CNTV_CTL_EL0 register - RW. */
620#define ARMV8_AARCH64_SYSREG_CNTV_CTL_EL0 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 3, 14, 3, 1)
621
622/** VPIDR_EL2 register - RW. */
623#define ARMV8_AARCH64_SYSREG_VPIDR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 0, 0, 0)
624/** VMPIDR_EL2 register - RW. */
625#define ARMV8_AARCH64_SYSREG_VMPIDR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 0, 0, 5)
626
627/** SCTLR_EL2 register - RW. */
628#define ARMV8_AARCH64_SYSREG_SCTLR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 0, 0)
629/** ACTLR_EL2 register - RW. */
630#define ARMV8_AARCH64_SYSREG_ACTLR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 0, 1)
631
632/** HCR_EL2 register - RW. */
633#define ARMV8_AARCH64_SYSREG_HCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 0)
634/** MDCR_EL2 register - RW. */
635#define ARMV8_AARCH64_SYSREG_MDCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 1)
636/** CPTR_EL2 register - RW. */
637#define ARMV8_AARCH64_SYSREG_CPTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 2)
638/** HSTR_EL2 register - RW. */
639#define ARMV8_AARCH64_SYSREG_HSTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 3)
640/** HFGRTR_EL2 register - RW. */
641#define ARMV8_AARCH64_SYSREG_HFGRTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 4)
642/** HFGWTR_EL2 register - RW. */
643#define ARMV8_AARCH64_SYSREG_HFGWTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 5)
644/** HFGITR_EL2 register - RW. */
645#define ARMV8_AARCH64_SYSREG_HFGITR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 6)
646/** HACR_EL2 register - RW. */
647#define ARMV8_AARCH64_SYSREG_HACR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 1, 7)
648
649/** ZCR_EL2 register - RW. */
650#define ARMV8_AARCH64_SYSREG_ZCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 2, 0)
651/** TRFCR_EL2 register - RW. */
652#define ARMV8_AARCH64_SYSREG_TRFCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 2, 1)
653/** HCRX_EL2 register - RW. */
654#define ARMV8_AARCH64_SYSREG_HCRX_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 2, 2)
655
656/** SDER32_EL2 register - RW. */
657#define ARMV8_AARCH64_SYSREG_SDER32_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 1, 3, 0)
658
659/** TTBR0_EL2 register - RW. */
660#define ARMV8_AARCH64_SYSREG_TTBR0_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 0, 0)
661/** TTBR1_EL2 register - RW. */
662#define ARMV8_AARCH64_SYSREG_TTBR1_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 0, 1)
663/** TCR_EL2 register - RW. */
664#define ARMV8_AARCH64_SYSREG_TCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 0, 2)
665
666/** VTTBR_EL2 register - RW. */
667#define ARMV8_AARCH64_SYSREG_VTTBR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 1, 0)
668/** VTCR_EL2 register - RW. */
669#define ARMV8_AARCH64_SYSREG_VTCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 1, 2)
670
671/** VNCR_EL2 register - RW. */
672#define ARMV8_AARCH64_SYSREG_VNCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 2, 0)
673
674/** VSTTBR_EL2 register - RW. */
675#define ARMV8_AARCH64_SYSREG_VSTTBR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 6, 0)
676/** VSTCR_EL2 register - RW. */
677#define ARMV8_AARCH64_SYSREG_VSTCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 2, 6, 2)
678
679/** DACR32_EL2 register - RW. */
680#define ARMV8_AARCH64_SYSREG_DACR32_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 3, 0, 0)
681
682/** HDFGRTR_EL2 register - RW. */
683#define ARMV8_AARCH64_SYSREG_HDFGRTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 3, 1, 4)
684/** HDFGWTR_EL2 register - RW. */
685#define ARMV8_AARCH64_SYSREG_HDFGWTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 3, 1, 5)
686/** HAFGRTR_EL2 register - RW. */
687#define ARMV8_AARCH64_SYSREG_HAFGRTR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 3, 1, 6)
688
689/** SPSR_EL2 register - RW. */
690#define ARMV8_AARCH64_SYSREG_SPSR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 4, 0, 0)
691/** ELR_EL2 register - RW. */
692#define ARMV8_AARCH64_SYSREG_ELR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 4, 0, 1)
693
694/** SP_EL1 register - RW. */
695#define ARMV8_AARCH64_SYSREG_SP_EL1 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 4, 1, 0)
696
697/** IFSR32_EL2 register - RW. */
698#define ARMV8_AARCH64_SYSREG_IFSR32_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 0, 1)
699
700/** AFSR0_EL2 register - RW. */
701#define ARMV8_AARCH64_SYSREG_AFSR0_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 1, 0)
702/** AFSR1_EL2 register - RW. */
703#define ARMV8_AARCH64_SYSREG_AFSR1_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 1, 1)
704
705/** ESR_EL2 register - RW. */
706#define ARMV8_AARCH64_SYSREG_ESR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 2, 0)
707/** VSESR_EL2 register - RW. */
708#define ARMV8_AARCH64_SYSREG_VSESR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 2, 3)
709
710/** FPEXC32_EL2 register - RW. */
711#define ARMV8_AARCH64_SYSREG_FPEXC32_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 3, 0)
712
713/** TFSR_EL2 register - RW. */
714#define ARMV8_AARCH64_SYSREG_TFSR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 5, 6, 0)
715
716/** FAR_EL2 register - RW. */
717#define ARMV8_AARCH64_SYSREG_FAR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 6, 0, 0)
718/** HPFAR_EL2 register - RW. */
719#define ARMV8_AARCH64_SYSREG_HPFAR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 6, 0, 4)
720
721/** PMSCR_EL2 register - RW. */
722#define ARMV8_AARCH64_SYSREG_PMSCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 9, 9, 0)
723
724/** MAIR_EL2 register - RW. */
725#define ARMV8_AARCH64_SYSREG_MAIR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 2, 0)
726
727/** AMAIR_EL2 register - RW. */
728#define ARMV8_AARCH64_SYSREG_AMAIR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 3, 0)
729
730/** MPAMHCR_EL2 register - RW. */
731#define ARMV8_AARCH64_SYSREG_MPAMHCR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 4, 0)
732/** MPAMVPMV_EL2 register - RW. */
733#define ARMV8_AARCH64_SYSREG_MPAMVPMV_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 4, 1)
734
735/** MPAM2_EL2 register - RW. */
736#define ARMV8_AARCH64_SYSREG_MPAM2_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 5, 0)
737
738/** MPAMVPM0_EL2 register - RW. */
739#define ARMV8_AARCH64_SYSREG_MPAMVPM0_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 0)
740/** MPAMVPM1_EL2 register - RW. */
741#define ARMV8_AARCH64_SYSREG_MPAMVPM1_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 1)
742/** MPAMVPM2_EL2 register - RW. */
743#define ARMV8_AARCH64_SYSREG_MPAMVPM2_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 2)
744/** MPAMVPM3_EL2 register - RW. */
745#define ARMV8_AARCH64_SYSREG_MPAMVPM3_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 3)
746/** MPAMVPM4_EL2 register - RW. */
747#define ARMV8_AARCH64_SYSREG_MPAMVPM4_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 4)
748/** MPAMVPM5_EL2 register - RW. */
749#define ARMV8_AARCH64_SYSREG_MPAMVPM5_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 5)
750/** MPAMVPM6_EL2 register - RW. */
751#define ARMV8_AARCH64_SYSREG_MPAMVPM6_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 6)
752/** MPAMVPM7_EL2 register - RW. */
753#define ARMV8_AARCH64_SYSREG_MPAMVPM7_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 10, 6, 7)
754
755/** VBAR_EL2 register - RW. */
756#define ARMV8_AARCH64_SYSREG_VBAR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 12, 0, 0)
757/** RVBAR_EL2 register - RW. */
758#define ARMV8_AARCH64_SYSREG_RVBAR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 12, 0, 1)
759/** RMR_EL2 register - RW. */
760#define ARMV8_AARCH64_SYSREG_RMR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 12, 0, 2)
761
762/** VDISR_EL2 register - RW. */
763#define ARMV8_AARCH64_SYSREG_VDISR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 12, 1, 1)
764
765/** CONTEXTIDR_EL2 register - RW. */
766#define ARMV8_AARCH64_SYSREG_CONTEXTIDR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 13, 0, 1)
767/** TPIDR_EL2 register - RW. */
768#define ARMV8_AARCH64_SYSREG_TPIDR_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 13, 0, 2)
769/** SCXTNUM_EL2 register - RW. */
770#define ARMV8_AARCH64_SYSREG_SCXTNUM_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 13, 0, 7)
771
772/** CNTVOFF_EL2 register - RW. */
773#define ARMV8_AARCH64_SYSREG_CNTVOFF_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 0, 3)
774/** CNTPOFF_EL2 register - RW. */
775#define ARMV8_AARCH64_SYSREG_CNTPOFF_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 0, 6)
776
777/** CNTHCTL_EL2 register - RW. */
778#define ARMV8_AARCH64_SYSREG_CNTHCTL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 1, 0)
779
780/** CNTHP_TVAL_EL2 register - RW. */
781#define ARMV8_AARCH64_SYSREG_CNTHP_TVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 2, 0)
782/** CNTHP_CTL_EL2 register - RW. */
783#define ARMV8_AARCH64_SYSREG_CNTHP_CTL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 2, 1)
784/** CNTHP_CVAL_EL2 register - RW. */
785#define ARMV8_AARCH64_SYSREG_CNTHP_CVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 2, 2)
786
787/** CNTHV_TVAL_EL2 register - RW. */
788#define ARMV8_AARCH64_SYSREG_CNTHV_TVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 3, 0)
789/** CNTHV_CTL_EL2 register - RW. */
790#define ARMV8_AARCH64_SYSREG_CNTHV_CTL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 3, 1)
791/** CNTHV_CVAL_EL2 register - RW. */
792#define ARMV8_AARCH64_SYSREG_CNTHV_CVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 3, 2)
793
794/** CNTHVS_TVAL_EL2 register - RW. */
795#define ARMV8_AARCH64_SYSREG_CNTHVS_TVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 4, 0)
796/** CNTHVS_CTL_EL2 register - RW. */
797#define ARMV8_AARCH64_SYSREG_CNTHVS_CTL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 4, 1)
798/** CNTHVS_CVAL_EL2 register - RW. */
799#define ARMV8_AARCH64_SYSREG_CNTHVS_CVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 4, 2)
800
801/** CNTHPS_TVAL_EL2 register - RW. */
802#define ARMV8_AARCH64_SYSREG_CNTHPS_TVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 5, 0)
803/** CNTHPS_CTL_EL2 register - RW. */
804#define ARMV8_AARCH64_SYSREG_CNTHPS_CTL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 5, 1)
805/** CNTHPS_CVAL_EL2 register - RW. */
806#define ARMV8_AARCH64_SYSREG_CNTHPS_CVAL_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 4, 14, 5, 2)
807
808/** SP_EL2 register - RW. */
809#define ARMV8_AARCH64_SYSREG_SP_EL2 ARMV8_AARCH64_SYSREG_ID_CREATE(3, 6, 4, 1, 0)
810/** @} */
811
812
813#ifndef RT_IN_ASSEMBLER
814/**
815 * SPSR_EL2 (according to chapter C5.2.19)
816 */
817typedef union ARMV8SPSREL2
818{
819 /** The plain unsigned view. */
820 uint64_t u;
821 /** The 8-bit view. */
822 uint8_t au8[8];
823 /** The 16-bit view. */
824 uint16_t au16[4];
825 /** The 32-bit view. */
826 uint32_t au32[2];
827 /** The 64-bit view. */
828 uint64_t u64;
829} ARMV8SPSREL2;
830/** Pointer to SPSR_EL2. */
831typedef ARMV8SPSREL2 *PARMV8SPSREL2;
832/** Pointer to const SPSR_EL2. */
833typedef const ARMV8SPSREL2 *PCXARMV8SPSREL2;
834#endif /* !RT_IN_ASSEMBLER */
835
836
837/** @name SPSR_EL2 (When exception is taken from AArch64 state)
838 * @{
839 */
840/** Bit 0 - 3 - M - AArch64 Exception level and selected stack pointer. */
841#define ARMV8_SPSR_EL2_AARCH64_M (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
842#define ARMV8_SPSR_EL2_AARCH64_GET_M(a_Spsr) ((a_Spsr) & ARMV8_SPSR_EL2_AARCH64_M)
843/** Bit 0 - SP - Selected stack pointer. */
844#define ARMV8_SPSR_EL2_AARCH64_SP RT_BIT_64(0)
845#define ARMV8_SPSR_EL2_AARCH64_SP_BIT 0
846/** Bit 1 - Reserved (read as zero). */
847#define ARMV8_SPSR_EL2_AARCH64_RSVD_1 RT_BIT_64(1)
848/** Bit 2 - 3 - EL - Exception level. */
849#define ARMV8_SPSR_EL2_AARCH64_EL (RT_BIT_64(2) | RT_BIT_64(3))
850#define ARMV8_SPSR_EL2_AARCH64_EL_SHIFT 2
851#define ARMV8_SPSR_EL2_AARCH64_GET_EL(a_Spsr) (((a_Spsr) >> ARMV8_SPSR_EL2_AARCH64_EL_SHIFT) & 3)
852#define ARMV8_SPSR_EL2_AARCH64_SET_EL(a_El) ((a_El) << ARMV8_SPSR_EL2_AARCH64_EL_SHIFT)
853/** Bit 4 - M[4] - Execution state (0 means AArch64, when 1 this contains a AArch32 state). */
854#define ARMV8_SPSR_EL2_AARCH64_M4 RT_BIT_64(4)
855#define ARMV8_SPSR_EL2_AARCH64_M4_BIT 4
856/** Bit 5 - T - T32 instruction set state (only valid when ARMV8_SPSR_EL2_AARCH64_M4 is set). */
857#define ARMV8_SPSR_EL2_AARCH64_T RT_BIT_64(5)
858#define ARMV8_SPSR_EL2_AARCH64_T_BIT 5
859/** Bit 6 - I - FIQ interrupt mask. */
860#define ARMV8_SPSR_EL2_AARCH64_F RT_BIT_64(6)
861#define ARMV8_SPSR_EL2_AARCH64_F_BIT 6
862/** Bit 7 - I - IRQ interrupt mask. */
863#define ARMV8_SPSR_EL2_AARCH64_I RT_BIT_64(7)
864#define ARMV8_SPSR_EL2_AARCH64_I_BIT 7
865/** Bit 8 - A - SError interrupt mask. */
866#define ARMV8_SPSR_EL2_AARCH64_A RT_BIT_64(8)
867#define ARMV8_SPSR_EL2_AARCH64_A_BIT 8
868/** Bit 9 - D - Debug Exception mask. */
869#define ARMV8_SPSR_EL2_AARCH64_D RT_BIT_64(9)
870#define ARMV8_SPSR_EL2_AARCH64_D_BIT 9
871/** Bit 10 - 11 - BTYPE - Branch Type indicator. */
872#define ARMV8_SPSR_EL2_AARCH64_BYTPE (RT_BIT_64(10) | RT_BIT_64(11))
873#define ARMV8_SPSR_EL2_AARCH64_BYTPE_SHIFT 10
874#define ARMV8_SPSR_EL2_AARCH64_GET_BYTPE(a_Spsr) (((a_Spsr) >> ARMV8_SPSR_EL2_AARCH64_BYTPE_SHIFT) & 3)
875/** Bit 12 - SSBS - Speculative Store Bypass. */
876#define ARMV8_SPSR_EL2_AARCH64_SSBS RT_BIT_64(12)
877#define ARMV8_SPSR_EL2_AARCH64_SSBS_BIT 12
878/** Bit 13 - ALLINT - All IRQ or FIQ interrupts mask. */
879#define ARMV8_SPSR_EL2_AARCH64_ALLINT RT_BIT_64(13)
880#define ARMV8_SPSR_EL2_AARCH64_ALLINT_BIT 13
881/** Bit 14 - 19 - Reserved (read as zero). */
882#define ARMV8_SPSR_EL2_AARCH64_RSVD_14_19 ( RT_BIT_64(14) | RT_BIT_64(15) | RT_BIT_64(16) \
883 | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
884/** Bit 20 - IL - Illegal Execution State flag. */
885#define ARMV8_SPSR_EL2_AARCH64_IL RT_BIT_64(20)
886#define ARMV8_SPSR_EL2_AARCH64_IL_BIT 20
887/** Bit 21 - SS - Software Step flag. */
888#define ARMV8_SPSR_EL2_AARCH64_SS RT_BIT_64(21)
889#define ARMV8_SPSR_EL2_AARCH64_SS_BIT 21
890/** Bit 22 - PAN - Privileged Access Never flag. */
891#define ARMV8_SPSR_EL2_AARCH64_PAN RT_BIT_64(25)
892#define ARMV8_SPSR_EL2_AARCH64_PAN_BIT 22
893/** Bit 23 - UAO - User Access Override flag. */
894#define ARMV8_SPSR_EL2_AARCH64_UAO RT_BIT_64(23)
895#define ARMV8_SPSR_EL2_AARCH64_UAO_BIT 23
896/** Bit 24 - DIT - Data Independent Timing flag. */
897#define ARMV8_SPSR_EL2_AARCH64_DIT RT_BIT_64(24)
898#define ARMV8_SPSR_EL2_AARCH64_DIT_BIT 24
899/** Bit 25 - TCO - Tag Check Override flag. */
900#define ARMV8_SPSR_EL2_AARCH64_TCO RT_BIT_64(25)
901#define ARMV8_SPSR_EL2_AARCH64_TCO_BIT 25
902/** Bit 26 - 27 - Reserved (read as zero). */
903#define ARMV8_SPSR_EL2_AARCH64_RSVD_26_27 (RT_BIT_64(26) | RT_BIT_64(27))
904/** Bit 28 - V - Overflow condition flag. */
905#define ARMV8_SPSR_EL2_AARCH64_V RT_BIT_64(28)
906#define ARMV8_SPSR_EL2_AARCH64_V_BIT 28
907/** Bit 29 - C - Carry condition flag. */
908#define ARMV8_SPSR_EL2_AARCH64_C RT_BIT_64(29)
909#define ARMV8_SPSR_EL2_AARCH64_C_BIT 29
910/** Bit 30 - Z - Zero condition flag. */
911#define ARMV8_SPSR_EL2_AARCH64_Z RT_BIT_64(30)
912#define ARMV8_SPSR_EL2_AARCH64_Z_BIT 30
913/** Bit 31 - N - Negative condition flag. */
914#define ARMV8_SPSR_EL2_AARCH64_N RT_BIT_64(31)
915#define ARMV8_SPSR_EL2_AARCH64_N_BIT 31
916/** Bit 32 - 63 - Reserved (read as zero). */
917#define ARMV8_SPSR_EL2_AARCH64_RSVD_32_63 (UINT64_C(0xffffffff00000000))
918/** Checks whether the given SPSR value contains a AARCH64 execution state. */
919#define ARMV8_SPSR_EL2_IS_AARCH64_STATE(a_Spsr) (!((a_Spsr) & ARMV8_SPSR_EL2_AARCH64_M4))
920/** @} */
921
922/** @name Aarch64 Exception levels
923 * @{ */
924/** Exception Level 0 - User mode. */
925#define ARMV8_AARCH64_EL_0 0
926/** Exception Level 1 - Supervisor mode. */
927#define ARMV8_AARCH64_EL_1 1
928/** Exception Level 2 - Hypervisor mode. */
929#define ARMV8_AARCH64_EL_2 2
930/** @} */
931
932
933/** @name ESR_EL2 (Exception Syndrome Register, EL2)
934 * @{
935 */
936/** Bit 0 - 24 - ISS - Instruction Specific Syndrome, encoding depends on the exception class. */
937#define ARMV8_ESR_EL2_ISS UINT64_C(0x1ffffff)
938#define ARMV8_ESR_EL2_ISS_GET(a_Esr) ((a_Esr) & ARMV8_ESR_EL2_ISS)
939/** Bit 25 - IL - Instruction length for synchronous exception (0 means 16-bit instruction, 1 32-bit instruction). */
940#define ARMV8_ESR_EL2_IL RT_BIT_64(25)
941#define ARMV8_ESR_EL2_IL_BIT 25
942#define ARMV8_ESR_EL2_IL_IS_32BIT(a_Esr) RT_BOOL((a_Esr) & ARMV8_ESR_EL2_IL)
943#define ARMV8_ESR_EL2_IL_IS_16BIT(a_Esr) (!((a_Esr) & ARMV8_ESR_EL2_IL))
944/** Bit 26 - 31 - EC - Exception class, indicates reason for the exception that this register holds information about. */
945#define ARMV8_ESR_EL2_EC ( RT_BIT_64(26) | RT_BIT_64(27) | RT_BIT_64(28) \
946 | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
947#define ARMV8_ESR_EL2_EC_GET(a_Esr) (((a_Esr) & ARMV8_ESR_EL2_EC) >> 26)
948/** Bit 32 - 36 - ISS2 - Only valid when FEAT_LS64_V and/or FEAT_LS64_ACCDATA is present. */
949#define ARMV8_ESR_EL2_ISS2 ( RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) \
950 | RT_BIT_64(35) | RT_BIT_64(36))
951#define ARMV8_ESR_EL2_ISS2_GET(a_Esr) (((a_Esr) & ARMV8_ESR_EL2_ISS2) >> 32)
952/** @} */
953
954
955/** @name ESR_EL2 Exception Classes (EC)
956 * @{ */
957/** Unknown exception reason. */
958#define ARMV8_ESR_EL2_EC_UNKNOWN UINT32_C(0)
959/** Trapped WF* instruction. */
960#define ARMV8_ESR_EL2_EC_TRAPPED_WFX UINT32_C(1)
961/** AArch32 - Trapped MCR or MRC access (coproc == 0b1111) not reported through ARMV8_ESR_EL2_EC_UNKNOWN. */
962#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_MCR_MRC_COPROC_15 UINT32_C(3)
963/** AArch32 - Trapped MCRR or MRRC access (coproc == 0b1111) not reported through ARMV8_ESR_EL2_EC_UNKNOWN. */
964#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_MCRR_MRRC_COPROC15 UINT32_C(4)
965/** AArch32 - Trapped MCR or MRC access (coproc == 0b1110). */
966#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_MCR_MRC_COPROC_14 UINT32_C(5)
967/** AArch32 - Trapped LDC or STC access. */
968#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_LDC_STC UINT32_C(6)
969/** AArch32 - Trapped access to SME, SVE or Advanced SIMD or floating point fnunctionality. */
970#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_SME_SVE_NEON UINT32_C(7)
971/** AArch32 - Trapped VMRS access not reported using ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_SME_SVE_NEON. */
972#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_VMRS UINT32_C(8)
973/** AArch32 - Trapped pointer authentication instruction. */
974#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_PA_INSN UINT32_C(9)
975/** FEAT_LS64 - Exception from LD64B or ST64B instruction. */
976#define ARMV8_ESR_EL2_EC_LS64_EXCEPTION UINT32_C(10)
977/** AArch32 - Trapped MRRC access (coproc == 0b1110). */
978#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_MRRC_COPROC14 UINT32_C(12)
979/** FEAT_BTI - Branch Target Exception. */
980#define ARMV8_ESR_EL2_EC_BTI_BRANCH_TARGET_EXCEPTION UINT32_C(13)
981/** Illegal Execution State. */
982#define ARMV8_ESR_EL2_ILLEGAL_EXECUTION_STATE UINT32_C(14)
983/** AArch32 - SVC instruction execution. */
984#define ARMV8_ESR_EL2_EC_AARCH32_SVC_INSN UINT32_C(17)
985/** AArch32 - HVC instruction execution. */
986#define ARMV8_ESR_EL2_EC_AARCH32_HVC_INSN UINT32_C(18)
987/** AArch32 - SMC instruction execution. */
988#define ARMV8_ESR_EL2_EC_AARCH32_SMC_INSN UINT32_C(19)
989/** AArch64 - SVC instruction execution. */
990#define ARMV8_ESR_EL2_EC_AARCH64_SVC_INSN UINT32_C(21)
991/** AArch64 - HVC instruction execution. */
992#define ARMV8_ESR_EL2_EC_AARCH64_HVC_INSN UINT32_C(22)
993/** AArch64 - SMC instruction execution. */
994#define ARMV8_ESR_EL2_EC_AARCH64_SMC_INSN UINT32_C(23)
995/** AArch64 - Trapped MSR, MRS or System instruction execution in AArch64 state. */
996#define ARMV8_ESR_EL2_EC_AARCH64_TRAPPED_SYS_INSN UINT32_C(24)
997/** FEAT_SVE - Access to SVE vunctionality not reported using ARMV8_ESR_EL2_EC_UNKNOWN. */
998#define ARMV8_ESR_EL2_EC_SVE_TRAPPED UINT32_C(25)
999/** FEAT_PAuth and FEAT_NV - Trapped ERET, ERETAA or ERTAB instruction. */
1000#define ARMV8_ESR_EL2_EC_PAUTH_NV_TRAPPED_ERET_ERETAA_ERETAB UINT32_C(26)
1001/** FEAT_TME - Exception from TSTART instruction. */
1002#define ARMV8_ESR_EL2_EC_TME_TSTART_INSN_EXCEPTION UINT32_C(27)
1003/** FEAT_FPAC - Exception from a Pointer Authentication instruction failure. */
1004#define ARMV8_ESR_EL2_EC_FPAC_PA_INSN_FAILURE_EXCEPTION UINT32_C(28)
1005/** FEAT_SME - Access to SME functionality trapped. */
1006#define ARMV8_ESR_EL2_EC_SME_TRAPPED_SME_ACCESS UINT32_C(29)
1007/** FEAT_RME - Exception from Granule Protection Check. */
1008#define ARMV8_ESR_EL2_EC_RME_GRANULE_PROT_CHECK_EXCEPTION UINT32_C(30)
1009/** Instruction Abort from a lower Exception level. */
1010#define ARMV8_ESR_EL2_INSN_ABORT_FROM_LOWER_EL UINT32_C(32)
1011/** Instruction Abort from the same Exception level. */
1012#define ARMV8_ESR_EL2_INSN_ABORT_FROM_EL2 UINT32_C(33)
1013/** PC alignment fault exception. */
1014#define ARMV8_ESR_EL2_PC_ALIGNMENT_EXCEPTION UINT32_C(34)
1015/** Data Abort from a lower Exception level. */
1016#define ARMV8_ESR_EL2_DATA_ABORT_FROM_LOWER_EL UINT32_C(36)
1017/** Data Abort from the same Exception level (or access associated with VNCR_EL2). */
1018#define ARMV8_ESR_EL2_DATA_ABORT_FROM_EL2 UINT32_C(37)
1019/** SP alignment fault exception. */
1020#define ARMV8_ESR_EL2_SP_ALIGNMENT_EXCEPTION UINT32_C(38)
1021/** FEAT_MOPS - Memory Operation Exception. */
1022#define ARMV8_ESR_EL2_EC_MOPS_EXCEPTION UINT32_C(39)
1023/** AArch32 - Trapped floating point exception. */
1024#define ARMV8_ESR_EL2_EC_AARCH32_TRAPPED_FP_EXCEPTION UINT32_C(40)
1025/** AArch64 - Trapped floating point exception. */
1026#define ARMV8_ESR_EL2_EC_AARCH64_TRAPPED_FP_EXCEPTION UINT32_C(44)
1027/** SError interrupt. */
1028#define ARMV8_ESR_EL2_SERROR_INTERRUPT UINT32_C(47)
1029/** Breakpoint Exception from a lower Exception level. */
1030#define ARMV8_ESR_EL2_BKPT_EXCEPTION_FROM_LOWER_EL UINT32_C(48)
1031/** Breakpoint Exception from the same Exception level. */
1032#define ARMV8_ESR_EL2_BKPT_EXCEPTION_FROM_EL2 UINT32_C(49)
1033/** Software Step Exception from a lower Exception level. */
1034#define ARMV8_ESR_EL2_SS_EXCEPTION_FROM_LOWER_EL UINT32_C(50)
1035/** Software Step Exception from the same Exception level. */
1036#define ARMV8_ESR_EL2_SS_EXCEPTION_FROM_EL2 UINT32_C(51)
1037/** Watchpoint Exception from a lower Exception level. */
1038#define ARMV8_ESR_EL2_WATCHPOINT_EXCEPTION_FROM_LOWER_EL UINT32_C(52)
1039/** Watchpoint Exception from the same Exception level. */
1040#define ARMV8_ESR_EL2_WATCHPOINT_EXCEPTION_FROM_EL2 UINT32_C(53)
1041/** AArch32 - BKPT instruction execution. */
1042#define ARMV8_ESR_EL2_EC_AARCH32_BKPT_INSN UINT32_C(56)
1043/** AArch32 - Vector Catch exception. */
1044#define ARMV8_ESR_EL2_EC_AARCH32_VEC_CATCH_EXCEPTION UINT32_C(58)
1045/** AArch64 - BRK instruction execution. */
1046#define ARMV8_ESR_EL2_EC_AARCH64_BRK_INSN UINT32_C(60)
1047/** @} */
1048
1049
1050/** @name ISS encoding for Data Abort exceptions.
1051 * @{ */
1052/** Bit 0 - 5 - DFSC - Data Fault Status Code. */
1053#define ARMV8_EC_ISS_DATA_ABRT_DFSC ( RT_BIT_32(0) | RT_BIT_32(1) | RT_BIT_32(2) \
1054 | RT_BIT_32(3) | RT_BIT_32(4) | RT_BIT_32(5))
1055#define ARMV8_EC_ISS_DATA_ABRT_DFSC_GET(a_Iss) ((a_Iss) & ARMV8_EC_ISS_DATA_ABRT_DFSC)
1056/** Bit 6 - WnR - Write not Read. */
1057#define ARMV8_EC_ISS_DATA_ABRT_WNR RT_BIT_32(6)
1058#define ARMV8_EC_ISS_DATA_ABRT_WNR_BIT 6
1059/** Bit 7 - S1PTW - Stage 2 translation fault for an access made for a stage 1 translation table walk. */
1060#define ARMV8_EC_ISS_DATA_ABRT_S1PTW RT_BIT_32(7)
1061#define ARMV8_EC_ISS_DATA_ABRT_S1PTW_BIT 7
1062/** Bit 8 - CM - Cache maintenance instruction. */
1063#define ARMV8_EC_ISS_DATA_ABRT_CM RT_BIT_32(8)
1064#define ARMV8_EC_ISS_DATA_ABRT_CM_BIT 8
1065/** Bit 9 - EA - External abort type. */
1066#define ARMV8_EC_ISS_DATA_ABRT_EA RT_BIT_32(9)
1067#define ARMV8_EC_ISS_DATA_ABRT_EA_BIT 9
1068/** Bit 10 - FnV - FAR not Valid. */
1069#define ARMV8_EC_ISS_DATA_ABRT_FNV RT_BIT_32(10)
1070#define ARMV8_EC_ISS_DATA_ABRT_FNV_BIT 10
1071/** Bit 11 - 12 - LST - Load/Store Type. */
1072#define ARMV8_EC_ISS_DATA_ABRT_LST (RT_BIT_32(11) | RT_BIT_32(12))
1073#define ARMV8_EC_ISS_DATA_ABRT_LST_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_DATA_ABRT_LST) >> 11)
1074/** Bit 13 - VNCR - Fault came from use of VNCR_EL2 register by EL1 code. */
1075#define ARMV8_EC_ISS_DATA_ABRT_VNCR RT_BIT_32(13)
1076#define ARMV8_EC_ISS_DATA_ABRT_VNCR_BIT 13
1077/** Bit 14 - AR - Acquire/Release semantics. */
1078#define ARMV8_EC_ISS_DATA_ABRT_AR RT_BIT_32(14)
1079#define ARMV8_EC_ISS_DATA_ABRT_AR_BIT 14
1080/** Bit 15 - SF - Sixty Four bit general-purpose register transfer (only when ISV is 1). */
1081#define ARMV8_EC_ISS_DATA_ABRT_SF RT_BIT_32(15)
1082#define ARMV8_EC_ISS_DATA_ABRT_SF_BIT 15
1083/** Bit 16 - 20 - SRT - Syndrome Register Transfer. */
1084#define ARMV8_EC_ISS_DATA_ABRT_SRT ( RT_BIT_32(16) | RT_BIT_32(17) | RT_BIT_32(18) \
1085 | RT_BIT_32(19) | RT_BIT_32(20))
1086#define ARMV8_EC_ISS_DATA_ABRT_SRT_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_DATA_ABRT_SRT) >> 16)
1087/** Bit 21 - SSE - Syndrome Sign Extend. */
1088#define ARMV8_EC_ISS_DATA_ABRT_SSE RT_BIT_32(21)
1089#define ARMV8_EC_ISS_DATA_ABRT_SSE_BIT 21
1090/** Bit 22 - 23 - SAS - Syndrome Access Size. */
1091#define ARMV8_EC_ISS_DATA_ABRT_SAS (RT_BIT_32(22) | RT_BIT_32(23))
1092#define ARMV8_EC_ISS_DATA_ABRT_SAS_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_DATA_ABRT_SAS) >> 22)
1093/** Bit 24 - ISV - Instruction Syndrome Valid. */
1094#define ARMV8_EC_ISS_DATA_ABRT_ISV RT_BIT_32(24)
1095#define ARMV8_EC_ISS_DATA_ABRT_ISV_BIT 24
1096/** @} */
1097
1098
1099/** @name Data Fault Status Code (DFSC).
1100 * @{ */
1101/** Address size fault, level 0 of translation or translation table base register. */
1102#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ADDR_SIZE_FAULT_LVL0 0
1103/** Address size fault, level 1. */
1104#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ADDR_SIZE_FAULT_LVL1 1
1105/** Address size fault, level 2. */
1106#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ADDR_SIZE_FAULT_LVL2 2
1107/** Address size fault, level 3. */
1108#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ADDR_SIZE_FAULT_LVL3 3
1109/** Translation fault, level 0. */
1110#define ARMV8_EC_ISS_DATA_ABRT_DFSC_TRANSLATION_FAULT_LVL0 4
1111/** Translation fault, level 1. */
1112#define ARMV8_EC_ISS_DATA_ABRT_DFSC_TRANSLATION_FAULT_LVL1 5
1113/** Translation fault, level 2. */
1114#define ARMV8_EC_ISS_DATA_ABRT_DFSC_TRANSLATION_FAULT_LVL2 6
1115/** Translation fault, level 3. */
1116#define ARMV8_EC_ISS_DATA_ABRT_DFSC_TRANSLATION_FAULT_LVL3 7
1117/** FEAT_LPA2 - Access flag fault, level 0. */
1118#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ACCESS_FLAG_FAULT_LVL0 8
1119/** Access flag fault, level 1. */
1120#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ACCESS_FLAG_FAULT_LVL1 9
1121/** Access flag fault, level 2. */
1122#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ACCESS_FLAG_FAULT_LVL2 10
1123/** Access flag fault, level 3. */
1124#define ARMV8_EC_ISS_DATA_ABRT_DFSC_ACCESS_FLAG_FAULT_LVL3 11
1125/** FEAT_LPA2 - Permission fault, level 0. */
1126#define ARMV8_EC_ISS_DATA_ABRT_DFSC_PERMISSION_FAULT_LVL0 12
1127/** Permission fault, level 1. */
1128#define ARMV8_EC_ISS_DATA_ABRT_DFSC_PERMISSION_FAULT_LVL1 13
1129/** Permission fault, level 2. */
1130#define ARMV8_EC_ISS_DATA_ABRT_DFSC_PERMISSION_FAULT_LVL2 14
1131/** Permission fault, level 3. */
1132#define ARMV8_EC_ISS_DATA_ABRT_DFSC_PERMISSION_FAULT_LVL3 15
1133/** Synchronous External abort, not a translation table walk or hardware update of translation table. */
1134#define ARMV8_EC_ISS_DATA_ABRT_DFSC_SYNC_EXTERNAL 16
1135/** FEAT_MTE2 - Synchronous Tag Check Fault. */
1136#define ARMV8_EC_ISS_DATA_ABRT_DFSC_MTE2_SYNC_TAG_CHK_FAULT 17
1137/** @todo Do the rest (lazy developer). */
1138/** @} */
1139
1140
1141/** @name SAS encoding.
1142 * @{ */
1143/** Byte access. */
1144#define ARMV8_EC_ISS_DATA_ABRT_SAS_BYTE 0
1145/** Halfword access (uint16_t). */
1146#define ARMV8_EC_ISS_DATA_ABRT_SAS_HALFWORD 1
1147/** Word access (uint32_t). */
1148#define ARMV8_EC_ISS_DATA_ABRT_SAS_WORD 2
1149/** Doubleword access (uint64_t). */
1150#define ARMV8_EC_ISS_DATA_ABRT_SAS_DWORD 3
1151/** @} */
1152
1153
1154/** @name ISS encoding for trapped MSR, MRS or System instruction exceptions.
1155 * @{ */
1156/** Bit 0 - Direction flag. */
1157#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_DIRECTION RT_BIT_32(0)
1158#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_DIRECTION_IS_READ(a_Iss) RT_BOOL((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_DIRECTION)
1159/** Bit 1 - 4 - CRm value from the instruction. */
1160#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRM ( RT_BIT_32(1) | RT_BIT_32(2) | RT_BIT_32(3) \
1161 | RT_BIT_32(4))
1162#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRM_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRM) >> 1)
1163/** Bit 5 - 9 - Rt value from the instruction. */
1164#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_RT ( RT_BIT_32(5) | RT_BIT_32(6) | RT_BIT_32(7) \
1165 | RT_BIT_32(8) | RT_BIT_32(9))
1166#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_RT_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_RT) >> 5)
1167/** Bit 10 - 13 - CRn value from the instruction. */
1168#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRN ( RT_BIT_32(10) | RT_BIT_32(11) | RT_BIT_32(12) \
1169 | RT_BIT_32(13))
1170#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRN_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_CRN) >> 10)
1171/** Bit 14 - 16 - Op2 value from the instruction. */
1172#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP1 (RT_BIT_32(14) | RT_BIT_32(15) | RT_BIT_32(16))
1173#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP1_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP1) >> 14)
1174/** Bit 17 - 19 - Op2 value from the instruction. */
1175#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP2 (RT_BIT_32(17) | RT_BIT_32(18) | RT_BIT_32(19))
1176#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP2_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP2) >> 17)
1177/** Bit 20 - 21 - Op0 value from the instruction. */
1178#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP0 (RT_BIT_32(20) | RT_BIT_32(21))
1179#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP0_GET(a_Iss) (((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_OP0) >> 20)
1180/** Bit 22 - 24 - Reserved. */
1181#define ARMV8_EC_ISS_AARCH64_TRAPPED_SYS_INSN_RSVD (RT_BIT_32(22) | RT_BIT_32(23) | RT_BIT_32(24))
1182/** @} */
1183
1184
1185/** @name ISS encoding for trapped HVC instruction exceptions.
1186 * @{ */
1187/** Bit 0 - 15 - imm16 value of the instruction. */
1188#define ARMV8_EC_ISS_AARCH64_TRAPPED_HVC_INSN_IMM (UINT16_C(0xffff))
1189#define ARMV8_EC_ISS_AARCH64_TRAPPED_HVC_INSN_IMM_GET(a_Iss) ((a_Iss) & ARMV8_EC_ISS_AARCH64_TRAPPED_HVC_INSN_IMM)
1190/** @} */
1191
1192
1193/** @name TCR_EL1 - Translation Control Register (EL1)
1194 * @{
1195 */
1196/** Bit 0 - 5 - Size offset of the memory region addressed by TTBR0_EL1 (2^(64-T0SZ)). */
1197#define ARMV8_TCR_EL1_AARCH64_T0SZ ( RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) \
1198 | RT_BIT_64(3) | RT_BIT_64(4) | RT_BIT_64(5))
1199#define ARMV8_TCR_EL1_AARCH64_T0SZ_GET(a_Tcr) ((a_Tcr) & ARMV8_TCR_EL1_AARCH64_T1SZ)
1200/** Bit 7 - Translation table walk disable for translations using TTBR0_EL1. */
1201#define ARMV8_TCR_EL1_AARCH64_EPD0 RT_BIT_64(7)
1202#define ARMV8_TCR_EL1_AARCH64_EPD0_BIT 7
1203/** Bit 8 - 9 - Inner cacheability attribute for memory associated with translation table walks using TTBR0_EL1. */
1204#define ARMV8_TCR_EL1_AARCH64_IRGN0 (RT_BIT_64(8) | RT_BIT_64(9))
1205#define ARMV8_TCR_EL1_AARCH64_IRGN0_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_IRGN0) >> 8)
1206/** Non cacheable. */
1207# define ARMV8_TCR_EL1_AARCH64_IRGN0_NON_CACHEABLE 0
1208/** Write-Back, Read-Allocate, Write-Allocate Cacheable. */
1209# define ARMV8_TCR_EL1_AARCH64_IRGN0_WB_RA_WA 1
1210/** Write-Through, Read-Allocate, No Write-Allocate Cacheable. */
1211# define ARMV8_TCR_EL1_AARCH64_IRGN0_WT_RA_NWA 2
1212/** Write-Back, Read-Allocate, No Write-Allocate Cacheable. */
1213# define ARMV8_TCR_EL1_AARCH64_IRGN0_WB_RA_NWA 3
1214/** Bit 27 - 26 - Outer cacheability attribute for memory associated with translation table walks using TTBR0_EL1. */
1215#define ARMV8_TCR_EL1_AARCH64_ORGN0 (RT_BIT_64(10) | RT_BIT_64(11))
1216#define ARMV8_TCR_EL1_AARCH64_ORGN0_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_ORGN0) >> 10)
1217/** Non cacheable. */
1218# define ARMV8_TCR_EL1_AARCH64_ORGN0_NON_CACHEABLE 0
1219/** Write-Back, Read-Allocate, Write-Allocate Cacheable. */
1220# define ARMV8_TCR_EL1_AARCH64_ORGN0_WB_RA_WA 1
1221/** Write-Through, Read-Allocate, No Write-Allocate Cacheable. */
1222# define ARMV8_TCR_EL1_AARCH64_ORGN0_WT_RA_NWA 2
1223/** Write-Back, Read-Allocate, No Write-Allocate Cacheable. */
1224# define ARMV8_TCR_EL1_AARCH64_ORGN0_WB_RA_NWA 3
1225/** Bit 12 - 13 - Shareability attribute memory associated with translation table walks using TTBR0_EL1. */
1226#define ARMV8_TCR_EL1_AARCH64_SH0 (RT_BIT_64(12) | RT_BIT_64(13))
1227#define ARMV8_TCR_EL1_AARCH64_SH0_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_SH0) >> 12)
1228/** Non shareable. */
1229# define ARMV8_TCR_EL1_AARCH64_SH0_NON_SHAREABLE 0
1230/** Invalid value. */
1231# define ARMV8_TCR_EL1_AARCH64_SH0_INVALID 1
1232/** Outer Shareable. */
1233# define ARMV8_TCR_EL1_AARCH64_SH0_OUTER_SHAREABLE 2
1234/** Inner Shareable. */
1235# define ARMV8_TCR_EL1_AARCH64_SH0_INNER_SHAREABLE 3
1236/** Bit 14 - 15 - Translation Granule Size for TTBR0_EL1. */
1237#define ARMV8_TCR_EL1_AARCH64_TG0 (RT_BIT_64(14) | RT_BIT_64(15))
1238#define ARMV8_TCR_EL1_AARCH64_TG0_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_TG0) >> 14)
1239/** Invalid granule size. */
1240# define ARMV8_TCR_EL1_AARCH64_TG0_INVALID 0
1241/** 16KiB granule size. */
1242# define ARMV8_TCR_EL1_AARCH64_TG0_16KB 1
1243/** 4KiB granule size. */
1244# define ARMV8_TCR_EL1_AARCH64_TG0_4KB 2
1245/** 64KiB granule size. */
1246# define ARMV8_TCR_EL1_AARCH64_TG0_64KB 3
1247/** Bit 16 - 21 - Size offset of the memory region addressed by TTBR1_EL1 (2^(64-T1SZ)). */
1248#define ARMV8_TCR_EL1_AARCH64_T1SZ ( RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) \
1249 | RT_BIT_64(19) | RT_BIT_64(20) | RT_BIT_64(21))
1250#define ARMV8_TCR_EL1_AARCH64_T1SZ_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_T1SZ) >> 16)
1251/** Bit 22 - Selects whether TTBR0_EL1 (0) or TTBR1_EL1 (1) defines the ASID. */
1252#define ARMV8_TCR_EL1_AARCH64_A1 RT_BIT_64(22)
1253#define ARMV8_TCR_EL1_AARCH64_A1_BIT 22
1254/** Bit 23 - Translation table walk disable for translations using TTBR1_EL1. */
1255#define ARMV8_TCR_EL1_AARCH64_EPD1 RT_BIT_64(23)
1256#define ARMV8_TCR_EL1_AARCH64_EPD1_BIT 23
1257/** Bit 24 - 25 - Inner cacheability attribute for memory associated with translation table walks using TTBR1_EL1. */
1258#define ARMV8_TCR_EL1_AARCH64_IRGN1 (RT_BIT_64(24) | RT_BIT_64(25))
1259#define ARMV8_TCR_EL1_AARCH64_IRGN1_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_IRGN1) >> 26)
1260/** Non cacheable. */
1261# define ARMV8_TCR_EL1_AARCH64_IRGN1_NON_CACHEABLE 0
1262/** Write-Back, Read-Allocate, Write-Allocate Cacheable. */
1263# define ARMV8_TCR_EL1_AARCH64_IRGN1_WB_RA_WA 1
1264/** Write-Through, Read-Allocate, No Write-Allocate Cacheable. */
1265# define ARMV8_TCR_EL1_AARCH64_IRGN1_WT_RA_NWA 2
1266/** Write-Back, Read-Allocate, No Write-Allocate Cacheable. */
1267# define ARMV8_TCR_EL1_AARCH64_IRGN1_WB_RA_NWA 3
1268/** Bit 27 - 26 - Outer cacheability attribute for memory associated with translation table walks using TTBR1_EL1. */
1269#define ARMV8_TCR_EL1_AARCH64_ORGN1 (RT_BIT_64(26) | RT_BIT_64(27))
1270#define ARMV8_TCR_EL1_AARCH64_ORGN1_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_ORGN1) >> 26)
1271/** Non cacheable. */
1272# define ARMV8_TCR_EL1_AARCH64_ORGN1_NON_CACHEABLE 0
1273/** Write-Back, Read-Allocate, Write-Allocate Cacheable. */
1274# define ARMV8_TCR_EL1_AARCH64_ORGN1_WB_RA_WA 1
1275/** Write-Through, Read-Allocate, No Write-Allocate Cacheable. */
1276# define ARMV8_TCR_EL1_AARCH64_ORGN1_WT_RA_NWA 2
1277/** Write-Back, Read-Allocate, No Write-Allocate Cacheable. */
1278# define ARMV8_TCR_EL1_AARCH64_ORGN1_WB_RA_NWA 3
1279/** Bit 28 - 29 - Shareability attribute memory associated with translation table walks using TTBR1_EL1. */
1280#define ARMV8_TCR_EL1_AARCH64_SH1 (RT_BIT_64(28) | RT_BIT_64(29))
1281#define ARMV8_TCR_EL1_AARCH64_SH1_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_SH1) >> 28)
1282/** Non shareable. */
1283# define ARMV8_TCR_EL1_AARCH64_SH1_NON_SHAREABLE 0
1284/** Invalid value. */
1285# define ARMV8_TCR_EL1_AARCH64_SH1_INVALID 1
1286/** Outer Shareable. */
1287# define ARMV8_TCR_EL1_AARCH64_SH1_OUTER_SHAREABLE 2
1288/** Inner Shareable. */
1289# define ARMV8_TCR_EL1_AARCH64_SH1_INNER_SHAREABLE 3
1290/** Bit 30 - 31 - Translation Granule Size for TTBR1_EL1. */
1291#define ARMV8_TCR_EL1_AARCH64_TG1 (RT_BIT_64(30) | RT_BIT_64(31))
1292#define ARMV8_TCR_EL1_AARCH64_TG1_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_TG1) >> 30)
1293/** Invalid granule size. */
1294# define ARMV8_TCR_EL1_AARCH64_TG1_INVALID 0
1295/** 16KiB granule size. */
1296# define ARMV8_TCR_EL1_AARCH64_TG1_16KB 1
1297/** 4KiB granule size. */
1298# define ARMV8_TCR_EL1_AARCH64_TG1_4KB 2
1299/** 64KiB granule size. */
1300# define ARMV8_TCR_EL1_AARCH64_TG1_64KB 3
1301/** Bit 32 - 34 - Intermediate Physical Address Size. */
1302#define ARMV8_TCR_EL1_AARCH64_IPS (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34))
1303#define ARMV8_TCR_EL1_AARCH64_IPS_GET(a_Tcr) (((a_Tcr) & ARMV8_TCR_EL1_AARCH64_IPS) >> 32)
1304/** IPA - 32 bits, 4GiB. */
1305# define ARMV8_TCR_EL1_AARCH64_IPS_32BITS 0
1306/** IPA - 36 bits, 64GiB. */
1307# define ARMV8_TCR_EL1_AARCH64_IPS_36BITS 1
1308/** IPA - 40 bits, 1TiB. */
1309# define ARMV8_TCR_EL1_AARCH64_IPS_40BITS 2
1310/** IPA - 42 bits, 4TiB. */
1311# define ARMV8_TCR_EL1_AARCH64_IPS_42BITS 3
1312/** IPA - 44 bits, 16TiB. */
1313# define ARMV8_TCR_EL1_AARCH64_IPS_44BITS 4
1314/** IPA - 48 bits, 256TiB. */
1315# define ARMV8_TCR_EL1_AARCH64_IPS_48BITS 5
1316/** IPA - 52 bits, 4PiB. */
1317# define ARMV8_TCR_EL1_AARCH64_IPS_52BITS 6
1318/** Bit 36 - ASID Size (0 - 8 bit, 1 - 16 bit). */
1319#define ARMV8_TCR_EL1_AARCH64_AS RT_BIT_64(36)
1320#define ARMV8_TCR_EL1_AARCH64_AS_BIT 36
1321/** Bit 37 - Top Byte Ignore for translations from TTBR0_EL1. */
1322#define ARMV8_TCR_EL1_AARCH64_TBI0 RT_BIT_64(37)
1323#define ARMV8_TCR_EL1_AARCH64_TBI0_BIT 37
1324/** Bit 38 - Top Byte Ignore for translations from TTBR1_EL1. */
1325#define ARMV8_TCR_EL1_AARCH64_TBI1 RT_BIT_64(38)
1326#define ARMV8_TCR_EL1_AARCH64_TBI1_BIT 38
1327/** Bit 39 - Hardware Access flag update in stage 1 translations from EL0 and EL1. */
1328#define ARMV8_TCR_EL1_AARCH64_HA RT_BIT_64(39)
1329#define ARMV8_TCR_EL1_AARCH64_HA_BIT 39
1330/** Bit 40 - Hardware management of dirty state in stage 1 translations from EL0 and EL1. */
1331#define ARMV8_TCR_EL1_AARCH64_HD RT_BIT_64(40)
1332#define ARMV8_TCR_EL1_AARCH64_HD_BIT 40
1333/** Bit 41 - Hierarchical Permission Disables for TTBR0_EL1. */
1334#define ARMV8_TCR_EL1_AARCH64_HPD0 RT_BIT_64(41)
1335#define ARMV8_TCR_EL1_AARCH64_HPD0_BIT 41
1336/** Bit 42 - Hierarchical Permission Disables for TTBR1_EL1. */
1337#define ARMV8_TCR_EL1_AARCH64_HPD1 RT_BIT_64(42)
1338#define ARMV8_TCR_EL1_AARCH64_HPD1_BIT 42
1339/** Bit 43 - Bit[59] Hardware Use for translations using TTBR0_EL1. */
1340#define ARMV8_TCR_EL1_AARCH64_HWU059 RT_BIT_64(43)
1341#define ARMV8_TCR_EL1_AARCH64_HWU059_BIT 43
1342/** Bit 44 - Bit[60] Hardware Use for translations using TTBR0_EL1. */
1343#define ARMV8_TCR_EL1_AARCH64_HWU060 RT_BIT_64(44)
1344#define ARMV8_TCR_EL1_AARCH64_HWU060_BIT 44
1345/** Bit 46 - Bit[61] Hardware Use for translations using TTBR0_EL1. */
1346#define ARMV8_TCR_EL1_AARCH64_HWU061 RT_BIT_64(45)
1347#define ARMV8_TCR_EL1_AARCH64_HWU061_BIT 45
1348/** Bit 46 - Bit[62] Hardware Use for translations using TTBR0_EL1. */
1349#define ARMV8_TCR_EL1_AARCH64_HWU062 RT_BIT_64(46)
1350#define ARMV8_TCR_EL1_AARCH64_HWU062_BIT 46
1351/** Bit 47 - Bit[59] Hardware Use for translations using TTBR1_EL1. */
1352#define ARMV8_TCR_EL1_AARCH64_HWU159 RT_BIT_64(47)
1353#define ARMV8_TCR_EL1_AARCH64_HWU159_BIT 47
1354/** Bit 48 - Bit[60] Hardware Use for translations using TTBR1_EL1. */
1355#define ARMV8_TCR_EL1_AARCH64_HWU160 RT_BIT_64(48)
1356#define ARMV8_TCR_EL1_AARCH64_HWU160_BIT 48
1357/** Bit 49 - Bit[61] Hardware Use for translations using TTBR1_EL1. */
1358#define ARMV8_TCR_EL1_AARCH64_HWU161 RT_BIT_64(49)
1359#define ARMV8_TCR_EL1_AARCH64_HWU161_BIT 49
1360/** Bit 50 - Bit[62] Hardware Use for translations using TTBR1_EL1. */
1361#define ARMV8_TCR_EL1_AARCH64_HWU162 RT_BIT_64(50)
1362#define ARMV8_TCR_EL1_AARCH64_HWU162_BIT 50
1363/** Bit 51 - Control the use of the top byte of instruction addresses for address matching for translations using TTBR0_EL1. */
1364#define ARMV8_TCR_EL1_AARCH64_TBID0 RT_BIT_64(51)
1365#define ARMV8_TCR_EL1_AARCH64_TBID0_BIT 51
1366/** Bit 52 - Control the use of the top byte of instruction addresses for address matching for translations using TTBR1_EL1. */
1367#define ARMV8_TCR_EL1_AARCH64_TBID1 RT_BIT_64(52)
1368#define ARMV8_TCR_EL1_AARCH64_TBID1_BIT 52
1369/** Bit 53 - Non fault translation table walk disable for stage 1 translations using TTBR0_EL1. */
1370#define ARMV8_TCR_EL1_AARCH64_NFD0 RT_BIT_64(53)
1371#define ARMV8_TCR_EL1_AARCH64_NFD0_BIT 53
1372/** Bit 54 - Non fault translation table walk disable for stage 1 translations using TTBR1_EL1. */
1373#define ARMV8_TCR_EL1_AARCH64_NFD1 RT_BIT_64(54)
1374#define ARMV8_TCR_EL1_AARCH64_NFD1_BIT 54
1375/** Bit 55 - Faulting Control for Unprivileged access to any address translated by TTBR0_EL1. */
1376#define ARMV8_TCR_EL1_AARCH64_E0PD0 RT_BIT_64(55)
1377#define ARMV8_TCR_EL1_AARCH64_E0PD0_BIT 55
1378/** Bit 56 - Faulting Control for Unprivileged access to any address translated by TTBR1_EL1. */
1379#define ARMV8_TCR_EL1_AARCH64_E0PD1 RT_BIT_64(56)
1380#define ARMV8_TCR_EL1_AARCH64_E0PD1_BIT 56
1381/** Bit 57 - TCMA0 */
1382#define ARMV8_TCR_EL1_AARCH64_TCMA0 RT_BIT_64(57)
1383#define ARMV8_TCR_EL1_AARCH64_TCMA0_BIT 57
1384/** Bit 58 - TCMA1 */
1385#define ARMV8_TCR_EL1_AARCH64_TCMA1 RT_BIT_64(58)
1386#define ARMV8_TCR_EL1_AARCH64_TCMA1_BIT 58
1387/** Bit 59 - Data Sharing(?). */
1388#define ARMV8_TCR_EL1_AARCH64_DS RT_BIT_64(59)
1389#define ARMV8_TCR_EL1_AARCH64_DS_BIT 59
1390/** @} */
1391
1392
1393/** @name TTBR<0,1>_EL1 - Translation Table Base Register <0,1> (EL1)
1394 * @{
1395 */
1396/** Bit 0 - Common not Private (FEAT_TTCNP). */
1397#define ARMV8_TTBR_EL1_AARCH64_CNP RT_BIT_64(0)
1398#define ARMV8_TTBR_EL1_AARCH64_CNP_BIT 0
1399/** Bit 1 - 47 - Translation table base address. */
1400#define ARMV8_TTBR_EL1_AARCH64_BADDR UINT64_C(0x0000fffffffffffe)
1401#define ARMV8_TTBR_EL1_AARCH64_BADDR_GET(a_Ttbr) (((a_Ttbr) & ARMV8_TTBR_EL1_AARCH64_BADDR) >> 1)
1402/** Bit 48 - 63 - ASID. */
1403#define ARMV8_TTBR_EL1_AARCH64_ASID UINT64_C(0xffff000000000000)
1404#define ARMV8_TTBR_EL1_AARCH64_ASID_GET(a_Ttbr) (((a_Ttbr) & ARMV8_TTBR_EL1_AARCH64_ASID) >> 48)
1405/** @} */
1406
1407
1408/** @name ICC_PMR_EL1 - Interrupt Controller Interrupt Priority Mask Register
1409 * @{ */
1410/** Bit 0 - 7 - Priority - The priority mask level for the CPU interface. */
1411#define ARMV8_ICC_PMR_EL1_AARCH64_PRIORITY UINT64_C(0xff)
1412#define ARMV8_ICC_PMR_EL1_AARCH64_PRIORITY_GET(a_Pmr) ((a_Pmr) & ARMV8_ICC_PMR_EL1_AARCH64_PRIORITY)
1413#define ARMV8_ICC_PMR_EL1_AARCH64_PRIORITY_SET(a_Prio) ((a_Prio) & ARMV8_ICC_PMR_EL1_AARCH64_PRIORITY)
1414/** @} */
1415
1416
1417/** @name ICC_BPR0_EL1 - The group priority for Group 0 interrupts.
1418 * @{ */
1419/** Bit 0 - 2 - BinaryPoint - Controls how the 8-bit interrupt priority field is split into a group priority and subpriority field. */
1420#define ARMV8_ICC_BPR0_EL1_AARCH64_BINARYPOINT (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2))
1421#define ARMV8_ICC_BPR0_EL1_AARCH64_BINARYPOINT_GET(a_Bpr0) ((a_Bpr0) & ARMV8_ICC_BPR0_EL1_AARCH64_BINARYPOINT)
1422#define ARMV8_ICC_BPR0_EL1_AARCH64_BINARYPOINT_SET(a_BinaryPt) ((a_BinaryPt) & ARMV8_ICC_BPR0_EL1_AARCH64_BINARYPOINT)
1423/** @} */
1424
1425
1426/** @name ICC_BPR1_EL1 - The group priority for Group 1 interrupts.
1427 * @{ */
1428/** Bit 0 - 2 - BinaryPoint - Controls how the 8-bit interrupt priority field is split into a group priority and subpriority field. */
1429#define ARMV8_ICC_BPR1_EL1_AARCH64_BINARYPOINT (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2))
1430#define ARMV8_ICC_BPR1_EL1_AARCH64_BINARYPOINT_GET(a_Bpr1) ((a_Bpr1) & ARMV8_ICC_BPR1_EL1_AARCH64_BINARYPOINT)
1431#define ARMV8_ICC_BPR1_EL1_AARCH64_BINARYPOINT_SET(a_BinaryPt) ((a_BinaryPt) & ARMV8_ICC_BPR1_EL1_AARCH64_BINARYPOINT)
1432/** @} */
1433
1434
1435/** @name ICC_CTLR_EL1 - Interrupt Controller Control Register (EL1)
1436 * @{ */
1437/** Bit 0 - Common Binary Pointer Register - RW. */
1438#define ARMV8_ICC_CTLR_EL1_AARCH64_CBPR RT_BIT_64(0)
1439#define ARMV8_ICC_CTLR_EL1_AARCH64_CBPR_BIT 0
1440/** Bit 1 - EOI mode for current security state, when set ICC_DIR_EL1 provides interrupt deactivation functionality - RW. */
1441#define ARMV8_ICC_CTLR_EL1_AARCH64_EOIMODE RT_BIT_64(1)
1442#define ARMV8_ICC_CTLR_EL1_AARCH64_EOIMODE_BIT 1
1443/** Bit 7 - Priority Mask Hint Enable - RW (under circumstances). */
1444#define ARMV8_ICC_CTLR_EL1_AARCH64_PMHE RT_BIT_64(7)
1445#define ARMV8_ICC_CTLR_EL1_AARCH64_PMHE_BIT 7
1446/** Bit 8 - 10 - Priority bits - RO. */
1447#define ARMV8_ICC_CTLR_EL1_AARCH64_PRIBITS (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10))
1448#define ARMV8_ICC_CTLR_EL1_AARCH64_PRIBITS_SET(a_PriBits) (((a_PriBits) << 8) & ARMV8_ICC_CTLR_EL1_AARCH64_PRIBITS)
1449/** Bit 11 - 13 - Interrupt identifier bits - RO. */
1450#define ARMV8_ICC_CTLR_EL1_AARCH64_IDBITS (RT_BIT_64(11) | RT_BIT_64(12) | RT_BIT_64(13))
1451#define ARMV8_ICC_CTLR_EL1_AARCH64_IDBITS_SET(a_IdBits) (((a_IdBits) << 11) & ARMV8_ICC_CTLR_EL1_AARCH64_IDBITS)
1452/** INTIDS are 16-bit wide. */
1453# define ARMV8_ICC_CTLR_EL1_AARCH64_IDBITS_16BITS 0
1454/** INTIDS are 24-bit wide. */
1455# define ARMV8_ICC_CTLR_EL1_AARCH64_IDBITS_24BITS 1
1456/** Bit 14 - SEI Supported - RO. */
1457#define ARMV8_ICC_CTLR_EL1_AARCH64_SEIS RT_BIT_64(14)
1458#define ARMV8_ICC_CTLR_EL1_AARCH64_SEIS_BIT 14
1459/** Bit 15 - Affinity 3 Valid - RO. */
1460#define ARMV8_ICC_CTLR_EL1_AARCH64_A3V RT_BIT_64(15)
1461#define ARMV8_ICC_CTLR_EL1_AARCH64_A3V_BIT 15
1462/** Bit 18 - Range Selector Support - RO. */
1463#define ARMV8_ICC_CTLR_EL1_AARCH64_RSS RT_BIT_64(18)
1464#define ARMV8_ICC_CTLR_EL1_AARCH64_RSS_BIT 18
1465/** Bit 19 - Extended INTID range supported - RO. */
1466#define ARMV8_ICC_CTLR_EL1_AARCH64_EXTRANGE RT_BIT_64(19)
1467#define ARMV8_ICC_CTLR_EL1_AARCH64_EXTRANGE_BIT 19
1468/** All RW bits. */
1469#define ARMV8_ICC_CTLR_EL1_RW (ARMV8_ICC_CTLR_EL1_AARCH64_CBPR | ARMV8_ICC_CTLR_EL1_AARCH64_EOIMODE | ARMV8_ICC_CTLR_EL1_AARCH64_PMHE)
1470/** All RO bits (including Res0). */
1471#define ARMV8_ICC_CTLR_EL1_RO ~ARMV8_ICC_CTLR_EL1_RW
1472/** @} */
1473
1474
1475/** @name ICC_IGRPEN0_EL1 - Interrupt Controller Interrupt Group 0 Enable Register (EL1)
1476 * @{ */
1477/** Bit 0 - Enables Group 0 interrupts for the current Security state. */
1478#define ARMV8_ICC_IGRPEN0_EL1_AARCH64_ENABLE RT_BIT_64(0)
1479#define ARMV8_ICC_IGRPEN0_EL1_AARCH64_ENABLE_BIT 0
1480/** @} */
1481
1482
1483/** @name ICC_IGRPEN1_EL1 - Interrupt Controller Interrupt Group 1 Enable Register (EL1)
1484 * @{ */
1485/** Bit 0 - Enables Group 1 interrupts for the current Security state. */
1486#define ARMV8_ICC_IGRPEN1_EL1_AARCH64_ENABLE RT_BIT_64(0)
1487#define ARMV8_ICC_IGRPEN1_EL1_AARCH64_ENABLE_BIT 0
1488/** @} */
1489
1490
1491/** @name ICC_SGI1R_EL1 - Interrupt Controller Software Generated Interrupt Group 1 Register (EL1) - WO
1492 * @{ */
1493/** Bit 0 - 15 - Target List, the set of PEs for which SGI interrupts will be generated. */
1494#define ARMV8_ICC_SGI1R_EL1_AARCH64_TARGET_LIST (UINT64_C(0x000000000000ffff))
1495#define ARMV8_ICC_SGI1R_EL1_AARCH64_TARGET_LIST_GET(a_Sgi1R) ((a_Sgi1R) & ARMV8_ICC_SGI1R_EL1_AARCH64_TARGET_LIST)
1496/** Bit 16 - 23 - The affinity 1 of the affinity path of the cluster for which SGI interrupts will be generated. */
1497#define ARMV8_ICC_SGI1R_EL1_AARCH64_AFF1 (UINT64_C(0x00000000007f0000))
1498#define ARMV8_ICC_SGI1R_EL1_AARCH64_AFF1_GET(a_Sgi1R) (((a_Sgi1R) & ARMV8_ICC_SGI1R_EL1_AARCH64_AFF1) >> 16)
1499/** Bit 24 - 27 - The INTID of the SGI. */
1500#define ARMV8_ICC_SGI1R_EL1_AARCH64_INTID (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
1501#define ARMV8_ICC_SGI1R_EL1_AARCH64_INTID_GET(a_Sgi1R) (((a_Sgi1R) & ARMV8_ICC_SGI1R_EL1_AARCH64_INTID) >> 24)
1502/* Bit 28 - 31 - Reserved. */
1503/** Bit 32 - 39 - The affinity 2 of the affinity path of the cluster for which SGI interrupts will be generated. */
1504#define ARMV8_ICC_SGI1R_EL1_AARCH64_AFF2 (UINT64_C(0x000000ff00000000))
1505#define ARMV8_ICC_SGI1R_EL1_AARCH64_AFF2_GET(a_Sgi1R) (((a_Sgi1R) & ARMV8_ICC_SGI1R_EL1_AARCH64_AFF2) >> 32)
1506/** Bit 40 - Interrupt Routing Mode - 1 means interrupts to all PEs in the system excluding the generating PE. */
1507#define ARMV8_ICC_SGI1R_EL1_AARCH64_IRM RT_BIT_64(40)
1508#define ARMV8_ICC_SGI1R_EL1_AARCH64_IRM_BIT 40
1509/* Bit 41 - 43 - Reserved. */
1510/** Bit 44 - 47 - Range selector. */
1511#define ARMV8_ICC_SGI1R_EL1_AARCH64_RS (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
1512#define ARMV8_ICC_SGI1R_EL1_AARCH64_RS_GET(a_Sgi1R) (((a_Sgi1R) & ARMV8_ICC_SGI1R_EL1_AARCH64_RS) >> 44)
1513/** Bit 48 - 55 - The affinity 3 of the affinity path of the cluster for which SGI interrupts will be generated. */
1514#define ARMV8_ICC_SGI1R_EL1_AARCH64_AFF3 (UINT64_C(0x00ff000000000000))
1515#define ARMV8_ICC_SGI1R_EL1_AARCH64_AFF3_GET(a_Sgi1R) (((a_Sgi1R) & ARMV8_ICC_SGI1R_EL1_AARCH64_AFF3) >> 48)
1516/* Bit 56 - 63 - Reserved. */
1517/** @} */
1518
1519
1520/** @name CNTV_CTL_EL0 - Counter-timer Virtual Timer Control register.
1521 * @{ */
1522/** Bit 0 - Enables the timer. */
1523#define ARMV8_CNTV_CTL_EL0_AARCH64_ENABLE RT_BIT_64(0)
1524#define ARMV8_CNTV_CTL_EL0_AARCH64_ENABLE_BIT 0
1525/** Bit 1 - Timer interrupt mask bit. */
1526#define ARMV8_CNTV_CTL_EL0_AARCH64_IMASK RT_BIT_64(1)
1527#define ARMV8_CNTV_CTL_EL0_AARCH64_IMASK_BIT 1
1528/** Bit 2 - Timer status bit. */
1529#define ARMV8_CNTV_CTL_EL0_AARCH64_ISTATUS RT_BIT_64(2)
1530#define ARMV8_CNTV_CTL_EL0_AARCH64_ISTATUS_BIT 2
1531/** @} */
1532
1533
1534/** @name OSLAR_EL1 - OS Lock Access Register.
1535 * @{ */
1536/** Bit 0 - The OS Lock status bit. */
1537#define ARMV8_OSLAR_EL1_AARCH64_OSLK RT_BIT_64(0)
1538#define ARMV8_OSLAR_EL1_AARCH64_OSLK_BIT 0
1539/** @} */
1540
1541
1542/** @name OSLSR_EL1 - OS Lock Status Register.
1543 * @{ */
1544/** Bit 0 - OSLM[0] Bit 0 of OS Lock model implemented. */
1545#define ARMV8_OSLSR_EL1_AARCH64_OSLM0 RT_BIT_64(0)
1546#define ARMV8_OSLSR_EL1_AARCH64_OSLM0_BIT 0
1547/** Bit 1 - The OS Lock status bit. */
1548#define ARMV8_OSLSR_EL1_AARCH64_OSLK RT_BIT_64(1)
1549#define ARMV8_OSLSR_EL1_AARCH64_OSLK_BIT 1
1550/** Bit 2 - Not 32-bit access. */
1551#define ARMV8_OSLSR_EL1_AARCH64_NTT RT_BIT_64(2)
1552#define ARMV8_OSLSR_EL1_AARCH64_NTT_BIT 2
1553/** Bit 0 - OSLM[1] Bit 1 of OS Lock model implemented. */
1554#define ARMV8_OSLSR_EL1_AARCH64_OSLM1 RT_BIT_64(3)
1555#define ARMV8_OSLSR_EL1_AARCH64_OSLM1_BIT 3
1556/** @} */
1557
1558
1559/** @name ID_AA64ISAR0_EL1 - AArch64 Instruction Set Attribute Register 0.
1560 * @{ */
1561/* Bit 0 - 3 - Reserved. */
1562/** Bit 4 - 7 - Indicates support for AES instructions in AArch64 state. */
1563#define ARMV8_ID_AA64ISAR0_EL1_AES_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
1564#define ARMV8_ID_AA64ISAR0_EL1_AES_SHIFT 4
1565/** No AES instructions implemented. */
1566# define ARMV8_ID_AA64ISAR0_EL1_AES_NOT_IMPL 0
1567/** AES, AESD, AESMC and AESIMC instructions implemented (FEAT_AES). */
1568# define ARMV8_ID_AA64ISAR0_EL1_AES_SUPPORTED 1
1569/** AES, AESD, AESMC and AESIMC instructions implemented and PMULL and PMULL2 instructions operating on 64bit source elements (FEAT_PMULL). */
1570# define ARMV8_ID_AA64ISAR0_EL1_AES_SUPPORTED_PMULL 2
1571/** Bit 8 - 11 - Indicates support for SHA1 instructions in AArch64 state. */
1572#define ARMV8_ID_AA64ISAR0_EL1_SHA1_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
1573#define ARMV8_ID_AA64ISAR0_EL1_SHA1_SHIFT 8
1574/** No SHA1 instructions implemented. */
1575# define ARMV8_ID_AA64ISAR0_EL1_SHA1_NOT_IMPL 0
1576/** SHA1C, SHA1P, SHA1M, SHA1H, SHA1SU0 and SHA1SU1 instructions implemented (FEAT_SHA1). */
1577# define ARMV8_ID_AA64ISAR0_EL1_SHA1_SUPPORTED 1
1578/** Bit 12 - 15 - Indicates support for SHA2 instructions in AArch64 state. */
1579#define ARMV8_ID_AA64ISAR0_EL1_SHA2_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
1580#define ARMV8_ID_AA64ISAR0_EL1_SHA2_SHIFT 12
1581/** No SHA2 instructions implemented. */
1582# define ARMV8_ID_AA64ISAR0_EL1_SHA2_NOT_IMPL 0
1583/** SHA256 instructions implemented (FEAT_SHA256). */
1584# define ARMV8_ID_AA64ISAR0_EL1_SHA2_SUPPORTED_SHA256 1
1585/** SHA256 and SHA512 instructions implemented (FEAT_SHA512). */
1586# define ARMV8_ID_AA64ISAR0_EL1_SHA2_SUPPORTED_SHA256_SHA512 2
1587/** Bit 16 - 19 - Indicates support for CRC32 instructions in AArch64 state. */
1588#define ARMV8_ID_AA64ISAR0_EL1_CRC32_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
1589#define ARMV8_ID_AA64ISAR0_EL1_CRC32_SHIFT 16
1590/** No CRC32 instructions implemented. */
1591# define ARMV8_ID_AA64ISAR0_EL1_CRC32_NOT_IMPL 0
1592/** CRC32 instructions implemented (FEAT_CRC32). */
1593# define ARMV8_ID_AA64ISAR0_EL1_CRC32_SUPPORTED 1
1594/** Bit 20 - 23 - Indicates support for Atomic instructions in AArch64 state. */
1595#define ARMV8_ID_AA64ISAR0_EL1_ATOMIC_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
1596#define ARMV8_ID_AA64ISAR0_EL1_ATOMIC_SHIFT 20
1597/** No Atomic instructions implemented. */
1598# define ARMV8_ID_AA64ISAR0_EL1_ATOMIC_NOT_IMPL 0
1599/** Atomic instructions implemented (FEAT_LSE). */
1600# define ARMV8_ID_AA64ISAR0_EL1_ATOMIC_SUPPORTED 2
1601/** Bit 24 - 27 - Indicates support for TME instructions. */
1602#define ARMV8_ID_AA64ISAR0_EL1_TME_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
1603#define ARMV8_ID_AA64ISAR0_EL1_TME_SHIFT 24
1604/** TME instructions are not implemented. */
1605# define ARMV8_ID_AA64ISAR0_EL1_TME_NOT_IMPL 0
1606/** TME instructions are implemented. */
1607# define ARMV8_ID_AA64ISAR0_EL1_TME_SUPPORTED 1
1608/** Bit 28 - 31 - Indicates support for SQRDMLAH and SQRDMLSH instructions in AArch64 state. */
1609#define ARMV8_ID_AA64ISAR0_EL1_RDM_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
1610#define ARMV8_ID_AA64ISAR0_EL1_RDM_SHIFT 28
1611/** No RDMA instructions implemented. */
1612# define ARMV8_ID_AA64ISAR0_EL1_RDM_NOT_IMPL 0
1613/** SQRDMLAH and SQRDMLSH instructions implemented (FEAT_RDM). */
1614# define ARMV8_ID_AA64ISAR0_EL1_RDM_SUPPORTED 1
1615/** Bit 32 - 35 - Indicates support for SHA3 instructions in AArch64 state. */
1616#define ARMV8_ID_AA64ISAR0_EL1_SHA3_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
1617#define ARMV8_ID_AA64ISAR0_EL1_SHA3_SHIFT 32
1618/** No SHA3 instructions implemented. */
1619# define ARMV8_ID_AA64ISAR0_EL1_SHA3_NOT_IMPL 0
1620/** EOR3, RAX1, XAR and BCAX instructions implemented (FEAT_SHA3). */
1621# define ARMV8_ID_AA64ISAR0_EL1_SHA3_SUPPORTED 1
1622/** Bit 36 - 39 - Indicates support for SM3 instructions in AArch64 state. */
1623#define ARMV8_ID_AA64ISAR0_EL1_SM3_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
1624#define ARMV8_ID_AA64ISAR0_EL1_SM3_SHIFT 36
1625/** No SM3 instructions implemented. */
1626# define ARMV8_ID_AA64ISAR0_EL1_SM3_NOT_IMPL 0
1627/** SM3 instructions implemented (FEAT_SM3). */
1628# define ARMV8_ID_AA64ISAR0_EL1_SM3_SUPPORTED 1
1629/** Bit 40 - 43 - Indicates support for SM4 instructions in AArch64 state. */
1630#define ARMV8_ID_AA64ISAR0_EL1_SM4_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
1631#define ARMV8_ID_AA64ISAR0_EL1_SM4_SHIFT 40
1632/** No SM4 instructions implemented. */
1633# define ARMV8_ID_AA64ISAR0_EL1_SM4_NOT_IMPL 0
1634/** SM4 instructions implemented (FEAT_SM4). */
1635# define ARMV8_ID_AA64ISAR0_EL1_SM4_SUPPORTED 1
1636/** Bit 44 - 47 - Indicates support for Dot Product instructions in AArch64 state. */
1637#define ARMV8_ID_AA64ISAR0_EL1_DP_MASK (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
1638#define ARMV8_ID_AA64ISAR0_EL1_DP_SHIFT 44
1639/** No Dot Product instructions implemented. */
1640# define ARMV8_ID_AA64ISAR0_EL1_DP_NOT_IMPL 0
1641/** UDOT and SDOT instructions implemented (FEAT_DotProd). */
1642# define ARMV8_ID_AA64ISAR0_EL1_DP_SUPPORTED 1
1643/** Bit 48 - 51 - Indicates support for FMLAL and FMLSL instructions. */
1644#define ARMV8_ID_AA64ISAR0_EL1_FHM_MASK (RT_BIT_64(48) | RT_BIT_64(49) | RT_BIT_64(50) | RT_BIT_64(51))
1645#define ARMV8_ID_AA64ISAR0_EL1_FHM_SHIFT 48
1646/** FMLAL and FMLSL instructions are not implemented. */
1647# define ARMV8_ID_AA64ISAR0_EL1_FHM_NOT_IMPL 0
1648/** FMLAL and FMLSL instructions are implemented (FEAT_FHM). */
1649# define ARMV8_ID_AA64ISAR0_EL1_FHM_SUPPORTED 1
1650/** Bit 52 - 55 - Indicates support for flag manipulation instructions. */
1651#define ARMV8_ID_AA64ISAR0_EL1_TS_MASK (RT_BIT_64(52) | RT_BIT_64(53) | RT_BIT_64(54) | RT_BIT_64(55))
1652#define ARMV8_ID_AA64ISAR0_EL1_TS_SHIFT 52
1653/** No flag manipulation instructions implemented. */
1654# define ARMV8_ID_AA64ISAR0_EL1_TS_NOT_IMPL 0
1655/** CFINV, RMIF, SETF16 and SETF8 instrutions are implemented (FEAT_FlagM). */
1656# define ARMV8_ID_AA64ISAR0_EL1_TS_SUPPORTED 1
1657/** CFINV, RMIF, SETF16, SETF8, AXFLAG and XAFLAG instrutions are implemented (FEAT_FlagM2). */
1658# define ARMV8_ID_AA64ISAR0_EL1_TS_SUPPORTED_2 2
1659/** Bit 56 - 59 - Indicates support for Outer Shareable and TLB range maintenance instructions. */
1660#define ARMV8_ID_AA64ISAR0_EL1_TLB_MASK (RT_BIT_64(56) | RT_BIT_64(57) | RT_BIT_64(58) | RT_BIT_64(59))
1661#define ARMV8_ID_AA64ISAR0_EL1_TLB_SHIFT 56
1662/** Outer Sahreable and TLB range maintenance instructions are not implemented. */
1663# define ARMV8_ID_AA64ISAR0_EL1_TLB_NOT_IMPL 0
1664/** Outer Shareable TLB maintenance instructions are implemented (FEAT_TLBIOS). */
1665# define ARMV8_ID_AA64ISAR0_EL1_TLB_SUPPORTED 1
1666/** Outer Shareable and TLB range maintenance instructions are implemented (FEAT_TLBIRANGE). */
1667# define ARMV8_ID_AA64ISAR0_EL1_TLB_SUPPORTED_RANGE 2
1668/** Bit 60 - 63 - Indicates support for Random Number instructons in AArch64 state. */
1669#define ARMV8_ID_AA64ISAR0_EL1_RNDR_MASK (RT_BIT_64(60) | RT_BIT_64(61) | RT_BIT_64(62) | RT_BIT_64(63))
1670#define ARMV8_ID_AA64ISAR0_EL1_RNDR_SHIFT 60
1671/** No Random Number instructions implemented. */
1672# define ARMV8_ID_AA64ISAR0_EL1_RNDR_NOT_IMPL 0
1673/** RNDR and RDNRRS registers are implemented . */
1674# define ARMV8_ID_AA64ISAR0_EL1_RNDR_SUPPORTED 1
1675/** @} */
1676
1677
1678/** @name ID_AA64ISAR1_EL1 - AArch64 Instruction Set Attribute Register 0.
1679 * @{ */
1680/** Bit 0 - 3 - Indicates support for Data Persistence writeback instructions in AArch64 state. */
1681#define ARMV8_ID_AA64ISAR1_EL1_DPB_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
1682#define ARMV8_ID_AA64ISAR1_EL1_DPB_SHIFT 0
1683/** DC CVAP not supported. */
1684# define ARMV8_ID_AA64ISAR1_EL1_DPB_NOT_IMPL 0
1685/** DC CVAP supported (FEAT_DPB). */
1686# define ARMV8_ID_AA64ISAR1_EL1_DPB_SUPPORTED 1
1687/** DC CVAP and DC CVADP supported (FEAT_DPB2). */
1688# define ARMV8_ID_AA64ISAR1_EL1_DPB_SUPPORTED_2 2
1689/** Bit 4 - 7 - Indicates whether QARMA5 algorithm is implemented in the PE for address authentication. */
1690#define ARMV8_ID_AA64ISAR1_EL1_APA_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
1691#define ARMV8_ID_AA64ISAR1_EL1_APA_SHIFT 4
1692/** Address Authentication using the QARMA5 algorithm is not implemented. */
1693# define ARMV8_ID_AA64ISAR1_EL1_APA_NOT_IMPL 0
1694/** Address Authentication using the QARMA5 algorithm is implemented (FEAT_PAuth, FEAT_PACQARMA5). */
1695# define ARMV8_ID_AA64ISAR1_EL1_APA_SUPPORTED_PAUTH 1
1696/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC is supported (FEAT_EPAC, FEAT_PACQARMA5). */
1697# define ARMV8_ID_AA64ISAR1_EL1_APA_SUPPORTED_EPAC 2
1698/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 is supported (FEAT_PAuth2, FEAT_PACQARMA5). */
1699# define ARMV8_ID_AA64ISAR1_EL1_APA_SUPPORTED_PAUTH2 3
1700/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 and FPAC are supported (FEAT_FPAC, FEAT_PACQARMA5). */
1701# define ARMV8_ID_AA64ISAR1_EL1_APA_SUPPORTED_FPAC 4
1702/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 and combined FPAC are supported (FEAT_FPACCOMBINE, FEAT_PACQARMA5). */
1703# define ARMV8_ID_AA64ISAR1_EL1_APA_SUPPORTED_FPACCOMBINE 5
1704/** Bit 8 - 11 - Indicates whether an implementation defined algorithm is implemented in the PE for address authentication. */
1705#define ARMV8_ID_AA64ISAR1_EL1_API_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
1706#define ARMV8_ID_AA64ISAR1_EL1_API_SHIFT 8
1707/** Address Authentication using the QARMA5 algorithm is not implemented. */
1708# define ARMV8_ID_AA64ISAR1_EL1_API_NOT_IMPL 0
1709/** Address Authentication using the QARMA5 algorithm is implemented (FEAT_PAuth, FEAT_PACIMP). */
1710# define ARMV8_ID_AA64ISAR1_EL1_API_SUPPORTED_PAUTH 1
1711/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC is supported (FEAT_EPAC, FEAT_PACIMP). */
1712# define ARMV8_ID_AA64ISAR1_EL1_API_SUPPORTED_EPAC 2
1713/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 is supported (FEAT_PAuth2, FEAT_PACIMP). */
1714# define ARMV8_ID_AA64ISAR1_EL1_API_SUPPORTED_PAUTH2 3
1715/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 and FPAC are supported (FEAT_FPAC, FEAT_PACIMP). */
1716# define ARMV8_ID_AA64ISAR1_EL1_API_SUPPORTED_FPAC 4
1717/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 and combined FPAC are supported (FEAT_FPACCOMBINE, FEAT_PACIMP). */
1718# define ARMV8_ID_AA64ISAR1_EL1_API_SUPPORTED_FPACCOMBINE 5
1719/** Bit 12 - 15 - Indicates support for JavaScript conversion from double precision floating values to integers in AArch64 state. */
1720#define ARMV8_ID_AA64ISAR1_EL1_FJCVTZS_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
1721#define ARMV8_ID_AA64ISAR1_EL1_FJCVTZS_SHIFT 12
1722/** No FJCVTZS instruction implemented. */
1723# define ARMV8_ID_AA64ISAR1_EL1_FJCVTZS_NOT_IMPL 0
1724/** FJCVTZS instruction implemented (FEAT_JSCVT). */
1725# define ARMV8_ID_AA64ISAR1_EL1_FJCVTZS_SUPPORTED 1
1726/** Bit 16 - 19 - Indicates support for CRC32 instructions in AArch64 state. */
1727#define ARMV8_ID_AA64ISAR1_EL1_FCMA_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
1728#define ARMV8_ID_AA64ISAR1_EL1_FCMA_SHIFT 16
1729/** No FCMLA and FCADD instructions implemented. */
1730# define ARMV8_ID_AA64ISAR1_EL1_FCMA_NOT_IMPL 0
1731/** FCMLA and FCADD instructions implemented (FEAT_FCMA). */
1732# define ARMV8_ID_AA64ISAR1_EL1_FCMA_SUPPORTED 1
1733/** Bit 20 - 23 - Indicates support for weaker release consistency, RCpc, based model. */
1734#define ARMV8_ID_AA64ISAR1_EL1_LRCPC_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
1735#define ARMV8_ID_AA64ISAR1_EL1_LRCPC_SHIFT 20
1736/** No RCpc instructions implemented. */
1737# define ARMV8_ID_AA64ISAR1_EL1_LRCPC_NOT_IMPL 0
1738/** The no offset LDAPR, LDAPRB and LDAPRH instructions are implemented (FEAT_LRCPC). */
1739# define ARMV8_ID_AA64ISAR1_EL1_LRCPC_SUPPORTED 1
1740/** The no offset LDAPR, LDAPRB, LDAPRH, LDAPR and STLR instructions are implemented (FEAT_LRCPC2). */
1741# define ARMV8_ID_AA64ISAR1_EL1_LRCPC_SUPPORTED_2 2
1742/** Bit 24 - 27 - Indicates whether the QARMA5 algorithm is implemented in the PE for generic code authentication in AArch64 state. */
1743#define ARMV8_ID_AA64ISAR1_EL1_GPA_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
1744#define ARMV8_ID_AA64ISAR1_EL1_GPA_SHIFT 24
1745/** Generic Authentication using the QARMA5 algorithm is not implemented. */
1746# define ARMV8_ID_AA64ISAR1_EL1_GPA_NOT_IMPL 0
1747/** Generic Authentication using the QARMA5 algorithm is implemented (FEAT_PACQARMA5). */
1748# define ARMV8_ID_AA64ISAR1_EL1_GPA_SUPPORTED 1
1749/** Bit 28 - 31 - Indicates whether an implementation defined algorithm is implemented in the PE for generic code authentication in AArch64 state. */
1750#define ARMV8_ID_AA64ISAR1_EL1_GPI_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
1751#define ARMV8_ID_AA64ISAR1_EL1_GPI_SHIFT 28
1752/** Generic Authentication using an implementation defined algorithm is not implemented. */
1753# define ARMV8_ID_AA64ISAR1_EL1_GPI_NOT_IMPL 0
1754/** Generic Authentication using an implementation defined algorithm is implemented (FEAT_PACIMP). */
1755# define ARMV8_ID_AA64ISAR1_EL1_GPI_SUPPORTED 1
1756/** Bit 32 - 35 - Indicates support for SHA3 instructions in AArch64 state. */
1757#define ARMV8_ID_AA64ISAR1_EL1_FRINTTS_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
1758#define ARMV8_ID_AA64ISAR1_EL1_FRINTTS_SHIFT 32
1759/** FRINT32Z, FRINT32X, FRINT64Z and FRINT64X instructions are not implemented. */
1760# define ARMV8_ID_AA64ISAR1_EL1_FRINTTS_NOT_IMPL 0
1761/** FRINT32Z, FRINT32X, FRINT64Z and FRINT64X instructions are implemented (FEAT_FRINTTS). */
1762# define ARMV8_ID_AA64ISAR1_EL1_FRINTTS_SUPPORTED 1
1763/** Bit 36 - 39 - Indicates support for SB instructions in AArch64 state. */
1764#define ARMV8_ID_AA64ISAR1_EL1_SB_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
1765#define ARMV8_ID_AA64ISAR1_EL1_SB_SHIFT 36
1766/** No SB instructions implemented. */
1767# define ARMV8_ID_AA64ISAR1_EL1_SB_NOT_IMPL 0
1768/** SB instructions implemented (FEAT_SB). */
1769# define ARMV8_ID_AA64ISAR1_EL1_SB_SUPPORTED 1
1770/** Bit 40 - 43 - Indicates support for prediction invalidation instructions in AArch64 state. */
1771#define ARMV8_ID_AA64ISAR1_EL1_SPECRES_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
1772#define ARMV8_ID_AA64ISAR1_EL1_SPECRES_SHIFT 40
1773/** Prediction invalidation instructions are not implemented. */
1774# define ARMV8_ID_AA64ISAR1_EL1_SPECRES_NOT_IMPL 0
1775/** Prediction invalidation instructions are implemented (FEAT_SPECRES). */
1776# define ARMV8_ID_AA64ISAR1_EL1_SPECRES_SUPPORTED 1
1777/** Bit 44 - 47 - Indicates support for Advanced SIMD and Floating-point BFloat16 instructions in AArch64 state. */
1778#define ARMV8_ID_AA64ISAR1_EL1_BF16_MASK (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
1779#define ARMV8_ID_AA64ISAR1_EL1_BF16_SHIFT 44
1780/** BFloat16 instructions are not implemented. */
1781# define ARMV8_ID_AA64ISAR1_EL1_BF16_NOT_IMPL 0
1782/** BFCVT, BFCVTN, BFCVTN2, BFDOT, BFMLALB, BFMLALT and BFMMLA instructions are implemented (FEAT_BF16). */
1783# define ARMV8_ID_AA64ISAR1_EL1_BF16_SUPPORTED_BF16 1
1784/** BFCVT, BFCVTN, BFCVTN2, BFDOT, BFMLALB, BFMLALT and BFMMLA instructions are implemented and FPCR.EBF is supported (FEAT_EBF16). */
1785# define ARMV8_ID_AA64ISAR1_EL1_BF16_SUPPORTED_EBF16 2
1786/** Bit 48 - 51 - Indicates support for Data Gathering Hint instructions. */
1787#define ARMV8_ID_AA64ISAR1_EL1_DGH_MASK (RT_BIT_64(48) | RT_BIT_64(49) | RT_BIT_64(50) | RT_BIT_64(51))
1788#define ARMV8_ID_AA64ISAR1_EL1_DGH_SHIFT 48
1789/** Data Gathering Hint instructions are not implemented. */
1790# define ARMV8_ID_AA64ISAR1_EL1_DGH_NOT_IMPL 0
1791/** Data Gathering Hint instructions are implemented (FEAT_DGH). */
1792# define ARMV8_ID_AA64ISAR1_EL1_DGH_SUPPORTED 1
1793/** Bit 52 - 55 - Indicates support for Advanced SIMD and Floating-point Int8 matri multiplication instructions. */
1794#define ARMV8_ID_AA64ISAR1_EL1_I8MM_MASK (RT_BIT_64(52) | RT_BIT_64(53) | RT_BIT_64(54) | RT_BIT_64(55))
1795#define ARMV8_ID_AA64ISAR1_EL1_I8MM_SHIFT 52
1796/** No Int8 matrix multiplication instructions implemented. */
1797# define ARMV8_ID_AA64ISAR1_EL1_I8MM_NOT_IMPL 0
1798/** SMMLA, SUDOT, UMMLA, USMMLA and USDOT instrutions are implemented (FEAT_I8MM). */
1799# define ARMV8_ID_AA64ISAR1_EL1_I8MM_SUPPORTED 1
1800/** Bit 56 - 59 - Indicates support for the XS attribute, the TLBI and DSB insturctions with the nXS qualifier in AArch64 state. */
1801#define ARMV8_ID_AA64ISAR1_EL1_XS_MASK (RT_BIT_64(56) | RT_BIT_64(57) | RT_BIT_64(58) | RT_BIT_64(59))
1802#define ARMV8_ID_AA64ISAR1_EL1_XS_SHIFT 56
1803/** The XS attribute and the TLBI and DSB instructions with the nXS qualifier are not supported. */
1804# define ARMV8_ID_AA64ISAR1_EL1_XS_NOT_IMPL 0
1805/** The XS attribute and the TLBI and DSB instructions with the nXS qualifier are supported (FEAT_XS). */
1806# define ARMV8_ID_AA64ISAR1_EL1_XS_SUPPORTED 1
1807/** Bit 60 - 63 - Indicates support LD64B and ST64B* instructons and the ACCDATA_EL1 register. */
1808#define ARMV8_ID_AA64ISAR1_EL1_LS64_MASK (RT_BIT_64(60) | RT_BIT_64(61) | RT_BIT_64(62) | RT_BIT_64(63))
1809#define ARMV8_ID_AA64ISAR1_EL1_LS64_SHIFT 60
1810/** The LD64B, ST64B, ST64BV and ST64BV0 instructions, the ACCDATA_EL1 register and associated traps are not supported. */
1811# define ARMV8_ID_AA64ISAR1_EL1_LS64_NOT_IMPL 0
1812/** The LD64B and ST64B instructions are supported (FEAT_LS64). */
1813# define ARMV8_ID_AA64ISAR1_EL1_LS64_SUPPORTED 1
1814/** The LD64B, ST64B, ST64BV and associated traps are not supported (FEAT_LS64_V). */
1815# define ARMV8_ID_AA64ISAR1_EL1_LS64_SUPPORTED_V 2
1816/** The LD64B, ST64B, ST64BV and ST64BV0 instructions, the ACCDATA_EL1 register and associated traps are supported (FEAT_LS64_ACCDATA). */
1817# define ARMV8_ID_AA64ISAR1_EL1_LS64_SUPPORTED_ACCDATA 3
1818/** @} */
1819
1820
1821/** @name ID_AA64ISAR2_EL1 - AArch64 Instruction Set Attribute Register 0.
1822 * @{ */
1823/** Bit 0 - 3 - Indicates support for WFET and WFIT instructions in AArch64 state. */
1824#define ARMV8_ID_AA64ISAR2_EL1_WFXT_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
1825#define ARMV8_ID_AA64ISAR2_EL1_WFXT_SHIFT 0
1826/** WFET and WFIT are not supported. */
1827# define ARMV8_ID_AA64ISAR2_EL1_WFXT_NOT_IMPL 0
1828/** WFET and WFIT are supported (FEAT_WFxT). */
1829# define ARMV8_ID_AA64ISAR2_EL1_WFXT_SUPPORTED 2
1830/** Bit 4 - 7 - Indicates support for 12 bits of mantissa in reciprocal and reciprocal square root instructions in AArch64 state, when FPCR.AH is 1. */
1831#define ARMV8_ID_AA64ISAR2_EL1_RPRES_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
1832#define ARMV8_ID_AA64ISAR2_EL1_RPRES_SHIFT 4
1833/** Reciprocal and reciprocal square root estimates give 8 bits of mantissa when FPCR.AH is 1. */
1834# define ARMV8_ID_AA64ISAR2_EL1_RPRES_NOT_IMPL 0
1835/** Reciprocal and reciprocal square root estimates give 12 bits of mantissa when FPCR.AH is 1 (FEAT_RPRES). */
1836# define ARMV8_ID_AA64ISAR2_EL1_RPRES_SUPPORTED 1
1837/** Bit 8 - 11 - Indicates whether the QARMA3 algorithm is implemented in the PE for generic code authentication in AArch64 state. */
1838#define ARMV8_ID_AA64ISAR2_EL1_GPA3_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
1839#define ARMV8_ID_AA64ISAR2_EL1_GPA3_SHIFT 8
1840/** Generic Authentication using the QARMA3 algorithm is not implemented. */
1841# define ARMV8_ID_AA64ISAR2_EL1_GPA3_NOT_IMPL 0
1842/** Generic Authentication using the QARMA3 algorithm is implemented (FEAT_PACQARMA3). */
1843# define ARMV8_ID_AA64ISAR2_EL1_GPA3_SUPPORTED 1
1844/** Bit 12 - 15 - Indicates whether QARMA3 algorithm is implemented in the PE for address authentication. */
1845#define ARMV8_ID_AA64ISAR2_EL1_APA3_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
1846#define ARMV8_ID_AA64ISAR2_EL1_APA3_SHIFT 12
1847/** Address Authentication using the QARMA3 algorithm is not implemented. */
1848# define ARMV8_ID_AA64ISAR2_EL1_APA3_NOT_IMPL 0
1849/** Address Authentication using the QARMA5 algorithm is implemented (FEAT_PAuth, FEAT_PACQARMA3). */
1850# define ARMV8_ID_AA64ISAR2_EL1_APA3_SUPPORTED_PAUTH 1
1851/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC is supported (FEAT_EPAC, FEAT_PACQARMA3). */
1852# define ARMV8_ID_AA64ISAR2_EL1_APA3_SUPPORTED_EPAC 2
1853/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 is supported (FEAT_PAuth2, FEAT_PACQARMA3). */
1854# define ARMV8_ID_AA64ISAR2_EL1_APA3_SUPPORTED_PAUTH2 3
1855/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 and FPAC are supported (FEAT_FPAC, FEAT_PACQARMA3). */
1856# define ARMV8_ID_AA64ISAR2_EL1_APA3_SUPPORTED_FPAC 4
1857/** Address Authentication using the QARMA5 algorithm is implemented and enhanced PAC 2 and combined FPAC are supported (FEAT_FPACCOMBINE, FEAT_PACQARMA3). */
1858# define ARMV8_ID_AA64ISAR2_EL1_APA3_SUPPORTED_FPACCOMBINE 5
1859/** Bit 16 - 19 - Indicates support for Memory Copy and Memory Set instructions in AArch64 state. */
1860#define ARMV8_ID_AA64ISAR2_EL1_MOPS_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
1861#define ARMV8_ID_AA64ISAR2_EL1_MOPS_SHIFT 16
1862/** No Memory Copy and Memory Set instructions implemented. */
1863# define ARMV8_ID_AA64ISAR2_EL1_MOPS_NOT_IMPL 0
1864/** Memory Copy and Memory Set instructions implemented (FEAT_MOPS). */
1865# define ARMV8_ID_AA64ISAR2_EL1_MOPS_SUPPORTED 1
1866/** Bit 20 - 23 - Indicates support for weaker release consistency, RCpc, based model. */
1867#define ARMV8_ID_AA64ISAR2_EL1_BC_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
1868#define ARMV8_ID_AA64ISAR2_EL1_BC_SHIFT 20
1869/** BC instruction is not implemented. */
1870# define ARMV8_ID_AA64ISAR2_EL1_BC_NOT_IMPL 0
1871/** BC instruction is implemented (FEAT_HBC). */
1872# define ARMV8_ID_AA64ISAR2_EL1_BC_SUPPORTED 1
1873/** Bit 24 - 27 - Indicates whether the ConstPACField() functions used as part of PAC additions returns FALSE or TRUE. */
1874#define ARMV8_ID_AA64ISAR2_EL1_PACFRAC_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
1875#define ARMV8_ID_AA64ISAR2_EL1_PACFRAC_SHIFT 24
1876/** ConstPACField() returns FALSE. */
1877# define ARMV8_ID_AA64ISAR2_EL1_PACFRAC_FALSE 0
1878/** ConstPACField() returns TRUE (FEAT_CONSTPACFIELD). */
1879# define ARMV8_ID_AA64ISAR2_EL1_PACFRAC_TRUE 1
1880/* Bit 28 - 63 - Reserved. */
1881/** @} */
1882
1883
1884/** @name ID_AA64PFR0_EL1 - AArch64 Processor Feature Register 0.
1885 * @{ */
1886/** Bit 0 - 3 - EL0 Exception level handling. */
1887#define ARMV8_ID_AA64PFR0_EL1_EL0_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
1888#define ARMV8_ID_AA64PFR0_EL1_EL0_SHIFT 0
1889/** EL0 can be executed in AArch64 state only. */
1890# define ARMV8_ID_AA64PFR0_EL1_EL0_AARCH64_ONLY 1
1891/** EL0 can be executed in AArch64 and AArch32 state. */
1892# define ARMV8_ID_AA64PFR0_EL1_EL0_AARCH64_AARCH32 2
1893/** Bit 4 - 7 - EL1 Exception level handling. */
1894#define ARMV8_ID_AA64PFR0_EL1_EL1_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
1895#define ARMV8_ID_AA64PFR0_EL1_EL1_SHIFT 4
1896/** EL1 can be executed in AArch64 state only. */
1897# define ARMV8_ID_AA64PFR0_EL1_EL1_AARCH64_ONLY 1
1898/** EL1 can be executed in AArch64 and AArch32 state. */
1899# define ARMV8_ID_AA64PFR0_EL1_EL1_AARCH64_AARCH32 2
1900/** Bit 8 - 11 - EL2 Exception level handling. */
1901#define ARMV8_ID_AA64PFR0_EL1_EL2_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
1902#define ARMV8_ID_AA64PFR0_EL1_EL2_SHIFT 8
1903/** EL2 is not implemented. */
1904# define ARMV8_ID_AA64PFR0_EL1_EL2_NOT_IMPL 0
1905/** EL2 can be executed in AArch64 state only. */
1906# define ARMV8_ID_AA64PFR0_EL1_EL2_AARCH64_ONLY 1
1907/** EL2 can be executed in AArch64 and AArch32 state. */
1908# define ARMV8_ID_AA64PFR0_EL1_EL2_AARCH64_AARCH32 2
1909/** Bit 12 - 15 - EL3 Exception level handling. */
1910#define ARMV8_ID_AA64PFR0_EL1_EL3_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
1911#define ARMV8_ID_AA64PFR0_EL1_EL3_SHIFT 12
1912/** EL3 is not implemented. */
1913# define ARMV8_ID_AA64PFR0_EL1_EL3_NOT_IMPL 0
1914/** EL3 can be executed in AArch64 state only. */
1915# define ARMV8_ID_AA64PFR0_EL1_EL3_AARCH64_ONLY 1
1916/** EL3 can be executed in AArch64 and AArch32 state. */
1917# define ARMV8_ID_AA64PFR0_EL1_EL3_AARCH64_AARCH32 2
1918/** Bit 16 - 19 - Floating-point support. */
1919#define ARMV8_ID_AA64PFR0_EL1_FP_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
1920#define ARMV8_ID_AA64PFR0_EL1_FP_SHIFT 16
1921/** Floating-point is implemented and support single and double precision. */
1922# define ARMV8_ID_AA64PFR0_EL1_FP_IMPL_SP_DP 0
1923/** Floating-point is implemented and support single, double and half precision. */
1924# define ARMV8_ID_AA64PFR0_EL1_FP_IMPL_SP_DP_HP 1
1925/** Floating-point is not implemented. */
1926# define ARMV8_ID_AA64PFR0_EL1_FP_NOT_IMPL 0xf
1927/** Bit 20 - 23 - Advanced SIMD support. */
1928#define ARMV8_ID_AA64PFR0_EL1_ADVSIMD_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
1929#define ARMV8_ID_AA64PFR0_EL1_ADVSIMD_SHIFT 20
1930/** Advanced SIMD is implemented and support single and double precision. */
1931# define ARMV8_ID_AA64PFR0_EL1_ADVSIMD_IMPL_SP_DP 0
1932/** Advanced SIMD is implemented and support single, double and half precision. */
1933# define ARMV8_ID_AA64PFR0_EL1_ADVSIMD_IMPL_SP_DP_HP 1
1934/** Advanced SIMD is not implemented. */
1935# define ARMV8_ID_AA64PFR0_EL1_ADVSIMD_NOT_IMPL 0xf
1936/** Bit 24 - 27 - System register GIC CPU interface support. */
1937#define ARMV8_ID_AA64PFR0_EL1_GIC_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
1938#define ARMV8_ID_AA64PFR0_EL1_GIC_SHIFT 24
1939/** GIC CPU interface system registers are not implemented. */
1940# define ARMV8_ID_AA64PFR0_EL1_GIC_NOT_IMPL 0
1941/** System register interface to versions 3.0 and 4.0 of the GIC CPU interface is supported. */
1942# define ARMV8_ID_AA64PFR0_EL1_GIC_V3_V4 1
1943/** System register interface to version 4.1 of the GIC CPU interface is supported. */
1944# define ARMV8_ID_AA64PFR0_EL1_GIC_V4_1 3
1945/** Bit 28 - 31 - RAS Extension version. */
1946#define ARMV8_ID_AA64PFR0_EL1_RAS_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
1947#define ARMV8_ID_AA64PFR0_EL1_RAS_SHIFT 28
1948/** No RAS extension. */
1949# define ARMV8_ID_AA64PFR0_EL1_RAS_NOT_IMPL 0
1950/** RAS Extension implemented. */
1951# define ARMV8_ID_AA64PFR0_EL1_RAS_SUPPORTED 1
1952/** FEAT_RASv1p1 implemented. */
1953# define ARMV8_ID_AA64PFR0_EL1_RAS_V1P1 2
1954/** Bit 32 - 35 - Scalable Vector Extension (SVE) support. */
1955#define ARMV8_ID_AA64PFR0_EL1_SVE_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
1956#define ARMV8_ID_AA64PFR0_EL1_SVE_SHIFT 32
1957/** SVE is not supported. */
1958# define ARMV8_ID_AA64PFR0_EL1_SVE_NOT_IMPL 0
1959/** SVE is supported. */
1960# define ARMV8_ID_AA64PFR0_EL1_SVE_SUPPORTED 1
1961/** Bit 36 - 39 - Secure EL2 support. */
1962#define ARMV8_ID_AA64PFR0_EL1_SEL2_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
1963#define ARMV8_ID_AA64PFR0_EL1_SEL2_SHIFT 36
1964/** Secure EL2 is not supported. */
1965# define ARMV8_ID_AA64PFR0_EL1_SEL2_NOT_IMPL 0
1966/** Secure EL2 is implemented. */
1967# define ARMV8_ID_AA64PFR0_EL1_SEL2_SUPPORTED 1
1968/** Bit 40 - 43 - MPAM support. */
1969#define ARMV8_ID_AA64PFR0_EL1_MPAM_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
1970#define ARMV8_ID_AA64PFR0_EL1_MPAM_SHIFT 40
1971/** MPAM extension major version number is 0. */
1972# define ARMV8_ID_AA64PFR0_EL1_MPAM_MAJOR_V0 0
1973/** MPAM extension major version number is 1. */
1974# define ARMV8_ID_AA64PFR0_EL1_MPAM_MAJOR_V1 1
1975/** Bit 44 - 47 - Activity Monitor Extension support. */
1976#define ARMV8_ID_AA64PFR0_EL1_AMU_MASK (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
1977#define ARMV8_ID_AA64PFR0_EL1_AMU_SHIFT 44
1978/** Activity Monitor extension is not implemented. */
1979# define ARMV8_ID_AA64PFR0_EL1_AMU_NOT_IMPL 0
1980/** Activity Monitor extension is implemented as of FEAT_AMUv1. */
1981# define ARMV8_ID_AA64PFR0_EL1_AMU_V1 1
1982/** Activity Monitor extension is implemented as of FEAT_AMUv1p1 including virtualization support. */
1983# define ARMV8_ID_AA64PFR0_EL1_AMU_V1P1 2
1984/** Bit 48 - 51 - Data Independent Timing support. */
1985#define ARMV8_ID_AA64PFR0_EL1_DIT_MASK (RT_BIT_64(48) | RT_BIT_64(49) | RT_BIT_64(50) | RT_BIT_64(51))
1986#define ARMV8_ID_AA64PFR0_EL1_DIT_SHIFT 48
1987/** AArch64 does not guarantee constant execution time of any instructions. */
1988# define ARMV8_ID_AA64PFR0_EL1_DIT_NOT_IMPL 0
1989/** AArch64 provides the PSTATE.DIT mechanism to guarantee constant execution time of certain instructions (FEAT_DIT). */
1990# define ARMV8_ID_AA64PFR0_EL1_DIT_SUPPORTED 1
1991/** Bit 52 - 55 - Realm Management Extension support. */
1992#define ARMV8_ID_AA64PFR0_EL1_RME_MASK (RT_BIT_64(52) | RT_BIT_64(53) | RT_BIT_64(54) | RT_BIT_64(55))
1993#define ARMV8_ID_AA64PFR0_EL1_RME_SHIFT 52
1994/** Realm Management Extension not implemented. */
1995# define ARMV8_ID_AA64PFR0_EL1_RME_NOT_IMPL 0
1996/** RMEv1 is implemented (FEAT_RME). */
1997# define ARMV8_ID_AA64PFR0_EL1_RME_SUPPORTED 1
1998/** Bit 56 - 59 - Speculative use out of context branch targets support. */
1999#define ARMV8_ID_AA64PFR0_EL1_CSV2_MASK (RT_BIT_64(56) | RT_BIT_64(57) | RT_BIT_64(58) | RT_BIT_64(59))
2000#define ARMV8_ID_AA64PFR0_EL1_CSV2_SHIFT 56
2001/** Implementation does not disclose whether FEAT_CSV2 is implemented. */
2002# define ARMV8_ID_AA64PFR0_EL1_CSV2_NOT_EXPOSED 0
2003/** FEAT_CSV2 is implemented. */
2004# define ARMV8_ID_AA64PFR0_EL1_CSV2_SUPPORTED 1
2005/** FEAT_CSV2_2 is implemented. */
2006# define ARMV8_ID_AA64PFR0_EL1_CSV2_2_SUPPORTED 2
2007/** FEAT_CSV2_3 is implemented. */
2008# define ARMV8_ID_AA64PFR0_EL1_CSV2_3_SUPPORTED 3
2009/** Bit 60 - 63 - Speculative use of faulting data support. */
2010#define ARMV8_ID_AA64PFR0_EL1_CSV3_MASK (RT_BIT_64(60) | RT_BIT_64(61) | RT_BIT_64(62) | RT_BIT_64(63))
2011#define ARMV8_ID_AA64PFR0_EL1_CSV3_SHIFT 60
2012/** Implementation does not disclose whether data loaded under speculation with a permission or domain fault can be used. */
2013# define ARMV8_ID_AA64PFR0_EL1_CSV3_NOT_EXPOSED 0
2014/** FEAT_CSV3 is supported . */
2015# define ARMV8_ID_AA64PFR0_EL1_CSV3_SUPPORTED 1
2016/** @} */
2017
2018
2019/** @name ID_AA64PFR1_EL1 - AArch64 Processor Feature Register 1.
2020 * @{ */
2021/** Bit 0 - 3 - Branch Target Identification support. */
2022#define ARMV8_ID_AA64PFR1_EL1_BT_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
2023#define ARMV8_ID_AA64PFR1_EL1_BT_SHIFT 0
2024/** The Branch Target Identification mechanism is not implemented. */
2025# define ARMV8_ID_AA64PFR1_EL1_BT_NOT_IMPL 0
2026/** The Branch Target Identifcation mechanism is implemented. */
2027# define ARMV8_ID_AA64PFR1_EL1_BT_SUPPORTED 1
2028/** Bit 4 - 7 - Speculative Store Bypassing control support. */
2029#define ARMV8_ID_AA64PFR1_EL1_SSBS_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
2030#define ARMV8_ID_AA64PFR1_EL1_SSBS_SHIFT 4
2031/** AArch64 provides no mechanism to control the use of Speculative Store Bypassing. */
2032# define ARMV8_ID_AA64PFR1_EL1_SSBS_NOT_IMPL 0
2033/** AArch64 provides the PSTATE.SSBS mechanism to mark regions that are Speculative Store Bypass Safe. */
2034# define ARMV8_ID_AA64PFR1_EL1_SSBS_SUPPORTED 1
2035/** AArch64 provides the PSTATE.SSBS mechanism to mark regions that are Speculative Store Bypass Safe and adds MSR and MRS instructions
2036 * to directly read and write the PSTATE.SSBS field. */
2037# define ARMV8_ID_AA64PFR1_EL1_SSBS_SUPPORTED_MSR_MRS 2
2038/** Bit 8 - 11 - Memory Tagging Extension support. */
2039#define ARMV8_ID_AA64PFR1_EL1_MTE_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
2040#define ARMV8_ID_AA64PFR1_EL1_MTE_SHIFT 8
2041/** MTE is not implemented. */
2042# define ARMV8_ID_AA64PFR1_EL1_MTE_NOT_IMPL 0
2043/** Instruction only Memory Tagging Extensions implemented. */
2044# define ARMV8_ID_AA64PFR1_EL1_MTE_INSN_ONLY 1
2045/** Full Memory Tagging Extension implemented. */
2046# define ARMV8_ID_AA64PFR1_EL1_MTE_FULL 2
2047/** Full Memory Tagging Extension with asymmetric Tag Check Fault handling implemented. */
2048# define ARMV8_ID_AA64PFR1_EL1_MTE_FULL_ASYM_TAG_FAULT_CHK 3
2049/** Bit 12 - 15 - RAS Extension fractional field. */
2050#define ARMV8_ID_AA64PFR1_EL1_RASFRAC_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
2051#define ARMV8_ID_AA64PFR1_EL1_RASFRAC_SHIFT 12
2052/** RAS Extension is implemented. */
2053# define ARMV8_ID_AA64PFR1_EL1_RASFRAC_IMPL 0
2054/** FEAT_RASv1p1 is implemented. */
2055# define ARMV8_ID_AA64PFR1_EL1_RASFRAC_RASV1P1 1
2056/** Bit 16 - 19 - MPAM minor version number. */
2057#define ARMV8_ID_AA64PFR1_EL1_MPAMFRAC_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
2058#define ARMV8_ID_AA64PFR1_EL1_MPAMFRAC_SHIFT 16
2059/** The minor version of number of the MPAM extension is 0. */
2060# define ARMV8_ID_AA64PFR1_EL1_MPAMFRAC_0 0
2061/** The minor version of number of the MPAM extension is 1. */
2062# define ARMV8_ID_AA64PFR1_EL1_MPAMFRAC_1 1
2063/* Bit 20 - 23 - Reserved. */
2064/** Bit 24 - 27 - Scalable Matrix Extension support. */
2065#define ARMV8_ID_AA64PFR1_EL1_SME_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
2066#define ARMV8_ID_AA64PFR1_EL1_SME_SHIFT 24
2067/** Scalable Matrix Extensions are not implemented. */
2068# define ARMV8_ID_AA64PFR1_EL1_SME_NOT_IMPL 0
2069/** Scalable Matrix Extensions are implemented (FEAT_SME). */
2070# define ARMV8_ID_AA64PFR1_EL1_SME_SUPPORTED 1
2071/** Scalable Matrix Extensions are implemented + SME2 ZT0 register(FEAT_SME2). */
2072# define ARMV8_ID_AA64PFR1_EL1_SME_SME2 2
2073/** Bit 28 - 31 - Random Number trap to EL3 support. */
2074#define ARMV8_ID_AA64PFR1_EL1_RNDRTRAP_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
2075#define ARMV8_ID_AA64PFR1_EL1_RNDRTRAP_SHIFT 28
2076/** Trapping of RNDR and RNDRRS to EL3 is not supported. */
2077# define ARMV8_ID_AA64PFR1_EL1_RNDRTRAP_NOT_IMPL 0
2078/** Trapping of RNDR and RDNRRS to EL3 is supported. */
2079# define ARMV8_ID_AA64PFR1_EL1_RNDRTRAP_SUPPORTED 1
2080/** Bit 32 - 35 - CSV2 fractional field. */
2081#define ARMV8_ID_AA64PFR1_EL1_CSV2FRAC_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
2082#define ARMV8_ID_AA64PFR1_EL1_CSV2FRAC_SHIFT 32
2083/** Either CSV2 not exposed or implementation does not expose whether FEAT_CSV2_1p1 is implemented. */
2084# define ARMV8_ID_AA64PFR1_EL1_CSV2FRAC_NOT_EXPOSED 0
2085/** FEAT_CSV2_1p1 is implemented. */
2086# define ARMV8_ID_AA64PFR1_EL1_CSV2FRAC_1P1 1
2087/** FEAT_CSV2_1p2 is implemented. */
2088# define ARMV8_ID_AA64PFR1_EL1_CSV2FRAC_1P2 2
2089/** Bit 36 - 39 - Non-maskable Interrupt support. */
2090#define ARMV8_ID_AA64PFR1_EL1_NMI_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
2091#define ARMV8_ID_AA64PFR1_EL1_NMI_SHIFT 36
2092/** SCTLR_ELx.{SPINTMASK, NMI} and PSTATE.ALLINT and associated instructions are not supported. */
2093# define ARMV8_ID_AA64PFR1_EL1_NMI_NOT_IMPL 0
2094/** SCTLR_ELx.{SPINTMASK, NMI} and PSTATE.ALLINT and associated instructions are supported (FEAT_NMI). */
2095# define ARMV8_ID_AA64PFR1_EL1_NMI_SUPPORTED 1
2096/** @} */
2097
2098
2099/** @name ID_AA64MMFR0_EL1 - AArch64 Memory Model Feature Register 0.
2100 * @{ */
2101/** Bit 0 - 3 - Physical Address range supported. */
2102#define ARMV8_ID_AA64MMFR0_EL1_PARANGE_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
2103#define ARMV8_ID_AA64MMFR0_EL1_PARANGE_SHIFT 0
2104/** Physical Address range is 32 bits, 4GiB. */
2105# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_32BITS 0
2106/** Physical Address range is 36 bits, 64GiB. */
2107# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_36BITS 1
2108/** Physical Address range is 40 bits, 1TiB. */
2109# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_40BITS 2
2110/** Physical Address range is 42 bits, 4TiB. */
2111# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_42BITS 3
2112/** Physical Address range is 44 bits, 16TiB. */
2113# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_44BITS 4
2114/** Physical Address range is 48 bits, 256TiB. */
2115# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_48BITS 5
2116/** Physical Address range is 52 bits, 4PiB. */
2117# define ARMV8_ID_AA64MMFR0_EL1_PARANGE_52BITS 6
2118/** Bit 4 - 7 - Number of ASID bits. */
2119#define ARMV8_ID_AA64MMFR0_EL1_ASIDBITS_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
2120#define ARMV8_ID_AA64MMFR0_EL1_ASIDBITS_SHIFT 4
2121/** ASID bits is 8. */
2122# define ARMV8_ID_AA64MMFR0_EL1_ASIDBITS_8 0
2123/** ASID bits is 16. */
2124# define ARMV8_ID_AA64MMFR0_EL1_ASIDBITS_16 2
2125/** Bit 8 - 11 - Indicates support for mixed-endian configuration. */
2126#define ARMV8_ID_AA64MMFR0_EL1_BIGEND_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
2127#define ARMV8_ID_AA64MMFR0_EL1_BIGEND_SHIFT 8
2128/** No mixed-endian support. */
2129# define ARMV8_ID_AA64MMFR0_EL1_BIGEND_NOT_IMPL 0
2130/** Mixed-endian supported. */
2131# define ARMV8_ID_AA64MMFR0_EL1_BIGEND_SUPPORTED 1
2132/** Bit 12 - 15 - Indicates support for a distinction between Secure and Non-secure Memory. */
2133#define ARMV8_ID_AA64MMFR0_EL1_SNSMEM_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
2134#define ARMV8_ID_AA64MMFR0_EL1_SNSMEM_SHIFT 12
2135/** No distinction between Secure and Non-secure Memory supported. */
2136# define ARMV8_ID_AA64MMFR0_EL1_SNSMEM_NOT_IMPL 0
2137/** Distinction between Secure and Non-secure Memory supported. */
2138# define ARMV8_ID_AA64MMFR0_EL1_SNSMEM_SUPPORTED 1
2139/** Bit 16 - 19 - Indicates support for mixed-endian at EL0 only. */
2140#define ARMV8_ID_AA64MMFR0_EL1_BIGENDEL0_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
2141#define ARMV8_ID_AA64MMFR0_EL1_BIGENDEL0_SHIFT 16
2142/** No mixed-endian support at EL0. */
2143# define ARMV8_ID_AA64MMFR0_EL1_BIGENDEL0_NOT_IMPL 0
2144/** Mixed-endian support at EL0. */
2145# define ARMV8_ID_AA64MMFR0_EL1_BIGENDEL0_SUPPORTED 1
2146/** Bit 20 - 23 - Indicates support for 16KiB memory translation granule size. */
2147#define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
2148#define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_SHIFT 20
2149/** 16KiB granule size not supported. */
2150# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_NOT_IMPL 0
2151/** 16KiB granule size is supported. */
2152# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_SUPPORTED 1
2153/** 16KiB granule size is supported and supports 52-bit input addresses and can describe 52-bit output addresses (FEAT_LPA2). */
2154# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_SUPPORTED_52BIT 2
2155/** Bit 24 - 27 - Indicates support for 64KiB memory translation granule size. */
2156#define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
2157#define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_SHIFT 24
2158/** 64KiB granule supported. */
2159# define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_SUPPORTED 0
2160/** 64KiB granule not supported. */
2161# define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_NOT_IMPL 0xf
2162/** Bit 28 - 31 - Indicates support for 4KiB memory translation granule size. */
2163#define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
2164#define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_SHIFT 28
2165/** 4KiB granule supported. */
2166# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_SUPPORTED 0
2167/** 4KiB granule size is supported and supports 52-bit input addresses and can describe 52-bit output addresses (FEAT_LPA2). */
2168# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_SUPPORTED_52BIT 1
2169/** 4KiB granule not supported. */
2170# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_NOT_IMPL 0xf
2171/** Bit 32 - 35 - Indicates support for 16KiB granule size at stage 2. */
2172#define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_2_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
2173#define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_2_SHIFT 32
2174/** Support for 16KiB granule at stage 2 is identified in the ID_AA64MMFR0_EL1.TGran16 field. */
2175# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_2_SUPPORT_BY_TGRAN16 0
2176/** 16KiB granule not supported at stage 2. */
2177# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_2_NOT_IMPL 1
2178/** 16KiB granule supported at stage 2. */
2179# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_2_SUPPORTED 2
2180/** 16KiB granule supported at stage 2 and supports 52-bit input addresses and can describe 52-bit output addresses (FEAT_LPA2). */
2181# define ARMV8_ID_AA64MMFR0_EL1_TGRAN16_2_SUPPORTED_52BIT 3
2182/** Bit 36 - 39 - Indicates support for 64KiB granule size at stage 2. */
2183#define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_2_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
2184#define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_2_SHIFT 36
2185/** Support for 64KiB granule at stage 2 is identified in the ID_AA64MMFR0_EL1.TGran64 field. */
2186# define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_2_SUPPORT_BY_TGRAN64 0
2187/** 64KiB granule not supported at stage 2. */
2188# define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_2_NOT_IMPL 1
2189/** 64KiB granule supported at stage 2. */
2190# define ARMV8_ID_AA64MMFR0_EL1_TGRAN64_2_SUPPORTED 2
2191/** Bit 40 - 43 - Indicates HCRX_EL2 and its associated EL3 trap support. */
2192#define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_2_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
2193#define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_2_SHIFT 40
2194/** Support for 4KiB granule at stage 2 is identified in the ID_AA64MMFR0_EL1.TGran4 field. */
2195# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_2_SUPPORT_BY_TGRAN16 0
2196/** 4KiB granule not supported at stage 2. */
2197# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_2_NOT_IMPL 1
2198/** 4KiB granule supported at stage 2. */
2199# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_2_SUPPORTED 2
2200/** 4KiB granule supported at stage 2 and supports 52-bit input addresses and can describe 52-bit output addresses (FEAT_LPA2). */
2201# define ARMV8_ID_AA64MMFR0_EL1_TGRAN4_2_SUPPORTED_52BIT 3
2202/** Bit 44 - 47 - Indicates support for disabling context synchronizing exception entry and exit. */
2203#define ARMV8_ID_AA64MMFR0_EL1_EXS_MASK (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
2204#define ARMV8_ID_AA64MMFR0_EL1_EXS_SHIFT 44
2205/** All exception entries and exits are context synchronization events. */
2206# define ARMV8_ID_AA64MMFR0_EL1_EXS_NOT_IMPL 0
2207/** Non-context synchronizing exception entry and exit are supported (FEAT_ExS). */
2208# define ARMV8_ID_AA64MMFR0_EL1_EXS_SUPPORTED 1
2209/* Bit 48 - 55 - Reserved. */
2210/** Bit 56 - 59 - Indicates the presence of the Fine-Grained Trap controls. */
2211#define ARMV8_ID_AA64MMFR0_EL1_FGT_MASK (RT_BIT_64(56) | RT_BIT_64(57) | RT_BIT_64(58) | RT_BIT_64(59))
2212#define ARMV8_ID_AA64MMFR0_EL1_FGT_SHIFT 56
2213/** Fine-grained trap controls are not implemented. */
2214# define ARMV8_ID_AA64MMFR0_EL1_FGT_NOT_IMPL 0
2215/** Fine-grained trap controls are implemented (FEAT_FGT). */
2216# define ARMV8_ID_AA64MMFR0_EL1_FGT_SUPPORTED 1
2217/** Bit 60 - 63 - Indicates the presence of Enhanced Counter Virtualization. */
2218#define ARMV8_ID_AA64MMFR0_EL1_ECV_MASK (RT_BIT_64(60) | RT_BIT_64(61) | RT_BIT_64(62) | RT_BIT_64(63))
2219#define ARMV8_ID_AA64MMFR0_EL1_ECV_SHIFT 60
2220/** Enhanced Counter Virtualization is not implemented. */
2221# define ARMV8_ID_AA64MMFR0_EL1_ECV_NOT_IMPL 0
2222/** Enhanced Counter Virtualization is implemented (FEAT_ECV). */
2223# define ARMV8_ID_AA64MMFR0_EL1_ECV_SUPPORTED 1
2224/** Enhanced Counter Virtualization is implemented and includes support for CNTHCTL_EL2.ECV and CNTPOFF_EL2 (FEAT_ECV). */
2225# define ARMV8_ID_AA64MMFR0_EL1_ECV_SUPPORTED_2 2
2226/** @} */
2227
2228
2229/** @name ID_AA64MMFR1_EL1 - AArch64 Memory Model Feature Register 1.
2230 * @{ */
2231/** Bit 0 - 3 - Hardware updates to Access flag and Dirty state in translation tables. */
2232#define ARMV8_ID_AA64MMFR1_EL1_HAFDBS_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
2233#define ARMV8_ID_AA64MMFR1_EL1_HAFDBS_SHIFT 0
2234/** Hardware update of the Access flag and dirty state are not supported. */
2235# define ARMV8_ID_AA64MMFR1_EL1_HAFDBS_NOT_IMPL 0
2236/** Support for hardware update of the Access flag for Block and Page descriptors. */
2237# define ARMV8_ID_AA64MMFR1_EL1_HAFDBS_SUPPORTED 1
2238/** Support for hardware update of the Access flag for Block and Page descriptors, hardware update of dirty state supported. */
2239# define ARMV8_ID_AA64MMFR1_EL1_HAFDBS_DIRTY_SUPPORTED 2
2240/** Bit 4 - 7 - EL1 Exception level handling. */
2241#define ARMV8_ID_AA64MMFR1_EL1_VMIDBITS_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
2242#define ARMV8_ID_AA64MMFR1_EL1_VMIDBITS_SHIFT 4
2243/** VMID bits is 8. */
2244# define ARMV8_ID_AA64MMFR1_EL1_VMIDBITS_8 0
2245/** VMID bits is 16 (FEAT_VMID16). */
2246# define ARMV8_ID_AA64MMFR1_EL1_VMIDBITS_16 2
2247/** Bit 8 - 11 - Virtualization Host Extensions support. */
2248#define ARMV8_ID_AA64MMFR1_EL1_VHE_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
2249#define ARMV8_ID_AA64MMFR1_EL1_VHE_SHIFT 8
2250/** Virtualization Host Extensions are not supported. */
2251# define ARMV8_ID_AA64MMFR1_EL1_VHE_NOT_IMPL 0
2252/** Virtualization Host Extensions are supported. */
2253# define ARMV8_ID_AA64MMFR1_EL1_VHE_SUPPORTED 1
2254/** Bit 12 - 15 - Hierarchical Permission Disables. */
2255#define ARMV8_ID_AA64MMFR1_EL1_HPDS_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
2256#define ARMV8_ID_AA64MMFR1_EL1_HPDS_SHIFT 12
2257/** Disabling of hierarchical controls not supported. */
2258# define ARMV8_ID_AA64MMFR1_EL1_HPDS_NOT_IMPL 0
2259/** Disabling of hierarchical controls supported (FEAT_HPDS). */
2260# define ARMV8_ID_AA64MMFR1_EL1_HPDS_SUPPORTED 1
2261/** FEAT_HPDS + possible hardware allocation of bits[62:59] of the translation table descriptors from the final lookup level (FEAT_HPDS2). */
2262# define ARMV8_ID_AA64MMFR1_EL1_HPDS_SUPPORTED_2 2
2263/** Bit 16 - 19 - LORegions support. */
2264#define ARMV8_ID_AA64MMFR1_EL1_LO_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
2265#define ARMV8_ID_AA64MMFR1_EL1_LO_SHIFT 16
2266/** LORegions not supported. */
2267# define ARMV8_ID_AA64MMFR1_EL1_LO_NOT_IMPL 0
2268/** LORegions supported. */
2269# define ARMV8_ID_AA64MMFR1_EL1_LO_SUPPORTED 1
2270/** Bit 20 - 23 - Privileged Access Never support. */
2271#define ARMV8_ID_AA64MMFR1_EL1_PAN_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
2272#define ARMV8_ID_AA64MMFR1_EL1_PAN_SHIFT 20
2273/** PAN not supported. */
2274# define ARMV8_ID_AA64MMFR1_EL1_PAN_NOT_IMPL 0
2275/** PAN supported (FEAT_PAN). */
2276# define ARMV8_ID_AA64MMFR1_EL1_PAN_SUPPORTED 1
2277/** PAN supported and AT S1E1RP and AT S1E1WP instructions supported (FEAT_PAN2). */
2278# define ARMV8_ID_AA64MMFR1_EL1_PAN_SUPPORTED_2 2
2279/** PAN supported and AT S1E1RP and AT S1E1WP instructions and SCTRL_EL1.EPAN and SCTRL_EL2.EPAN supported (FEAT_PAN3). */
2280# define ARMV8_ID_AA64MMFR1_EL1_PAN_SUPPORTED_3 3
2281/** Bit 24 - 27 - Describes whether the PE can generate SError interrupt exceptions. */
2282#define ARMV8_ID_AA64MMFR1_EL1_SPECSEI_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
2283#define ARMV8_ID_AA64MMFR1_EL1_SPECSEI_SHIFT 24
2284/** The PE never generates an SError interrupt due to an External abort on a speculative read. */
2285# define ARMV8_ID_AA64MMFR1_EL1_SPECSEI_NOT_IMPL 0
2286/** The PE might generate an SError interrupt due to an External abort on a speculative read. */
2287# define ARMV8_ID_AA64MMFR1_EL1_SPECSEI_SUPPORTED 1
2288/** Bit 28 - 31 - Indicates support for execute-never control distinction by Exception level at stage 2. */
2289#define ARMV8_ID_AA64MMFR1_EL1_XNX_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
2290#define ARMV8_ID_AA64MMFR1_EL1_XNX_SHIFT 28
2291/** Distinction between EL0 and EL1 execute-never control at stage 2 not supported. */
2292# define ARMV8_ID_AA64MMFR1_EL1_XNX_NOT_IMPL 0
2293/** Distinction between EL0 and EL1 execute-never control at stage 2 supported (FEAT_XNX). */
2294# define ARMV8_ID_AA64MMFR1_EL1_XNX_SUPPORTED 1
2295/** Bit 32 - 35 - Indicates support for the configurable delayed trapping of WFE. */
2296#define ARMV8_ID_AA64MMFR1_EL1_TWED_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
2297#define ARMV8_ID_AA64MMFR1_EL1_TWED_SHIFT 32
2298/** Configurable delayed trapping of WFE is not supported. */
2299# define ARMV8_ID_AA64MMFR1_EL1_TWED_NOT_IMPL 0
2300/** Configurable delayed trapping of WFE is supported (FEAT_TWED). */
2301# define ARMV8_ID_AA64MMFR1_EL1_TWED_SUPPORTED 1
2302/** Bit 36 - 39 - Indicates support for Enhanced Translation Synchronization. */
2303#define ARMV8_ID_AA64MMFR1_EL1_ETS_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
2304#define ARMV8_ID_AA64MMFR1_EL1_ETS_SHIFT 36
2305/** Enhanced Translation Synchronization is not supported. */
2306# define ARMV8_ID_AA64MMFR1_EL1_ETS_NOT_IMPL 0
2307/** Enhanced Translation Synchronization is implemented. */
2308# define ARMV8_ID_AA64MMFR1_EL1_ETS_SUPPORTED 1
2309/** Bit 40 - 43 - Indicates HCRX_EL2 and its associated EL3 trap support. */
2310#define ARMV8_ID_AA64MMFR1_EL1_HCX_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
2311#define ARMV8_ID_AA64MMFR1_EL1_HCX_SHIFT 40
2312/** HCRX_EL2 and its associated EL3 trap are not supported. */
2313# define ARMV8_ID_AA64MMFR1_EL1_HCX_NOT_IMPL 0
2314/** HCRX_EL2 and its associated EL3 trap are supported (FEAT_HCX). */
2315# define ARMV8_ID_AA64MMFR1_EL1_HCX_SUPPORTED 1
2316/** Bit 44 - 47 - Indicates support for FPCR.{AH,FIZ,NEP}. */
2317#define ARMV8_ID_AA64MMFR1_EL1_AFP_MASK (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
2318#define ARMV8_ID_AA64MMFR1_EL1_AFP_SHIFT 44
2319/** The FPCR.{AH,FIZ,NEP} fields are not supported. */
2320# define ARMV8_ID_AA64MMFR1_EL1_AFP_NOT_IMPL 0
2321/** The FPCR.{AH,FIZ,NEP} fields are supported (FEAT_AFP). */
2322# define ARMV8_ID_AA64MMFR1_EL1_AFP_SUPPORTED 1
2323/** Bit 48 - 51 - Indicates support for intermediate caching of translation table walks. */
2324#define ARMV8_ID_AA64MMFR1_EL1_NTLBPA_MASK (RT_BIT_64(48) | RT_BIT_64(49) | RT_BIT_64(50) | RT_BIT_64(51))
2325#define ARMV8_ID_AA64MMFR1_EL1_NTLBPA_SHIFT 48
2326/** The intermediate caching of translation table walks might include non-coherent physical translation caches. */
2327# define ARMV8_ID_AA64MMFR1_EL1_NTLBPA_INCLUDE_NON_COHERENT 0
2328/** The intermediate caching of translation table walks does not include non-coherent physical translation caches (FEAT_nTLBPA). */
2329# define ARMV8_ID_AA64MMFR1_EL1_NTLBPA_INCLUDE_COHERENT_ONLY 1
2330/** Bit 52 - 55 - Indicates whether SCTLR_EL1.TIDCP and SCTLR_EL2.TIDCP are implemented in AArch64 state. */
2331#define ARMV8_ID_AA64MMFR1_EL1_TIDCP1_MASK (RT_BIT_64(52) | RT_BIT_64(53) | RT_BIT_64(54) | RT_BIT_64(55))
2332#define ARMV8_ID_AA64MMFR1_EL1_TIDCP1_SHIFT 52
2333/** SCTLR_EL1.TIDCP and SCTLR_EL2.TIDCP bits are not implemented. */
2334# define ARMV8_ID_AA64MMFR1_EL1_TIDCP1_NOT_IMPL 0
2335/** SCTLR_EL1.TIDCP and SCTLR_EL2.TIDCP bits are implemented (FEAT_TIDCP1). */
2336# define ARMV8_ID_AA64MMFR1_EL1_TIDCP1_SUPPORTED 1
2337/** Bit 56 - 59 - Indicates support for cache maintenance instruction permission. */
2338#define ARMV8_ID_AA64MMFR1_EL1_CMOW_MASK (RT_BIT_64(56) | RT_BIT_64(57) | RT_BIT_64(58) | RT_BIT_64(59))
2339#define ARMV8_ID_AA64MMFR1_EL1_CMOW_SHIFT 56
2340/** SCTLR_EL1.CMOW, SCTLR_EL2.CMOW and HCRX_EL2.CMOW bits are not implemented. */
2341# define ARMV8_ID_AA64MMFR1_EL1_CMOW_NOT_IMPL 0
2342/** SCTLR_EL1.CMOW, SCTLR_EL2.CMOW and HCRX_EL2.CMOW bits are implemented (FEAT_CMOW). */
2343# define ARMV8_ID_AA64MMFR1_EL1_CMOW_SUPPORTED 1
2344/* Bit 60 - 63 - Reserved. */
2345/** @} */
2346
2347
2348/** @name ID_AA64MMFR2_EL1 - AArch64 Memory Model Feature Register 2.
2349 * @{ */
2350/** Bit 0 - 3 - Indicates support for Common not Private translations. */
2351#define ARMV8_ID_AA64MMFR2_EL1_CNP_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
2352#define ARMV8_ID_AA64MMFR2_EL1_CNP_SHIFT 0
2353/** Common not Private translations are not supported. */
2354# define ARMV8_ID_AA64MMFR2_EL1_CNP_NOT_IMPL 0
2355/** Support for Common not Private translations (FEAT_TTNCP). */
2356# define ARMV8_ID_AA64MMFR2_EL1_CNP_SUPPORTED 1
2357/** Bit 4 - 7 - Indicates support for User Access Override. */
2358#define ARMV8_ID_AA64MMFR2_EL1_UAO_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
2359#define ARMV8_ID_AA64MMFR2_EL1_UAO_SHIFT 4
2360/** User Access Override is not supported. */
2361# define ARMV8_ID_AA64MMFR2_EL1_UAO_NOT_IMPL 0
2362/** User Access Override is supported (FEAT_UAO). */
2363# define ARMV8_ID_AA64MMFR2_EL1_UAO_SUPPORTED 1
2364/** Bit 8 - 11 - Indicates support for LSMAOE and nTLSMD bits in SCTLR_ELx. */
2365#define ARMV8_ID_AA64MMFR2_EL1_LSM_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
2366#define ARMV8_ID_AA64MMFR2_EL1_LSM_SHIFT 8
2367/** LSMAOE and nTLSMD bits are not supported. */
2368# define ARMV8_ID_AA64MMFR2_EL1_LSM_NOT_IMPL 0
2369/** LSMAOE and nTLSMD bits are supported (FEAT_LSMAOC). */
2370# define ARMV8_ID_AA64MMFR2_EL1_LSM_SUPPORTED 1
2371/** Bit 12 - 15 - Indicates support for the IESB bit in SCTLR_ELx registers. */
2372#define ARMV8_ID_AA64MMFR2_EL1_IESB_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
2373#define ARMV8_ID_AA64MMFR2_EL1_IESB_SHIFT 12
2374/** IESB bit is not supported. */
2375# define ARMV8_ID_AA64MMFR2_EL1_IESB_NOT_IMPL 0
2376/** IESB bit is supported (FEAT_IESB). */
2377# define ARMV8_ID_AA64MMFR2_EL1_IESB_SUPPORTED 1
2378/** Bit 16 - 19 - Indicates support for larger virtual address. */
2379#define ARMV8_ID_AA64MMFR2_EL1_VARANGE_MASK (RT_BIT_64(16) | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
2380#define ARMV8_ID_AA64MMFR2_EL1_VARANGE_SHIFT 16
2381/** Virtual address range is 48 bits. */
2382# define ARMV8_ID_AA64MMFR2_EL1_VARANGE_48BITS 0
2383/** 52 bit virtual addresses supported for 64KiB granules (FEAT_LVA). */
2384# define ARMV8_ID_AA64MMFR2_EL1_VARANGE_52BITS_64KB_GRAN 1
2385/** Bit 20 - 23 - Revised CCSIDR_EL1 register format supported. */
2386#define ARMV8_ID_AA64MMFR2_EL1_CCIDX_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
2387#define ARMV8_ID_AA64MMFR2_EL1_CCIDX_SHIFT 20
2388/** CCSIDR_EL1 register format is 32-bit. */
2389# define ARMV8_ID_AA64MMFR2_EL1_CCIDX_32BIT 0
2390/** CCSIDR_EL1 register format is 64-bit (FEAT_CCIDX). */
2391# define ARMV8_ID_AA64MMFR2_EL1_CCIDX_64BIT 1
2392/** Bit 24 - 27 - Indicates support for nested virtualization. */
2393#define ARMV8_ID_AA64MMFR2_EL1_NV_MASK (RT_BIT_64(24) | RT_BIT_64(25) | RT_BIT_64(26) | RT_BIT_64(27))
2394#define ARMV8_ID_AA64MMFR2_EL1_NV_SHIFT 24
2395/** Nested virtualization is not supported. */
2396# define ARMV8_ID_AA64MMFR2_EL1_NV_NOT_IMPL 0
2397/** The HCR_EL2.{AT,NV1,NV} bits are implemented (FEAT_NV). */
2398# define ARMV8_ID_AA64MMFR2_EL1_NV_SUPPORTED 1
2399/** The VNCR_EL2 register and HCR_EL2.{NV2,AT,NV1,NV} bits are implemented (FEAT_NV2). */
2400# define ARMV8_ID_AA64MMFR2_EL1_NV_SUPPORTED_2 2
2401/** Bit 28 - 31 - Indicates support for small translation tables. */
2402#define ARMV8_ID_AA64MMFR2_EL1_ST_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
2403#define ARMV8_ID_AA64MMFR2_EL1_ST_SHIFT 28
2404/** The maximum value of TCR_ELx.{T0SZ,T1SZ} is 39. */
2405# define ARMV8_ID_AA64MMFR2_EL1_ST_NOT_IMPL 0
2406/** The maximum value of TCR_ELx.{T0SZ,T1SZ} is 48 for 4KiB and 16KiB, and 47 for 64KiB granules (FEAT_TTST). */
2407# define ARMV8_ID_AA64MMFR2_EL1_ST_SUPPORTED 1
2408/** Bit 32 - 35 - Indicates support for unaligned single-copy atomicity and atomic functions. */
2409#define ARMV8_ID_AA64MMFR2_EL1_AT_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
2410#define ARMV8_ID_AA64MMFR2_EL1_AT_SHIFT 32
2411/** Unaligned single-copy atomicity and atomic functions are not supported. */
2412# define ARMV8_ID_AA64MMFR2_EL1_AT_NOT_IMPL 0
2413/** Unaligned single-copy atomicity and atomic functions are supported (FEAT_LSE2). */
2414# define ARMV8_ID_AA64MMFR2_EL1_AT_SUPPORTED 1
2415/** Bit 36 - 39 - Indicates value of ESR_ELx.EC that reports an exception generated by a read access to the feature ID space. */
2416#define ARMV8_ID_AA64MMFR2_EL1_IDS_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
2417#define ARMV8_ID_AA64MMFR2_EL1_IDS_SHIFT 36
2418/** ESR_ELx.EC is 0 for traps generated by a read access to the feature ID space. */
2419# define ARMV8_ID_AA64MMFR2_EL1_IDS_EC_0 0
2420/** ESR_ELx.EC is 0x18 for traps generated by a read access to the feature ID space (FEAT_IDST). */
2421# define ARMV8_ID_AA64MMFR2_EL1_IDS_EC_18H 1
2422/** Bit 40 - 43 - Indicates support for the HCR_EL2.FWB bit. */
2423#define ARMV8_ID_AA64MMFR2_EL1_FWB_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
2424#define ARMV8_ID_AA64MMFR2_EL1_FWB_SHIFT 40
2425/** HCR_EL2.FWB bit is not supported. */
2426# define ARMV8_ID_AA64MMFR2_EL1_FWB_NOT_IMPL 0
2427/** HCR_EL2.FWB bit is supported (FEAT_S2FWB). */
2428# define ARMV8_ID_AA64MMFR2_EL1_FWB_SUPPORTED 1
2429/* Bit 44 - 47 - Reserved. */
2430/** Bit 48 - 51 - Indicates support for TTL field in address operations. */
2431#define ARMV8_ID_AA64MMFR2_EL1_TTL_MASK (RT_BIT_64(48) | RT_BIT_64(49) | RT_BIT_64(50) | RT_BIT_64(51))
2432#define ARMV8_ID_AA64MMFR2_EL1_TTL_SHIFT 48
2433/** TLB maintenance instructions by address have bits [47:44] Res0. */
2434# define ARMV8_ID_AA64MMFR2_EL1_TTL_NOT_IMPL 0
2435/** TLB maintenance instructions by address have bits [47:44] holding the TTL field (FEAT_TTL). */
2436# define ARMV8_ID_AA64MMFR2_EL1_TTL_SUPPORTED 1
2437/** Bit 52 - 55 - Identification of the hardware requirements of the hardware to have break-before-make sequences when
2438 * changing block size for a translation. */
2439#define ARMV8_ID_AA64MMFR2_EL1_BBM_MASK (RT_BIT_64(52) | RT_BIT_64(53) | RT_BIT_64(54) | RT_BIT_64(55))
2440#define ARMV8_ID_AA64MMFR2_EL1_BBM_SHIFT 52
2441/** Level 0 support for changing block size is supported (FEAT_BBM). */
2442# define ARMV8_ID_AA64MMFR2_EL1_BBM_LVL0 0
2443/** Level 1 support for changing block size is supported (FEAT_BBM). */
2444# define ARMV8_ID_AA64MMFR2_EL1_BBM_LVL1 1
2445/** Level 2 support for changing block size is supported (FEAT_BBM). */
2446# define ARMV8_ID_AA64MMFR2_EL1_BBM_LVL2 2
2447/** Bit 56 - 59 - Indicates support for Enhanced Virtualization Traps. */
2448#define ARMV8_ID_AA64MMFR2_EL1_EVT_MASK (RT_BIT_64(56) | RT_BIT_64(57) | RT_BIT_64(58) | RT_BIT_64(59))
2449#define ARMV8_ID_AA64MMFR2_EL1_EVT_SHIFT 56
2450/** Enhanced Virtualization Traps are not supported. */
2451# define ARMV8_ID_AA64MMFR2_EL1_EVT_NOT_IMPL 0
2452/** Enhanced Virtualization Traps are supported (FEAT_EVT). */
2453# define ARMV8_ID_AA64MMFR2_EL1_EVT_SUPPORTED 1
2454/** Enhanced Virtualization Traps are supported with additional traps (FEAT_EVT). */
2455# define ARMV8_ID_AA64MMFR2_EL1_EVT_SUPPORTED_2 2
2456/** Bit 60 - 63 - Indicates support for E0PDx mechanism. */
2457#define ARMV8_ID_AA64MMFR2_EL1_E0PD_MASK (RT_BIT_64(60) | RT_BIT_64(61) | RT_BIT_64(62) | RT_BIT_64(63))
2458#define ARMV8_ID_AA64MMFR2_EL1_E0PD_SHIFT 60
2459/** E0PDx mechanism is not supported. */
2460# define ARMV8_ID_AA64MMFR2_EL1_E0PD_NOT_IMPL 0
2461/** E0PDx mechanism is supported (FEAT_E0PD). */
2462# define ARMV8_ID_AA64MMFR2_EL1_E0PD_SUPPORTED 1
2463/** @} */
2464
2465
2466/** @name ID_AA64DFR0_EL1 - AArch64 Debug Feature Register 0.
2467 * @{ */
2468/** Bit 0 - 3 - Indicates the Debug Architecture version supported. */
2469#define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_MASK (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
2470#define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_SHIFT 0
2471/** Armv8 debug architecture version. */
2472# define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_ARMV8 6
2473/** Armv8 debug architecture version with virtualization host extensions. */
2474# define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_ARMV8_VHE 7
2475/** Armv8.2 debug architecture version (FEAT_Debugv8p2). */
2476# define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_ARMV8p2 8
2477/** Armv8.4 debug architecture version (FEAT_Debugv8p4). */
2478# define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_ARMV8p4 9
2479/** Armv8.8 debug architecture version (FEAT_Debugv8p8). */
2480# define ARMV8_ID_AA64DFR0_EL1_DEBUGVER_ARMV8p8 10
2481/** Bit 4 - 7 - Indicates trace support. */
2482#define ARMV8_ID_AA64DFR0_EL1_TRACEVER_MASK (RT_BIT_64(4) | RT_BIT_64(5) | RT_BIT_64(6) | RT_BIT_64(7))
2483#define ARMV8_ID_AA64DFR0_EL1_TRACEVER_SHIFT 4
2484/** Trace unit System registers not implemented. */
2485# define ARMV8_ID_AA64DFR0_EL1_TRACEVER_NOT_IMPL 0
2486/** Trace unit System registers supported. */
2487# define ARMV8_ID_AA64DFR0_EL1_TRACEVER_SUPPORTED 1
2488/** Bit 8 - 11 - Performance Monitors Extension version. */
2489#define ARMV8_ID_AA64DFR0_EL1_PMUVER_MASK (RT_BIT_64(8) | RT_BIT_64(9) | RT_BIT_64(10) | RT_BIT_64(11))
2490#define ARMV8_ID_AA64DFR0_EL1_PMUVER_SHIFT 8
2491/** Performance Monitors Extension not supported. */
2492# define ARMV8_ID_AA64DFR0_EL1_PMUVER_NOT_IMPL 0
2493/** Performance Monitors Extension v3 supported (FEAT_PMUv3). */
2494# define ARMV8_ID_AA64DFR0_EL1_PMUVER_SUPPORTED_V3 1
2495/** Performance Monitors Extension v3 supported (FEAT_PMUv3p1). */
2496# define ARMV8_ID_AA64DFR0_EL1_PMUVER_SUPPORTED_V3P1 4
2497/** Performance Monitors Extension v3 supported (FEAT_PMUv3p4). */
2498# define ARMV8_ID_AA64DFR0_EL1_PMUVER_SUPPORTED_V3P4 5
2499/** Performance Monitors Extension v3 supported (FEAT_PMUv3p5). */
2500# define ARMV8_ID_AA64DFR0_EL1_PMUVER_SUPPORTED_V3P5 6
2501/** Performance Monitors Extension v3 supported (FEAT_PMUv3p7). */
2502# define ARMV8_ID_AA64DFR0_EL1_PMUVER_SUPPORTED_V3P7 7
2503/** Performance Monitors Extension v3 supported (FEAT_PMUv3p8). */
2504# define ARMV8_ID_AA64DFR0_EL1_PMUVER_SUPPORTED_V3P8 8
2505/** Bit 12 - 15 - Number of breakpoints, minus 1. */
2506#define ARMV8_ID_AA64DFR0_EL1_BRPS_MASK (RT_BIT_64(12) | RT_BIT_64(13) | RT_BIT_64(14) | RT_BIT_64(15))
2507#define ARMV8_ID_AA64DFR0_EL1_BRPS_SHIFT 12
2508/* Bit 16 - 19 - Reserved 0. */
2509/** Bit 20 - 23 - Number of watchpoints, minus 1. */
2510#define ARMV8_ID_AA64DFR0_EL1_WRPS_MASK (RT_BIT_64(20) | RT_BIT_64(21) | RT_BIT_64(22) | RT_BIT_64(23))
2511#define ARMV8_ID_AA64DFR0_EL1_WRPS_SHIFT 20
2512/* Bit 24 - 27 - Reserved 0. */
2513/** Bit 28 - 31 - Number of context-aware breakpoints. */
2514#define ARMV8_ID_AA64DFR0_EL1_CTXCMPS_MASK (RT_BIT_64(28) | RT_BIT_64(29) | RT_BIT_64(30) | RT_BIT_64(31))
2515#define ARMV8_ID_AA64DFR0_EL1_CTXCMPS_SHIFT 28
2516/** Bit 32 - 35 - Statistical Profiling Extension version. */
2517#define ARMV8_ID_AA64DFR0_EL1_PMSVER_MASK (RT_BIT_64(32) | RT_BIT_64(33) | RT_BIT_64(34) | RT_BIT_64(35))
2518#define ARMV8_ID_AA64DFR0_EL1_PMSVER_SHIFT 32
2519/** Statistical Profiling Extension not implemented. */
2520# define ARMV8_ID_AA64DFR0_EL1_PMSVER_NOT_IMPL 0
2521/** Statistical Profiling Extension supported (FEAT_SPE). */
2522# define ARMV8_ID_AA64DFR0_EL1_PMSVER_SUPPORTED 1
2523/** Statistical Profiling Extension supported, version 1.1 (FEAT_SPEv1p1). */
2524# define ARMV8_ID_AA64DFR0_EL1_PMSVER_SUPPORTED_V1P1 2
2525/** Statistical Profiling Extension supported, version 1.2 (FEAT_SPEv1p2). */
2526# define ARMV8_ID_AA64DFR0_EL1_PMSVER_SUPPORTED_V1P2 3
2527/** Statistical Profiling Extension supported, version 1.2 (FEAT_SPEv1p3). */
2528# define ARMV8_ID_AA64DFR0_EL1_PMSVER_SUPPORTED_V1P3 4
2529/** Bit 36 - 39 - OS Double Lock implemented. */
2530#define ARMV8_ID_AA64DFR0_EL1_DOUBLELOCK_MASK (RT_BIT_64(36) | RT_BIT_64(37) | RT_BIT_64(38) | RT_BIT_64(39))
2531#define ARMV8_ID_AA64DFR0_EL1_DOUBLELOCK_SHIFT 36
2532/** OS Double Lock is not implemented. */
2533# define ARMV8_ID_AA64DFR0_EL1_DOUBLELOCK_NOT_IMPL 0xf
2534/** OS Double Lock is supported (FEAT_DoubleLock). */
2535# define ARMV8_ID_AA64DFR0_EL1_DOUBLELOCK_SUPPORTED 0
2536/** Bit 40 - 43 - Indicates the Armv8.4 self-hosted Trace Extension. */
2537#define ARMV8_ID_AA64DFR0_EL1_TRACEFILT_MASK (RT_BIT_64(40) | RT_BIT_64(41) | RT_BIT_64(42) | RT_BIT_64(43))
2538#define ARMV8_ID_AA64DFR0_EL1_TRACEFILT_SHIFT 40
2539/** Armv8.4 self-hosted Trace Extension not implemented. */
2540# define ARMV8_ID_AA64DFR0_EL1_TRACEFILT_NOT_IMPL 0
2541/** Armv8.4 self-hosted Trace Extension is supported (FEAT_TRF). */
2542# define ARMV8_ID_AA64DFR0_EL1_TRACEFILT_SUPPORTED 1
2543/** Bit 44 - 47 - Indicates support for the Trace Buffer Extension. */
2544#define ARMV8_ID_AA64DFR0_EL1_TRACEBUFFER_MASK (RT_BIT_64(44) | RT_BIT_64(45) | RT_BIT_64(46) | RT_BIT_64(47))
2545#define ARMV8_ID_AA64DFR0_EL1_TRACEBUFFER_SHIFT 44
2546/** Trace Buffer Extension is not implemented. */
2547# define ARMV8_ID_AA64DFR0_EL1_TRACEBUFFER_NOT_IMPL 0
2548/** Trace Buffer Extension is supported (FEAT_TRBE). */
2549# define ARMV8_ID_AA64DFR0_EL1_TRACEBUFFER_SUPPORTED 1
2550/** Bit 48 - 51 - Indicates support for the multi-threaded PMU extension. */
2551#define ARMV8_ID_AA64DFR0_EL1_MTPMU_MASK (RT_BIT_64(48) | RT_BIT_64(49) | RT_BIT_64(50) | RT_BIT_64(51))
2552#define ARMV8_ID_AA64DFR0_EL1_MTPMU_SHIFT 48
2553/** Multi-threaded PMU extension is not implemented. */
2554# define ARMV8_ID_AA64DFR0_EL1_MTPMU_NOT_IMPL 0
2555/** Multi-threaded PMU extension is supported (FEAT_MTPMU). */
2556# define ARMV8_ID_AA64DFR0_EL1_MTPMU_SUPPORTED 1
2557/** Multi-threaded PMU extension is not implemented. */
2558# define ARMV8_ID_AA64DFR0_EL1_MTPMU_NOT_IMPL_2 0xf
2559/** Bit 52 - 55 - Indicates support for the Branch Record Buffer extension. */
2560#define ARMV8_ID_AA64DFR0_EL1_BRBE_MASK (RT_BIT_64(52) | RT_BIT_64(53) | RT_BIT_64(54) | RT_BIT_64(55))
2561#define ARMV8_ID_AA64DFR0_EL1_BRBE_SHIFT 52
2562/** Branch Record Buffer extension is not implemented. */
2563# define ARMV8_ID_AA64DFR0_EL1_BRBE_NOT_IMPL 0
2564/** Branch Record Buffer extension is supported (FEAT_BRBE). */
2565# define ARMV8_ID_AA64DFR0_EL1_BRBE_SUPPORTED 1
2566/** Branch Record Buffer extension is supported and supports branch recording at EL3 (FEAT_BRBEv1p1). */
2567# define ARMV8_ID_AA64DFR0_EL1_BRBE_SUPPORTED_V1P1 2
2568/* Bit 56 - 59 - Reserved. */
2569/** Bit 60 - 63 - Indicates support for Zero PMU event counters for guest operating systems. */
2570#define ARMV8_ID_AA64DFR0_EL1_HPMN0_MASK (RT_BIT_64(60) | RT_BIT_64(61) | RT_BIT_64(62) | RT_BIT_64(63))
2571#define ARMV8_ID_AA64DFR0_EL1_HPMN0_SHIFT 60
2572/** Setting MDCE_EL2.HPMN to zero has CONSTRAINED UNPREDICTABLE behavior. */
2573# define ARMV8_ID_AA64DFR0_EL1_HPMN0_NOT_IMPL 0
2574/** Setting MDCE_EL2.HPMN to zero has defined behavior (FEAT_HPMN0). */
2575# define ARMV8_ID_AA64DFR0_EL1_HPMN0_SUPPORTED 1
2576/** @} */
2577
2578
2579/** @name FPCR - AArch64 Floating Point Control Register.
2580 * @{ */
2581/** Bit 0 - Flush Inputs to Zero when FEAT_AFP is supported. */
2582#define ARMV8_FPCR_FIZ RT_BIT_64(0)
2583#define ARMV8_FPCR_FIZ_BIT 0
2584/** Bit 1 - Alternate Handling of floating-point numbers when FEAT_AFP is supported. */
2585#define ARMV8_FPCR_AH RT_BIT_64(1)
2586#define ARMV8_FPCR_AH_BIT 1
2587/** Bit 2 - Controls how the output elements other than the lowest element of the vector are determined for
2588 * Advanced SIMD scalar instructions, when FEAT_AFP is supported. */
2589#define ARMV8_FPCR_NEP RT_BIT_64(2)
2590#define ARMV8_FPCR_NEP_BIT 2
2591/* Bit 3 - 7 - Reserved.*/
2592/** Bit 8 - Invalid Operation floating-point exception trap enable. */
2593#define ARMV8_FPCR_IOE RT_BIT_64(8)
2594#define ARMV8_FPCR_IOE_BIT 8
2595/** Bit 9 - Divide by Zero floating-point exception trap enable. */
2596#define ARMV8_FPCR_DZE RT_BIT_64(9)
2597#define ARMV8_FPCR_DZE_BIT 9
2598/** Bit 10 - Overflow floating-point exception trap enable. */
2599#define ARMV8_FPCR_OFE RT_BIT_64(10)
2600#define ARMV8_FPCR_OFE_BIT 10
2601/** Bit 11 - Underflow floating-point exception trap enable. */
2602#define ARMV8_FPCR_UFE RT_BIT_64(11)
2603#define ARMV8_FPCR_UFE_BIT 11
2604/** Bit 12 - Inexact floating-point exception trap enable. */
2605#define ARMV8_FPCR_IXE RT_BIT_64(12)
2606#define ARMV8_FPCR_IXE_BIT 12
2607/** Bit 13 - Controls numeric behavior of BFloat16 dot productions calculations performed,
2608 * supported when FEAT_EBF16 is supported. */
2609#define ARMV8_FPCR_EBF RT_BIT_64(13)
2610#define ARMV8_FPCR_EBF_BIT 13
2611/* Bit 14 - Reserved */
2612/** Bit 15 - Input Denormal floating-point exception trap enable. */
2613#define ARMV8_FPCR_IDE RT_BIT_64(15)
2614#define ARMV8_FPCR_IDE_BIT 15
2615/* Bit 16 - 18 - Reserved for AArch64 (Len field for AArch32). */
2616/** Bit 19 - Flushing denormalized numbers to zero control bit on half-precision data-processing instructions,
2617 * available when FEAT_FP16 is supported. */
2618#define ARMV8_FPCR_FZ16 RT_BIT_64(19)
2619#define ARMV8_FPCR_FZ16_BIT 19
2620/* Bit 20 - 21 - Reserved for AArch64 (Stride field dor AArch32). */
2621/** Bit 22 - 23 - Rounding Mode control field. */
2622#define ARMV8_FPCR_RMODE_MASK (RT_BIT_64(22) | RT_BIT_64(23))
2623#define ARMV8_FPCR_RMODE_SHIFT 22
2624/** Round to Nearest (RN) mode. */
2625# define ARMV8_FPCR_RMODE_RN 0
2626/** Round towards Plus Infinity (RP) mode. */
2627# define ARMV8_FPCR_RMODE_RP 1
2628/** Round towards Minus Infinity (RM) mode. */
2629# define ARMV8_FPCR_RMODE_RM 2
2630/** Round towards Zero (RZ) mode. */
2631# define ARMV8_FPCR_RMODE_RZ 3
2632/** Bit 24 - Flushing denormalized numbers to zero control bit. */
2633#define ARMV8_FPCR_FZ RT_BIT_64(24)
2634#define ARMV8_FPCR_FZ_BIT 24
2635/** Bit 25 - Default NaN use for NaN propagation. */
2636#define ARMV8_FPCR_DN RT_BIT_64(25)
2637#define ARMV8_FPCR_DN_BIT 25
2638/** Bit 26 - Alternative half-precision control bit. */
2639#define ARMV8_FPCR_AHP RT_BIT_64(26)
2640#define ARMV8_FPCR_AHP_BIT 26
2641/* Bit 27 - 63 - Reserved. */
2642/** @} */
2643
2644
2645/** @name FPSR - AArch64 Floating Point Status Register.
2646 * @{ */
2647/** Bit 0 - Invalid Operation cumulative floating-point exception bit. */
2648#define ARMV8_FPSR_IOC RT_BIT_64(0)
2649/** Bit 1 - Divide by Zero cumulative floating-point exception bit. */
2650#define ARMV8_FPSR_DZC RT_BIT_64(1)
2651/** Bit 2 - Overflow cumulative floating-point exception bit. */
2652#define ARMV8_FPSR_OFC RT_BIT_64(2)
2653/** Bit 3 - Underflow cumulative floating-point exception bit. */
2654#define ARMV8_FPSR_UFC RT_BIT_64(3)
2655/** Bit 4 - Inexact cumulative floating-point exception bit. */
2656#define ARMV8_FPSR_IXC RT_BIT_64(4)
2657/* Bit 5 - 6 - Reserved. */
2658/** Bit 7 - Input Denormal cumulative floating-point exception bit. */
2659#define ARMV8_FPSR_IDC RT_BIT_64(7)
2660/* Bit 8 - 26 - Reserved. */
2661/** Bit 27 - Cumulative saturation bit, Advanced SIMD only. */
2662#define ARMV8_FPSR_QC RT_BIT_64(27)
2663/* Bit 28 - 31 - NZCV bits for AArch32 floating point operations. */
2664/* Bit 32 - 63 - Reserved. */
2665/** @} */
2666
2667
2668
2669/** @name SCTLR_EL1 - AArch64 System Control Register (EL1).
2670 * @{ */
2671/** Bit 0 - MMU enable for EL1 and EL0 stage 1 address translation. */
2672#define ARMV8_SCTLR_EL1_M RT_BIT_64(0)
2673/** Bit 1 - Alignment check enable for EL1 and EL0. */
2674#define ARMV8_SCTLR_EL1_A RT_BIT_64(1)
2675/** Bit 2 - Stage 1 cacheability control, for data accesses. */
2676#define ARMV8_SCTLR_EL1_C RT_BIT_64(2)
2677/** Bit 3 - SP alignment check enable. */
2678#define ARMV8_SCTLR_EL1_SA RT_BIT_64(3)
2679/** Bit 4 - SP alignment check enable for EL0. */
2680#define ARMV8_SCTLR_EL1_SA0 RT_BIT_64(4)
2681/** Bit 5 - System instruction memory barrier enable from AArch32 EL0. */
2682#define ARMV8_SCTLR_EL1_CP15BEN RT_BIT_64(5)
2683/** Bit 6 - Non-aligned access enable. */
2684#define ARMV8_SCTLR_EL1_nAA RT_BIT_64(6)
2685/** Bit 7 - IT disable, disables some uses of IT instructions at EL0 using AArch32. */
2686#define ARMV8_SCTLR_EL1_ITD RT_BIT_64(7)
2687/** Bit 8 - SETEND instruction disable, disables SETEND instructions at EL0 using AArch32. */
2688#define ARMV8_SCTLR_EL1_SED RT_BIT_64(8)
2689/** Bit 9 - User Mask Access. Traps EL0 execution of MSR and MRS instructions that access the PSTATE.{D,A,I,F} masks to EL1. */
2690#define ARMV8_SCTLR_EL1_UMA RT_BIT_64(9)
2691/** Bit 10 - Enable EL0 acccess to the CFP*, DVP* and CPP* instructions if FEAT_SPECRES is supported. */
2692#define ARMV8_SCTLR_EL1_EnRCTX RT_BIT_64(10)
2693/** Bit 11 - Exception Exit is Context Synchronizing (FEAT_ExS required). */
2694#define ARMV8_SCTLR_EL1_EOS RT_BIT_64(11)
2695/** Bit 12 - Stage 1 instruction access cacheability control, for access at EL0 and EL1. */
2696#define ARMV8_SCTLR_EL1_I RT_BIT_64(12)
2697/** @todo Finish (lazy developer). */
2698/** @} */
2699
2700
2701/** @name SCTLR_EL2 - AArch64 System Control Register (EL2) - 32-bit.
2702 * @{ */
2703/** Bit 0 - MMU enable for EL2. */
2704#define ARMV8_SCTLR_EL2_M RT_BIT_64(0)
2705/** Bit 1 - Alignment check enable. */
2706#define ARMV8_SCTLR_EL2_A RT_BIT_64(1)
2707/** Bit 2 - Global enable for data and unified caches. */
2708#define ARMV8_SCTLR_EL2_C RT_BIT_64(2)
2709/** Bit 3 - SP alignment check enable. */
2710#define ARMV8_SCTLR_EL2_SA RT_BIT_64(3)
2711/* Bit 4 - 11 - Reserved. */
2712/** Bit 12 - Instruction cache enable. */
2713#define ARMV8_SCTLR_EL2_I RT_BIT_64(12)
2714/* Bit 13 - 18 - Reserved. */
2715/** Bit 19 - Force treatment of all memory regions with write permissions as XN. */
2716#define ARMV8_SCTLR_EL2_WXN RT_BIT_64(19)
2717/* Bit 20 - 24 - Reserved. */
2718/** Bit 25 - Exception endianess - set means big endian, clear little endian. */
2719#define ARMV8_SCTLR_EL2_EE RT_BIT_64(25)
2720/* Bit 26 - 31 - Reserved. */
2721/** @} */
2722
2723
2724#if (!defined(VBOX_FOR_DTRACE_LIB) && defined(__cplusplus) && !defined(ARMV8_WITHOUT_MK_INSTR)) || defined(DOXYGEN_RUNNING)
2725/** @defgroup grp_rt_armv8_mkinstr Instruction Encoding Helpers
2726 * @ingroup grp_rt_armv8
2727 *
2728 * A few inlined functions and macros for assiting in encoding common ARMv8
2729 * instructions.
2730 *
2731 * @{ */
2732
2733/** A64: Official NOP instruction. */
2734#define ARMV8_A64_INSTR_NOP UINT32_C(0xd503201f)
2735/** A64: Return instruction. */
2736#define ARMV8_A64_INSTR_RET UINT32_C(0xd65f03c0)
2737/** A64: Return instruction with LR pointer authentication using SP and key A. */
2738#define ARMV8_A64_INSTR_RETAA UINT32_C(0xd65f0bff)
2739/** A64: Return instruction with LR pointer authentication using SP and key B. */
2740#define ARMV8_A64_INSTR_RETAB UINT32_C(0xd65f0fff)
2741/** A64: Insert pointer authentication code into X17 using X16 and key B. */
2742#define ARMV8_A64_INSTR_PACIB1716 UINT32_C(0xd503215f)
2743/** A64: Insert pointer authentication code into LR using SP and key B. */
2744#define ARMV8_A64_INSTR_PACIBSP UINT32_C(0xd503237f)
2745/** A64: Insert pointer authentication code into LR using XZR and key B. */
2746#define ARMV8_A64_INSTR_PACIBZ UINT32_C(0xd503235f)
2747/** A64: Invert the carry flag (PSTATE.C). */
2748#define ARMV8_A64_INSTR_CFINV UINT32_C(0xd500401f)
2749
2750
2751/** Memory barrier: Shareability domain. */
2752typedef enum
2753{
2754 kArm64InstMbReqDomain_OuterShareable = 0,
2755 kArm64InstMbReqDomain_Nonshareable,
2756 kArm64InstMbReqDomain_InnerShareable,
2757 kArm64InstMbReqDomain_FullSystem
2758} ARM64INSTRMBREQDOMAIN;
2759
2760/** Memory barrier: Access type. */
2761typedef enum
2762{
2763 kArm64InstMbReqType_All0 = 0, /**< Special. Only used with PSSBB and SSBB. */
2764 kArm64InstMbReqType_Reads,
2765 kArm64InstMbReqType_Writes,
2766 kArm64InstMbReqType_All
2767} ARM64INSTRMBREQTYPE;
2768
2769/**
2770 * A64: DMB option
2771 */
2772DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrDmb(ARM64INSTRMBREQDOMAIN enmDomain = kArm64InstMbReqDomain_FullSystem,
2773 ARM64INSTRMBREQTYPE enmType = kArm64InstMbReqType_All)
2774{
2775 return UINT32_C(0xd50330bf)
2776 | ((uint32_t)enmDomain << 8)
2777 | ((uint32_t)enmType << 10);
2778}
2779
2780
2781/**
2782 * A64: DSB option
2783 */
2784DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrDsb(ARM64INSTRMBREQDOMAIN enmDomain = kArm64InstMbReqDomain_FullSystem,
2785 ARM64INSTRMBREQTYPE enmType = kArm64InstMbReqType_All)
2786{
2787 return UINT32_C(0xd503309f)
2788 | ((uint32_t)enmDomain << 8)
2789 | ((uint32_t)enmType << 10);
2790}
2791
2792
2793/**
2794 * A64: SSBB
2795 */
2796DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSsbb(void)
2797{
2798 return Armv8A64MkInstrDsb(kArm64InstMbReqDomain_OuterShareable, kArm64InstMbReqType_All0);
2799}
2800
2801
2802/**
2803 * A64: PSSBB
2804 */
2805DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrPSsbb(void)
2806{
2807 return Armv8A64MkInstrDsb(kArm64InstMbReqDomain_Nonshareable, kArm64InstMbReqType_All0);
2808}
2809
2810
2811/**
2812 * A64: ISB option
2813 *
2814 * @note Only the default option selection is supported, all others are
2815 * currently reserved.
2816 */
2817DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrIsb(ARM64INSTRMBREQDOMAIN enmDomain = kArm64InstMbReqDomain_FullSystem,
2818 ARM64INSTRMBREQTYPE enmType = kArm64InstMbReqType_All)
2819{
2820 return UINT32_C(0xd50330df)
2821 | ((uint32_t)enmDomain << 8)
2822 | ((uint32_t)enmType << 10);
2823}
2824
2825
2826typedef enum
2827{
2828 /** Add @a iImm7*sizeof(reg) to @a iBaseReg after the store/load,
2829 * and update the register. */
2830 kArm64InstrStLdPairType_PostIndex = 1,
2831 /** Add @a iImm7*sizeof(reg) to @a iBaseReg before the store/load,
2832 * but don't update the register. */
2833 kArm64InstrStLdPairType_Signed = 2,
2834 /** Add @a iImm7*sizeof(reg) to @a iBaseReg before the store/load,
2835 * and update the register. */
2836 kArm64InstrStLdPairType_PreIndex = 3
2837} ARM64INSTRSTLDPAIRTYPE;
2838
2839/**
2840 * A64: Encodes either stp (store register pair) or ldp (load register pair).
2841 *
2842 * @returns The encoded instruction.
2843 * @param fLoad true for ldp, false of stp.
2844 * @param u2Opc When @a fSimdFp is @c false:
2845 * - 0 for 32-bit GPRs (Wt).
2846 * - 1 for encoding stgp or ldpsw.
2847 * - 2 for 64-bit GRPs (Xt).
2848 * - 3 illegal.
2849 * When @a fSimdFp is @c true:
2850 * - 0 for 32-bit SIMD&FP registers (St).
2851 * - 1 for 64-bit SIMD&FP registers (Dt).
2852 * - 2 for 128-bit SIMD&FP regsiters (Qt).
2853 * @param enmType The instruction variant wrt addressing and updating of the
2854 * addressing register.
2855 * @param iReg1 The first register to store/load.
2856 * @param iReg2 The second register to store/load.
2857 * @param iBaseReg The base register to use when addressing. SP is allowed.
2858 * @param iImm7 Signed addressing immediate value scaled, range -64..63,
2859 * will be multiplied by the register size.
2860 * @param fSimdFp true for SIMD&FP registers, false for GPRs and
2861 * stgp/ldpsw instructions.
2862 */
2863DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStLdPair(bool fLoad, uint32_t u2Opc, ARM64INSTRSTLDPAIRTYPE enmType,
2864 uint32_t iReg1, uint32_t iReg2, uint32_t iBaseReg, int32_t iImm7 = 0,
2865 bool fSimdFp = false)
2866{
2867 Assert(u2Opc < 3); Assert(iReg1 <= 31); Assert(iReg2 <= 31); Assert(iBaseReg <= 31); Assert(iImm7 < 64 && iImm7 >= -64);
2868 return (u2Opc << 30)
2869 | UINT32_C(0x28000000) /* 0b101000000000000000000000000000 */
2870 | ((uint32_t)fSimdFp << 26) /* VR bit, see "Top-level encodings for A64" */
2871 | ((uint32_t)enmType << 23)
2872 | ((uint32_t)fLoad << 22)
2873 | (((uint32_t)iImm7 & UINT32_C(0x7f)) << 15)
2874 | (iReg2 << 10)
2875 | (iBaseReg << 5)
2876 | iReg1;
2877}
2878
2879
2880/** A64: ldp x1, x2, [x3] */
2881DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLdPairGpr(uint32_t iReg1, uint32_t iReg2, uint32_t iBaseReg, int32_t iImm7 = 0,
2882 ARM64INSTRSTLDPAIRTYPE enmType = kArm64InstrStLdPairType_Signed,
2883 bool f64Bit = true)
2884{
2885 return Armv8A64MkInstrStLdPair(true /*fLoad*/, f64Bit ? 2 : 0, enmType, iReg1, iReg2, iBaseReg, iImm7);
2886}
2887
2888
2889/** A64: stp x1, x2, [x3] */
2890DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStPairGpr(uint32_t iReg1, uint32_t iReg2, uint32_t iBaseReg, int32_t iImm7 = 0,
2891 ARM64INSTRSTLDPAIRTYPE enmType = kArm64InstrStLdPairType_Signed,
2892 bool f64Bit = true)
2893{
2894 return Armv8A64MkInstrStLdPair(false /*fLoad*/, f64Bit ? 2 : 0, enmType, iReg1, iReg2, iBaseReg, iImm7);
2895}
2896
2897
2898typedef enum /* Size VR Opc */
2899{ /* \ | / */
2900 kArmv8A64InstrLdStType_Mask_Size = 0x300,
2901 kArmv8A64InstrLdStType_Mask_VR = 0x010,
2902 kArmv8A64InstrLdStType_Mask_Opc = 0x003,
2903 kArmv8A64InstrLdStType_Shift_Size = 8,
2904 kArmv8A64InstrLdStType_Shift_VR = 4,
2905 kArmv8A64InstrLdStType_Shift_Opc = 0,
2906
2907 kArmv8A64InstrLdStType_St_Byte = 0x000,
2908 kArmv8A64InstrLdStType_Ld_Byte = 0x001,
2909 kArmv8A64InstrLdStType_Ld_SignByte64 = 0x002,
2910 kArmv8A64InstrLdStType_Ld_SignByte32 = 0x003,
2911
2912 kArmv8A64InstrLdStType_St_Half = 0x100, /**< Half = 16-bit */
2913 kArmv8A64InstrLdStType_Ld_Half = 0x101, /**< Half = 16-bit */
2914 kArmv8A64InstrLdStType_Ld_SignHalf64 = 0x102, /**< Half = 16-bit */
2915 kArmv8A64InstrLdStType_Ld_SignHalf32 = 0x103, /**< Half = 16-bit */
2916
2917 kArmv8A64InstrLdStType_St_Word = 0x200, /**< Word = 32-bit */
2918 kArmv8A64InstrLdStType_Ld_Word = 0x201, /**< Word = 32-bit */
2919 kArmv8A64InstrLdStType_Ld_SignWord64 = 0x202, /**< Word = 32-bit */
2920
2921 kArmv8A64InstrLdStType_St_Dword = 0x300, /**< Dword = 64-bit */
2922 kArmv8A64InstrLdStType_Ld_Dword = 0x301, /**< Dword = 64-bit */
2923
2924 kArmv8A64InstrLdStType_Prefetch = 0x302, /**< Not valid in all variations, check docs. */
2925
2926 kArmv8A64InstrLdStType_St_Vr_Byte = 0x010,
2927 kArmv8A64InstrLdStType_Ld_Vr_Byte = 0x011,
2928 kArmv8A64InstrLdStType_St_Vr_128 = 0x012,
2929 kArmv8A64InstrLdStType_Ld_Vr_128 = 0x013,
2930
2931 kArmv8A64InstrLdStType_St_Vr_Half = 0x110, /**< Half = 16-bit */
2932 kArmv8A64InstrLdStType_Ld_Vr_Half = 0x111, /**< Half = 16-bit */
2933
2934 kArmv8A64InstrLdStType_St_Vr_Word = 0x210, /**< Word = 32-bit */
2935 kArmv8A64InstrLdStType_Ld_Vr_Word = 0x211, /**< Word = 32-bit */
2936
2937 kArmv8A64InstrLdStType_St_Vr_Dword = 0x310, /**< Dword = 64-bit */
2938 kArmv8A64InstrLdStType_Ld_Vr_Dword = 0x311 /**< Dword = 64-bit */
2939
2940} ARMV8A64INSTRLDSTTYPE;
2941/** Checks if a ARMV8A64INSTRLDSTTYPE value is a store operation or not. */
2942#define ARMV8A64INSTRLDSTTYPE_IS_STORE(a_enmLdStType) (((unsigned)a_enmLdStType & (unsigned)kArmv8A64InstrLdStType_Mask_Opc) == 0)
2943
2944
2945/**
2946 * A64: Encodes load/store with unscaled 9-bit signed immediate.
2947 *
2948 * @returns The encoded instruction.
2949 * @param u32Opcode The base opcode value.
2950 * @param enmType The load/store instruction type. Prefech valid (PRFUM)
2951 * @param iReg The register to load into / store.
2952 * @param iBaseReg The base register to use when addressing. SP is allowed.
2953 * @param i9ImmDisp The 9-bit signed addressing displacement. Unscaled.
2954 */
2955DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStLdImm9Ex(uint32_t u32Opcode, ARMV8A64INSTRLDSTTYPE enmType,
2956 uint32_t iReg, uint32_t iBaseReg, int32_t i9ImmDisp = 0)
2957{
2958 Assert(i9ImmDisp >= -256 && i9ImmDisp < 256); Assert(iReg < 32); Assert(iBaseReg < 32);
2959 return u32Opcode
2960 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_Size) << (30 - kArmv8A64InstrLdStType_Shift_Size))
2961 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_VR) << (26 - kArmv8A64InstrLdStType_Shift_VR))
2962 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_Opc) << (22 - kArmv8A64InstrLdStType_Shift_Opc))
2963 | (((uint32_t)i9ImmDisp & UINT32_C(0x1ff)) << 12)
2964 | (iBaseReg << 5)
2965 | iReg;
2966}
2967
2968
2969/**
2970 * A64: Encodes load/store with unscaled 9-bit signed immediate.
2971 *
2972 * @returns The encoded instruction.
2973 * @param enmType The load/store instruction type. Prefech valid (PRFUM)
2974 * @param iReg The register to load into / store.
2975 * @param iBaseReg The base register to use when addressing. SP is allowed.
2976 * @param i9ImmDisp The 9-bit signed addressing displacement. Unscaled.
2977 */
2978DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSturLdur(ARMV8A64INSTRLDSTTYPE enmType,
2979 uint32_t iReg, uint32_t iBaseReg, int32_t i9ImmDisp = 0)
2980{
2981 /* 3 2 1 0 */
2982 /* 10987654321098765432109876543210 */
2983 return Armv8A64MkInstrStLdImm9Ex(UINT32_C(0x38000000) /* 0b00111000000000000000000000000000 */,
2984 enmType, iReg, iBaseReg, i9ImmDisp);
2985}
2986
2987/**
2988 * A64: Encodes load/store with unscaled 9-bit signed immediate, post-indexed.
2989 *
2990 * @returns The encoded instruction.
2991 * @param enmType The load/store instruction type. Prefech not valid.
2992 * @param iReg The register to load into / store.
2993 * @param iBaseReg The base register to use when addressing. SP is allowed.
2994 * Written back.
2995 * @param i9ImmDisp The 9-bit signed addressing displacement. Unscaled.
2996 */
2997DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStrLdrPostIndex9(ARMV8A64INSTRLDSTTYPE enmType,
2998 uint32_t iReg, uint32_t iBaseReg, int32_t i9ImmDisp = 0)
2999{
3000 Assert(enmType != kArmv8A64InstrLdStType_Prefetch); /* 3 2 1 0 */
3001 /* 10987654321098765432109876543210 */
3002 return Armv8A64MkInstrStLdImm9Ex(UINT32_C(0x38000400) /* 0b00111000000000000000010000000000 */,
3003 enmType, iReg, iBaseReg, i9ImmDisp);
3004}
3005
3006/**
3007 * A64: Encodes load/store with unscaled 9-bit signed immediate, pre-indexed
3008 *
3009 * @returns The encoded instruction.
3010 * @param enmType The load/store instruction type. Prefech valid (PRFUM)
3011 * @param iReg The register to load into / store.
3012 * @param iBaseReg The base register to use when addressing. SP is allowed.
3013 * Written back.
3014 * @param i9ImmDisp The 9-bit signed addressing displacement. Unscaled.
3015 */
3016DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStrLdrPreIndex9(ARMV8A64INSTRLDSTTYPE enmType,
3017 uint32_t iReg, uint32_t iBaseReg, int32_t i9ImmDisp = 0)
3018{
3019 Assert(enmType != kArmv8A64InstrLdStType_Prefetch); /* 3 2 1 0 */
3020 /* 10987654321098765432109876543210 */
3021 return Armv8A64MkInstrStLdImm9Ex(UINT32_C(0x38000c00) /* 0b00111000000000000000110000000000 */,
3022 enmType, iReg, iBaseReg, i9ImmDisp);
3023}
3024
3025/**
3026 * A64: Encodes unprivileged load/store with unscaled 9-bit signed immediate.
3027 *
3028 * @returns The encoded instruction.
3029 * @param enmType The load/store instruction type. Prefech not valid,
3030 * nor any SIMD&FP variants.
3031 * @param iReg The register to load into / store.
3032 * @param iBaseReg The base register to use when addressing. SP is allowed.
3033 * @param i9ImmDisp The 9-bit signed addressing displacement. Unscaled.
3034 */
3035DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSttrLdtr(ARMV8A64INSTRLDSTTYPE enmType,
3036 uint32_t iReg, uint32_t iBaseReg, int32_t i9ImmDisp = 0)
3037{
3038 Assert(enmType != kArmv8A64InstrLdStType_Prefetch);
3039 Assert(!((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_VR));
3040 /* 3 2 1 0 */
3041 /* 10987654321098765432109876543210 */
3042 return Armv8A64MkInstrStLdImm9Ex(UINT32_C(0x38000800) /* 0b00111000000000000000100000000000 */,
3043 enmType, iReg, iBaseReg, i9ImmDisp);
3044}
3045
3046
3047/**
3048 * A64: Encodes load/store w/ scaled 12-bit unsigned address displacement.
3049 *
3050 * @returns The encoded instruction.
3051 * @param enmType The load/store instruction type. Prefech not valid,
3052 * nor any SIMD&FP variants.
3053 * @param iReg The register to load into / store.
3054 * @param iBaseReg The base register to use when addressing. SP is allowed.
3055 * @param u12ImmDisp Addressing displacement, scaled by size.
3056 */
3057DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStLdRUOff(ARMV8A64INSTRLDSTTYPE enmType,
3058 uint32_t iReg, uint32_t iBaseReg, uint32_t u12ImmDisp)
3059{
3060 Assert(u12ImmDisp < 4096U);
3061 Assert(iReg < 32); /* 3 2 1 0 */
3062 Assert(iBaseReg < 32); /* 10987654321098765432109876543210 */
3063 return UINT32_C(0x39000000) /* 0b00111001000000000000000000000000 */
3064 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_Size) << (30 - kArmv8A64InstrLdStType_Shift_Size))
3065 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_VR) << (26 - kArmv8A64InstrLdStType_Shift_VR))
3066 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_Opc) << (22 - kArmv8A64InstrLdStType_Shift_Opc))
3067 | (u12ImmDisp << 10)
3068 | (iBaseReg << 5)
3069 | iReg;
3070}
3071
3072typedef enum
3073{
3074 kArmv8A64InstrLdStExtend_Uxtw = 2, /**< Zero-extend (32-bit) word. */
3075 kArmv8A64InstrLdStExtend_Lsl = 3, /**< Shift left (64-bit). */
3076 kArmv8A64InstrLdStExtend_Sxtw = 6, /**< Sign-extend (32-bit) word. */
3077 kArmv8A64InstrLdStExtend_Sxtx = 7 /**< Sign-extend (64-bit) dword (to 128-bit SIMD&FP reg, presumably). */
3078} ARMV8A64INSTRLDSTEXTEND;
3079
3080/**
3081 * A64: Encodes load/store w/ index register.
3082 *
3083 * @returns The encoded instruction.
3084 * @param enmType The load/store instruction type.
3085 * @param iReg The register to load into / store.
3086 * @param iBaseReg The base register to use when addressing. SP is allowed.
3087 * @param iRegIndex The index register.
3088 * @param enmExtend The extending to apply to @a iRegIndex.
3089 * @param fShifted Whether to shift the index. The shift amount corresponds
3090 * to the access size (thus irrelevant for byte accesses).
3091 */
3092DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrStLdRegIdx(ARMV8A64INSTRLDSTTYPE enmType,
3093 uint32_t iReg, uint32_t iBaseReg, uint32_t iRegIndex,
3094 ARMV8A64INSTRLDSTEXTEND enmExtend = kArmv8A64InstrLdStExtend_Lsl,
3095 bool fShifted = false)
3096{
3097 Assert(iRegIndex < 32);
3098 Assert(iReg < 32); /* 3 2 1 0 */
3099 Assert(iBaseReg < 32); /* 10987654321098765432109876543210 */
3100 return UINT32_C(0x38200800) /* 0b00111000001000000000100000000000 */
3101 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_Size) << (30 - kArmv8A64InstrLdStType_Shift_Size))
3102 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_VR) << (26 - kArmv8A64InstrLdStType_Shift_VR))
3103 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdStType_Mask_Opc) << (22 - kArmv8A64InstrLdStType_Shift_Opc))
3104 | (iRegIndex << 16)
3105 | ((uint32_t)enmExtend << 13)
3106 | ((uint32_t)fShifted << 12)
3107 | (iBaseReg << 5)
3108 | iReg;
3109}
3110
3111typedef enum /* VR Opc */
3112{ /* \ | */
3113 kArmv8A64InstrLdrLitteral_Mask_Vr = 0x10,
3114 kArmv8A64InstrLdrLitteral_Mask_Opc = 0x03,
3115 kArmv8A64InstrLdrLitteral_Shift_Vr = 4,
3116 kArmv8A64InstrLdrLitteral_Shift_Opc = 0,
3117
3118 kArmv8A64InstrLdrLitteral_Word = 0x00, /**< word = 32-bit */
3119 kArmv8A64InstrLdrLitteral_Dword = 0x01, /**< dword = 64-bit */
3120 kArmv8A64InstrLdrLitteral_SignWord64 = 0x02, /**< Loads word, signextending it to 64-bit */
3121 kArmv8A64InstrLdrLitteral_Prefetch = 0x03, /**< prfm */
3122
3123 kArmv8A64InstrLdrLitteral_Vr_Word = 0x10, /**< word = 32-bit */
3124 kArmv8A64InstrLdrLitteral_Vr_Dword = 0x11, /**< dword = 64-bit */
3125 kArmv8A64InstrLdrLitteral_Vr_128 = 0x12
3126} ARMV8A64INSTRLDRLITTERAL;
3127
3128
3129/**
3130 * A64: Encodes load w/ a PC relative 19-bit signed immediate.
3131 *
3132 * @returns The encoded instruction.
3133 * @param enmType The load instruction type.
3134 * @param iReg The register to load into.
3135 * @param i19Imm The signed immediate value, multiplied by 4 regardless
3136 * of access size.
3137 */
3138DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLdrLitteral(ARMV8A64INSTRLDRLITTERAL enmType, uint32_t iReg, int32_t i19Imm)
3139{
3140 Assert(i19Imm >= -262144 && i19Imm < 262144);
3141 Assert(iReg < 32); /* 3 2 1 0 */
3142 /* 10987654321098765432109876543210 */
3143 return UINT32_C(0x30000000) /* 0b00110000000000000000000000000000 */
3144 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdrLitteral_Mask_Vr) << (26 - kArmv8A64InstrLdrLitteral_Shift_Vr))
3145 | (((uint32_t)enmType & (uint32_t)kArmv8A64InstrLdrLitteral_Mask_Opc) << (30 - kArmv8A64InstrLdrLitteral_Shift_Opc))
3146 | (((uint32_t)i19Imm & UINT32_C(0x00ffffe0)) << 5)
3147 | iReg;
3148}
3149
3150
3151typedef enum
3152{
3153 kArmv8A64InstrMovWide_Not = 0, /**< MOVN - reg = ~(imm16 << hw*16; */
3154 kArmv8A64InstrMovWide_Zero = 2, /**< MOVZ - reg = imm16 << hw*16; */
3155 kArmv8A64InstrMovWide_Keep = 3 /**< MOVK - keep the other halfwords. */
3156} ARMV8A64INSTRMOVWIDE;
3157
3158/**
3159 * A64: Encode a move wide immediate instruction.
3160 *
3161 * @returns The encoded instruction.
3162 * @param enmType The load instruction type.
3163 * @param iRegDst The register to mov the immediate into.
3164 * @param uImm16 The immediate value.
3165 * @param iHalfWord Which of the 4 (@a f64Bit = true) or 2 register (16-bit)
3166 * half-words to target:
3167 * - 0 for bits 15:00,
3168 * - 1 for bits 31:16,
3169 * - 2 for bits 47:32 (f64Bit=true only),
3170 * - 3 for bits 63:48 (f64Bit=true only).
3171 * @param f64Bit true for 64-bit GPRs (default), @c false for 32-bit GPRs.
3172 */
3173DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMovWide(ARMV8A64INSTRMOVWIDE enmType, uint32_t iRegDst, uint32_t uImm16,
3174 uint32_t iHalfWord = 0, bool f64Bit = true)
3175{
3176 Assert(iRegDst < 32U); Assert(uImm16 <= (uint32_t)UINT16_MAX); Assert(iHalfWord < 2U + (2U * f64Bit));
3177 return ((uint32_t)f64Bit << 31)
3178 | ((uint32_t)enmType << 29)
3179 | UINT32_C(0x12800000)
3180 | (iHalfWord << 21)
3181 | (uImm16 << 5)
3182 | iRegDst;
3183}
3184
3185/** A64: Encodes a MOVN instruction.
3186 * @see Armv8A64MkInstrMovWide for parameter details. */
3187DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMovN(uint32_t iRegDst, uint32_t uImm16, uint32_t iHalfWord = 0, bool f64Bit = true)
3188{
3189 return Armv8A64MkInstrMovWide(kArmv8A64InstrMovWide_Not, iRegDst, uImm16, iHalfWord, f64Bit);
3190}
3191
3192/** A64: Encodes a MOVZ instruction.
3193 * @see Armv8A64MkInstrMovWide for parameter details. */
3194DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMovZ(uint32_t iRegDst, uint32_t uImm16, uint32_t iHalfWord = 0, bool f64Bit = true)
3195{
3196 return Armv8A64MkInstrMovWide(kArmv8A64InstrMovWide_Zero, iRegDst, uImm16, iHalfWord, f64Bit);
3197}
3198
3199/** A64: Encodes a MOVK instruction.
3200 * @see Armv8A64MkInstrMovWide for parameter details. */
3201DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMovK(uint32_t iRegDst, uint32_t uImm16, uint32_t iHalfWord = 0, bool f64Bit = true)
3202{
3203 return Armv8A64MkInstrMovWide(kArmv8A64InstrMovWide_Keep, iRegDst, uImm16, iHalfWord, f64Bit);
3204}
3205
3206
3207typedef enum
3208{
3209 kArmv8A64InstrShift_Lsl = 0,
3210 kArmv8A64InstrShift_Lsr,
3211 kArmv8A64InstrShift_Asr,
3212 kArmv8A64InstrShift_Ror
3213} ARMV8A64INSTRSHIFT;
3214
3215
3216/**
3217 * A64: Encodes a logical instruction with a shifted 2nd register operand.
3218 *
3219 * @returns The encoded instruction.
3220 * @param u2Opc The logical operation to perform.
3221 * @param fNot Whether to complement the 2nd operand.
3222 * @param iRegResult The output register.
3223 * @param iReg1 The 1st register operand.
3224 * @param iReg2Shifted The 2nd register operand, to which the optional
3225 * shifting is applied.
3226 * @param f64Bit true for 64-bit GPRs (default), @c false for 32-bit
3227 * GPRs.
3228 * @param offShift6 The shift amount (default: none).
3229 * @param enmShift The shift operation (default: LSL).
3230 */
3231DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLogicalShiftedReg(uint32_t u2Opc, bool fNot,
3232 uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted,
3233 bool f64Bit, uint32_t offShift6, ARMV8A64INSTRSHIFT enmShift)
3234{
3235 Assert(u2Opc < 4); Assert(offShift6 < (f64Bit ? UINT32_C(64) : UINT32_C(32)));
3236 Assert(iRegResult < 32); Assert(iReg1 < 32); Assert(iReg2Shifted < 32);
3237 return ((uint32_t)f64Bit << 31)
3238 | (u2Opc << 29)
3239 | UINT32_C(0x0a000000)
3240 | ((uint32_t)enmShift << 22)
3241 | ((uint32_t)fNot << 21)
3242 | (iReg2Shifted << 16)
3243 | (offShift6 << 10)
3244 | (iReg1 << 5)
3245 | iRegResult;
3246}
3247
3248
3249/** A64: Encodes an AND instruction.
3250 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3251DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAnd(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3252 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3253{
3254 return Armv8A64MkInstrLogicalShiftedReg(0, false /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3255}
3256
3257
3258/** A64: Encodes an BIC instruction.
3259 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3260DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBic(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3261 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3262{
3263 return Armv8A64MkInstrLogicalShiftedReg(0, true /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3264}
3265
3266
3267/** A64: Encodes an ORR instruction.
3268 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3269DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrOrr(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3270 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3271{
3272 return Armv8A64MkInstrLogicalShiftedReg(1, false /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3273}
3274
3275
3276/** A64: Encodes an MOV instruction.
3277 * This is an alias for "orr dst, xzr, src". */
3278DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMov(uint32_t iRegResult, uint32_t idxRegSrc, bool f64Bit = true)
3279{
3280 return Armv8A64MkInstrOrr(iRegResult, ARMV8_A64_REG_XZR, idxRegSrc, f64Bit);
3281}
3282
3283
3284/** A64: Encodes an ORN instruction.
3285 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3286DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrOrn(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3287 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3288{
3289 return Armv8A64MkInstrLogicalShiftedReg(1, true /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3290}
3291
3292
3293/** A64: Encodes an EOR instruction.
3294 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3295DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrEor(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3296 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3297{
3298 return Armv8A64MkInstrLogicalShiftedReg(2, false /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3299}
3300
3301
3302/** A64: Encodes an EON instruction.
3303 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3304DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrEon(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3305 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3306{
3307 return Armv8A64MkInstrLogicalShiftedReg(2, true /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3308}
3309
3310
3311/** A64: Encodes an ANDS instruction.
3312 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3313DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAnds(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3314 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3315{
3316 return Armv8A64MkInstrLogicalShiftedReg(3, false /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3317}
3318
3319
3320/** A64: Encodes an BICS instruction.
3321 * @see Armv8A64MkInstrLogicalShiftedReg for parameter details. */
3322DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBics(uint32_t iRegResult, uint32_t iReg1, uint32_t iReg2Shifted, bool f64Bit = true,
3323 uint32_t offShift6 = 0, ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
3324{
3325 return Armv8A64MkInstrLogicalShiftedReg(3, true /*fNot*/, iRegResult, iReg1, iReg2Shifted, f64Bit, offShift6, enmShift);
3326}
3327
3328
3329
3330/*
3331 * Data processing instructions with two source register operands.
3332 */
3333
3334
3335/** A64: Encodes an SUBP instruction. */
3336DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSubP(uint32_t iRegResult, uint32_t iRegMinuend, uint32_t iRegSubtrahend)
3337{
3338 Assert(iRegResult < 32); Assert(iRegMinuend < 32); Assert(iRegSubtrahend < 32);
3339 return UINT32_C(0x80000000)
3340 | UINT32_C(0x1ac00000)
3341 | (UINT32_C(0) << 10)
3342 | (iRegSubtrahend << 16)
3343 | (iRegMinuend << 5)
3344 | iRegResult;
3345}
3346
3347
3348/** A64: Encodes an SUBPS instruction. */
3349DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSubPS(uint32_t iRegResult, uint32_t iRegMinuend, uint32_t iRegSubtrahend)
3350{
3351 Assert(iRegResult < 32); Assert(iRegMinuend < 32); Assert(iRegSubtrahend < 32);
3352 return UINT32_C(0x80000000)
3353 | UINT32_C(0x20000000)
3354 | UINT32_C(0x1ac00000)
3355 | (UINT32_C(0) << 10)
3356 | (iRegSubtrahend << 16)
3357 | (iRegMinuend << 5)
3358 | iRegResult;
3359}
3360
3361
3362/** A64: Encodes an UDIV instruction. */
3363DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUDiv(uint32_t iRegResult, uint32_t iRegDividend, uint32_t iRegDivisor, bool f64Bit = true)
3364{
3365 Assert(iRegResult < 32); Assert(iRegDividend < 32); Assert(iRegDivisor < 32);
3366 return ((uint32_t)f64Bit << 31)
3367 | UINT32_C(0x1ac00000)
3368 | (UINT32_C(2) << 10)
3369 | (iRegDivisor << 16)
3370 | (iRegDividend << 5)
3371 | iRegResult;
3372}
3373
3374
3375/** A64: Encodes an SDIV instruction. */
3376DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSDiv(uint32_t iRegResult, uint32_t iRegDividend, uint32_t iRegDivisor, bool f64Bit = true)
3377{
3378 Assert(iRegResult < 32); Assert(iRegDividend < 32); Assert(iRegDivisor < 32);
3379 return ((uint32_t)f64Bit << 31)
3380 | UINT32_C(0x1ac00000)
3381 | (UINT32_C(3) << 10)
3382 | (iRegDivisor << 16)
3383 | (iRegDividend << 5)
3384 | iRegResult;
3385}
3386
3387
3388/** A64: Encodes an IRG instruction. */
3389DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrIrg(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2)
3390{
3391 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3392 return UINT32_C(0x80000000)
3393 | UINT32_C(0x1ac00000)
3394 | (UINT32_C(4) << 10)
3395 | (iRegSrc2 << 16)
3396 | (iRegSrc1 << 5)
3397 | iRegResult;
3398}
3399
3400
3401/** A64: Encodes a GMI instruction. */
3402DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrGmi(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2)
3403{
3404 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3405 return UINT32_C(0x80000000)
3406 | UINT32_C(0x1ac00000)
3407 | (UINT32_C(5) << 10)
3408 | (iRegSrc2 << 16)
3409 | (iRegSrc1 << 5)
3410 | iRegResult;
3411}
3412
3413
3414/** A64: Encodes an LSLV instruction. */
3415DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLslv(uint32_t iRegResult, uint32_t iRegSrc, uint32_t iRegCount, bool f64Bit = true)
3416{
3417 Assert(iRegResult < 32); Assert(iRegSrc < 32); Assert(iRegCount < 32);
3418 return ((uint32_t)f64Bit << 31)
3419 | UINT32_C(0x1ac00000)
3420 | (UINT32_C(8) << 10)
3421 | (iRegCount << 16)
3422 | (iRegSrc << 5)
3423 | iRegResult;
3424}
3425
3426
3427/** A64: Encodes an LSRV instruction. */
3428DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLsrv(uint32_t iRegResult, uint32_t iRegSrc, uint32_t iRegCount, bool f64Bit = true)
3429{
3430 Assert(iRegResult < 32); Assert(iRegSrc < 32); Assert(iRegCount < 32);
3431 return ((uint32_t)f64Bit << 31)
3432 | UINT32_C(0x1ac00000)
3433 | (UINT32_C(9) << 10)
3434 | (iRegCount << 16)
3435 | (iRegSrc << 5)
3436 | iRegResult;
3437}
3438
3439
3440/** A64: Encodes an ASRV instruction. */
3441DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAsrv(uint32_t iRegResult, uint32_t iRegSrc, uint32_t iRegCount, bool f64Bit = true)
3442{
3443 Assert(iRegResult < 32); Assert(iRegSrc < 32); Assert(iRegCount < 32);
3444 return ((uint32_t)f64Bit << 31)
3445 | UINT32_C(0x1ac00000)
3446 | (UINT32_C(10) << 10)
3447 | (iRegCount << 16)
3448 | (iRegSrc << 5)
3449 | iRegResult;
3450}
3451
3452
3453/** A64: Encodes a RORV instruction. */
3454DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrRorv(uint32_t iRegResult, uint32_t iRegSrc, uint32_t iRegCount, bool f64Bit = true)
3455{
3456 Assert(iRegResult < 32); Assert(iRegSrc < 32); Assert(iRegCount < 32);
3457 return ((uint32_t)f64Bit << 31)
3458 | UINT32_C(0x1ac00000)
3459 | (UINT32_C(11) << 10)
3460 | (iRegCount << 16)
3461 | (iRegSrc << 5)
3462 | iRegResult;
3463}
3464
3465
3466/** A64: Encodes a PACGA instruction. */
3467DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrPacga(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2)
3468{
3469 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3470 return UINT32_C(0x80000000)
3471 | UINT32_C(0x1ac00000)
3472 | (UINT32_C(12) << 10)
3473 | (iRegSrc2 << 16)
3474 | (iRegSrc1 << 5)
3475 | iRegResult;
3476}
3477
3478
3479/** A64: Encodes a CRC32* instruction. */
3480DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue, uint32_t uSize)
3481{
3482 Assert(iRegResult < 32); Assert(iRegCrc < 32); Assert(iRegValue < 32); Assert(uSize < 4);
3483 return ((uint32_t)(uSize == 3) << 31)
3484 | UINT32_C(0x1ac00000)
3485 | (UINT32_C(16) << 10)
3486 | (uSize << 10)
3487 | (iRegValue << 16)
3488 | (iRegCrc << 5)
3489 | iRegResult;
3490}
3491
3492
3493/** A64: Encodes a CRC32B instruction. */
3494DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32B(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3495{
3496 return Armv8A64MkInstrCrc32(iRegResult, iRegCrc, iRegValue, 0);
3497}
3498
3499
3500/** A64: Encodes a CRC32H instruction. */
3501DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32H(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3502{
3503 return Armv8A64MkInstrCrc32(iRegResult, iRegCrc, iRegValue, 1);
3504}
3505
3506
3507/** A64: Encodes a CRC32W instruction. */
3508DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32W(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3509{
3510 return Armv8A64MkInstrCrc32(iRegResult, iRegCrc, iRegValue, 2);
3511}
3512
3513
3514/** A64: Encodes a CRC32X instruction. */
3515DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32X(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3516{
3517 return Armv8A64MkInstrCrc32(iRegResult, iRegCrc, iRegValue, 3);
3518}
3519
3520
3521/** A64: Encodes a CRC32C* instruction. */
3522DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32c(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue, uint32_t uSize)
3523{
3524 Assert(iRegResult < 32); Assert(iRegCrc < 32); Assert(iRegValue < 32); Assert(uSize < 4);
3525 return ((uint32_t)(uSize == 3) << 31)
3526 | UINT32_C(0x1ac00000)
3527 | (UINT32_C(20) << 10)
3528 | (uSize << 10)
3529 | (iRegValue << 16)
3530 | (iRegCrc << 5)
3531 | iRegResult;
3532}
3533
3534
3535/** A64: Encodes a CRC32B instruction. */
3536DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32cB(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3537{
3538 return Armv8A64MkInstrCrc32c(iRegResult, iRegCrc, iRegValue, 0);
3539}
3540
3541
3542/** A64: Encodes a CRC32CH instruction. */
3543DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32cH(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3544{
3545 return Armv8A64MkInstrCrc32c(iRegResult, iRegCrc, iRegValue, 1);
3546}
3547
3548
3549/** A64: Encodes a CRC32CW instruction. */
3550DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32cW(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3551{
3552 return Armv8A64MkInstrCrc32c(iRegResult, iRegCrc, iRegValue, 2);
3553}
3554
3555
3556/** A64: Encodes a CRC32CX instruction. */
3557DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCrc32cX(uint32_t iRegResult, uint32_t iRegCrc, uint32_t iRegValue)
3558{
3559 return Armv8A64MkInstrCrc32c(iRegResult, iRegCrc, iRegValue, 3);
3560}
3561
3562
3563/** A64: Encodes an SMAX instruction. */
3564DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSMax(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true)
3565{
3566 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3567 return ((uint32_t)f64Bit << 31)
3568 | UINT32_C(0x1ac00000)
3569 | (UINT32_C(24) << 10)
3570 | (iRegSrc2 << 16)
3571 | (iRegSrc1 << 5)
3572 | iRegResult;
3573}
3574
3575
3576/** A64: Encodes an UMAX instruction. */
3577DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUMax(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true)
3578{
3579 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3580 return ((uint32_t)f64Bit << 31)
3581 | UINT32_C(0x1ac00000)
3582 | (UINT32_C(25) << 10)
3583 | (iRegSrc2 << 16)
3584 | (iRegSrc1 << 5)
3585 | iRegResult;
3586}
3587
3588
3589/** A64: Encodes an SMIN instruction. */
3590DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSMin(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true)
3591{
3592 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3593 return ((uint32_t)f64Bit << 31)
3594 | UINT32_C(0x1ac00000)
3595 | (UINT32_C(26) << 10)
3596 | (iRegSrc2 << 16)
3597 | (iRegSrc1 << 5)
3598 | iRegResult;
3599}
3600
3601
3602/** A64: Encodes an UMIN instruction. */
3603DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUMin(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true)
3604{
3605 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
3606 return ((uint32_t)f64Bit << 31)
3607 | UINT32_C(0x1ac00000)
3608 | (UINT32_C(27) << 10)
3609 | (iRegSrc2 << 16)
3610 | (iRegSrc1 << 5)
3611 | iRegResult;
3612}
3613
3614
3615# ifdef IPRT_INCLUDED_asm_h /* don't want this to be automatically included here. */
3616
3617/**
3618 * Converts immS and immR values (to logical instructions) to a 32-bit mask.
3619 *
3620 * @returns The decoded mask.
3621 * @param uImm6SizeLen The immS value from the instruction. (No N part
3622 * here, as that must be zero for instructions
3623 * operating on 32-bit wide registers.)
3624 * @param uImm6Rotations The immR value from the instruction.
3625 */
3626DECLINLINE(uint32_t) Armv8A64ConvertImmRImmS2Mask32(uint32_t uImm6SizeLen, uint32_t uImm6Rotations)
3627{
3628 Assert(uImm6SizeLen < 64); Assert(uImm6Rotations < 64);
3629
3630 /* Determine the element size. */
3631 unsigned const cBitsElementLog2 = ASMBitLastSetU32(uImm6SizeLen ^ 0x3f) - 1U;
3632 Assert(cBitsElementLog2 + 1U != 0U);
3633
3634 unsigned const cBitsElement = RT_BIT_32(cBitsElementLog2);
3635 Assert(uImm6Rotations < cBitsElement);
3636
3637 /* Extract the number of bits set to 1: */
3638 unsigned const cBitsSetTo1 = (uImm6SizeLen & (cBitsElement - 1U)) + 1;
3639 Assert(cBitsSetTo1 < cBitsElement);
3640 uint32_t const uElement = RT_BIT_32(cBitsSetTo1) - 1U;
3641
3642 /* Produce the unrotated pattern. */
3643 static const uint32_t s_auReplicate[]
3644 = { UINT32_MAX, UINT32_MAX / 3, UINT32_MAX / 15, UINT32_MAX / 255, UINT32_MAX / 65535, 1 };
3645 uint32_t const uPattern = s_auReplicate[cBitsElementLog2] * uElement;
3646
3647 /* Rotate it and return. */
3648 return ASMRotateRightU32(uPattern, uImm6Rotations & (cBitsElement - 1U));
3649}
3650
3651
3652/**
3653 * Converts N+immS and immR values (to logical instructions) to a 64-bit mask.
3654 *
3655 * @returns The decoded mask.
3656 * @param uImm7SizeLen The N:immS value from the instruction.
3657 * @param uImm6Rotations The immR value from the instruction.
3658 */
3659DECLINLINE(uint64_t) Armv8A64ConvertImmRImmS2Mask64(uint32_t uImm7SizeLen, uint32_t uImm6Rotations)
3660{
3661 Assert(uImm7SizeLen < 128); Assert(uImm6Rotations < 64);
3662
3663 /* Determine the element size. */
3664 unsigned const cBitsElementLog2 = ASMBitLastSetU32(uImm7SizeLen ^ 0x3f) - 1U;
3665 Assert(cBitsElementLog2 + 1U != 0U);
3666
3667 unsigned const cBitsElement = RT_BIT_32(cBitsElementLog2);
3668 Assert(uImm6Rotations < cBitsElement);
3669
3670 /* Extract the number of bits set to 1: */
3671 unsigned const cBitsSetTo1 = (uImm7SizeLen & (cBitsElement - 1U)) + 1;
3672 Assert(cBitsSetTo1 < cBitsElement);
3673 uint64_t const uElement = RT_BIT_64(cBitsSetTo1) - 1U;
3674
3675 /* Produce the unrotated pattern. */
3676 static const uint64_t s_auReplicate[]
3677 = { UINT64_MAX, UINT64_MAX / 3, UINT64_MAX / 15, UINT64_MAX / 255, UINT64_MAX / 65535, UINT64_MAX / UINT32_MAX, 1 };
3678 uint64_t const uPattern = s_auReplicate[cBitsElementLog2] * uElement;
3679
3680 /* Rotate it and return. */
3681 return ASMRotateRightU64(uPattern, uImm6Rotations & (cBitsElement - 1U));
3682}
3683
3684
3685/**
3686 * Variant of Armv8A64ConvertImmRImmS2Mask64 where the N bit is separate from
3687 * the immS value.
3688 */
3689DECLINLINE(uint64_t) Armv8A64ConvertImmRImmS2Mask64(uint32_t uN, uint32_t uImm6SizeLen, uint32_t uImm6Rotations)
3690{
3691 return Armv8A64ConvertImmRImmS2Mask64((uN << 6) | uImm6SizeLen, uImm6Rotations);
3692}
3693
3694
3695/**
3696 * Helper for Armv8A64MkInstrLogicalImm and friends that tries to convert a
3697 * 32-bit bitmask to a set of immediates for those instructions.
3698 *
3699 * @returns true if successful, false if not.
3700 * @param fMask The mask value to convert.
3701 * @param puImm6SizeLen Where to return the immS part (N is always zero for
3702 * 32-bit wide masks).
3703 * @param puImm6Rotations Where to return the immR.
3704 */
3705DECLINLINE(bool) Armv8A64ConvertMask32ToImmRImmS(uint32_t fMask, uint32_t *puImm6SizeLen, uint32_t *puImm6Rotations)
3706{
3707 /* Fend off 0 and UINT32_MAX as these cannot be represented. */
3708 if ((uint32_t)(fMask + 1U) <= 1)
3709 return false;
3710
3711 /* Rotate the value will we get all 1s at the bottom and the zeros at the top. */
3712 unsigned const cRor = ASMCountTrailingZerosU32(fMask);
3713 unsigned const cRol = ASMCountLeadingZerosU32(~fMask);
3714 if (cRor)
3715 fMask = ASMRotateRightU32(fMask, cRor);
3716 else
3717 fMask = ASMRotateLeftU32(fMask, cRol);
3718 Assert(fMask & RT_BIT_32(0));
3719 Assert(!(fMask & RT_BIT_32(31)));
3720
3721 /* Count the trailing ones and leading zeros. */
3722 unsigned const cOnes = ASMCountTrailingZerosU32(~fMask);
3723 unsigned const cZeros = ASMCountLeadingZerosU32(fMask);
3724
3725 /* The potential element length is then the sum of the two above. */
3726 unsigned const cBitsElement = cOnes + cZeros;
3727 if (!RT_IS_POWER_OF_TWO(cBitsElement) || cBitsElement < 2)
3728 return false;
3729
3730 /* Special case: 32 bits element size. Since we're done here. */
3731 if (cBitsElement == 32)
3732 *puImm6SizeLen = cOnes - 1;
3733 else
3734 {
3735 /* Extract the element bits and check that these are replicated in the whole pattern. */
3736 uint32_t const uElement = RT_BIT_32(cOnes) - 1U;
3737 unsigned const cBitsElementLog2 = ASMBitFirstSetU32(cBitsElement) - 1;
3738
3739 static const uint32_t s_auReplicate[]
3740 = { UINT32_MAX, UINT32_MAX / 3, UINT32_MAX / 15, UINT32_MAX / 255, UINT32_MAX / 65535, 1 };
3741 if (s_auReplicate[cBitsElementLog2] * uElement == fMask)
3742 *puImm6SizeLen = (cOnes - 1) | ((0x3e << cBitsElementLog2) & 0x3f);
3743 else
3744 return false;
3745 }
3746 *puImm6Rotations = cRor ? cBitsElement - cRor : cRol;
3747
3748 return true;
3749}
3750
3751
3752/**
3753 * Helper for Armv8A64MkInstrLogicalImm and friends that tries to convert a
3754 * 64-bit bitmask to a set of immediates for those instructions.
3755 *
3756 * @returns true if successful, false if not.
3757 * @param fMask The mask value to convert.
3758 * @param puImm7SizeLen Where to return the N:immS part.
3759 * @param puImm6Rotations Where to return the immR.
3760 */
3761DECLINLINE(bool) Armv8A64ConvertMask64ToImmRImmS(uint64_t fMask, uint32_t *puImm7SizeLen, uint32_t *puImm6Rotations)
3762{
3763 /* Fend off 0 and UINT64_MAX as these cannot be represented. */
3764 if ((uint64_t)(fMask + 1U) <= 1)
3765 return false;
3766
3767 /* Rotate the value will we get all 1s at the bottom and the zeros at the top. */
3768 unsigned const cRor = ASMCountTrailingZerosU64(fMask);
3769 unsigned const cRol = ASMCountLeadingZerosU64(~fMask);
3770 if (cRor)
3771 fMask = ASMRotateRightU64(fMask, cRor);
3772 else
3773 fMask = ASMRotateLeftU64(fMask, cRol);
3774 Assert(fMask & RT_BIT_64(0));
3775 Assert(!(fMask & RT_BIT_64(63)));
3776
3777 /* Count the trailing ones and leading zeros. */
3778 unsigned const cOnes = ASMCountTrailingZerosU64(~fMask);
3779 unsigned const cZeros = ASMCountLeadingZerosU64(fMask);
3780
3781 /* The potential element length is then the sum of the two above. */
3782 unsigned const cBitsElement = cOnes + cZeros;
3783 if (!RT_IS_POWER_OF_TWO(cBitsElement) || cBitsElement < 2)
3784 return false;
3785
3786 /* Special case: 64 bits element size. Since we're done here. */
3787 if (cBitsElement == 64)
3788 *puImm7SizeLen = (cOnes - 1) | 0x40 /*N*/;
3789 else
3790 {
3791 /* Extract the element bits and check that these are replicated in the whole pattern. */
3792 uint64_t const uElement = RT_BIT_64(cOnes) - 1U;
3793 unsigned const cBitsElementLog2 = ASMBitFirstSetU64(cBitsElement) - 1;
3794
3795 static const uint64_t s_auReplicate[]
3796 = { UINT64_MAX, UINT64_MAX / 3, UINT64_MAX / 15, UINT64_MAX / 255, UINT64_MAX / 65535, UINT64_MAX / UINT32_MAX, 1 };
3797 if (s_auReplicate[cBitsElementLog2] * uElement == fMask)
3798 *puImm7SizeLen = (cOnes - 1) | ((0x3e << cBitsElementLog2) & 0x3f);
3799 else
3800 return false;
3801 }
3802 *puImm6Rotations = cRor ? cBitsElement - cRor : cRol;
3803
3804 return true;
3805}
3806
3807# endif /* IPRT_INCLUDED_asm_h */
3808
3809/**
3810 * A64: Encodes a logical instruction with an complicated immediate mask.
3811 *
3812 * The @a uImm7SizeLen parameter specifies two things:
3813 * 1. the element size and
3814 * 2. the number of bits set to 1 in the pattern.
3815 *
3816 * The element size is extracted by NOT'ing bits 5:0 (excludes the N bit at the
3817 * top) and using the position of the first bit set as a power of two.
3818 *
3819 * | N | 5 | 4 | 3 | 2 | 1 | 0 | element size |
3820 * |---|---|---|---|---|---|---|--------------|
3821 * | 0 | 1 | 1 | 1 | 1 | 0 | x | 2 bits |
3822 * | 0 | 1 | 1 | 1 | 0 | x | x | 4 bits |
3823 * | 0 | 1 | 1 | 0 | x | x | x | 8 bits |
3824 * | 0 | 1 | 0 | x | x | x | x | 16 bits |
3825 * | 0 | 0 | x | x | x | x | x | 32 bits |
3826 * | 1 | x | x | x | x | x | x | 64 bits |
3827 *
3828 * The 'x' forms the number of 1 bits in the pattern, minus one (i.e.
3829 * there is always one zero bit in the pattern).
3830 *
3831 * The @a uImm6Rotations parameter specifies how many bits to the right,
3832 * the element pattern is rotated. The rotation count must be less than the
3833 * element bit count (size).
3834 *
3835 * @returns The encoded instruction.
3836 * @param u2Opc The logical operation to perform.
3837 * @param iRegResult The output register.
3838 * @param iRegSrc The 1st register operand.
3839 * @param uImm7SizeLen The size/pattern length. We've combined the 1-bit N
3840 * field at the top of the 6-bit 'imms' field.
3841 *
3842 * @param uImm6Rotations The rotation count.
3843 * @param f64Bit true for 64-bit GPRs, @c false for 32-bit GPRs.
3844 * @see https://dinfuehr.github.io/blog/encoding-of-immediate-values-on-aarch64/
3845 * https://gist.githubusercontent.com/dinfuehr/51a01ac58c0b23e4de9aac313ed6a06a/raw/1892a274aa3238d55f83eec5b3828da2aec5f229/aarch64-logical-immediates.txt
3846 */
3847DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLogicalImm(uint32_t u2Opc, uint32_t iRegResult, uint32_t iRegSrc,
3848 uint32_t uImm7SizeLen, uint32_t uImm6Rotations, bool f64Bit)
3849{
3850 Assert(u2Opc < 4); Assert(uImm7SizeLen < (f64Bit ? UINT32_C(0x7f) : UINT32_C(0x3f)));
3851 Assert(uImm6Rotations <= UINT32_C(0x3f)); Assert(iRegResult < 32); Assert(iRegSrc < 32);
3852 return ((uint32_t)f64Bit << 31)
3853 | (u2Opc << 29)
3854 | UINT32_C(0x12000000)
3855 | ((uImm7SizeLen & UINT32_C(0x40)) << (22 - 6))
3856 | (uImm6Rotations << 16)
3857 | ((uImm7SizeLen & UINT32_C(0x3f)) << 10)
3858 | (iRegSrc << 5)
3859 | iRegResult;
3860}
3861
3862
3863/** A64: Encodes an AND instruction w/ complicated immediate mask.
3864 * @see Armv8A64MkInstrLogicalImm for parameter details. */
3865DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAndImm(uint32_t iRegResult, uint32_t iRegSrc,
3866 uint32_t uImm7SizeLen, uint32_t uImm6Rotations = 0, bool f64Bit = true)
3867{
3868 return Armv8A64MkInstrLogicalImm(0, iRegResult, iRegSrc, uImm7SizeLen, uImm6Rotations, f64Bit);
3869}
3870
3871
3872/** A64: Encodes an ORR instruction w/ complicated immediate mask.
3873 * @see Armv8A64MkInstrLogicalImm for parameter details. */
3874DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrOrrImm(uint32_t iRegResult, uint32_t iRegSrc,
3875 uint32_t uImm7SizeLen, uint32_t uImm6Rotations = 0, bool f64Bit = true)
3876{
3877 return Armv8A64MkInstrLogicalImm(1, iRegResult, iRegSrc, uImm7SizeLen, uImm6Rotations, f64Bit);
3878}
3879
3880
3881/** A64: Encodes an EOR instruction w/ complicated immediate mask.
3882 * @see Armv8A64MkInstrLogicalImm for parameter details. */
3883DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrEorImm(uint32_t iRegResult, uint32_t iRegSrc,
3884 uint32_t uImm7SizeLen, uint32_t uImm6Rotations = 0, bool f64Bit = true)
3885{
3886 return Armv8A64MkInstrLogicalImm(2, iRegResult, iRegSrc, uImm7SizeLen, uImm6Rotations, f64Bit);
3887}
3888
3889
3890/** A64: Encodes an ANDS instruction w/ complicated immediate mask.
3891 * @see Armv8A64MkInstrLogicalImm for parameter details. */
3892DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAndsImm(uint32_t iRegResult, uint32_t iRegSrc,
3893 uint32_t uImm7SizeLen, uint32_t uImm6Rotations = 0, bool f64Bit = true)
3894{
3895 return Armv8A64MkInstrLogicalImm(3, iRegResult, iRegSrc, uImm7SizeLen, uImm6Rotations, f64Bit);
3896}
3897
3898
3899/** A64: Encodes an TST instruction w/ complicated immediate mask.
3900 * @see Armv8A64MkInstrLogicalImm for parameter details. */
3901DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrTstImm(uint32_t iRegSrc,
3902 uint32_t uImm7SizeLen, uint32_t uImm6Rotations = 0, bool f64Bit = true)
3903{
3904 return Armv8A64MkInstrAndsImm(ARMV8_A64_REG_XZR, iRegSrc, uImm7SizeLen, uImm6Rotations, f64Bit);
3905}
3906
3907
3908/**
3909 * A64: Encodes a bitfield instruction.
3910 *
3911 * @returns The encoded instruction.
3912 * @param u2Opc The bitfield operation to perform.
3913 * @param iRegResult The output register.
3914 * @param iRegSrc The 1st register operand.
3915 * @param cImm6Ror The right rotation count.
3916 * @param uImm6S The leftmost bit to be moved.
3917 * @param f64Bit true for 64-bit GPRs, @c false for 32-bit GPRs.
3918 * @param uN1 This must match @a f64Bit for all instructions
3919 * currently specified.
3920 * @see https://dinfuehr.github.io/blog/encoding-of-immediate-values-on-aarch64/
3921 * https://gist.githubusercontent.com/dinfuehr/51a01ac58c0b23e4de9aac313ed6a06a/raw/1892a274aa3238d55f83eec5b3828da2aec5f229/aarch64-logical-immediates.txt
3922 */
3923DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBitfieldImm(uint32_t u2Opc, uint32_t iRegResult, uint32_t iRegSrc,
3924 uint32_t cImm6Ror, uint32_t uImm6S, bool f64Bit, uint32_t uN1)
3925{
3926 Assert(cImm6Ror <= (f64Bit ? UINT32_C(0x3f) : UINT32_C(0x1f))); Assert(iRegResult < 32); Assert(u2Opc < 4);
3927 Assert(uImm6S <= (f64Bit ? UINT32_C(0x3f) : UINT32_C(0x1f))); Assert(iRegSrc < 32); Assert(uN1 <= (unsigned)f64Bit);
3928 return ((uint32_t)f64Bit << 31)
3929 | (u2Opc << 29)
3930 | UINT32_C(0x13000000)
3931 | (uN1 << 22)
3932 | (cImm6Ror << 16)
3933 | (uImm6S << 10)
3934 | (iRegSrc << 5)
3935 | iRegResult;
3936}
3937
3938
3939/** A64: Encodes a SBFM instruction.
3940 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3941DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSbfm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cImm6Ror, uint32_t uImm6S,
3942 bool f64Bit = true, uint32_t uN1 = UINT32_MAX)
3943{
3944 return Armv8A64MkInstrBitfieldImm(0, iRegResult, iRegSrc, cImm6Ror, uImm6S, f64Bit, uN1 == UINT32_MAX ? f64Bit : uN1);
3945}
3946
3947
3948/** A64: Encodes a SXTB instruction (sign-extend 8-bit value to 32/64-bit).
3949 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3950DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSxtb(uint32_t iRegResult, uint32_t iRegSrc, bool f64Bit = true)
3951{
3952 return Armv8A64MkInstrSbfm(iRegResult, iRegSrc, 0, 7, f64Bit);
3953}
3954
3955
3956/** A64: Encodes a SXTH instruction (sign-extend 16-bit value to 32/64-bit).
3957 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3958DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSxth(uint32_t iRegResult, uint32_t iRegSrc, bool f64Bit = true)
3959{
3960 return Armv8A64MkInstrSbfm(iRegResult, iRegSrc, 0, 15, f64Bit);
3961}
3962
3963
3964/** A64: Encodes a SXTH instruction (sign-extend 32-bit value to 64-bit).
3965 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3966DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSxtw(uint32_t iRegResult, uint32_t iRegSrc)
3967{
3968 return Armv8A64MkInstrSbfm(iRegResult, iRegSrc, 0, 31, true /*f64Bit*/);
3969}
3970
3971
3972/** A64: Encodes an ASR instruction w/ immediate shift value.
3973 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3974DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAsrImm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cShift, bool f64Bit = true)
3975{
3976 uint32_t const cWidth = f64Bit ? 63 : 31;
3977 Assert(cShift > 0); Assert(cShift <= cWidth);
3978 return Armv8A64MkInstrBitfieldImm(0, iRegResult, iRegSrc, cShift, cWidth /*uImm6S*/, f64Bit, f64Bit);
3979}
3980
3981
3982/** A64: Encodes a BFM instruction.
3983 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3984DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBfm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cImm6Ror, uint32_t uImm6S,
3985 bool f64Bit = true, uint32_t uN1 = UINT32_MAX)
3986{
3987 return Armv8A64MkInstrBitfieldImm(1, iRegResult, iRegSrc, cImm6Ror, uImm6S, f64Bit, uN1 == UINT32_MAX ? f64Bit : uN1);
3988}
3989
3990
3991/** A64: Encodes a BFI instruction (insert).
3992 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
3993DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBfi(uint32_t iRegResult, uint32_t iRegSrc,
3994 uint32_t offFirstBit, uint32_t cBitsWidth, bool f64Bit = true)
3995{
3996 Assert(cBitsWidth > 0U); Assert(cBitsWidth < (f64Bit ? 64U : 32U)); Assert(offFirstBit < (f64Bit ? 64U : 32U));
3997 return Armv8A64MkInstrBfm(iRegResult, iRegSrc, (uint32_t)-(int32_t)offFirstBit & (f64Bit ? 0x3f : 0x1f),
3998 cBitsWidth - 1, f64Bit);
3999}
4000
4001
4002/** A64: Encodes a BFC instruction (clear).
4003 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4004DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBfc(uint32_t iRegResult,
4005 uint32_t offFirstBit, uint32_t cBitsWidth, bool f64Bit = true)
4006{
4007 return Armv8A64MkInstrBfi(iRegResult, ARMV8_A64_REG_XZR, offFirstBit, cBitsWidth, f64Bit);
4008}
4009
4010
4011/** A64: Encodes a BFXIL instruction (insert low).
4012 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4013DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBfxil(uint32_t iRegResult, uint32_t iRegSrc,
4014 uint32_t offFirstBit, uint32_t cBitsWidth, bool f64Bit = true)
4015{
4016 Assert(cBitsWidth > 0U); Assert(cBitsWidth < (f64Bit ? 64U : 32U)); Assert(offFirstBit < (f64Bit ? 64U : 32U));
4017 Assert(offFirstBit + cBitsWidth <= (f64Bit ? 64U : 32U));
4018 return Armv8A64MkInstrBfm(iRegResult, iRegSrc, (uint32_t)offFirstBit, offFirstBit + cBitsWidth - 1, f64Bit);
4019}
4020
4021
4022/** A64: Encodes an UBFM instruction.
4023 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4024DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUbfm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cImm6Ror, uint32_t uImm6S,
4025 bool f64Bit = true, uint32_t uN1 = UINT32_MAX)
4026{
4027 return Armv8A64MkInstrBitfieldImm(2, iRegResult, iRegSrc, cImm6Ror, uImm6S, f64Bit, uN1 == UINT32_MAX ? f64Bit : uN1);
4028}
4029
4030
4031/** A64: Encodes an UBFX instruction (zero extending extract).
4032 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4033DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUbfx(uint32_t iRegResult, uint32_t iRegSrc,
4034 uint32_t offFirstBit, uint32_t cBitsWidth, bool f64Bit = true)
4035{
4036 return Armv8A64MkInstrUbfm(iRegResult, iRegSrc, offFirstBit, offFirstBit + cBitsWidth - 1, f64Bit);
4037}
4038
4039
4040/** A64: Encodes an UBFIZ instruction (zero extending extract from bit zero,
4041 * shifted into destination).
4042 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4043DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUbfiz(uint32_t iRegResult, uint32_t iRegSrc,
4044 uint32_t offFirstBitDst, uint32_t cBitsWidth, bool f64Bit = true)
4045{
4046 uint32_t fMask = f64Bit ? 0x3f : 0x1f;
4047 return Armv8A64MkInstrUbfm(iRegResult, iRegSrc, -(int32_t)offFirstBitDst & fMask, cBitsWidth - 1, f64Bit);
4048}
4049
4050
4051/** A64: Encodes an LSL instruction w/ immediate shift value.
4052 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4053DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLslImm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cShift, bool f64Bit = true)
4054{
4055 uint32_t const cWidth = f64Bit ? 63 : 31;
4056 Assert(cShift > 0); Assert(cShift <= cWidth);
4057 return Armv8A64MkInstrBitfieldImm(2, iRegResult, iRegSrc, (uint32_t)(0 - cShift) & cWidth,
4058 cWidth - cShift /*uImm6S*/, f64Bit, f64Bit);
4059}
4060
4061
4062/** A64: Encodes an LSR instruction w/ immediate shift value.
4063 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4064DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrLsrImm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cShift, bool f64Bit = true)
4065{
4066 uint32_t const cWidth = f64Bit ? 63 : 31;
4067 Assert(cShift > 0); Assert(cShift <= cWidth);
4068 return Armv8A64MkInstrBitfieldImm(2, iRegResult, iRegSrc, cShift, cWidth /*uImm6S*/, f64Bit, f64Bit);
4069}
4070
4071
4072/** A64: Encodes an UXTB instruction - zero extend byte (8-bit).
4073 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4074DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUxtb(uint32_t iRegResult, uint32_t iRegSrc, bool f64Bit = false)
4075{
4076 return Armv8A64MkInstrBitfieldImm(2, iRegResult, iRegSrc, 0, 7, f64Bit, f64Bit);
4077}
4078
4079
4080/** A64: Encodes an UXTH instruction - zero extend half word (16-bit).
4081 * @see Armv8A64MkInstrBitfieldImm for parameter details. */
4082DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrUxth(uint32_t iRegResult, uint32_t iRegSrc, bool f64Bit = false)
4083{
4084 return Armv8A64MkInstrBitfieldImm(2, iRegResult, iRegSrc, 0, 15, f64Bit, f64Bit);
4085}
4086
4087
4088/**
4089 * A64: Encodes an EXTR instruction with an immediate.
4090 *
4091 * @returns The encoded instruction.
4092 * @param iRegResult The register to store the result in. ZR is valid.
4093 * @param iRegLow The register holding the least significant bits in the
4094 * extraction. ZR is valid.
4095 * @param iRegHigh The register holding the most significant bits in the
4096 * extraction. ZR is valid.
4097 * @param uLsb The bit number of the least significant bit, or where in
4098 * @a iRegLow to start the
4099 * extraction.
4100 * @param f64Bit true for 64-bit GRPs (default), false for 32-bit GPRs.
4101 */
4102DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrExtrImm(uint32_t iRegResult, uint32_t iRegLow, uint32_t iRegHigh, uint32_t uLsb,
4103 bool f64Bit = true)
4104{
4105 Assert(uLsb < (uint32_t)(f64Bit ? 64 : 32)); Assert(iRegHigh < 32); Assert(iRegLow < 32); Assert(iRegResult < 32);
4106 return ((uint32_t)f64Bit << 31)
4107 | UINT32_C(0x13800000)
4108 | ((uint32_t)f64Bit << 22) /*N*/
4109 | (iRegHigh << 16)
4110 | (uLsb << 10)
4111 | (iRegLow << 5)
4112 | iRegResult;
4113}
4114
4115
4116/** A64: Rotates the value of a register (alias for EXTR). */
4117DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrRorImm(uint32_t iRegResult, uint32_t iRegSrc, uint32_t cShift, bool f64Bit = true)
4118{
4119 return Armv8A64MkInstrExtrImm(iRegResult, iRegSrc, iRegSrc, cShift, f64Bit);
4120}
4121
4122
4123/**
4124 * A64: Encodes either add, adds, sub or subs with unsigned 12-bit immediate.
4125 *
4126 * @returns The encoded instruction.
4127 * @param fSub true for sub and subs, false for add and
4128 * adds.
4129 * @param iRegResult The register to store the result in.
4130 * SP is valid when @a fSetFlags = false,
4131 * and ZR is valid otherwise.
4132 * @param iRegSrc The register containing the augend (@a fSub
4133 * = false) or minuend (@a fSub = true). SP is
4134 * a valid registers for all variations.
4135 * @param uImm12AddendSubtrahend The addend (@a fSub = false) or subtrahend
4136 * (@a fSub = true).
4137 * @param f64Bit true for 64-bit GRPs (default), false for
4138 * 32-bit GPRs.
4139 * @param fSetFlags Whether to set flags (adds / subs) or not
4140 * (add / sub - default).
4141 * @param fShift12 Whether to shift uImm12AddendSubtrahend 12
4142 * bits to the left, or not (default).
4143 */
4144DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAddSubUImm12(bool fSub, uint32_t iRegResult, uint32_t iRegSrc,
4145 uint32_t uImm12AddendSubtrahend, bool f64Bit = true,
4146 bool fSetFlags = false, bool fShift12 = false)
4147{
4148 Assert(uImm12AddendSubtrahend < 4096); Assert(iRegSrc < 32); Assert(iRegResult < 32);
4149 return ((uint32_t)f64Bit << 31)
4150 | ((uint32_t)fSub << 30)
4151 | ((uint32_t)fSetFlags << 29)
4152 | UINT32_C(0x11000000)
4153 | ((uint32_t)fShift12 << 22)
4154 | (uImm12AddendSubtrahend << 10)
4155 | (iRegSrc << 5)
4156 | iRegResult;
4157}
4158
4159
4160/** Alias for sub zxr, reg, \#uimm12. */
4161DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCmpUImm12(uint32_t iRegSrc, uint32_t uImm12Comprahend,
4162 bool f64Bit = true, bool fShift12 = false)
4163{
4164 return Armv8A64MkInstrAddSubUImm12(true /*fSub*/, ARMV8_A64_REG_XZR, iRegSrc, uImm12Comprahend,
4165 f64Bit, true /*fSetFlags*/, fShift12);
4166}
4167
4168
4169/** ADD dst, src, \#uimm12 */
4170DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAddUImm12(uint32_t iRegResult, uint32_t iRegSrc, uint32_t uImm12Addend,
4171 bool f64Bit = true, bool fSetFlags = false, bool fShift12 = false)
4172{
4173 return Armv8A64MkInstrAddSubUImm12(false /*fSub*/, iRegResult, iRegSrc, uImm12Addend, f64Bit, fSetFlags, fShift12);
4174}
4175
4176
4177/** SUB dst, src, \#uimm12 */
4178DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSubUImm12(uint32_t iRegResult, uint32_t iRegSrc, uint32_t uImm12Subtrahend,
4179 bool f64Bit = true, bool fSetFlags = false, bool fShift12 = false)
4180{
4181 return Armv8A64MkInstrAddSubUImm12(true /*fSub*/, iRegResult, iRegSrc, uImm12Subtrahend, f64Bit, fSetFlags, fShift12);
4182}
4183
4184
4185/**
4186 * A64: Encodes either add, adds, sub or subs with shifted register.
4187 *
4188 * @returns The encoded instruction.
4189 * @param fSub true for sub and subs, false for add and
4190 * adds.
4191 * @param iRegResult The register to store the result in.
4192 * SP is NOT valid, but ZR is.
4193 * @param iRegSrc1 The register containing the augend (@a fSub
4194 * = false) or minuend (@a fSub = true).
4195 * SP is NOT valid, but ZR is.
4196 * @param iRegSrc2 The register containing the addened (@a fSub
4197 * = false) or subtrahend (@a fSub = true).
4198 * SP is NOT valid, but ZR is.
4199 * @param f64Bit true for 64-bit GRPs (default), false for
4200 * 32-bit GPRs.
4201 * @param fSetFlags Whether to set flags (adds / subs) or not
4202 * (add / sub - default).
4203 * @param cShift The shift count to apply to @a iRegSrc2.
4204 * @param enmShift The shift type to apply to the @a iRegSrc2
4205 * register. kArmv8A64InstrShift_Ror is
4206 * reserved.
4207 */
4208DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAddSubReg(bool fSub, uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4209 bool f64Bit = true, bool fSetFlags = false, uint32_t cShift = 0,
4210 ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
4211{
4212 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
4213 Assert(cShift < (f64Bit ? 64U : 32U)); Assert(enmShift != kArmv8A64InstrShift_Ror);
4214
4215 return ((uint32_t)f64Bit << 31)
4216 | ((uint32_t)fSub << 30)
4217 | ((uint32_t)fSetFlags << 29)
4218 | UINT32_C(0x0b000000)
4219 | ((uint32_t)enmShift << 22)
4220 | (iRegSrc2 << 16)
4221 | (cShift << 10)
4222 | (iRegSrc1 << 5)
4223 | iRegResult;
4224}
4225
4226
4227/** Alias for sub zxr, reg1, reg2 [, LSL/LSR/ASR/ROR \#xx]. */
4228DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCmpReg(uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true, uint32_t cShift = 0,
4229 ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
4230{
4231 return Armv8A64MkInstrAddSubReg(true /*fSub*/, ARMV8_A64_REG_XZR, iRegSrc1, iRegSrc2,
4232 f64Bit, true /*fSetFlags*/, cShift, enmShift);
4233}
4234
4235
4236/** ADD dst, reg1, reg2 [, LSL/LSR/ASR/ROR \#xx] */
4237DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAddReg(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4238 bool f64Bit = true, bool fSetFlags = false, uint32_t cShift = 0,
4239 ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
4240{
4241 return Armv8A64MkInstrAddSubReg(false /*fSub*/, iRegResult, iRegSrc1, iRegSrc2, f64Bit, fSetFlags, cShift, enmShift);
4242}
4243
4244
4245/** SUB dst, reg1, reg2 [, LSL/LSR/ASR/ROR \#xx] */
4246DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSubReg(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4247 bool f64Bit = true, bool fSetFlags = false, uint32_t cShift = 0,
4248 ARMV8A64INSTRSHIFT enmShift = kArmv8A64InstrShift_Lsl)
4249{
4250 return Armv8A64MkInstrAddSubReg(true /*fSub*/, iRegResult, iRegSrc1, iRegSrc2, f64Bit, fSetFlags, cShift, enmShift);
4251}
4252
4253
4254/** NEG dst */
4255DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrNeg(uint32_t iRegResult, bool f64Bit = true, bool fSetFlags = false)
4256{
4257 return Armv8A64MkInstrAddSubReg(true /*fSub*/, iRegResult, ARMV8_A64_REG_XZR, iRegResult, f64Bit, fSetFlags);
4258}
4259
4260
4261/** Extension option for 'extended register' instructions. */
4262typedef enum ARMV8A64INSTREXTEND
4263{
4264 kArmv8A64InstrExtend_UxtB = 0,
4265 kArmv8A64InstrExtend_UxtH,
4266 kArmv8A64InstrExtend_UxtW,
4267 kArmv8A64InstrExtend_UxtX,
4268 kArmv8A64InstrExtend_SxtB,
4269 kArmv8A64InstrExtend_SxtH,
4270 kArmv8A64InstrExtend_SxtW,
4271 kArmv8A64InstrExtend_SxtX,
4272 /** The default is either UXTW or UXTX depending on whether the instruction
4273 * is in 32-bit or 64-bit mode. Thus, this needs to be resolved according
4274 * to the f64Bit value. */
4275 kArmv8A64InstrExtend_Default
4276} ARMV8A64INSTREXTEND;
4277
4278
4279/**
4280 * A64: Encodes either add, adds, sub or subs with extended register encoding.
4281 *
4282 * @returns The encoded instruction.
4283 * @param fSub true for sub and subs, false for add and
4284 * adds.
4285 * @param iRegResult The register to store the result in.
4286 * SP is NOT valid, but ZR is.
4287 * @param iRegSrc1 The register containing the augend (@a fSub
4288 * = false) or minuend (@a fSub = true).
4289 * SP is valid, but ZR is NOT.
4290 * @param iRegSrc2 The register containing the addened (@a fSub
4291 * = false) or subtrahend (@a fSub = true).
4292 * SP is NOT valid, but ZR is.
4293 * @param f64Bit true for 64-bit GRPs (default), false for
4294 * 32-bit GPRs.
4295 * @param fSetFlags Whether to set flags (adds / subs) or not
4296 * (add / sub - default).
4297 * @param enmExtend The type of extension to apply to @a
4298 * iRegSrc2.
4299 * @param cShift The left shift count to apply to @a iRegSrc2
4300 * after enmExtend processing is done.
4301 * Max shift is 4 for some reason.
4302 */
4303DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAddSubRegExtend(bool fSub, uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4304 bool f64Bit = true, bool fSetFlags = false,
4305 ARMV8A64INSTREXTEND enmExtend = kArmv8A64InstrExtend_Default,
4306 uint32_t cShift = 0)
4307{
4308 if (enmExtend == kArmv8A64InstrExtend_Default)
4309 enmExtend = f64Bit ? kArmv8A64InstrExtend_UxtW : kArmv8A64InstrExtend_UxtX;
4310 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32); Assert(cShift <= 4);
4311
4312 return ((uint32_t)f64Bit << 31)
4313 | ((uint32_t)fSub << 30)
4314 | ((uint32_t)fSetFlags << 29)
4315 | UINT32_C(0x0b200000)
4316 | (iRegSrc2 << 16)
4317 | ((uint32_t)enmExtend << 13)
4318 | (cShift << 10)
4319 | (iRegSrc1 << 5)
4320 | iRegResult;
4321}
4322
4323
4324/**
4325 * A64: Encodes either adc, adcs, sbc or sbcs with two source registers.
4326 *
4327 * @returns The encoded instruction.
4328 * @param fSub true for sbc and sbcs, false for adc and
4329 * adcs.
4330 * @param iRegResult The register to store the result in. SP is
4331 * NOT valid, but ZR is.
4332 * @param iRegSrc1 The register containing the augend (@a fSub
4333 * = false) or minuend (@a fSub = true).
4334 * SP is NOT valid, but ZR is.
4335 * @param iRegSrc2 The register containing the addened (@a fSub
4336 * = false) or subtrahend (@a fSub = true).
4337 * SP is NOT valid, but ZR is.
4338 * @param f64Bit true for 64-bit GRPs (default), false for
4339 * 32-bit GPRs.
4340 * @param fSetFlags Whether to set flags (adds / subs) or not
4341 * (add / sub - default).
4342 */
4343DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAdcSbc(bool fSub, uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4344 bool f64Bit = true, bool fSetFlags = false)
4345{
4346 Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
4347
4348 return ((uint32_t)f64Bit << 31)
4349 | ((uint32_t)fSub << 30)
4350 | ((uint32_t)fSetFlags << 29)
4351 | UINT32_C(0x1a000000)
4352 | (iRegSrc2 << 16)
4353 | (iRegSrc1 << 5)
4354 | iRegResult;
4355}
4356
4357
4358/** ADC dst, reg1, reg2 */
4359DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAdc(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4360 bool f64Bit = true, bool fSetFlags = false)
4361{
4362 return Armv8A64MkInstrAdcSbc(false /*fSub*/, iRegResult, iRegSrc1, iRegSrc2, f64Bit, fSetFlags);
4363}
4364
4365
4366/** ADCS dst, reg1, reg2 */
4367DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrAdcs(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true)
4368{
4369 return Armv8A64MkInstrAdcSbc(false /*fSub*/, iRegResult, iRegSrc1, iRegSrc2, f64Bit, true /*fSetFlags*/);
4370}
4371
4372
4373/** SBC dst, reg1, reg2 */
4374DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSbc(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4375 bool f64Bit = true, bool fSetFlags = false)
4376{
4377 return Armv8A64MkInstrAdcSbc(true /*fSub*/, iRegResult, iRegSrc1, iRegSrc2, f64Bit, fSetFlags);
4378}
4379
4380
4381/** SBCS dst, reg1, reg2 */
4382DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSbcs(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2, bool f64Bit = true)
4383{
4384 return Armv8A64MkInstrAdcSbc(true /*fSub*/, iRegResult, iRegSrc1, iRegSrc2, f64Bit, true /*fSetFlags*/);
4385}
4386
4387
4388/**
4389 * A64: Encodes a B (unconditional branch w/ imm) instruction.
4390 *
4391 * @returns The encoded instruction.
4392 * @param iImm26 Signed number of instruction to jump (i.e. *4).
4393 */
4394DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrB(int32_t iImm26)
4395{
4396 Assert(iImm26 >= -67108864 && iImm26 < 67108864);
4397 return UINT32_C(0x14000000) | ((uint32_t)iImm26 & UINT32_C(0x3ffffff));
4398}
4399
4400
4401/**
4402 * A64: Encodes a BL (unconditional call w/ imm) instruction.
4403 *
4404 * @returns The encoded instruction.
4405 * @param iImm26 Signed number of instruction to jump (i.e. *4).
4406 */
4407DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBl(int32_t iImm26)
4408{
4409 return Armv8A64MkInstrB(iImm26) | RT_BIT_32(31);
4410}
4411
4412
4413/**
4414 * A64: Encodes a BR (unconditional branch w/ register) instruction.
4415 *
4416 * @returns The encoded instruction.
4417 * @param iReg The register containing the target address.
4418 */
4419DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBr(uint32_t iReg)
4420{
4421 Assert(iReg < 32);
4422 return UINT32_C(0xd61f0000) | (iReg << 5);
4423}
4424
4425
4426/**
4427 * A64: Encodes a BLR instruction.
4428 *
4429 * @returns The encoded instruction.
4430 * @param iReg The register containing the target address.
4431 */
4432DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBlr(uint32_t iReg)
4433{
4434 return Armv8A64MkInstrBr(iReg) | RT_BIT_32(21);
4435}
4436
4437
4438/**
4439 * A64: Encodes CBZ and CBNZ (conditional branch w/ immediate) instructions.
4440 *
4441 * @returns The encoded instruction.
4442 * @param fJmpIfNotZero false to jump if register is zero, true to jump if
4443 * its not zero.
4444 * @param iImm19 Signed number of instruction to jump (i.e. *4).
4445 * @param iReg The GPR to check for zero / non-zero value.
4446 * @param f64Bit true for 64-bit register, false for 32-bit.
4447 */
4448DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCbzCbnz(bool fJmpIfNotZero, int32_t iImm19, uint32_t iReg, bool f64Bit = true)
4449{
4450 Assert(iReg < 32); Assert(iImm19 >= -262144 && iImm19 < 262144);
4451 return ((uint32_t)f64Bit << 31)
4452 | UINT32_C(0x34000000)
4453 | ((uint32_t)fJmpIfNotZero << 24)
4454 | (((uint32_t)iImm19 & 0x7ffff) << 5)
4455 | iReg;
4456}
4457
4458
4459/** A64: Encodes the CBZ instructions. */
4460DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCbz(int32_t iImm19, uint32_t iReg, bool f64Bit = true)
4461{
4462 return Armv8A64MkInstrCbzCbnz(false /*fJmpIfNotZero*/, iImm19, iReg, f64Bit);
4463}
4464
4465
4466/** A64: Encodes the CBNZ instructions. */
4467DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCbnz(int32_t iImm19, uint32_t iReg, bool f64Bit = true)
4468{
4469 return Armv8A64MkInstrCbzCbnz(true /*fJmpIfNotZero*/, iImm19, iReg, f64Bit);
4470}
4471
4472
4473/**
4474 * A64: Encodes TBZ and TBNZ (conditional branch w/ immediate) instructions.
4475 *
4476 * @returns The encoded instruction.
4477 * @param fJmpIfNotZero false to jump if register is zero, true to jump if
4478 * its not zero.
4479 * @param iImm14 Signed number of instruction to jump (i.e. *4).
4480 * @param iReg The GPR to check for zero / non-zero value.
4481 * @param iBitNo The bit to test for.
4482 */
4483DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrTbzTbnz(bool fJmpIfNotZero, int32_t iImm14, uint32_t iReg, uint32_t iBitNo)
4484{
4485 Assert(iReg < 32); Assert(iImm14 >= -8192 && iImm14 < 8192); Assert(iBitNo < 64);
4486 return ((uint32_t)(iBitNo & 0x20) << (31-5))
4487 | UINT32_C(0x36000000)
4488 | ((uint32_t)fJmpIfNotZero << 24)
4489 | ((iBitNo & 0x1f) << 19)
4490 | (((uint32_t)iImm14 & 0x3fff) << 5)
4491 | iReg;
4492}
4493
4494
4495/**
4496 * A64: Encodes TBZ (conditional branch w/ immediate) instructions.
4497 *
4498 * @returns The encoded instruction.
4499 * @param iImm14 Signed number of instruction to jump (i.e. *4).
4500 * @param iReg The GPR to check for zero / non-zero value.
4501 * @param iBitNo The bit to test for.
4502 */
4503DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrTbz(int32_t iImm14, uint32_t iReg, uint32_t iBitNo)
4504{
4505 return Armv8A64MkInstrTbzTbnz(false /*fJmpIfNotZero*/, iImm14, iReg, iBitNo);
4506}
4507
4508
4509/**
4510 * A64: Encodes TBNZ (conditional branch w/ immediate) instructions.
4511 *
4512 * @returns The encoded instruction.
4513 * @param iImm14 Signed number of instruction to jump (i.e. *4).
4514 * @param iReg The GPR to check for zero / non-zero value.
4515 * @param iBitNo The bit to test for.
4516 */
4517DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrTbnz(int32_t iImm14, uint32_t iReg, uint32_t iBitNo)
4518{
4519 return Armv8A64MkInstrTbzTbnz(true /*fJmpIfNotZero*/, iImm14, iReg, iBitNo);
4520}
4521
4522
4523
4524/** Armv8 Condition codes. */
4525typedef enum ARMV8INSTRCOND
4526{
4527 kArmv8InstrCond_Eq = 0, /**< 0 - Equal - Zero set. */
4528 kArmv8InstrCond_Ne, /**< 1 - Not equal - Zero clear. */
4529
4530 kArmv8InstrCond_Cs, /**< 2 - Carry set (also known as 'HS'). */
4531 kArmv8InstrCond_Hs = kArmv8InstrCond_Cs, /**< 2 - Unsigned higher or same. */
4532 kArmv8InstrCond_Cc, /**< 3 - Carry clear (also known as 'LO'). */
4533 kArmv8InstrCond_Lo = kArmv8InstrCond_Cc, /**< 3 - Unsigned lower. */
4534
4535 kArmv8InstrCond_Mi, /**< 4 - Negative result (minus). */
4536 kArmv8InstrCond_Pl, /**< 5 - Positive or zero result (plus). */
4537
4538 kArmv8InstrCond_Vs, /**< 6 - Overflow set. */
4539 kArmv8InstrCond_Vc, /**< 7 - Overflow clear. */
4540
4541 kArmv8InstrCond_Hi, /**< 8 - Unsigned higher. */
4542 kArmv8InstrCond_Ls, /**< 9 - Unsigned lower or same. */
4543
4544 kArmv8InstrCond_Ge, /**< a - Signed greater or equal. */
4545 kArmv8InstrCond_Lt, /**< b - Signed less than. */
4546
4547 kArmv8InstrCond_Gt, /**< c - Signed greater than. */
4548 kArmv8InstrCond_Le, /**< d - Signed less or equal. */
4549
4550 kArmv8InstrCond_Al, /**< e - Condition is always true. */
4551 kArmv8InstrCond_Al1 /**< f - Condition is always true. */
4552} ARMV8INSTRCOND;
4553
4554/**
4555 * A64: Encodes conditional branch instruction w/ immediate target.
4556 *
4557 * @returns The encoded instruction.
4558 * @param enmCond The branch condition.
4559 * @param iImm19 Signed number of instruction to jump (i.e. *4).
4560 */
4561DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBCond(ARMV8INSTRCOND enmCond, int32_t iImm19)
4562{
4563 Assert((unsigned)enmCond < 16);
4564 return UINT32_C(0x54000000)
4565 | (((uint32_t)iImm19 & 0x7ffff) << 5)
4566 | (uint32_t)enmCond;
4567}
4568
4569
4570/**
4571 * A64: Encodes the BRK instruction.
4572 *
4573 * @returns The encoded instruction.
4574 * @param uImm16 Unsigned immediate value.
4575 */
4576DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrBrk(uint32_t uImm16)
4577{
4578 Assert(uImm16 < _64K);
4579 return UINT32_C(0xd4200000)
4580 | (uImm16 << 5);
4581}
4582
4583/** @name RMA64_NZCV_F_XXX - readable NZCV mask for CCMP and friends.
4584 * @{ */
4585#define ARMA64_NZCV_F_N0_Z0_C0_V0 UINT32_C(0x0)
4586#define ARMA64_NZCV_F_N0_Z0_C0_V1 UINT32_C(0x1)
4587#define ARMA64_NZCV_F_N0_Z0_C1_V0 UINT32_C(0x2)
4588#define ARMA64_NZCV_F_N0_Z0_C1_V1 UINT32_C(0x3)
4589#define ARMA64_NZCV_F_N0_Z1_C0_V0 UINT32_C(0x4)
4590#define ARMA64_NZCV_F_N0_Z1_C0_V1 UINT32_C(0x5)
4591#define ARMA64_NZCV_F_N0_Z1_C1_V0 UINT32_C(0x6)
4592#define ARMA64_NZCV_F_N0_Z1_C1_V1 UINT32_C(0x7)
4593
4594#define ARMA64_NZCV_F_N1_Z0_C0_V0 UINT32_C(0x8)
4595#define ARMA64_NZCV_F_N1_Z0_C0_V1 UINT32_C(0x9)
4596#define ARMA64_NZCV_F_N1_Z0_C1_V0 UINT32_C(0xa)
4597#define ARMA64_NZCV_F_N1_Z0_C1_V1 UINT32_C(0xb)
4598#define ARMA64_NZCV_F_N1_Z1_C0_V0 UINT32_C(0xc)
4599#define ARMA64_NZCV_F_N1_Z1_C0_V1 UINT32_C(0xd)
4600#define ARMA64_NZCV_F_N1_Z1_C1_V0 UINT32_C(0xe)
4601#define ARMA64_NZCV_F_N1_Z1_C1_V1 UINT32_C(0xf)
4602/** @} */
4603
4604/**
4605 * A64: Encodes CCMP or CCMN with two register operands.
4606 *
4607 * @returns The encoded instruction.
4608 * @param iRegSrc1 The 1st register. SP is NOT valid, but ZR is.
4609 * @param iRegSrc2 The 2nd register. SP is NOT valid, but ZR is.
4610 * @param fNzcv The N, Z, C & V flags values to load if the condition
4611 * does not match. See RMA64_NZCV_F_XXX.
4612 * @param enmCond The condition guarding the compare.
4613 * @param fCCmp Set for CCMP (default), clear for CCMN.
4614 * @param f64Bit true for 64-bit GRPs (default), false for 32-bit GPRs.
4615 */
4616DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCCmpCmnReg(uint32_t iRegSrc1, uint32_t iRegSrc2, uint32_t fNzcv,
4617 ARMV8INSTRCOND enmCond, bool fCCmp = true, bool f64Bit = true)
4618{
4619 Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32); Assert(fNzcv < 16);
4620
4621 return ((uint32_t)f64Bit << 31)
4622 | ((uint32_t)fCCmp << 30)
4623 | UINT32_C(0x3a400000)
4624 | (iRegSrc2 << 16)
4625 | ((uint32_t)enmCond << 12)
4626 | (iRegSrc1 << 5)
4627 | fNzcv;
4628}
4629
4630/** CCMP w/ reg. */
4631DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCCmpReg(uint32_t iRegSrc1, uint32_t iRegSrc2, uint32_t fNzcv,
4632 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4633{
4634 return Armv8A64MkInstrCCmpCmnReg(iRegSrc1, iRegSrc2, fNzcv, enmCond, true /*fCCmp*/, f64Bit);
4635}
4636
4637
4638/** CCMN w/ reg. */
4639DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCCmnReg(uint32_t iRegSrc1, uint32_t iRegSrc2, uint32_t fNzcv,
4640 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4641{
4642 return Armv8A64MkInstrCCmpCmnReg(iRegSrc1, iRegSrc2, fNzcv, enmCond, false /*fCCmp*/, f64Bit);
4643}
4644
4645
4646/**
4647 * A64: Encodes CCMP or CCMN with register and 5-bit immediate.
4648 *
4649 * @returns The encoded instruction.
4650 * @param iRegSrc The register. SP is NOT valid, but ZR is.
4651 * @param uImm5 The immediate, to compare iRegSrc with.
4652 * @param fNzcv The N, Z, C & V flags values to load if the condition
4653 * does not match. See RMA64_NZCV_F_XXX.
4654 * @param enmCond The condition guarding the compare.
4655 * @param fCCmp Set for CCMP (default), clear for CCMN.
4656 * @param f64Bit true for 64-bit GRPs (default), false for 32-bit GPRs.
4657 */
4658DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCCmpCmnImm(uint32_t iRegSrc, uint32_t uImm5, uint32_t fNzcv, ARMV8INSTRCOND enmCond,
4659 bool fCCmp = true, bool f64Bit = true)
4660{
4661 Assert(iRegSrc < 32); Assert(uImm5 < 32); Assert(fNzcv < 16);
4662
4663 return ((uint32_t)f64Bit << 31)
4664 | ((uint32_t)fCCmp << 30)
4665 | UINT32_C(0x3a400800)
4666 | (uImm5 << 16)
4667 | ((uint32_t)enmCond << 12)
4668 | (iRegSrc << 5)
4669 | fNzcv;
4670}
4671
4672/** CCMP w/ immediate. */
4673DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCCmpImm(uint32_t iRegSrc, uint32_t uImm5, uint32_t fNzcv,
4674 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4675{
4676 return Armv8A64MkInstrCCmpCmnImm(iRegSrc, uImm5, fNzcv, enmCond, true /*fCCmp*/, f64Bit);
4677}
4678
4679
4680/** CCMN w/ immediate. */
4681DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCCmnImm(uint32_t iRegSrc, uint32_t uImm5, uint32_t fNzcv,
4682 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4683{
4684 return Armv8A64MkInstrCCmpCmnImm(iRegSrc, uImm5, fNzcv, enmCond, false /*fCCmp*/, f64Bit);
4685}
4686
4687
4688/**
4689 * A64: Encodes CSEL, CSINC, CSINV and CSNEG (three registers)
4690 *
4691 * @returns The encoded instruction.
4692 * @param uOp Opcode bit 30.
4693 * @param uOp2 Opcode bits 11:10.
4694 * @param iRegResult The result register. SP is NOT valid, but ZR is.
4695 * @param iRegSrc1 The 1st source register. SP is NOT valid, but ZR is.
4696 * @param iRegSrc2 The 2nd source register. SP is NOT valid, but ZR is.
4697 * @param enmCond The condition guarding the compare.
4698 * @param f64Bit true for 64-bit GRPs (default), false for 32-bit GPRs.
4699 */
4700DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCondSelect(uint32_t uOp, uint32_t uOp2, uint32_t iRegResult, uint32_t iRegSrc1,
4701 uint32_t iRegSrc2, ARMV8INSTRCOND enmCond, bool f64Bit = true)
4702{
4703 Assert(uOp <= 1); Assert(uOp2 <= 1); Assert(iRegResult < 32); Assert(iRegSrc1 < 32); Assert(iRegSrc2 < 32);
4704
4705 return ((uint32_t)f64Bit << 31)
4706 | (uOp << 30)
4707 | UINT32_C(0x1a800000)
4708 | (iRegSrc2 << 16)
4709 | ((uint32_t)enmCond << 12)
4710 | (uOp2 << 10)
4711 | (iRegSrc1 << 5)
4712 | iRegResult;
4713}
4714
4715
4716/** A64: Encodes CSEL.
4717 * @see Armv8A64MkInstrCondSelect for details. */
4718DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCSel(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4719 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4720{
4721 return Armv8A64MkInstrCondSelect(0, 0, iRegResult, iRegSrc1, iRegSrc2, enmCond, f64Bit);
4722}
4723
4724
4725/** A64: Encodes CSINC.
4726 * @see Armv8A64MkInstrCondSelect for details. */
4727DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCSInc(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4728 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4729{
4730 return Armv8A64MkInstrCondSelect(0, 1, iRegResult, iRegSrc1, iRegSrc2, enmCond, f64Bit);
4731}
4732
4733
4734/** A64: Encodes CSET.
4735 * @see Armv8A64MkInstrCondSelect for details. */
4736DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCSet(uint32_t iRegResult, ARMV8INSTRCOND enmCond, bool f64Bit = true)
4737{
4738 Assert(enmCond != kArmv8InstrCond_Al && enmCond != kArmv8InstrCond_Al1);
4739 enmCond = (ARMV8INSTRCOND)((uint32_t)enmCond ^ 1);
4740 return Armv8A64MkInstrCSInc(iRegResult, ARMV8_A64_REG_XZR, ARMV8_A64_REG_XZR, enmCond, f64Bit);
4741}
4742
4743
4744/** A64: Encodes CSINV.
4745 * @see Armv8A64MkInstrCondSelect for details. */
4746DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCSInv(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4747 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4748{
4749 return Armv8A64MkInstrCondSelect(1, 0, iRegResult, iRegSrc1, iRegSrc2, enmCond, f64Bit);
4750}
4751
4752/** A64: Encodes CSETM.
4753 * @see Armv8A64MkInstrCondSelect for details. */
4754DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCSetM(uint32_t iRegResult, ARMV8INSTRCOND enmCond, bool f64Bit = true)
4755{
4756 Assert(enmCond != kArmv8InstrCond_Al && enmCond != kArmv8InstrCond_Al1);
4757 enmCond = (ARMV8INSTRCOND)((uint32_t)enmCond ^ 1);
4758 return Armv8A64MkInstrCSInv(iRegResult, ARMV8_A64_REG_XZR, ARMV8_A64_REG_XZR, enmCond, f64Bit);
4759}
4760
4761
4762/** A64: Encodes CSNEG.
4763 * @see Armv8A64MkInstrCondSelect for details. */
4764DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrCSNeg(uint32_t iRegResult, uint32_t iRegSrc1, uint32_t iRegSrc2,
4765 ARMV8INSTRCOND enmCond, bool f64Bit = true)
4766{
4767 return Armv8A64MkInstrCondSelect(1, 1, iRegResult, iRegSrc1, iRegSrc2, enmCond, f64Bit);
4768}
4769
4770
4771/**
4772 * A64: Encodes REV instruction.
4773 *
4774 * @returns The encoded instruction.
4775 * @param iRegDst The destination register. SP is NOT valid.
4776 * @param iRegSrc The source register. SP is NOT valid, but ZR is
4777 * @param f64Bit true for 64-bit GRPs (default), false for 32-bit GPRs.
4778 */
4779DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrRev(uint32_t iRegDst, uint32_t iRegSrc, bool f64Bit = true)
4780{
4781 Assert(iRegDst < 32); Assert(iRegSrc < 32);
4782
4783 return ((uint32_t)f64Bit << 31)
4784 | UINT32_C(0x5ac00800)
4785 | ((uint32_t)f64Bit << 10)
4786 | (iRegSrc << 5)
4787 | iRegDst;
4788}
4789
4790
4791/**
4792 * A64: Encodes REV16 instruction.
4793 *
4794 * @returns The encoded instruction.
4795 * @param iRegDst The destination register. SP is NOT valid.
4796 * @param iRegSrc The source register. SP is NOT valid, but ZR is
4797 * @param f64Bit true for 64-bit GRPs (default), false for 32-bit GPRs.
4798 */
4799DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrRev16(uint32_t iRegDst, uint32_t iRegSrc, bool f64Bit = true)
4800{
4801 Assert(iRegDst < 32); Assert(iRegSrc < 32);
4802
4803 return ((uint32_t)f64Bit << 31)
4804 | UINT32_C(0x5ac00400)
4805 | (iRegSrc << 5)
4806 | iRegDst;
4807}
4808
4809
4810/**
4811 * A64: Encodes SETF8 & SETF16.
4812 *
4813 * @returns The encoded instruction.
4814 * @param iRegResult The register holding the result. SP is NOT valid.
4815 * @param f16Bit Set for SETF16, clear for SETF8.
4816 */
4817DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrSetF8SetF16(uint32_t iRegResult, bool f16Bit)
4818{
4819 Assert(iRegResult < 32);
4820
4821 return UINT32_C(0x3a00080d)
4822 | ((uint32_t)f16Bit << 14)
4823 | (iRegResult << 5);
4824}
4825
4826
4827/**
4828 * A64: Encodes RMIF.
4829 *
4830 * @returns The encoded instruction.
4831 * @param iRegSrc The source register to get flags from.
4832 * @param cRotateRight The right rotate count (LSB bit offset).
4833 * @param fMask Mask of which flag bits to set:
4834 * - bit 0: V
4835 * - bit 1: C
4836 * - bit 2: Z
4837 * - bit 3: N
4838 */
4839DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrRmif(uint32_t iRegSrc, uint32_t cRotateRight, uint32_t fMask)
4840{
4841 Assert(iRegSrc < 32); Assert(cRotateRight < 64); Assert(fMask <= 0xf);
4842
4843 return UINT32_C(0xba000400)
4844 | (cRotateRight << 15)
4845 | (iRegSrc << 5)
4846 | fMask;
4847}
4848
4849
4850/**
4851 * A64: Encodes MRS (for reading a system register into a GPR).
4852 *
4853 * @returns The encoded instruction.
4854 * @param iRegDst The register to put the result into. SP is NOT valid.
4855 * @param idSysReg The system register ID (ARMV8_AARCH64_SYSREG_XXX),
4856 * IPRT specific format, of the register to read.
4857 */
4858DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMrs(uint32_t iRegDst, uint32_t idSysReg)
4859{
4860 Assert(iRegDst < 32);
4861 Assert(idSysReg < RT_BIT_32(16) && (idSysReg & RT_BIT_32(15)));
4862
4863 /* Note. The top bit of idSysReg must always be set and is also set in
4864 0xd5300000, otherwise we'll be encoding a different instruction. */
4865 return UINT32_C(0xd5300000)
4866 | (idSysReg << 5)
4867 | iRegDst;
4868}
4869
4870
4871/**
4872 * A64: Encodes MSR (for writing a GPR to a system register).
4873 *
4874 * @returns The encoded instruction.
4875 * @param iRegSrc The register which value to write. SP is NOT valid.
4876 * @param idSysReg The system register ID (ARMV8_AARCH64_SYSREG_XXX),
4877 * IPRT specific format, of the register to write.
4878 */
4879DECL_FORCE_INLINE(uint32_t) Armv8A64MkInstrMsr(uint32_t iRegSrc, uint32_t idSysReg)
4880{
4881 Assert(iRegSrc < 32);
4882 Assert(idSysReg < RT_BIT_32(16) && (idSysReg & RT_BIT_32(15)));
4883
4884 /* Note. The top bit of idSysReg must always be set and is also set in
4885 0xd5100000, otherwise we'll be encoding a different instruction. */
4886 return UINT32_C(0xd5100000)
4887 | (idSysReg << 5)
4888 | iRegSrc;
4889}
4890
4891
4892/** @} */
4893
4894
4895/** @defgroup grp_rt_armv8_mkinstr_vec Vector Instruction Encoding Helpers
4896 * @ingroup grp_rt_armv8_mkinstr
4897 *
4898 * A few inlined functions and macros for assisting in encoding common ARMv8
4899 * Neon/SIMD instructions.
4900 *
4901 * @{ */
4902
4903/** Armv8 vector logical operation. */
4904typedef enum
4905{
4906 kArmv8VecInstrLogicOp_And = 0, /**< AND */
4907 kArmv8VecInstrLogicOp_Bic = RT_BIT_32(22), /**< BIC */
4908 kArmv8VecInstrLogicOp_Orr = RT_BIT_32(23), /**< ORR */
4909 kArmv8VecInstrLogicOp_Orn = RT_BIT_32(23) | RT_BIT_32(22), /**< ORN */
4910 kArmv8VecInstrLogicOp_Eor = RT_BIT_32(29), /**< EOR */
4911 kArmv8VecInstrLogicOp_Bsl = RT_BIT_32(29) | RT_BIT_32(22), /**< BSL */
4912 kArmv8VecInstrLogicOp_Bit = RT_BIT_32(29) | RT_BIT_32(23), /**< BIT */
4913 kArmv8VecInstrLogicOp_Bif = RT_BIT_32(29) | RT_BIT_32(23) | RT_BIT_32(22) /**< BIF */
4914} ARMV8INSTRVECLOGICOP;
4915
4916
4917/**
4918 * A64: Encodes logical instruction (vector, register).
4919 *
4920 * @returns The encoded instruction.
4921 * @param enmOp The operation to encode.
4922 * @param iVecRegDst The vector register to put the result into.
4923 * @param iVecRegSrc1 The 1st source register.
4924 * @param iVecRegSrc2 The 2nd source register.
4925 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
4926 * or just the low 64-bit (false).
4927 */
4928DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrLogical(ARMV8INSTRVECLOGICOP enmOp, uint32_t iVecRegDst, uint32_t iVecRegSrc1, uint32_t iVecRegSrc2,
4929 bool f128Bit = true)
4930{
4931 Assert(iVecRegDst < 32); Assert(iVecRegSrc1 < 32); Assert(iVecRegSrc2 < 32);
4932
4933 return UINT32_C(0x0e201c00)
4934 | (uint32_t)enmOp
4935 | ((uint32_t)f128Bit << 30)
4936 | (iVecRegSrc2 << 16)
4937 | (iVecRegSrc1 << 5)
4938 | iVecRegDst;
4939}
4940
4941
4942/**
4943 * A64: Encodes ORR (vector, register).
4944 *
4945 * @returns The encoded instruction.
4946 * @param iVecRegDst The vector register to put the result into.
4947 * @param iVecRegSrc1 The 1st source register.
4948 * @param iVecRegSrc2 The 2nd source register.
4949 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
4950 * or just the low 64-bit (false).
4951 */
4952DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrOrr(uint32_t iVecRegDst, uint32_t iVecRegSrc1, uint32_t iVecRegSrc2,
4953 bool f128Bit = true)
4954{
4955 return Armv8A64MkVecInstrLogical(kArmv8VecInstrLogicOp_Orr, iVecRegDst, iVecRegSrc1, iVecRegSrc2, f128Bit);
4956}
4957
4958
4959/**
4960 * A64: Encodes EOR (vector, register).
4961 *
4962 * @returns The encoded instruction.
4963 * @param iVecRegDst The vector register to put the result into.
4964 * @param iVecRegSrc1 The 1st source register.
4965 * @param iVecRegSrc2 The 2nd source register.
4966 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
4967 * or just the low 64-bit (false).
4968 */
4969DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrEor(uint32_t iVecRegDst, uint32_t iVecRegSrc1, uint32_t iVecRegSrc2,
4970 bool f128Bit = true)
4971{
4972 return Armv8A64MkVecInstrLogical(kArmv8VecInstrLogicOp_Eor, iVecRegDst, iVecRegSrc1, iVecRegSrc2, f128Bit);
4973}
4974
4975
4976/**
4977 * A64: Encodes AND (vector, register).
4978 *
4979 * @returns The encoded instruction.
4980 * @param iVecRegDst The vector register to put the result into.
4981 * @param iVecRegSrc1 The 1st source register.
4982 * @param iVecRegSrc2 The 2nd source register.
4983 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
4984 * or just the low 64-bit (false).
4985 */
4986DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrAnd(uint32_t iVecRegDst, uint32_t iVecRegSrc1, uint32_t iVecRegSrc2,
4987 bool f128Bit = true)
4988{
4989 return Armv8A64MkVecInstrLogical(kArmv8VecInstrLogicOp_And, iVecRegDst, iVecRegSrc1, iVecRegSrc2, f128Bit);
4990}
4991
4992
4993/** Armv8 UMOV/INS vector element size. */
4994typedef enum ARMV8INSTRUMOVINSSZ
4995{
4996 kArmv8InstrUmovInsSz_U8 = 0, /**< Byte. */
4997 kArmv8InstrUmovInsSz_U16 = 1, /**< Halfword. */
4998 kArmv8InstrUmovInsSz_U32 = 2, /**< 32-bit. */
4999 kArmv8InstrUmovInsSz_U64 = 3 /**< 64-bit (only valid when the destination is a 64-bit register. */
5000} ARMV8INSTRUMOVINSSZ;
5001
5002
5003/**
5004 * A64: Encodes UMOV (vector, register).
5005 *
5006 * @returns The encoded instruction.
5007 * @param iRegDst The register to put the result into.
5008 * @param iVecRegSrc The vector source register.
5009 * @param idxElem The element index.
5010 * @param enmSz Element size of the source vector register.
5011 * @param fDst64Bit Flag whether the destination register is 64-bit (true) or 32-bit (false).
5012 */
5013DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrUmov(uint32_t iRegDst, uint32_t iVecRegSrc, uint8_t idxElem,
5014 ARMV8INSTRUMOVINSSZ enmSz = kArmv8InstrUmovInsSz_U64, bool fDst64Bit = true)
5015{
5016 Assert(iRegDst < 32); Assert(iVecRegSrc < 32);
5017 Assert((fDst64Bit && enmSz == kArmv8InstrUmovInsSz_U64) || (!fDst64Bit && enmSz != kArmv8InstrUmovInsSz_U64));
5018 Assert( (enmSz == kArmv8InstrUmovInsSz_U8 && idxElem < 16)
5019 || (enmSz == kArmv8InstrUmovInsSz_U16 && idxElem < 8)
5020 || (enmSz == kArmv8InstrUmovInsSz_U32 && idxElem < 4)
5021 || (enmSz == kArmv8InstrUmovInsSz_U64 && idxElem < 2));
5022
5023 return UINT32_C(0x0e003c00)
5024 | ((uint32_t)fDst64Bit << 30)
5025 | ((uint32_t)idxElem << (16 + enmSz + 1))
5026 | (RT_BIT_32(enmSz) << 16)
5027 | (iVecRegSrc << 5)
5028 | iRegDst;
5029}
5030
5031
5032/**
5033 * A64: Encodes INS (vector, register).
5034 *
5035 * @returns The encoded instruction.
5036 * @param iVecRegDst The vector register to put the result into.
5037 * @param iRegSrc The source register.
5038 * @param idxElem The element index for the destination.
5039 * @param enmSz Element size of the source vector register.
5040 *
5041 * @note This instruction assumes a 32-bit W<n> register for all non 64bit vector sizes.
5042 */
5043DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrIns(uint32_t iVecRegDst, uint32_t iRegSrc, uint8_t idxElem,
5044 ARMV8INSTRUMOVINSSZ enmSz = kArmv8InstrUmovInsSz_U64)
5045{
5046 Assert(iRegSrc < 32); Assert(iVecRegDst < 32);
5047 Assert( (enmSz == kArmv8InstrUmovInsSz_U8 && idxElem < 16)
5048 || (enmSz == kArmv8InstrUmovInsSz_U16 && idxElem < 8)
5049 || (enmSz == kArmv8InstrUmovInsSz_U32 && idxElem < 4)
5050 || (enmSz == kArmv8InstrUmovInsSz_U64 && idxElem < 2));
5051
5052 return UINT32_C(0x4e001c00)
5053 | ((uint32_t)idxElem << (16 + enmSz + 1))
5054 | (RT_BIT_32(enmSz) << 16)
5055 | (iRegSrc << 5)
5056 | iVecRegDst;
5057}
5058
5059
5060/**
5061 * A64: Encodes DUP (vector, register).
5062 *
5063 * @returns The encoded instruction.
5064 * @param iVecRegDst The vector register to put the result into.
5065 * @param iRegSrc The source register (ZR is valid).
5066 * @param enmSz Element size of the source vector register.
5067 * @param f128Bit Flag whether the instruction operates on the whole 128-bit of the vector register (true) or
5068 * just the low 64-bit (false).
5069 *
5070 * @note This instruction assumes a 32-bit W<n> register for all non 64bit vector sizes.
5071 */
5072DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrDup(uint32_t iVecRegDst, uint32_t iRegSrc, ARMV8INSTRUMOVINSSZ enmSz,
5073 bool f128Bit = true)
5074{
5075 Assert(iRegSrc < 32); Assert(iVecRegDst < 32);
5076 Assert( (enmSz == kArmv8InstrUmovInsSz_U8)
5077 || (enmSz == kArmv8InstrUmovInsSz_U16)
5078 || (enmSz == kArmv8InstrUmovInsSz_U32)
5079 || (enmSz == kArmv8InstrUmovInsSz_U64));
5080
5081 return UINT32_C(0x0e000c00)
5082 | ((uint32_t)f128Bit << 30)
5083 | (RT_BIT_32(enmSz) << 16)
5084 | (iRegSrc << 5)
5085 | iVecRegDst;
5086}
5087
5088
5089/** Armv8 vector compare to zero vector element size. */
5090typedef enum ARMV8INSTRVECCMPZEROSZ
5091{
5092 kArmv8InstrCmpZeroSz_S8 = 0, /**< Byte. */
5093 kArmv8InstrCmpZeroSz_S16 = 1, /**< Halfword. */
5094 kArmv8InstrCmpZeroSz_S32 = 2, /**< 32-bit. */
5095 kArmv8InstrCmpZeroSz_S64 = 3 /**< 64-bit. */
5096} ARMV8INSTRVECCMPZEROSZ;
5097
5098
5099/** Armv8 vector compare to zero vector operation. */
5100typedef enum ARMV8INSTRVECCMPZEROOP
5101{
5102 kArmv8InstrCmpZeroOp_Gt = 0, /**< Greater than. */
5103 kArmv8InstrCmpZeroOp_Ge = RT_BIT_32(29), /**< Greater than or equal to. */
5104 kArmv8InstrCmpZeroOp_Eq = RT_BIT_32(12), /**< Equal to. */
5105 kArmv8InstrCmpZeroOp_Le = RT_BIT_32(29) | RT_BIT_32(12) /**< Lower than or equal to. */
5106} ARMV8INSTRVECCMPZEROOP;
5107
5108
5109/**
5110 * A64: Encodes CMGT, CMGE, CMEQ or CMLE against zero (vector, register).
5111 *
5112 * @returns The encoded instruction.
5113 * @param iVecRegDst The vector register to put the result into.
5114 * @param iVecRegSrc The vector source register.
5115 * @param enmSz Vector element size.
5116 * @param enmOp The compare operation against to encode.
5117 */
5118DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrCmpToZero(uint32_t iVecRegDst, uint32_t iVecRegSrc, ARMV8INSTRVECCMPZEROSZ enmSz,
5119 ARMV8INSTRVECCMPZEROOP enmOp)
5120{
5121 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5122
5123 return UINT32_C(0x5e208800)
5124 | ((uint32_t)enmSz << 22)
5125 | (RT_BIT_32(enmSz) << 16)
5126 | (iVecRegSrc << 5)
5127 | iVecRegDst
5128 | (uint32_t)enmOp;
5129}
5130
5131
5132/**
5133 * A64: Encodes CNT (vector, register).
5134 *
5135 * @returns The encoded instruction.
5136 * @param iVecRegDst The vector register to put the result into.
5137 * @param iVecRegSrc The vector source register.
5138 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
5139 * or just the low 64-bit (false).
5140 */
5141DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrCnt(uint32_t iVecRegDst, uint32_t iVecRegSrc, bool f128Bit = true)
5142{
5143 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5144
5145 return UINT32_C(0x0e205800)
5146 | ((uint32_t)f128Bit << 30)
5147 | (iVecRegSrc << 5)
5148 | iVecRegDst;
5149}
5150
5151
5152/** Armv8 vector unsigned sum long across vector element size. */
5153typedef enum ARMV8INSTRVECUADDLVSZ
5154{
5155 kArmv8InstrUAddLVSz_8B = 0, /**< 8 x 8-bit. */
5156 kArmv8InstrUAddLVSz_16B = RT_BIT_32(30), /**< 16 x 8-bit. */
5157 kArmv8InstrUAddLVSz_4H = 1, /**< 4 x 16-bit. */
5158 kArmv8InstrUAddLVSz_8H = RT_BIT_32(30) | 1, /**< 8 x 16-bit. */
5159 kArmv8InstrUAddLVSz_4S = RT_BIT_32(30) | 2 /**< 4 x 32-bit. */
5160} ARMV8INSTRVECUADDLVSZ;
5161
5162
5163/**
5164 * A64: Encodes UADDLV (vector, register).
5165 *
5166 * @returns The encoded instruction.
5167 * @param iVecRegDst The vector register to put the result into.
5168 * @param iVecRegSrc The vector source register.
5169 * @param enmSz Element size.
5170 */
5171DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrUAddLV(uint32_t iVecRegDst, uint32_t iVecRegSrc, ARMV8INSTRVECUADDLVSZ enmSz)
5172{
5173 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5174
5175 return UINT32_C(0x2e303800)
5176 | ((uint32_t)enmSz)
5177 | (iVecRegSrc << 5)
5178 | iVecRegDst;
5179}
5180
5181
5182/** Armv8 USHR/USRA/URSRA/SSHR/SRSA/SSHR vector element size. */
5183typedef enum ARMV8INSTRUSHIFTSZ
5184{
5185 kArmv8InstrShiftSz_U8 = 8, /**< Byte. */
5186 kArmv8InstrShiftSz_U16 = 16, /**< Halfword. */
5187 kArmv8InstrShiftSz_U32 = 32, /**< 32-bit. */
5188 kArmv8InstrShiftSz_U64 = 64 /**< 64-bit. */
5189} ARMV8INSTRUSHIFTSZ;
5190
5191/**
5192 * A64: Encodes USHR/USRA/URSRA/SSHR/SRSA/SSHR (vector, register).
5193 *
5194 * @returns The encoded instruction.
5195 * @param iVecRegDst The vector register to put the result into.
5196 * @param iVecRegSrc The vector source register.
5197 * @param cShift Number of bits to shift.
5198 * @param enmSz Element size.
5199 * @param fUnsigned Flag whether this a signed or unsigned shift,
5200 * @param fRound Flag whether this is the rounding shift variant.
5201 * @param fAccum Flag whether this is the accumulate shift variant.
5202 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
5203 * or just the low 64-bit (false).
5204 */
5205DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrShrImm(uint32_t iVecRegDst, uint32_t iVecRegSrc, uint8_t cShift, ARMV8INSTRUSHIFTSZ enmSz,
5206 bool fUnsigned = true, bool fRound = false, bool fAccum = false, bool f128Bit = true)
5207{
5208 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5209 Assert( cShift >= 1
5210 && ( (enmSz == kArmv8InstrShiftSz_U8 && cShift <= 8)
5211 || (enmSz == kArmv8InstrShiftSz_U16 && cShift <= 16)
5212 || (enmSz == kArmv8InstrShiftSz_U32 && cShift <= 32)
5213 || (enmSz == kArmv8InstrShiftSz_U64 && cShift <= 64)));
5214
5215 return UINT32_C(0x0f000400)
5216 | ((uint32_t)f128Bit << 30)
5217 | ((uint32_t)fUnsigned << 29)
5218 | ((((uint32_t)enmSz << 1) - cShift) << 16)
5219 | ((uint32_t)fRound << 13)
5220 | ((uint32_t)fAccum << 12)
5221 | (iVecRegSrc << 5)
5222 | iVecRegDst;
5223}
5224
5225
5226/**
5227 * A64: Encodes SHL (vector, register).
5228 *
5229 * @returns The encoded instruction.
5230 * @param iVecRegDst The vector register to put the result into.
5231 * @param iVecRegSrc The vector source register.
5232 * @param cShift Number of bits to shift.
5233 * @param enmSz Element size.
5234 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
5235 * or just the low 64-bit (false).
5236 */
5237DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrShlImm(uint32_t iVecRegDst, uint32_t iVecRegSrc, uint8_t cShift, ARMV8INSTRUSHIFTSZ enmSz,
5238 bool f128Bit = true)
5239{
5240 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5241 Assert( (enmSz == kArmv8InstrShiftSz_U8 && cShift < 8)
5242 || (enmSz == kArmv8InstrShiftSz_U16 && cShift < 16)
5243 || (enmSz == kArmv8InstrShiftSz_U32 && cShift < 32)
5244 || (enmSz == kArmv8InstrShiftSz_U64 && cShift < 64));
5245
5246 return UINT32_C(0x0f005400)
5247 | ((uint32_t)f128Bit << 30)
5248 | (((uint32_t)enmSz | cShift) << 16)
5249 | (iVecRegSrc << 5)
5250 | iVecRegDst;
5251}
5252
5253
5254/**
5255 * A64: Encodes SHLL/SHLL2/USHLL/USHLL2 (vector, register).
5256 *
5257 * @returns The encoded instruction.
5258 * @param iVecRegDst The vector register to put the result into.
5259 * @param iVecRegSrc The vector source register.
5260 * @param cShift Number of bits to shift.
5261 * @param enmSz Element size of the source vector register, the destination vector register
5262 * element size is twice as large, kArmv8InstrShiftSz_U64 is invalid.
5263 * @param fUnsigned Flag whether this is an unsigned shift left (true, default) or signed (false).
5264 * @param fUpper Flag whether this operates on the lower half (false, default) of the source vector register
5265 * or the upper half (true).
5266 */
5267DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrUShll(uint32_t iVecRegDst, uint32_t iVecRegSrc, uint8_t cShift, ARMV8INSTRUSHIFTSZ enmSz,
5268 bool fUnsigned = true, bool fUpper = false)
5269{
5270 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5271 Assert( (enmSz == kArmv8InstrShiftSz_U8 && cShift < 8)
5272 || (enmSz == kArmv8InstrShiftSz_U16 && cShift < 16)
5273 || (enmSz == kArmv8InstrShiftSz_U32 && cShift < 32));
5274
5275 return UINT32_C(0x0f00a400)
5276 | ((uint32_t)fUpper << 30)
5277 | ((uint32_t)fUnsigned << 29)
5278 | (((uint32_t)enmSz | cShift) << 16)
5279 | (iVecRegSrc << 5)
5280 | iVecRegDst;
5281}
5282
5283
5284/** Armv8 vector arith ops element size. */
5285typedef enum ARMV8INSTRVECARITHSZ
5286{
5287 kArmv8VecInstrArithSz_8 = 0, /**< 8-bit. */
5288 kArmv8VecInstrArithSz_16 = 1, /**< 16-bit. */
5289 kArmv8VecInstrArithSz_32 = 2, /**< 32-bit. */
5290 kArmv8VecInstrArithSz_64 = 3 /**< 64-bit. */
5291} ARMV8INSTRVECARITHSZ;
5292
5293
5294/** Armv8 vector arithmetic operation. */
5295typedef enum
5296{
5297 kArmv8VecInstrArithOp_Add = RT_BIT_32(15), /**< ADD */
5298 kArmv8VecInstrArithOp_Sub = RT_BIT_32(29) | RT_BIT_32(15), /**< SUB */
5299 kArmv8VecInstrArithOp_UnsignSat_Add = RT_BIT_32(29) | RT_BIT_32(11), /**< UQADD */
5300 kArmv8VecInstrArithOp_UnsignSat_Sub = RT_BIT_32(29) | RT_BIT_32(13) | RT_BIT_32(11), /**< UQSUB */
5301 kArmv8VecInstrArithOp_SignSat_Add = RT_BIT_32(11), /**< SQADD */
5302 kArmv8VecInstrArithOp_SignSat_Sub = RT_BIT_32(13) | RT_BIT_32(11), /**< SQSUB */
5303 kArmv8VecInstrArithOp_Mul = RT_BIT_32(15) | RT_BIT_32(12) | RT_BIT_32(11) /**< MUL */
5304} ARMV8INSTRVECARITHOP;
5305
5306
5307/**
5308 * A64: Encodes an arithmetic operation (vector, register).
5309 *
5310 * @returns The encoded instruction.
5311 * @param enmOp The operation to encode.
5312 * @param iVecRegDst The vector register to put the result into.
5313 * @param iVecRegSrc1 The first vector source register.
5314 * @param iVecRegSrc2 The second vector source register.
5315 * @param enmSz Element size.
5316 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
5317 * or just the low 64-bit (false).
5318 */
5319DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrArithOp(ARMV8INSTRVECARITHOP enmOp, uint32_t iVecRegDst, uint32_t iVecRegSrc1, uint32_t iVecRegSrc2,
5320 ARMV8INSTRVECARITHSZ enmSz, bool f128Bit = true)
5321{
5322 Assert(iVecRegDst < 32); Assert(iVecRegSrc1 < 32); Assert(iVecRegSrc2 < 32);
5323
5324 return UINT32_C(0x0e200400)
5325 | (uint32_t)enmOp
5326 | ((uint32_t)f128Bit << 30)
5327 | ((uint32_t)enmSz << 22)
5328 | (iVecRegSrc2 << 16)
5329 | (iVecRegSrc1 << 5)
5330 | iVecRegDst;
5331}
5332
5333
5334/** Armv8 vector compare operation. */
5335typedef enum ARMV8VECINSTRCMPOP
5336{
5337 /* U insn[15:10] */
5338 kArmv8VecInstrCmpOp_Gt = UINT32_C(0x3400), /**< Greater than (>) (signed) */
5339 kArmv8VecInstrCmpOp_Ge = UINT32_C(0x3c00), /**< Greater or equal (>=) (signed) */
5340 kArmv8VecInstrCmpOp_Hi = RT_BIT_32(29) | UINT32_C(0x3400), /**< Greater than (>) (unsigned) */
5341 kArmv8VecInstrCmpOp_Hs = RT_BIT_32(29) | UINT32_C(0x3c00), /**< Greater or equal (>=) (unsigned) */
5342 kArmv8VecInstrCmpOp_Eq = RT_BIT_32(29) | UINT32_C(0x8c00) /**< Equal (==) (unsigned) */
5343} ARMV8VECINSTRCMPOP;
5344
5345/**
5346 * A64: Encodes CMEQ/CMGE/CMGT/CMHI/CMHS (register variant) (vector, register).
5347 *
5348 * @returns The encoded instruction.
5349 * @param enmOp The operation to perform.
5350 * @param iVecRegDst The vector register to put the result into.
5351 * @param iVecRegSrc1 The first vector source register.
5352 * @param iVecRegSrc2 The second vector source register.
5353 * @param enmSz Element size.
5354 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
5355 * or just the low 64-bit (false).
5356 */
5357DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrCmp(ARMV8VECINSTRCMPOP enmOp, uint32_t iVecRegDst, uint32_t iVecRegSrc1, uint32_t iVecRegSrc2,
5358 ARMV8INSTRVECARITHSZ enmSz, bool f128Bit = true)
5359{
5360 Assert(iVecRegDst < 32); Assert(iVecRegSrc1 < 32); Assert(iVecRegSrc2 < 32);
5361
5362 return UINT32_C(0x0e200000)
5363 | ((uint32_t)f128Bit << 30)
5364 | ((uint32_t)enmSz << 22)
5365 | (iVecRegSrc2 << 16)
5366 | ((uint32_t)enmOp)
5367 | (iVecRegSrc1 << 5)
5368 | iVecRegDst;
5369}
5370
5371
5372/** Armv8 vector compare against zero operation. */
5373typedef enum ARMV8VECINSTRCMPZEROOP
5374{
5375 /* U insn[15:10] */
5376 kArmv8VecInstrCmpZeroOp_Gt = UINT32_C(0x8800), /**< Greater than zero (>) (signed) */
5377 kArmv8VecInstrCmpZeroOp_Eq = UINT32_C(0x9800), /**< Equal to zero (==) */
5378 kArmv8VecInstrCmpZeroOp_Lt = UINT32_C(0xa800), /**< Lower than zero (>=) (signed) */
5379 kArmv8VecInstrCmpZeroOp_Ge = RT_BIT_32(29) | UINT32_C(0x8800), /**< Greater or equal to zero (>=) (signed) */
5380 kArmv8VecInstrCmpZeroOp_Le = RT_BIT_32(29) | UINT32_C(0x9800) /**< Lower or equal to zero (<=) (signed) */
5381} ARMV8VECINSTRCMPZEROOP;
5382
5383/**
5384 * A64: Encodes CMEQ/CMGE/CMGT/CMLE/CMLT (zero variant) (vector, register).
5385 *
5386 * @returns The encoded instruction.
5387 * @param enmOp The operation to perform.
5388 * @param iVecRegDst The vector register to put the result into.
5389 * @param iVecRegSrc The first vector source register.
5390 * @param enmSz Element size.
5391 * @param f128Bit Flag whether this operates on the full 128-bit (true, default) of the vector register
5392 * or just the low 64-bit (false).
5393 */
5394DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrCmpAgainstZero(ARMV8VECINSTRCMPOP enmOp, uint32_t iVecRegDst, uint32_t iVecRegSrc,
5395 ARMV8INSTRVECARITHSZ enmSz, bool f128Bit = true)
5396{
5397 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5398
5399 return UINT32_C(0x0e200000)
5400 | ((uint32_t)f128Bit << 30)
5401 | ((uint32_t)enmSz << 22)
5402 | ((uint32_t)enmOp)
5403 | (iVecRegSrc << 5)
5404 | iVecRegDst;
5405}
5406
5407
5408/** Armv8 [Signed,Unsigned] Extract {Unsigned} operation. */
5409typedef enum
5410{
5411 kArmv8VecInstrQxtnOp_Sqxtn = RT_BIT_32(14), /**< SQXTN */
5412 kArmv8VecInstrQxtnOp_Sqxtun = RT_BIT_32(29) | RT_BIT_32(13), /**< SQXTUN */
5413 kArmv8VecInstrQxtnOp_Uqxtn = RT_BIT_32(29) | RT_BIT_32(14) /**< UQXTN */
5414} ARMV8INSTRVECQXTNOP;
5415
5416/**
5417 * A64: Encodes SQXTN/SQXTN2/UQXTN/UQXTN2/SQXTUN/SQXTUN2 (vector, register).
5418 *
5419 * @returns The encoded instruction.
5420 * @param enmOp The operation to perform.
5421 * @param fUpper Flag whether to write the result to the lower (false) or upper (true) half of the destinatiom register.
5422 * @param iVecRegDst The vector register to put the result into.
5423 * @param iVecRegSrc The first vector source register.
5424 * @param enmSz Element size.
5425 */
5426DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrQxtn(ARMV8INSTRVECQXTNOP enmOp, bool fUpper, uint32_t iVecRegDst, uint32_t iVecRegSrc, ARMV8INSTRVECARITHSZ enmSz)
5427{
5428 Assert(iVecRegDst < 32); Assert(iVecRegSrc < 32);
5429
5430 return UINT32_C(0x0e210800)
5431 | ((uint32_t)enmOp)
5432 | ((uint32_t)fUpper << 30)
5433 | ((uint32_t)enmSz << 22)
5434 | (iVecRegSrc << 5)
5435 | iVecRegDst;
5436}
5437
5438
5439/** Armv8 floating point size. */
5440typedef enum
5441{
5442 kArmv8VecInstrFpSz_2x_Single = 0, /**< 2x single precision values in the low 64-bit of the 128-bit register. */
5443 kArmv8VecInstrFpSz_4x_Single = RT_BIT_32(30), /**< 4x single precision values in the 128-bit register. */
5444 kArmv8VecInstrFpSz_2x_Double = RT_BIT_32(30) | RT_BIT_32(22) /**< 2x double precision values in the 128-bit register. */
5445} ARMV8INSTRVECFPSZ;
5446
5447
5448/** Armv8 3 operand floating point operation. */
5449typedef enum
5450{
5451 /* insn[29] insn[23] insn[15:11] */
5452 kArmv8VecInstrFpOp_Add = UINT32_C(0xd000), /**< FADD */
5453 kArmv8VecInstrFpOp_Sub = RT_BIT_32(23) | UINT32_C(0xd000), /**< FADD */
5454 kArmv8VecInstrFpOp_AddPairwise = RT_BIT_32(29) | UINT32_C(0xd000), /**< FADDP */
5455 kArmv8VecInstrFpOp_Mul = RT_BIT_32(29) | UINT32_C(0xd800), /**< FMUL */
5456 kArmv8VecInstrFpOp_Div = RT_BIT_32(29) | UINT32_C(0xf800), /**< FDIV */
5457
5458 kArmv8VecInstrFpOp_Max = UINT32_C(0xf000), /**< FMAX */
5459 kArmv8VecInstrFpOp_MaxNumber = UINT32_C(0xc000), /**< FMAXNM */
5460 kArmv8VecInstrFpOp_MaxNumberPairwise = RT_BIT_32(29) | UINT32_C(0xc000), /**< FMAXNMP */
5461 kArmv8VecInstrFpOp_MaxPairwise = RT_BIT_32(29) | UINT32_C(0xf000), /**< FMAXP */
5462
5463 kArmv8VecInstrFpOp_Min = RT_BIT_32(23) | UINT32_C(0xf000), /**< FMIN */
5464 kArmv8VecInstrFpOp_MinNumber = RT_BIT_32(23) | UINT32_C(0xc000), /**< FMINNM */
5465 kArmv8VecInstrFpOp_MinNumberPairwise = RT_BIT_32(29) | RT_BIT_32(23) | UINT32_C(0xc000), /**< FMINNMP */
5466 kArmv8VecInstrFpOp_MinPairwise = RT_BIT_32(29) | RT_BIT_32(23) | UINT32_C(0xf000), /**< FMINP */
5467
5468 kArmv8VecInstrFpOp_Fmla = UINT32_C(0xc800), /**< FMLA */
5469 kArmv8VecInstrFpOp_Fmls = RT_BIT_32(23) | UINT32_C(0xc800) /**< FMLS */
5470} ARMV8INSTRVECFPOP;
5471
5472/**
5473 * A64: Encodes a 3 operand floating point operation (vector, register).
5474 *
5475 * @returns The encoded instruction.
5476 * @param enmOp The operation to perform.
5477 * @param enmSz The size to operate on.
5478 * @param iVecRegDst The vector register to put the result into.
5479 * @param iVecRegSrc1 The first vector source register.
5480 * @param iVecRegSrc2 The second vector source register.
5481 */
5482DECL_FORCE_INLINE(uint32_t) Armv8A64MkVecInstrFp3Op(ARMV8INSTRVECFPOP enmOp, ARMV8INSTRVECFPSZ enmSz, uint32_t iVecRegDst,
5483 uint32_t iVecRegSrc1, uint32_t iVecRegSrc2)
5484{
5485 Assert(iVecRegDst < 32); Assert(iVecRegSrc1 < 32); Assert(iVecRegSrc2 < 32);
5486
5487 return UINT32_C(0x0e200400)
5488 | ((uint32_t)enmOp)
5489 | ((uint32_t)enmSz)
5490 | (iVecRegSrc2 << 16)
5491 | (iVecRegSrc1 << 5)
5492 | iVecRegDst;
5493}
5494
5495
5496/** @} */
5497
5498#endif /* !dtrace && __cplusplus */
5499
5500/** @} */
5501
5502#endif /* !IPRT_INCLUDED_armv8_h */
5503
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette