VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/Firmware/ArmPkg/Include/Chipset/AArch64.h@ 105681

Last change on this file since 105681 was 105670, checked in by vboxsync, 9 months ago

Devices/EFI/FirmwareNew: Merge edk2-stable-202405 and make it build on aarch64, bugref:4643

  • Property svn:eol-style set to native
File size: 4.9 KB
Line 
1/** @file
2
3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.<BR>
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8**/
9
10#ifndef AARCH64_H_
11#define AARCH64_H_
12
13#include <Chipset/AArch64Mmu.h>
14
15// ARM Interrupt ID in Exception Table
16#define ARM_ARCH_EXCEPTION_IRQ EXCEPT_AARCH64_IRQ
17
18// CPACR - Coprocessor Access Control Register definitions
19#define CPACR_TTA_EN (1UL << 28)
20#define CPACR_FPEN_EL1 (1UL << 20)
21#define CPACR_FPEN_FULL (3UL << 20)
22#define CPACR_CP_FULL_ACCESS 0x300000
23
24// Coprocessor Trap Register (CPTR)
25#define AARCH64_CPTR_TFP (1 << 10)
26
27// ID_AA64MMFR1 - AArch64 Memory Model Feature Register 0 definitions
28#define AARCH64_MMFR1_VH (0xF << 8)
29
30// ID_AA64PFR0 - AArch64 Processor Feature Register 0 definitions
31#define AARCH64_PFR0_FP (0xF << 16)
32#define AARCH64_PFR0_GIC (0xF << 24)
33
34// ID_AA64DFR0 - AArch64 Debug Feature Register 0 definitions
35#define AARCH64_DFR0_TRACEVER (0xFULL << 4)
36#define AARCH64_DFR0_TRBE (0xFULL << 44)
37
38// SCR - Secure Configuration Register definitions
39#define SCR_NS (1 << 0)
40#define SCR_IRQ (1 << 1)
41#define SCR_FIQ (1 << 2)
42#define SCR_EA (1 << 3)
43#define SCR_FW (1 << 4)
44#define SCR_AW (1 << 5)
45
46// MIDR - Main ID Register definitions
47#define ARM_CPU_TYPE_SHIFT 4
48#define ARM_CPU_TYPE_MASK 0xFFF
49#define ARM_CPU_TYPE_AEMV8 0xD0F
50#define ARM_CPU_TYPE_A53 0xD03
51#define ARM_CPU_TYPE_A57 0xD07
52#define ARM_CPU_TYPE_A72 0xD08
53#define ARM_CPU_TYPE_A15 0xC0F
54#define ARM_CPU_TYPE_A9 0xC09
55#define ARM_CPU_TYPE_A7 0xC07
56#define ARM_CPU_TYPE_A5 0xC05
57
58#define ARM_CPU_REV_MASK ((0xF << 20) | (0xF) )
59#define ARM_CPU_REV(rn, pn) ((((rn) & 0xF) << 20) | ((pn) & 0xF))
60
61// Hypervisor Configuration Register
62#define ARM_HCR_FMO BIT3
63#define ARM_HCR_IMO BIT4
64#define ARM_HCR_AMO BIT5
65#define ARM_HCR_TSC BIT19
66#define ARM_HCR_TGE BIT27
67
68// Exception Syndrome Register
69#define AARCH64_ESR_EC(Ecr) ((0x3F << 26) & (Ecr))
70#define AARCH64_ESR_ISS(Ecr) ((0x1FFFFFF) & (Ecr))
71
72#define AARCH64_ESR_EC_SMC32 (0x13 << 26)
73#define AARCH64_ESR_EC_SMC64 (0x17 << 26)
74
75// AArch64 Exception Level
76#define AARCH64_EL3 0xC
77#define AARCH64_EL2 0x8
78#define AARCH64_EL1 0x4
79
80// Saved Program Status Register definitions
81#define SPSR_A BIT8
82#define SPSR_I BIT7
83#define SPSR_F BIT6
84
85#define SPSR_AARCH32 BIT4
86
87#define SPSR_AARCH32_MODE_USER 0x0
88#define SPSR_AARCH32_MODE_FIQ 0x1
89#define SPSR_AARCH32_MODE_IRQ 0x2
90#define SPSR_AARCH32_MODE_SVC 0x3
91#define SPSR_AARCH32_MODE_ABORT 0x7
92#define SPSR_AARCH32_MODE_UNDEF 0xB
93#define SPSR_AARCH32_MODE_SYS 0xF
94
95// Counter-timer Hypervisor Control register definitions
96#define CNTHCTL_EL2_EL1PCTEN BIT0
97#define CNTHCTL_EL2_EL1PCEN BIT1
98
99#define ARM_VECTOR_TABLE_ALIGNMENT ((1 << 11)-1)
100
101// Vector table offset definitions
102#define ARM_VECTOR_CUR_SP0_SYNC 0x000
103#define ARM_VECTOR_CUR_SP0_IRQ 0x080
104#define ARM_VECTOR_CUR_SP0_FIQ 0x100
105#define ARM_VECTOR_CUR_SP0_SERR 0x180
106
107#define ARM_VECTOR_CUR_SPX_SYNC 0x200
108#define ARM_VECTOR_CUR_SPX_IRQ 0x280
109#define ARM_VECTOR_CUR_SPX_FIQ 0x300
110#define ARM_VECTOR_CUR_SPX_SERR 0x380
111
112#define ARM_VECTOR_LOW_A64_SYNC 0x400
113#define ARM_VECTOR_LOW_A64_IRQ 0x480
114#define ARM_VECTOR_LOW_A64_FIQ 0x500
115#define ARM_VECTOR_LOW_A64_SERR 0x580
116
117#define ARM_VECTOR_LOW_A32_SYNC 0x600
118#define ARM_VECTOR_LOW_A32_IRQ 0x680
119#define ARM_VECTOR_LOW_A32_FIQ 0x700
120#define ARM_VECTOR_LOW_A32_SERR 0x780
121
122// The ID_AA64ISAR2_EL1 register is not recognized by older
123// assemblers, we need to define it here.
124#define ID_AA64ISAR2_EL1 S3_0_C0_C6_2
125
126// The ID_AA64MMFR2_EL1 register was added in ARMv8.2. Since we
127// build for ARMv8.0, we need to define the register here.
128#define ID_AA64MMFR2_EL1 S3_0_C0_C7_2
129
130#define VECTOR_BASE(tbl) \
131 .section .text.##tbl##,"ax"; \
132 .align 11; \
133 .org 0x0; \
134 GCC_ASM_EXPORT(tbl); \
135 ASM_PFX(tbl): \
136
137#define VECTOR_ENTRY(tbl, off) \
138 .org off
139
140#define VECTOR_END(tbl) \
141 .org 0x800; \
142 .previous
143
144VOID
145EFIAPI
146ArmEnableSWPInstruction (
147 VOID
148 );
149
150UINTN
151EFIAPI
152ArmReadCbar (
153 VOID
154 );
155
156UINTN
157EFIAPI
158ArmReadTpidrurw (
159 VOID
160 );
161
162VOID
163EFIAPI
164ArmWriteTpidrurw (
165 UINTN Value
166 );
167
168UINTN
169EFIAPI
170ArmGetTCR (
171 VOID
172 );
173
174VOID
175EFIAPI
176ArmSetTCR (
177 UINTN Value
178 );
179
180UINTN
181EFIAPI
182ArmGetMAIR (
183 VOID
184 );
185
186VOID
187EFIAPI
188ArmSetMAIR (
189 UINTN Value
190 );
191
192VOID
193EFIAPI
194ArmDisableAlignmentCheck (
195 VOID
196 );
197
198VOID
199EFIAPI
200ArmEnableAlignmentCheck (
201 VOID
202 );
203
204VOID
205EFIAPI
206ArmDisableStackAlignmentCheck (
207 VOID
208 );
209
210VOID
211EFIAPI
212ArmEnableStackAlignmentCheck (
213 VOID
214 );
215
216VOID
217EFIAPI
218ArmDisableAllExceptions (
219 VOID
220 );
221
222VOID
223ArmWriteHcr (
224 IN UINTN Hcr
225 );
226
227UINTN
228ArmReadHcr (
229 VOID
230 );
231
232UINTN
233ArmReadCurrentEL (
234 VOID
235 );
236
237UINTN
238ArmWriteCptr (
239 IN UINT64 Cptr
240 );
241
242UINT32
243ArmReadCntHctl (
244 VOID
245 );
246
247VOID
248ArmWriteCntHctl (
249 IN UINT32 CntHctl
250 );
251
252#endif // AARCH64_H_
Note: See TracBrowser for help on using the repository browser.

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