TianoCore EDK2 master
Loading...
Searching...
No Matches
AArch64.h
Go to the documentation of this file.
1
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
70// Exception Syndrome Register
71#define AARCH64_ESR_EC(Ecr) ((0x3F << 26) & (Ecr))
72#define AARCH64_ESR_ISS(Ecr) ((0x1FFFFFF) & (Ecr))
73
74#define AARCH64_ESR_EC_SMC32 (0x13 << 26)
75#define AARCH64_ESR_EC_SMC64 (0x17 << 26)
76
77// AArch64 Exception Level
78#define AARCH64_EL3 0xC
79#define AARCH64_EL2 0x8
80#define AARCH64_EL1 0x4
81
82// Saved Program Status Register definitions
83#define SPSR_A BIT8
84#define SPSR_I BIT7
85#define SPSR_F BIT6
86
87#define SPSR_AARCH32 BIT4
88
89#define SPSR_AARCH32_MODE_USER 0x0
90#define SPSR_AARCH32_MODE_FIQ 0x1
91#define SPSR_AARCH32_MODE_IRQ 0x2
92#define SPSR_AARCH32_MODE_SVC 0x3
93#define SPSR_AARCH32_MODE_ABORT 0x7
94#define SPSR_AARCH32_MODE_UNDEF 0xB
95#define SPSR_AARCH32_MODE_SYS 0xF
96
97// Counter-timer Hypervisor Control register definitions
98#define CNTHCTL_EL2_EL1PCTEN BIT0
99#define CNTHCTL_EL2_EL1PCEN BIT1
100
101#define ARM_VECTOR_TABLE_ALIGNMENT ((1 << 11)-1)
102
103// Vector table offset definitions
104#define ARM_VECTOR_CUR_SP0_SYNC 0x000
105#define ARM_VECTOR_CUR_SP0_IRQ 0x080
106#define ARM_VECTOR_CUR_SP0_FIQ 0x100
107#define ARM_VECTOR_CUR_SP0_SERR 0x180
108
109#define ARM_VECTOR_CUR_SPX_SYNC 0x200
110#define ARM_VECTOR_CUR_SPX_IRQ 0x280
111#define ARM_VECTOR_CUR_SPX_FIQ 0x300
112#define ARM_VECTOR_CUR_SPX_SERR 0x380
113
114#define ARM_VECTOR_LOW_A64_SYNC 0x400
115#define ARM_VECTOR_LOW_A64_IRQ 0x480
116#define ARM_VECTOR_LOW_A64_FIQ 0x500
117#define ARM_VECTOR_LOW_A64_SERR 0x580
118
119#define ARM_VECTOR_LOW_A32_SYNC 0x600
120#define ARM_VECTOR_LOW_A32_IRQ 0x680
121#define ARM_VECTOR_LOW_A32_FIQ 0x700
122#define ARM_VECTOR_LOW_A32_SERR 0x780
123
124// The ID_AA64ISAR2_EL1 register is not recognized by older
125// assemblers, we need to define it here.
126#define ID_AA64ISAR2_EL1 S3_0_C0_C6_2
127
128// The ID_AA64MMFR2_EL1 register was added in ARMv8.2. Since we
129// build for ARMv8.0, we need to define the register here.
130#define ID_AA64MMFR2_EL1 S3_0_C0_C7_2
131
132#define VECTOR_BASE(tbl) \
133 .section .text.##tbl##,"ax"; \
134 .align 11; \
135 .org 0x0; \
136 GCC_ASM_EXPORT(tbl); \
137 ASM_PFX(tbl): \
138
139#define VECTOR_ENTRY(tbl, off) \
140 .org off
141
142#define VECTOR_END(tbl) \
143 .org 0x800; \
144 .previous
145
146VOID
147EFIAPI
148ArmEnableSWPInstruction (
149 VOID
150 );
151
152UINTN
153EFIAPI
154ArmReadCbar (
155 VOID
156 );
157
158UINTN
159EFIAPI
160ArmReadTpidrurw (
161 VOID
162 );
163
164VOID
165EFIAPI
166ArmWriteTpidrurw (
167 UINTN Value
168 );
169
170UINTN
171EFIAPI
172ArmGetTCR (
173 VOID
174 );
175
176VOID
177EFIAPI
178ArmSetTCR (
179 UINTN Value
180 );
181
182UINTN
183EFIAPI
184ArmGetMAIR (
185 VOID
186 );
187
188VOID
189EFIAPI
190ArmSetMAIR (
191 UINTN Value
192 );
193
194VOID
195EFIAPI
196ArmDisableAlignmentCheck (
197 VOID
198 );
199
200VOID
201EFIAPI
202ArmEnableAlignmentCheck (
203 VOID
204 );
205
206VOID
207EFIAPI
208ArmDisableStackAlignmentCheck (
209 VOID
210 );
211
212VOID
213EFIAPI
214ArmEnableStackAlignmentCheck (
215 VOID
216 );
217
218VOID
219EFIAPI
220ArmDisableAllExceptions (
221 VOID
222 );
223
224VOID
225ArmWriteHcr (
226 IN UINTN Hcr
227 );
228
229UINTN
230ArmReadHcr (
231 VOID
232 );
233
234UINTN
235ArmReadCurrentEL (
236 VOID
237 );
238
239UINT32
240ArmReadCntHctl (
241 VOID
242 );
243
244VOID
245ArmWriteCntHctl (
246 IN UINT32 CntHctl
247 );
248
249#endif // AARCH64_H_
UINT64 UINTN
#define IN
Definition: Base.h:279