]>
Commit | Line | Data |
---|---|---|
55a0d64b | 1 | /** @file\r |
2 | *\r | |
3c0c1d3f | 3 | * Copyright (c) 2011-2021, Arm Limited. All rights reserved.<BR>\r |
55a0d64b | 4 | *\r |
4059386c | 5 | * SPDX-License-Identifier: BSD-2-Clause-Patent\r |
55a0d64b | 6 | *\r |
7 | **/\r | |
8 | \r | |
3c0c1d3f PG |
9 | #ifndef ARMGIC_H_\r |
10 | #define ARMGIC_H_\r | |
55a0d64b | 11 | \r |
8d13298b | 12 | #include <Library/ArmGicArchLib.h>\r |
55a0d64b | 13 | \r |
55a0d64b | 14 | // GIC Distributor\r |
429309e0 MK |
15 | #define ARM_GIC_ICDDCR 0x000 // Distributor Control Register\r |
16 | #define ARM_GIC_ICDICTR 0x004 // Interrupt Controller Type Register\r | |
17 | #define ARM_GIC_ICDIIDR 0x008 // Implementer Identification Register\r | |
55a0d64b | 18 | \r |
919697ae | 19 | // Each reg base below repeats for Number of interrupts / 4 (see GIC spec)\r |
429309e0 MK |
20 | #define ARM_GIC_ICDISR 0x080 // Interrupt Security Registers\r |
21 | #define ARM_GIC_ICDISER 0x100 // Interrupt Set-Enable Registers\r | |
22 | #define ARM_GIC_ICDICER 0x180 // Interrupt Clear-Enable Registers\r | |
23 | #define ARM_GIC_ICDSPR 0x200 // Interrupt Set-Pending Registers\r | |
24 | #define ARM_GIC_ICDICPR 0x280 // Interrupt Clear-Pending Registers\r | |
25 | #define ARM_GIC_ICDABR 0x300 // Active Bit Registers\r | |
55a0d64b | 26 | \r |
919697ae | 27 | // Each reg base below repeats for Number of interrupts / 4\r |
429309e0 | 28 | #define ARM_GIC_ICDIPR 0x400 // Interrupt Priority Registers\r |
55a0d64b | 29 | \r |
919697ae | 30 | // Each reg base below repeats for Number of interrupts\r |
429309e0 MK |
31 | #define ARM_GIC_ICDIPTR 0x800 // Interrupt Processor Target Registers\r |
32 | #define ARM_GIC_ICDICFR 0xC00 // Interrupt Configuration Registers\r | |
55a0d64b | 33 | \r |
429309e0 | 34 | #define ARM_GIC_ICDPPISR 0xD00 // PPI Status register\r |
55a0d64b | 35 | \r |
36 | // just one of these\r | |
429309e0 | 37 | #define ARM_GIC_ICDSGIR 0xF00 // Software Generated Interrupt Register\r |
55a0d64b | 38 | \r |
919697ae | 39 | // GICv3 specific registers\r |
429309e0 | 40 | #define ARM_GICD_IROUTER 0x6100 // Interrupt Routing Registers\r |
919697ae | 41 | \r |
c7fefb69 | 42 | // GICD_CTLR bits\r |
429309e0 MK |
43 | #define ARM_GIC_ICDDCR_ARE (1 << 4) // Affinity Routing Enable (ARE)\r |
44 | #define ARM_GIC_ICDDCR_DS (1 << 6) // Disable Security (DS)\r | |
f6d46e29 | 45 | \r |
8659306a AB |
46 | // GICD_ICDICFR bits\r |
47 | #define ARM_GIC_ICDICFR_WIDTH 32 // ICDICFR is a 32 bit register\r | |
48 | #define ARM_GIC_ICDICFR_BYTES (ARM_GIC_ICDICFR_WIDTH / 8)\r | |
49 | #define ARM_GIC_ICDICFR_F_WIDTH 2 // Each F field is 2 bits\r | |
50 | #define ARM_GIC_ICDICFR_F_STRIDE 16 // (32/2) F fields per register\r | |
51 | #define ARM_GIC_ICDICFR_F_CONFIG1_BIT 1 // Bit number within F field\r | |
52 | #define ARM_GIC_ICDICFR_LEVEL_TRIGGERED 0x0 // Level triggered interrupt\r | |
53 | #define ARM_GIC_ICDICFR_EDGE_TRIGGERED 0x1 // Edge triggered interrupt\r | |
54 | \r | |
8659306a | 55 | // GIC Redistributor\r |
429309e0 MK |
56 | #define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB\r |
57 | #define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB\r | |
58 | #define ARM_GICR_SGI_VLPI_FRAME_SIZE SIZE_64KB\r | |
59 | #define ARM_GICR_SGI_RESERVED_FRAME_SIZE SIZE_64KB\r | |
919697ae OM |
60 | \r |
61 | // GIC Redistributor Control frame\r | |
429309e0 | 62 | #define ARM_GICR_TYPER 0x0008 // Redistributor Type Register\r |
919697ae | 63 | \r |
301402fa | 64 | // GIC Redistributor TYPER bit assignments\r |
429309e0 MK |
65 | #define ARM_GICR_TYPER_PLPIS (1 << 0) // Physical LPIs\r |
66 | #define ARM_GICR_TYPER_VLPIS (1 << 1) // Virtual LPIs\r | |
67 | #define ARM_GICR_TYPER_DIRECTLPI (1 << 3) // Direct LPIs\r | |
68 | #define ARM_GICR_TYPER_LAST (1 << 4) // Last Redistributor in series\r | |
69 | #define ARM_GICR_TYPER_DPGS (1 << 5) // Disable Processor Group\r | |
301402fa | 70 | // Selection Support\r |
429309e0 MK |
71 | #define ARM_GICR_TYPER_PROCNO (0xFFFF << 8) // Processor Number\r |
72 | #define ARM_GICR_TYPER_COMMONLPIAFF (0x3 << 24) // Common LPI Affinity\r | |
73 | #define ARM_GICR_TYPER_AFFINITY (0xFFFFFFFFULL << 32) // Redistributor Affinity\r | |
301402fa SM |
74 | \r |
75 | #define ARM_GICR_TYPER_GET_AFFINITY(TypeReg) (((TypeReg) & \\r | |
76 | ARM_GICR_TYPER_AFFINITY) >> 32)\r | |
77 | \r | |
919697ae | 78 | // GIC SGI & PPI Redistributor frame\r |
429309e0 MK |
79 | #define ARM_GICR_ISENABLER 0x0100 // Interrupt Set-Enable Registers\r |
80 | #define ARM_GICR_ICENABLER 0x0180 // Interrupt Clear-Enable Registers\r | |
919697ae | 81 | \r |
55a0d64b | 82 | // GIC Cpu interface\r |
429309e0 MK |
83 | #define ARM_GIC_ICCICR 0x00 // CPU Interface Control Register\r |
84 | #define ARM_GIC_ICCPMR 0x04 // Interrupt Priority Mask Register\r | |
85 | #define ARM_GIC_ICCBPR 0x08 // Binary Point Register\r | |
86 | #define ARM_GIC_ICCIAR 0x0C // Interrupt Acknowledge Register\r | |
87 | #define ARM_GIC_ICCEIOR 0x10 // End Of Interrupt Register\r | |
88 | #define ARM_GIC_ICCRPR 0x14 // Running Priority Register\r | |
89 | #define ARM_GIC_ICCPIR 0x18 // Highest Pending Interrupt Register\r | |
90 | #define ARM_GIC_ICCABPR 0x1C // Aliased Binary Point Register\r | |
91 | #define ARM_GIC_ICCIIDR 0xFC // Identification Register\r | |
92 | \r | |
93 | #define ARM_GIC_ICDSGIR_FILTER_TARGETLIST 0x0\r | |
94 | #define ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE 0x1\r | |
95 | #define ARM_GIC_ICDSGIR_FILTER_ITSELF 0x2\r | |
55a0d64b | 96 | \r |
97 | // Bit-masks to configure the CPU Interface Control register\r | |
429309e0 MK |
98 | #define ARM_GIC_ICCICR_ENABLE_SECURE 0x01\r |
99 | #define ARM_GIC_ICCICR_ENABLE_NS 0x02\r | |
100 | #define ARM_GIC_ICCICR_ACK_CTL 0x04\r | |
101 | #define ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ 0x08\r | |
102 | #define ARM_GIC_ICCICR_USE_SBPR 0x10\r | |
55a0d64b | 103 | \r |
1cb13673 | 104 | // Bit Mask for GICC_IIDR\r |
429309e0 MK |
105 | #define ARM_GIC_ICCIIDR_GET_PRODUCT_ID(IccIidr) (((IccIidr) >> 20) & 0xFFF)\r |
106 | #define ARM_GIC_ICCIIDR_GET_ARCH_VERSION(IccIidr) (((IccIidr) >> 16) & 0xF)\r | |
107 | #define ARM_GIC_ICCIIDR_GET_REVISION(IccIidr) (((IccIidr) >> 12) & 0xF)\r | |
108 | #define ARM_GIC_ICCIIDR_GET_IMPLEMENTER(IccIidr) ((IccIidr) & 0xFFF)\r | |
55a0d64b | 109 | \r |
5f81082e | 110 | // Bit Mask for\r |
429309e0 | 111 | #define ARM_GIC_ICCIAR_ACKINTID 0x3FF\r |
5f81082e | 112 | \r |
e700a1fc OM |
113 | UINTN\r |
114 | EFIAPI\r | |
115 | ArmGicGetInterfaceIdentification (\r | |
429309e0 | 116 | IN INTN GicInterruptInterfaceBase\r |
e700a1fc OM |
117 | );\r |
118 | \r | |
92534106 | 119 | // GIC Secure interfaces\r |
55a0d64b | 120 | VOID\r |
121 | EFIAPI\r | |
122 | ArmGicSetupNonSecure (\r | |
429309e0 MK |
123 | IN UINTN MpId,\r |
124 | IN INTN GicDistributorBase,\r | |
125 | IN INTN GicInterruptInterfaceBase\r | |
55a0d64b | 126 | );\r |
127 | \r | |
92534106 | 128 | VOID\r |
129 | EFIAPI\r | |
130 | ArmGicSetSecureInterrupts (\r | |
429309e0 MK |
131 | IN UINTN GicDistributorBase,\r |
132 | IN UINTN *GicSecureInterruptMask,\r | |
133 | IN UINTN GicSecureInterruptMaskSize\r | |
92534106 | 134 | );\r |
135 | \r | |
55a0d64b | 136 | VOID\r |
137 | EFIAPI\r | |
138 | ArmGicEnableInterruptInterface (\r | |
429309e0 | 139 | IN INTN GicInterruptInterfaceBase\r |
55a0d64b | 140 | );\r |
141 | \r | |
9736c297 | 142 | VOID\r |
143 | EFIAPI\r | |
144 | ArmGicDisableInterruptInterface (\r | |
429309e0 | 145 | IN INTN GicInterruptInterfaceBase\r |
9736c297 | 146 | );\r |
147 | \r | |
55a0d64b | 148 | VOID\r |
149 | EFIAPI\r | |
150 | ArmGicEnableDistributor (\r | |
429309e0 | 151 | IN INTN GicDistributorBase\r |
55a0d64b | 152 | );\r |
153 | \r | |
e700a1fc OM |
154 | VOID\r |
155 | EFIAPI\r | |
156 | ArmGicDisableDistributor (\r | |
429309e0 | 157 | IN INTN GicDistributorBase\r |
e700a1fc OM |
158 | );\r |
159 | \r | |
e9f7c58f | 160 | UINTN\r |
161 | EFIAPI\r | |
162 | ArmGicGetMaxNumInterrupts (\r | |
429309e0 | 163 | IN INTN GicDistributorBase\r |
e9f7c58f | 164 | );\r |
165 | \r | |
55a0d64b | 166 | VOID\r |
167 | EFIAPI\r | |
168 | ArmGicSendSgiTo (\r | |
429309e0 MK |
169 | IN INTN GicDistributorBase,\r |
170 | IN INTN TargetListFilter,\r | |
171 | IN INTN CPUTargetList,\r | |
172 | IN INTN SgiId\r | |
55a0d64b | 173 | );\r |
174 | \r | |
1b0ac0de OM |
175 | /*\r |
176 | * Acknowledge and return the value of the Interrupt Acknowledge Register\r | |
177 | *\r | |
178 | * InterruptId is returned separately from the register value because in\r | |
179 | * the GICv2 the register value contains the CpuId and InterruptId while\r | |
180 | * in the GICv3 the register value is only the InterruptId.\r | |
181 | *\r | |
182 | * @param GicInterruptInterfaceBase Base Address of the GIC CPU Interface\r | |
b0393756 EL |
183 | * @param InterruptId InterruptId read from the Interrupt\r |
184 | * Acknowledge Register\r | |
1b0ac0de OM |
185 | *\r |
186 | * @retval value returned by the Interrupt Acknowledge Register\r | |
187 | *\r | |
188 | */\r | |
2ca815a4 | 189 | UINTN\r |
55a0d64b | 190 | EFIAPI\r |
315649cd | 191 | ArmGicAcknowledgeInterrupt (\r |
429309e0 MK |
192 | IN UINTN GicInterruptInterfaceBase,\r |
193 | OUT UINTN *InterruptId\r | |
55a0d64b | 194 | );\r |
195 | \r | |
d80401a1 OM |
196 | VOID\r |
197 | EFIAPI\r | |
198 | ArmGicEndOfInterrupt (\r | |
429309e0 MK |
199 | IN UINTN GicInterruptInterfaceBase,\r |
200 | IN UINTN Source\r | |
d80401a1 OM |
201 | );\r |
202 | \r | |
55a0d64b | 203 | UINTN\r |
204 | EFIAPI\r | |
205 | ArmGicSetPriorityMask (\r | |
429309e0 MK |
206 | IN INTN GicInterruptInterfaceBase,\r |
207 | IN INTN PriorityMask\r | |
55a0d64b | 208 | );\r |
209 | \r | |
0d49b82e QN |
210 | VOID\r |
211 | EFIAPI\r | |
212 | ArmGicSetInterruptPriority (\r | |
429309e0 MK |
213 | IN UINTN GicDistributorBase,\r |
214 | IN UINTN GicRedistributorBase,\r | |
215 | IN UINTN Source,\r | |
216 | IN UINTN Priority\r | |
0d49b82e QN |
217 | );\r |
218 | \r | |
e700a1fc OM |
219 | VOID\r |
220 | EFIAPI\r | |
221 | ArmGicEnableInterrupt (\r | |
429309e0 MK |
222 | IN UINTN GicDistributorBase,\r |
223 | IN UINTN GicRedistributorBase,\r | |
224 | IN UINTN Source\r | |
e700a1fc OM |
225 | );\r |
226 | \r | |
227 | VOID\r | |
228 | EFIAPI\r | |
229 | ArmGicDisableInterrupt (\r | |
429309e0 MK |
230 | IN UINTN GicDistributorBase,\r |
231 | IN UINTN GicRedistributorBase,\r | |
232 | IN UINTN Source\r | |
e700a1fc OM |
233 | );\r |
234 | \r | |
235 | BOOLEAN\r | |
236 | EFIAPI\r | |
237 | ArmGicIsInterruptEnabled (\r | |
429309e0 MK |
238 | IN UINTN GicDistributorBase,\r |
239 | IN UINTN GicRedistributorBase,\r | |
240 | IN UINTN Source\r | |
e700a1fc OM |
241 | );\r |
242 | \r | |
bce29e30 | 243 | // GIC revision 2 specific declarations\r |
bce29e30 | 244 | \r |
b0393756 EL |
245 | // Interrupts from 1020 to 1023 are considered as special interrupts\r |
246 | // (eg: spurious interrupts)\r | |
247 | #define ARM_GIC_IS_SPECIAL_INTERRUPTS(Interrupt) \\r | |
248 | (((Interrupt) >= 1020) && ((Interrupt) <= 1023))\r | |
bce29e30 AB |
249 | \r |
250 | VOID\r | |
251 | EFIAPI\r | |
252 | ArmGicV2SetupNonSecure (\r | |
429309e0 MK |
253 | IN UINTN MpId,\r |
254 | IN INTN GicDistributorBase,\r | |
255 | IN INTN GicInterruptInterfaceBase\r | |
bce29e30 AB |
256 | );\r |
257 | \r | |
258 | VOID\r | |
259 | EFIAPI\r | |
260 | ArmGicV2EnableInterruptInterface (\r | |
429309e0 | 261 | IN INTN GicInterruptInterfaceBase\r |
bce29e30 AB |
262 | );\r |
263 | \r | |
264 | VOID\r | |
265 | EFIAPI\r | |
266 | ArmGicV2DisableInterruptInterface (\r | |
429309e0 | 267 | IN INTN GicInterruptInterfaceBase\r |
bce29e30 AB |
268 | );\r |
269 | \r | |
270 | UINTN\r | |
271 | EFIAPI\r | |
272 | ArmGicV2AcknowledgeInterrupt (\r | |
429309e0 | 273 | IN UINTN GicInterruptInterfaceBase\r |
bce29e30 AB |
274 | );\r |
275 | \r | |
276 | VOID\r | |
277 | EFIAPI\r | |
278 | ArmGicV2EndOfInterrupt (\r | |
429309e0 MK |
279 | IN UINTN GicInterruptInterfaceBase,\r |
280 | IN UINTN Source\r | |
bce29e30 AB |
281 | );\r |
282 | \r | |
bce29e30 | 283 | // GIC revision 3 specific declarations\r |
bce29e30 | 284 | \r |
429309e0 | 285 | #define ICC_SRE_EL2_SRE (1 << 0)\r |
bce29e30 | 286 | \r |
429309e0 | 287 | #define ARM_GICD_IROUTER_IRM BIT31\r |
bce29e30 AB |
288 | \r |
289 | UINT32\r | |
290 | EFIAPI\r | |
291 | ArmGicV3GetControlSystemRegisterEnable (\r | |
292 | VOID\r | |
293 | );\r | |
294 | \r | |
295 | VOID\r | |
296 | EFIAPI\r | |
297 | ArmGicV3SetControlSystemRegisterEnable (\r | |
429309e0 | 298 | IN UINT32 ControlSystemRegisterEnable\r |
bce29e30 AB |
299 | );\r |
300 | \r | |
301 | VOID\r | |
302 | EFIAPI\r | |
303 | ArmGicV3EnableInterruptInterface (\r | |
304 | VOID\r | |
305 | );\r | |
306 | \r | |
307 | VOID\r | |
308 | EFIAPI\r | |
309 | ArmGicV3DisableInterruptInterface (\r | |
310 | VOID\r | |
311 | );\r | |
312 | \r | |
313 | UINTN\r | |
314 | EFIAPI\r | |
315 | ArmGicV3AcknowledgeInterrupt (\r | |
316 | VOID\r | |
317 | );\r | |
318 | \r | |
319 | VOID\r | |
320 | EFIAPI\r | |
321 | ArmGicV3EndOfInterrupt (\r | |
429309e0 | 322 | IN UINTN Source\r |
bce29e30 AB |
323 | );\r |
324 | \r | |
325 | VOID\r | |
326 | ArmGicV3SetBinaryPointer (\r | |
429309e0 | 327 | IN UINTN BinaryPoint\r |
bce29e30 AB |
328 | );\r |
329 | \r | |
330 | VOID\r | |
331 | ArmGicV3SetPriorityMask (\r | |
429309e0 | 332 | IN UINTN Priority\r |
bce29e30 AB |
333 | );\r |
334 | \r | |
3c0c1d3f | 335 | #endif // ARMGIC_H_\r |