1 | /** @file
|
---|
2 | * IPRT - ARMv8 (AArch64 and AArch32) Structures and Definitions.
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2023 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/types.h>
|
---|
44 | # include <iprt/assert.h>
|
---|
45 | #else
|
---|
46 | # pragma D depends_on library vbox-types.d
|
---|
47 | #endif
|
---|
48 |
|
---|
49 | /** @defgroup grp_rt_armv8 ARMv8 Types and Definitions
|
---|
50 | * @ingroup grp_rt
|
---|
51 | * @{
|
---|
52 | */
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * SPSR_EL2 (according to chapter C5.2.19)
|
---|
56 | */
|
---|
57 | typedef union ARMV8SPSREL2
|
---|
58 | {
|
---|
59 | /** The plain unsigned view. */
|
---|
60 | uint64_t u;
|
---|
61 | /** The 8-bit view. */
|
---|
62 | uint8_t au8[8];
|
---|
63 | /** The 16-bit view. */
|
---|
64 | uint16_t au16[4];
|
---|
65 | /** The 32-bit view. */
|
---|
66 | uint32_t au32[2];
|
---|
67 | /** The 64-bit view. */
|
---|
68 | uint64_t u64;
|
---|
69 | } ARMV8SPSREL2;
|
---|
70 | /** Pointer to SPSR_EL2. */
|
---|
71 | typedef ARMV8SPSREL2 *PARMV8SPSREL2;
|
---|
72 | /** Pointer to const SPSR_EL2. */
|
---|
73 | typedef const ARMV8SPSREL2 *PCXARMV8SPSREL2;
|
---|
74 |
|
---|
75 |
|
---|
76 | /** @name SPSR_EL2 (When exception is taken from AArch64 state)
|
---|
77 | * @{
|
---|
78 | */
|
---|
79 | /** Bit 0 - 3 - M - AArch64 Exception level and selected stack pointer. */
|
---|
80 | #define ARMV8_SPSR_EL2_AARCH64_M (RT_BIT_64(0) | RT_BIT_64(1) | RT_BIT_64(2) | RT_BIT_64(3))
|
---|
81 | #define ARMV8_SPSR_EL2_AARCH64_GET_M(a_Spsr) ((a_Spsr) & ARMV8_SPSR_EL2_AARCH64_M)
|
---|
82 | /** Bit 0 - SP - Selected stack pointer. */
|
---|
83 | #define ARMV8_SPSR_EL2_AARCH64_SP RT_BIT_64(0)
|
---|
84 | #define ARMV8_SPSR_EL2_AARCH64_SP_BIT 0
|
---|
85 | /** Bit 1 - Reserved (read as zero). */
|
---|
86 | #define ARMV8_SPSR_EL2_AARCH64_RSVD_1 RT_BIT_64(1)
|
---|
87 | /** Bit 2 - 3 - EL - Exception level. */
|
---|
88 | #define ARMV8_SPSR_EL2_AARCH64_EL (RT_BIT_64(2) | RT_BIT_64(3))
|
---|
89 | #define ARMV8_SPSR_EL2_AARCH64_EL_SHIFT 2
|
---|
90 | #define ARMV8_SPSR_EL2_AARCH64_GET_EL(a_Spsr) (((a_Spsr) >> ARMV8_SPSR_EL2_AARCH64_EL_SHIFT) & 3)
|
---|
91 | #define ARMV8_SPSR_EL2_AARCH64_SET_EL(a_El) ((a_El) << ARMV8_SPSR_EL2_AARCH64_EL_SHIFT)
|
---|
92 | /** Bit 4 - M[4] - Execution state (0 means AArch64, when 1 this contains a AArch32 state). */
|
---|
93 | #define ARMV8_SPSR_EL2_AARCH64_M4 RT_BIT_64(4)
|
---|
94 | #define ARMV8_SPSR_EL2_AARCH64_M4_BIT 4
|
---|
95 | /** Bit 5 - Reserved (read as zero). */
|
---|
96 | #define ARMV8_SPSR_EL2_AARCH64_RSVD_5 RT_BIT_64(5)
|
---|
97 | /** Bit 6 - I - FIQ interrupt mask. */
|
---|
98 | #define ARMV8_SPSR_EL2_AARCH64_F RT_BIT_64(6)
|
---|
99 | #define ARMV8_SPSR_EL2_AARCH64_F_BIT 6
|
---|
100 | /** Bit 7 - I - IRQ interrupt mask. */
|
---|
101 | #define ARMV8_SPSR_EL2_AARCH64_I RT_BIT_64(7)
|
---|
102 | #define ARMV8_SPSR_EL2_AARCH64_I_BIT 7
|
---|
103 | /** Bit 8 - A - SError interrupt mask. */
|
---|
104 | #define ARMV8_SPSR_EL2_AARCH64_A RT_BIT_64(8)
|
---|
105 | #define ARMV8_SPSR_EL2_AARCH64_A_BIT 8
|
---|
106 | /** Bit 9 - D - Debug Exception mask. */
|
---|
107 | #define ARMV8_SPSR_EL2_AARCH64_D RT_BIT_64(9)
|
---|
108 | #define ARMV8_SPSR_EL2_AARCH64_D_BIT 9
|
---|
109 | /** Bit 10 - 11 - BTYPE - Branch Type indicator. */
|
---|
110 | #define ARMV8_SPSR_EL2_AARCH64_BYTPE (RT_BIT_64(10) | RT_BIT_64(11))
|
---|
111 | #define ARMV8_SPSR_EL2_AARCH64_BYTPE_SHIFT 10
|
---|
112 | #define ARMV8_SPSR_EL2_AARCH64_GET_BYTPE(a_Spsr) (((a_Spsr) >> ARMV8_SPSR_EL2_AARCH64_BYTPE_SHIFT) & 3)
|
---|
113 | /** Bit 12 - SSBS - Speculative Store Bypass. */
|
---|
114 | #define ARMV8_SPSR_EL2_AARCH64_SSBS RT_BIT_64(12)
|
---|
115 | #define ARMV8_SPSR_EL2_AARCH64_SSBS_BIT 12
|
---|
116 | /** Bit 13 - ALLINT - All IRQ or FIQ interrupts mask. */
|
---|
117 | #define ARMV8_SPSR_EL2_AARCH64_ALLINT RT_BIT_64(13)
|
---|
118 | #define ARMV8_SPSR_EL2_AARCH64_ALLINT_BIT 13
|
---|
119 | /** Bit 14 - 19 - Reserved (read as zero). */
|
---|
120 | #define ARMV8_SPSR_EL2_AARCH64_RSVD_14_19 ( RT_BIT_64(14) | RT_BIT_64(15) | RT_BIT_64(16) \
|
---|
121 | | RT_BIT_64(17) | RT_BIT_64(18) | RT_BIT_64(19))
|
---|
122 | /** Bit 20 - IL - Illegal Execution State flag. */
|
---|
123 | #define ARMV8_SPSR_EL2_AARCH64_IL RT_BIT_64(20)
|
---|
124 | #define ARMV8_SPSR_EL2_AARCH64_IL_BIT 20
|
---|
125 | /** Bit 21 - SS - Software Step flag. */
|
---|
126 | #define ARMV8_SPSR_EL2_AARCH64_SS RT_BIT_64(21)
|
---|
127 | #define ARMV8_SPSR_EL2_AARCH64_SS_BIT 21
|
---|
128 | /** Bit 22 - PAN - Privileged Access Never flag. */
|
---|
129 | #define ARMV8_SPSR_EL2_AARCH64_PAN RT_BIT_64(25)
|
---|
130 | #define ARMV8_SPSR_EL2_AARCH64_PAN_BIT 22
|
---|
131 | /** Bit 23 - UAO - User Access Override flag. */
|
---|
132 | #define ARMV8_SPSR_EL2_AARCH64_UAO RT_BIT_64(23)
|
---|
133 | #define ARMV8_SPSR_EL2_AARCH64_UAO_BIT 23
|
---|
134 | /** Bit 24 - DIT - Data Independent Timing flag. */
|
---|
135 | #define ARMV8_SPSR_EL2_AARCH64_DIT RT_BIT_64(24)
|
---|
136 | #define ARMV8_SPSR_EL2_AARCH64_DIT_BIT 24
|
---|
137 | /** Bit 25 - TCO - Tag Check Override flag. */
|
---|
138 | #define ARMV8_SPSR_EL2_AARCH64_TCO RT_BIT_64(25)
|
---|
139 | #define ARMV8_SPSR_EL2_AARCH64_TCO_BIT 25
|
---|
140 | /** Bit 26 - 27 - Reserved (read as zero). */
|
---|
141 | #define ARMV8_SPSR_EL2_AARCH64_RSVD_26_27 (RT_BIT_64(26) | RT_BIT_64(27))
|
---|
142 | /** Bit 28 - V - Overflow condition flag. */
|
---|
143 | #define ARMV8_SPSR_EL2_AARCH64_V RT_BIT_64(28)
|
---|
144 | #define ARMV8_SPSR_EL2_AARCH64_V_BIT 28
|
---|
145 | /** Bit 29 - C - Carry condition flag. */
|
---|
146 | #define ARMV8_SPSR_EL2_AARCH64_C RT_BIT_64(29)
|
---|
147 | #define ARMV8_SPSR_EL2_AARCH64_C_BIT 29
|
---|
148 | /** Bit 30 - Z - Zero condition flag. */
|
---|
149 | #define ARMV8_SPSR_EL2_AARCH64_Z RT_BIT_64(30)
|
---|
150 | #define ARMV8_SPSR_EL2_AARCH64_Z_BIT 30
|
---|
151 | /** Bit 31 - N - Negative condition flag. */
|
---|
152 | #define ARMV8_SPSR_EL2_AARCH64_N RT_BIT_64(31)
|
---|
153 | #define ARMV8_SPSR_EL2_AARCH64_N_BIT 31
|
---|
154 | /** Bit 32 - 63 - Reserved (read as zero). */
|
---|
155 | #define ARMV8_SPSR_EL2_AARCH64_RSVD_32_63 (UINT64_C(0xffffffff00000000))
|
---|
156 | /** Checks whether the given SPSR value contains a AARCH64 execution state. */
|
---|
157 | #define ARMV8_SPSR_EL2_IS_AARCH64_STATE(a_Spsr) (!((a_Spsr) & ARMV8_SPSR_EL2_AARCH64_M4))
|
---|
158 | /** @} */
|
---|
159 |
|
---|
160 | /** @name Aarch64 Exception levels
|
---|
161 | * @{ */
|
---|
162 | /** Exception Level 0 - User mode. */
|
---|
163 | #define ARMV8_AARCH64_EL_0 0
|
---|
164 | /** Exception Level 1 - Supervisor mode. */
|
---|
165 | #define ARMV8_AARCH64_EL_1 1
|
---|
166 | /** Exception Level 2 - Hypervisor mode. */
|
---|
167 | #define ARMV8_AARCH64_EL_0 2
|
---|
168 | /** @} */
|
---|
169 |
|
---|
170 |
|
---|
171 | /** @} */
|
---|
172 |
|
---|
173 | #endif /* !IPRT_INCLUDED_armv8_h */
|
---|
174 |
|
---|