]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Include/Library/ArmGicLib.h
ArmPkg: Tidy GIC code before changes.
[mirror_edk2.git] / ArmPkg / Include / Library / ArmGicLib.h
CommitLineData
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
95UINTN\r
96EFIAPI\r
97ArmGicGetInterfaceIdentification (\r
98 IN INTN GicInterruptInterfaceBase\r
99 );\r
100\r
92534106 101// GIC Secure interfaces\r
55a0d64b 102VOID\r
103EFIAPI\r
104ArmGicSetupNonSecure (\r
5e773144 105 IN UINTN MpId,\r
55a0d64b 106 IN INTN GicDistributorBase,\r
107 IN INTN GicInterruptInterfaceBase\r
108 );\r
109\r
92534106 110VOID\r
111EFIAPI\r
112ArmGicSetSecureInterrupts (\r
113 IN UINTN GicDistributorBase,\r
114 IN UINTN* GicSecureInterruptMask,\r
115 IN UINTN GicSecureInterruptMaskSize\r
116 );\r
117\r
55a0d64b 118VOID\r
119EFIAPI\r
120ArmGicEnableInterruptInterface (\r
121 IN INTN GicInterruptInterfaceBase\r
122 );\r
123\r
9736c297 124VOID\r
125EFIAPI\r
126ArmGicDisableInterruptInterface (\r
127 IN INTN GicInterruptInterfaceBase\r
128 );\r
129\r
55a0d64b 130VOID\r
131EFIAPI\r
132ArmGicEnableDistributor (\r
133 IN INTN GicDistributorBase\r
134 );\r
135\r
e700a1fc
OM
136VOID\r
137EFIAPI\r
138ArmGicDisableDistributor (\r
139 IN INTN GicDistributorBase\r
140 );\r
141\r
e9f7c58f 142UINTN\r
143EFIAPI\r
144ArmGicGetMaxNumInterrupts (\r
145 IN INTN GicDistributorBase\r
146 );\r
147\r
55a0d64b 148VOID\r
149EFIAPI\r
150ArmGicSendSgiTo (\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 171UINTN\r
55a0d64b 172EFIAPI\r
315649cd 173ArmGicAcknowledgeInterrupt (\r
1b0ac0de
OM
174 IN UINTN GicInterruptInterfaceBase,\r
175 OUT UINTN *InterruptId\r
55a0d64b 176 );\r
177\r
d80401a1
OM
178VOID\r
179EFIAPI\r
180ArmGicEndOfInterrupt (\r
181 IN UINTN GicInterruptInterfaceBase,\r
182 IN UINTN Source\r
183 );\r
184\r
55a0d64b 185UINTN\r
186EFIAPI\r
187ArmGicSetPriorityMask (\r
188 IN INTN GicInterruptInterfaceBase,\r
189 IN INTN PriorityMask\r
190 );\r
191\r
e700a1fc
OM
192VOID\r
193EFIAPI\r
194ArmGicEnableInterrupt (\r
195 IN UINTN GicDistributorBase,\r
41fb5d46 196 IN UINTN GicRedistributorBase,\r
e700a1fc
OM
197 IN UINTN Source\r
198 );\r
199\r
200VOID\r
201EFIAPI\r
202ArmGicDisableInterrupt (\r
203 IN UINTN GicDistributorBase,\r
41fb5d46 204 IN UINTN GicRedistributorBase,\r
e700a1fc
OM
205 IN UINTN Source\r
206 );\r
207\r
208BOOLEAN\r
209EFIAPI\r
210ArmGicIsInterruptEnabled (\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
223VOID\r
224EFIAPI\r
225ArmGicV2SetupNonSecure (\r
226 IN UINTN MpId,\r
227 IN INTN GicDistributorBase,\r
228 IN INTN GicInterruptInterfaceBase\r
229 );\r
230\r
231VOID\r
232EFIAPI\r
233ArmGicV2EnableInterruptInterface (\r
234 IN INTN GicInterruptInterfaceBase\r
235 );\r
236\r
237VOID\r
238EFIAPI\r
239ArmGicV2DisableInterruptInterface (\r
240 IN INTN GicInterruptInterfaceBase\r
241 );\r
242\r
243UINTN\r
244EFIAPI\r
245ArmGicV2AcknowledgeInterrupt (\r
246 IN UINTN GicInterruptInterfaceBase\r
247 );\r
248\r
249VOID\r
250EFIAPI\r
251ArmGicV2EndOfInterrupt (\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
262UINT32\r
263EFIAPI\r
264ArmGicV3GetControlSystemRegisterEnable (\r
265 VOID\r
266 );\r
267\r
268VOID\r
269EFIAPI\r
270ArmGicV3SetControlSystemRegisterEnable (\r
271 IN UINT32 ControlSystemRegisterEnable\r
272 );\r
273\r
274VOID\r
275EFIAPI\r
276ArmGicV3EnableInterruptInterface (\r
277 VOID\r
278 );\r
279\r
280VOID\r
281EFIAPI\r
282ArmGicV3DisableInterruptInterface (\r
283 VOID\r
284 );\r
285\r
286UINTN\r
287EFIAPI\r
288ArmGicV3AcknowledgeInterrupt (\r
289 VOID\r
290 );\r
291\r
292VOID\r
293EFIAPI\r
294ArmGicV3EndOfInterrupt (\r
295 IN UINTN Source\r
296 );\r
297\r
298VOID\r
299ArmGicV3SetBinaryPointer (\r
300 IN UINTN BinaryPoint\r
301 );\r
302\r
303VOID\r
304ArmGicV3SetPriorityMask (\r
305 IN UINTN Priority\r
306 );\r
307\r
55a0d64b 308#endif\r