]> git.proxmox.com Git - mirror_edk2.git/blame - ArmPkg/Include/Library/ArmGicLib.h
ArmPkg/ArmGic: enable ARE bit before driving GICv3 in native mode
[mirror_edk2.git] / ArmPkg / Include / Library / ArmGicLib.h
CommitLineData
55a0d64b 1/** @file\r
2*\r
919697ae 3* Copyright (c) 2011-2015, 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
18//\r
19// GIC definitions\r
20//\r
d5c6b7fc 21typedef enum {\r
5f525769
OM
22 ARM_GIC_ARCH_REVISION_2,\r
23 ARM_GIC_ARCH_REVISION_3\r
d5c6b7fc 24} ARM_GIC_ARCH_REVISION;\r
55a0d64b 25\r
26//\r
27// GIC Distributor\r
28//\r
29#define ARM_GIC_ICDDCR 0x000 // Distributor Control Register\r
30#define ARM_GIC_ICDICTR 0x004 // Interrupt Controller Type Register\r
31#define ARM_GIC_ICDIIDR 0x008 // Implementer Identification Register\r
32\r
919697ae 33// Each reg base below repeats for Number of interrupts / 4 (see GIC spec)\r
55a0d64b 34#define ARM_GIC_ICDISR 0x080 // Interrupt Security Registers\r
35#define ARM_GIC_ICDISER 0x100 // Interrupt Set-Enable Registers\r
36#define ARM_GIC_ICDICER 0x180 // Interrupt Clear-Enable Registers\r
37#define ARM_GIC_ICDSPR 0x200 // Interrupt Set-Pending Registers\r
38#define ARM_GIC_ICDICPR 0x280 // Interrupt Clear-Pending Registers\r
39#define ARM_GIC_ICDABR 0x300 // Active Bit Registers\r
40\r
919697ae 41// Each reg base below repeats for Number of interrupts / 4\r
55a0d64b 42#define ARM_GIC_ICDIPR 0x400 // Interrupt Priority Registers\r
43\r
919697ae 44// Each reg base below repeats for Number of interrupts\r
55a0d64b 45#define ARM_GIC_ICDIPTR 0x800 // Interrupt Processor Target Registers\r
46#define ARM_GIC_ICDICFR 0xC00 // Interrupt Configuration Registers\r
47\r
48#define ARM_GIC_ICDPPISR 0xD00 // PPI Status register\r
49\r
50// just one of these\r
51#define ARM_GIC_ICDSGIR 0xF00 // Software Generated Interrupt Register\r
52\r
919697ae
OM
53// GICv3 specific registers\r
54#define ARM_GICD_IROUTER 0x6100 // Interrupt Routing Registers\r
55\r
f6d46e29
AB
56// the Affinity Routing Enable (ARE) bit in GICD_CTLR\r
57#define ARM_GIC_ICDDCR_ARE (1 << 4)\r
58\r
919697ae
OM
59//\r
60// GIC Redistributor\r
61//\r
62\r
63#define ARM_GICR_CTLR_FRAME_SIZE SIZE_64KB\r
64#define ARM_GICR_SGI_PPI_FRAME_SIZE SIZE_64KB\r
65\r
66// GIC Redistributor Control frame\r
67#define ARM_GICR_TYPER 0x0008 // Redistributor Type Register\r
68\r
69// GIC SGI & PPI Redistributor frame\r
70#define ARM_GICR_ISENABLER 0x0100 // Interrupt Set-Enable Registers\r
71#define ARM_GICR_ICENABLER 0x0180 // Interrupt Clear-Enable Registers\r
72\r
55a0d64b 73//\r
74// GIC Cpu interface\r
75//\r
76#define ARM_GIC_ICCICR 0x00 // CPU Interface Control Register\r
77#define ARM_GIC_ICCPMR 0x04 // Interrupt Priority Mask Register\r
78#define ARM_GIC_ICCBPR 0x08 // Binary Point Register\r
79#define ARM_GIC_ICCIAR 0x0C // Interrupt Acknowledge Register\r
80#define ARM_GIC_ICCEIOR 0x10 // End Of Interrupt Register\r
81#define ARM_GIC_ICCRPR 0x14 // Running Priority Register\r
82#define ARM_GIC_ICCPIR 0x18 // Highest Pending Interrupt Register\r
83#define ARM_GIC_ICCABPR 0x1C // Aliased Binary Point Register\r
e700a1fc 84#define ARM_GIC_ICCIIDR 0xFC // Identification Register\r
55a0d64b 85\r
86#define ARM_GIC_ICDSGIR_FILTER_TARGETLIST 0x0\r
87#define ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE 0x1\r
88#define ARM_GIC_ICDSGIR_FILTER_ITSELF 0x2\r
89\r
90// Bit-masks to configure the CPU Interface Control register\r
91#define ARM_GIC_ICCICR_ENABLE_SECURE 0x01\r
92#define ARM_GIC_ICCICR_ENABLE_NS 0x02\r
93#define ARM_GIC_ICCICR_ACK_CTL 0x04\r
94#define ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ 0x08\r
95#define ARM_GIC_ICCICR_USE_SBPR 0x10\r
96\r
1cb13673 97// Bit Mask for GICC_IIDR\r
e700a1fc
OM
98#define ARM_GIC_ICCIIDR_GET_PRODUCT_ID(IccIidr) (((IccIidr) >> 20) & 0xFFF)\r
99#define ARM_GIC_ICCIIDR_GET_ARCH_VERSION(IccIidr) (((IccIidr) >> 16) & 0xF)\r
100#define ARM_GIC_ICCIIDR_GET_REVISION(IccIidr) (((IccIidr) >> 12) & 0xF)\r
101#define ARM_GIC_ICCIIDR_GET_IMPLEMENTER(IccIidr) ((IccIidr) & 0xFFF)\r
55a0d64b 102\r
5f81082e
OM
103// Bit Mask for\r
104#define ARM_GIC_ICCIAR_ACKINTID 0x3FF\r
105\r
d5c6b7fc
OM
106ARM_GIC_ARCH_REVISION\r
107EFIAPI\r
108ArmGicGetSupportedArchRevision (\r
109 VOID\r
110 );\r
111\r
e700a1fc
OM
112UINTN\r
113EFIAPI\r
114ArmGicGetInterfaceIdentification (\r
115 IN INTN GicInterruptInterfaceBase\r
116 );\r
117\r
55a0d64b 118//\r
92534106 119// GIC Secure interfaces\r
55a0d64b 120//\r
121VOID\r
122EFIAPI\r
123ArmGicSetupNonSecure (\r
5e773144 124 IN UINTN MpId,\r
55a0d64b 125 IN INTN GicDistributorBase,\r
126 IN INTN GicInterruptInterfaceBase\r
127 );\r
128\r
92534106 129VOID\r
130EFIAPI\r
131ArmGicSetSecureInterrupts (\r
132 IN UINTN GicDistributorBase,\r
133 IN UINTN* GicSecureInterruptMask,\r
134 IN UINTN GicSecureInterruptMaskSize\r
135 );\r
136\r
55a0d64b 137VOID\r
138EFIAPI\r
139ArmGicEnableInterruptInterface (\r
140 IN INTN GicInterruptInterfaceBase\r
141 );\r
142\r
9736c297 143VOID\r
144EFIAPI\r
145ArmGicDisableInterruptInterface (\r
146 IN INTN GicInterruptInterfaceBase\r
147 );\r
148\r
55a0d64b 149VOID\r
150EFIAPI\r
151ArmGicEnableDistributor (\r
152 IN INTN GicDistributorBase\r
153 );\r
154\r
e700a1fc
OM
155VOID\r
156EFIAPI\r
157ArmGicDisableDistributor (\r
158 IN INTN GicDistributorBase\r
159 );\r
160\r
e9f7c58f 161UINTN\r
162EFIAPI\r
163ArmGicGetMaxNumInterrupts (\r
164 IN INTN GicDistributorBase\r
165 );\r
166\r
55a0d64b 167VOID\r
168EFIAPI\r
169ArmGicSendSgiTo (\r
170 IN INTN GicDistributorBase,\r
171 IN INTN TargetListFilter,\r
4c19ece3 172 IN INTN CPUTargetList,\r
173 IN INTN SgiId\r
55a0d64b 174 );\r
175\r
1b0ac0de
OM
176/*\r
177 * Acknowledge and return the value of the Interrupt Acknowledge Register\r
178 *\r
179 * InterruptId is returned separately from the register value because in\r
180 * the GICv2 the register value contains the CpuId and InterruptId while\r
181 * in the GICv3 the register value is only the InterruptId.\r
182 *\r
183 * @param GicInterruptInterfaceBase Base Address of the GIC CPU Interface\r
184 * @param InterruptId InterruptId read from the Interrupt Acknowledge Register\r
185 *\r
186 * @retval value returned by the Interrupt Acknowledge Register\r
187 *\r
188 */\r
2ca815a4 189UINTN\r
55a0d64b 190EFIAPI\r
315649cd 191ArmGicAcknowledgeInterrupt (\r
1b0ac0de
OM
192 IN UINTN GicInterruptInterfaceBase,\r
193 OUT UINTN *InterruptId\r
55a0d64b 194 );\r
195\r
d80401a1
OM
196VOID\r
197EFIAPI\r
198ArmGicEndOfInterrupt (\r
199 IN UINTN GicInterruptInterfaceBase,\r
200 IN UINTN Source\r
201 );\r
202\r
55a0d64b 203UINTN\r
204EFIAPI\r
205ArmGicSetPriorityMask (\r
206 IN INTN GicInterruptInterfaceBase,\r
207 IN INTN PriorityMask\r
208 );\r
209\r
e700a1fc
OM
210VOID\r
211EFIAPI\r
212ArmGicEnableInterrupt (\r
213 IN UINTN GicDistributorBase,\r
41fb5d46 214 IN UINTN GicRedistributorBase,\r
e700a1fc
OM
215 IN UINTN Source\r
216 );\r
217\r
218VOID\r
219EFIAPI\r
220ArmGicDisableInterrupt (\r
221 IN UINTN GicDistributorBase,\r
41fb5d46 222 IN UINTN GicRedistributorBase,\r
e700a1fc
OM
223 IN UINTN Source\r
224 );\r
225\r
226BOOLEAN\r
227EFIAPI\r
228ArmGicIsInterruptEnabled (\r
229 IN UINTN GicDistributorBase,\r
41fb5d46 230 IN UINTN GicRedistributorBase,\r
e700a1fc
OM
231 IN UINTN Source\r
232 );\r
233\r
55a0d64b 234#endif\r