]>
Commit | Line | Data |
---|---|---|
55a0d64b | 1 | /** @file\r |
2 | *\r | |
b0393756 | 3 | * Copyright (c) 2011-2017, ARM Limited. All rights reserved.\r |
55a0d64b | 4 | *\r |
1cb13673 OM |
5 | * This program and the accompanying materials\r |
6 | * are licensed and made available under the terms and conditions of the BSD License\r | |
7 | * which accompanies this distribution. The full text of the license may be found at\r | |
8 | * http://opensource.org/licenses/bsd-license.php\r | |
9 | *\r | |
10 | * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
55a0d64b | 12 | *\r |
13 | **/\r | |
14 | \r | |
017baa1c OM |
15 | #ifndef __ARMGIC_H\r |
16 | #define __ARMGIC_H\r | |
55a0d64b | 17 | \r |
8d13298b | 18 | #include <Library/ArmGicArchLib.h>\r |
55a0d64b | 19 | \r |
55a0d64b | 20 | // GIC Distributor\r |
55a0d64b | 21 | #define ARM_GIC_ICDDCR 0x000 // Distributor Control Register\r |
22 | #define ARM_GIC_ICDICTR 0x004 // Interrupt Controller Type Register\r | |
23 | #define ARM_GIC_ICDIIDR 0x008 // Implementer Identification Register\r | |
24 | \r | |
919697ae | 25 | // Each reg base below repeats for Number of interrupts / 4 (see GIC spec)\r |
55a0d64b | 26 | #define ARM_GIC_ICDISR 0x080 // Interrupt Security Registers\r |
27 | #define ARM_GIC_ICDISER 0x100 // Interrupt Set-Enable Registers\r | |
28 | #define ARM_GIC_ICDICER 0x180 // Interrupt Clear-Enable Registers\r | |
29 | #define ARM_GIC_ICDSPR 0x200 // Interrupt Set-Pending Registers\r | |
30 | #define ARM_GIC_ICDICPR 0x280 // Interrupt Clear-Pending Registers\r | |
31 | #define ARM_GIC_ICDABR 0x300 // Active Bit Registers\r | |
32 | \r | |
919697ae | 33 | // Each reg base below repeats for Number of interrupts / 4\r |
55a0d64b | 34 | #define ARM_GIC_ICDIPR 0x400 // Interrupt Priority Registers\r |
35 | \r | |
919697ae | 36 | // Each reg base below repeats for Number of interrupts\r |
55a0d64b | 37 | #define ARM_GIC_ICDIPTR 0x800 // Interrupt Processor Target Registers\r |
38 | #define ARM_GIC_ICDICFR 0xC00 // Interrupt Configuration Registers\r | |
39 | \r | |
40 | #define ARM_GIC_ICDPPISR 0xD00 // PPI Status register\r | |
41 | \r | |
42 | // just one of these\r | |
43 | #define ARM_GIC_ICDSGIR 0xF00 // Software Generated Interrupt Register\r | |
44 | \r | |
919697ae OM |
45 | // GICv3 specific registers\r |
46 | #define ARM_GICD_IROUTER 0x6100 // Interrupt Routing Registers\r | |
47 | \r | |
c7fefb69 AB |
48 | // GICD_CTLR bits\r |
49 | #define ARM_GIC_ICDDCR_ARE (1 << 4) // Affinity Routing Enable (ARE)\r | |
50 | #define ARM_GIC_ICDDCR_DS (1 << 6) // Disable Security (DS)\r | |
f6d46e29 | 51 | \r |
919697ae | 52 | // GIC Redistributor\r |
919697ae OM |
53 | \r |
54 | #define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB\r | |
55 | #define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB\r | |
56 | \r | |
57 | // GIC Redistributor Control frame\r | |
58 | #define ARM_GICR_TYPER 0x0008 // Redistributor Type Register\r | |
59 | \r | |
60 | // GIC SGI & PPI Redistributor frame\r | |
61 | #define ARM_GICR_ISENABLER 0x0100 // Interrupt Set-Enable Registers\r | |
62 | #define ARM_GICR_ICENABLER 0x0180 // Interrupt Clear-Enable Registers\r | |
63 | \r | |
55a0d64b | 64 | // GIC Cpu interface\r |
55a0d64b | 65 | #define ARM_GIC_ICCICR 0x00 // CPU Interface Control Register\r |
66 | #define ARM_GIC_ICCPMR 0x04 // Interrupt Priority Mask Register\r | |
67 | #define ARM_GIC_ICCBPR 0x08 // Binary Point Register\r | |
68 | #define ARM_GIC_ICCIAR 0x0C // Interrupt Acknowledge Register\r | |
69 | #define ARM_GIC_ICCEIOR 0x10 // End Of Interrupt Register\r | |
70 | #define ARM_GIC_ICCRPR 0x14 // Running Priority Register\r | |
71 | #define ARM_GIC_ICCPIR 0x18 // Highest Pending Interrupt Register\r | |
72 | #define ARM_GIC_ICCABPR 0x1C // Aliased Binary Point Register\r | |
e700a1fc | 73 | #define ARM_GIC_ICCIIDR 0xFC // Identification Register\r |
55a0d64b | 74 | \r |
75 | #define ARM_GIC_ICDSGIR_FILTER_TARGETLIST 0x0\r | |
76 | #define ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE 0x1\r | |
77 | #define ARM_GIC_ICDSGIR_FILTER_ITSELF 0x2\r | |
78 | \r | |
79 | // Bit-masks to configure the CPU Interface Control register\r | |
80 | #define ARM_GIC_ICCICR_ENABLE_SECURE 0x01\r | |
81 | #define ARM_GIC_ICCICR_ENABLE_NS 0x02\r | |
82 | #define ARM_GIC_ICCICR_ACK_CTL 0x04\r | |
83 | #define ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ 0x08\r | |
84 | #define ARM_GIC_ICCICR_USE_SBPR 0x10\r | |
85 | \r | |
1cb13673 | 86 | // Bit Mask for GICC_IIDR\r |
e700a1fc OM |
87 | #define ARM_GIC_ICCIIDR_GET_PRODUCT_ID(IccIidr) (((IccIidr) >> 20) & 0xFFF)\r |
88 | #define ARM_GIC_ICCIIDR_GET_ARCH_VERSION(IccIidr) (((IccIidr) >> 16) & 0xF)\r | |
89 | #define ARM_GIC_ICCIIDR_GET_REVISION(IccIidr) (((IccIidr) >> 12) & 0xF)\r | |
90 | #define ARM_GIC_ICCIIDR_GET_IMPLEMENTER(IccIidr) ((IccIidr) & 0xFFF)\r | |
55a0d64b | 91 | \r |
5f81082e OM |
92 | // Bit Mask for\r |
93 | #define ARM_GIC_ICCIAR_ACKINTID 0x3FF\r | |
94 | \r | |
e700a1fc OM |
95 | UINTN\r |
96 | EFIAPI\r | |
97 | ArmGicGetInterfaceIdentification (\r | |
98 | IN INTN GicInterruptInterfaceBase\r | |
99 | );\r | |
100 | \r | |
92534106 | 101 | // GIC Secure interfaces\r |
55a0d64b | 102 | VOID\r |
103 | EFIAPI\r | |
104 | ArmGicSetupNonSecure (\r | |
5e773144 | 105 | IN UINTN MpId,\r |
55a0d64b | 106 | IN INTN GicDistributorBase,\r |
107 | IN INTN GicInterruptInterfaceBase\r | |
108 | );\r | |
109 | \r | |
92534106 | 110 | VOID\r |
111 | EFIAPI\r | |
112 | ArmGicSetSecureInterrupts (\r | |
113 | IN UINTN GicDistributorBase,\r | |
114 | IN UINTN* GicSecureInterruptMask,\r | |
115 | IN UINTN GicSecureInterruptMaskSize\r | |
116 | );\r | |
117 | \r | |
55a0d64b | 118 | VOID\r |
119 | EFIAPI\r | |
120 | ArmGicEnableInterruptInterface (\r | |
121 | IN INTN GicInterruptInterfaceBase\r | |
122 | );\r | |
123 | \r | |
9736c297 | 124 | VOID\r |
125 | EFIAPI\r | |
126 | ArmGicDisableInterruptInterface (\r | |
127 | IN INTN GicInterruptInterfaceBase\r | |
128 | );\r | |
129 | \r | |
55a0d64b | 130 | VOID\r |
131 | EFIAPI\r | |
132 | ArmGicEnableDistributor (\r | |
133 | IN INTN GicDistributorBase\r | |
134 | );\r | |
135 | \r | |
e700a1fc OM |
136 | VOID\r |
137 | EFIAPI\r | |
138 | ArmGicDisableDistributor (\r | |
139 | IN INTN GicDistributorBase\r | |
140 | );\r | |
141 | \r | |
e9f7c58f | 142 | UINTN\r |
143 | EFIAPI\r | |
144 | ArmGicGetMaxNumInterrupts (\r | |
145 | IN INTN GicDistributorBase\r | |
146 | );\r | |
147 | \r | |
55a0d64b | 148 | VOID\r |
149 | EFIAPI\r | |
150 | ArmGicSendSgiTo (\r | |
151 | IN INTN GicDistributorBase,\r | |
152 | IN INTN TargetListFilter,\r | |
4c19ece3 | 153 | IN INTN CPUTargetList,\r |
154 | IN INTN SgiId\r | |
55a0d64b | 155 | );\r |
156 | \r | |
1b0ac0de OM |
157 | /*\r |
158 | * Acknowledge and return the value of the Interrupt Acknowledge Register\r | |
159 | *\r | |
160 | * InterruptId is returned separately from the register value because in\r | |
161 | * the GICv2 the register value contains the CpuId and InterruptId while\r | |
162 | * in the GICv3 the register value is only the InterruptId.\r | |
163 | *\r | |
164 | * @param GicInterruptInterfaceBase Base Address of the GIC CPU Interface\r | |
b0393756 EL |
165 | * @param InterruptId InterruptId read from the Interrupt\r |
166 | * Acknowledge Register\r | |
1b0ac0de OM |
167 | *\r |
168 | * @retval value returned by the Interrupt Acknowledge Register\r | |
169 | *\r | |
170 | */\r | |
2ca815a4 | 171 | UINTN\r |
55a0d64b | 172 | EFIAPI\r |
315649cd | 173 | ArmGicAcknowledgeInterrupt (\r |
1b0ac0de OM |
174 | IN UINTN GicInterruptInterfaceBase,\r |
175 | OUT UINTN *InterruptId\r | |
55a0d64b | 176 | );\r |
177 | \r | |
d80401a1 OM |
178 | VOID\r |
179 | EFIAPI\r | |
180 | ArmGicEndOfInterrupt (\r | |
181 | IN UINTN GicInterruptInterfaceBase,\r | |
182 | IN UINTN Source\r | |
183 | );\r | |
184 | \r | |
55a0d64b | 185 | UINTN\r |
186 | EFIAPI\r | |
187 | ArmGicSetPriorityMask (\r | |
188 | IN INTN GicInterruptInterfaceBase,\r | |
189 | IN INTN PriorityMask\r | |
190 | );\r | |
191 | \r | |
e700a1fc OM |
192 | VOID\r |
193 | EFIAPI\r | |
194 | ArmGicEnableInterrupt (\r | |
195 | IN UINTN GicDistributorBase,\r | |
41fb5d46 | 196 | IN UINTN GicRedistributorBase,\r |
e700a1fc OM |
197 | IN UINTN Source\r |
198 | );\r | |
199 | \r | |
200 | VOID\r | |
201 | EFIAPI\r | |
202 | ArmGicDisableInterrupt (\r | |
203 | IN UINTN GicDistributorBase,\r | |
41fb5d46 | 204 | IN UINTN GicRedistributorBase,\r |
e700a1fc OM |
205 | IN UINTN Source\r |
206 | );\r | |
207 | \r | |
208 | BOOLEAN\r | |
209 | EFIAPI\r | |
210 | ArmGicIsInterruptEnabled (\r | |
211 | IN UINTN GicDistributorBase,\r | |
41fb5d46 | 212 | IN UINTN GicRedistributorBase,\r |
e700a1fc OM |
213 | IN UINTN Source\r |
214 | );\r | |
215 | \r | |
bce29e30 | 216 | // GIC revision 2 specific declarations\r |
bce29e30 | 217 | \r |
b0393756 EL |
218 | // Interrupts from 1020 to 1023 are considered as special interrupts\r |
219 | // (eg: spurious interrupts)\r | |
220 | #define ARM_GIC_IS_SPECIAL_INTERRUPTS(Interrupt) \\r | |
221 | (((Interrupt) >= 1020) && ((Interrupt) <= 1023))\r | |
bce29e30 AB |
222 | \r |
223 | VOID\r | |
224 | EFIAPI\r | |
225 | ArmGicV2SetupNonSecure (\r | |
226 | IN UINTN MpId,\r | |
227 | IN INTN GicDistributorBase,\r | |
228 | IN INTN GicInterruptInterfaceBase\r | |
229 | );\r | |
230 | \r | |
231 | VOID\r | |
232 | EFIAPI\r | |
233 | ArmGicV2EnableInterruptInterface (\r | |
234 | IN INTN GicInterruptInterfaceBase\r | |
235 | );\r | |
236 | \r | |
237 | VOID\r | |
238 | EFIAPI\r | |
239 | ArmGicV2DisableInterruptInterface (\r | |
240 | IN INTN GicInterruptInterfaceBase\r | |
241 | );\r | |
242 | \r | |
243 | UINTN\r | |
244 | EFIAPI\r | |
245 | ArmGicV2AcknowledgeInterrupt (\r | |
246 | IN UINTN GicInterruptInterfaceBase\r | |
247 | );\r | |
248 | \r | |
249 | VOID\r | |
250 | EFIAPI\r | |
251 | ArmGicV2EndOfInterrupt (\r | |
252 | IN UINTN GicInterruptInterfaceBase,\r | |
253 | IN UINTN Source\r | |
254 | );\r | |
255 | \r | |
bce29e30 | 256 | // GIC revision 3 specific declarations\r |
bce29e30 AB |
257 | \r |
258 | #define ICC_SRE_EL2_SRE (1 << 0)\r | |
259 | \r | |
260 | #define ARM_GICD_IROUTER_IRM BIT31\r | |
261 | \r | |
262 | UINT32\r | |
263 | EFIAPI\r | |
264 | ArmGicV3GetControlSystemRegisterEnable (\r | |
265 | VOID\r | |
266 | );\r | |
267 | \r | |
268 | VOID\r | |
269 | EFIAPI\r | |
270 | ArmGicV3SetControlSystemRegisterEnable (\r | |
271 | IN UINT32 ControlSystemRegisterEnable\r | |
272 | );\r | |
273 | \r | |
274 | VOID\r | |
275 | EFIAPI\r | |
276 | ArmGicV3EnableInterruptInterface (\r | |
277 | VOID\r | |
278 | );\r | |
279 | \r | |
280 | VOID\r | |
281 | EFIAPI\r | |
282 | ArmGicV3DisableInterruptInterface (\r | |
283 | VOID\r | |
284 | );\r | |
285 | \r | |
286 | UINTN\r | |
287 | EFIAPI\r | |
288 | ArmGicV3AcknowledgeInterrupt (\r | |
289 | VOID\r | |
290 | );\r | |
291 | \r | |
292 | VOID\r | |
293 | EFIAPI\r | |
294 | ArmGicV3EndOfInterrupt (\r | |
295 | IN UINTN Source\r | |
296 | );\r | |
297 | \r | |
298 | VOID\r | |
299 | ArmGicV3SetBinaryPointer (\r | |
300 | IN UINTN BinaryPoint\r | |
301 | );\r | |
302 | \r | |
303 | VOID\r | |
304 | ArmGicV3SetPriorityMask (\r | |
305 | IN UINTN Priority\r | |
306 | );\r | |
307 | \r | |
55a0d64b | 308 | #endif\r |