VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareNew/MdePkg/Include/AArch64/AArch64.h@ 108794

Last change on this file since 108794 was 108794, checked in by vboxsync, 2 weeks ago

Devices/EFI/FirmwareNew: Merge edk2-stable202502 from the vendor branch and make it build for the important platforms, bugref:4643

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