]> git.proxmox.com Git - mirror_edk2.git/blob - ArmPkg/Include/Library/ArmGicLib.h
ArmPkg/ArmGic: Introduced support for GicV2 to ArmGicLib
[mirror_edk2.git] / ArmPkg / Include / Library / ArmGicLib.h
1 /** @file
2 *
3 * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
4 *
5 * This program and the accompanying materials
6 * are licensed and made available under the terms and conditions of the BSD License
7 * which accompanies this distribution. The full text of the license may be found at
8 * http://opensource.org/licenses/bsd-license.php
9 *
10 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 *
13 **/
14
15 #ifndef __ARMGIC_H
16 #define __ARMGIC_H
17
18 //
19 // GIC definitions
20 //
21
22 //
23 // GIC Distributor
24 //
25 #define ARM_GIC_ICDDCR 0x000 // Distributor Control Register
26 #define ARM_GIC_ICDICTR 0x004 // Interrupt Controller Type Register
27 #define ARM_GIC_ICDIIDR 0x008 // Implementer Identification Register
28
29 // Each reg base below repeats for VE_NUM_ARM_GIC_REG_PER_INT_BITS (see GIC spec)
30 #define ARM_GIC_ICDISR 0x080 // Interrupt Security Registers
31 #define ARM_GIC_ICDISER 0x100 // Interrupt Set-Enable Registers
32 #define ARM_GIC_ICDICER 0x180 // Interrupt Clear-Enable Registers
33 #define ARM_GIC_ICDSPR 0x200 // Interrupt Set-Pending Registers
34 #define ARM_GIC_ICDICPR 0x280 // Interrupt Clear-Pending Registers
35 #define ARM_GIC_ICDABR 0x300 // Active Bit Registers
36
37 // Each reg base below repeats for VE_NUM_ARM_GIC_REG_PER_INT_BYTES
38 #define ARM_GIC_ICDIPR 0x400 // Interrupt Priority Registers
39
40 // Each reg base below repeats for VE_NUM_ARM_GIC_INTERRUPTS
41 #define ARM_GIC_ICDIPTR 0x800 // Interrupt Processor Target Registers
42 #define ARM_GIC_ICDICFR 0xC00 // Interrupt Configuration Registers
43
44 #define ARM_GIC_ICDPPISR 0xD00 // PPI Status register
45
46 // just one of these
47 #define ARM_GIC_ICDSGIR 0xF00 // Software Generated Interrupt Register
48
49 //
50 // GIC Cpu interface
51 //
52 #define ARM_GIC_ICCICR 0x00 // CPU Interface Control Register
53 #define ARM_GIC_ICCPMR 0x04 // Interrupt Priority Mask Register
54 #define ARM_GIC_ICCBPR 0x08 // Binary Point Register
55 #define ARM_GIC_ICCIAR 0x0C // Interrupt Acknowledge Register
56 #define ARM_GIC_ICCEIOR 0x10 // End Of Interrupt Register
57 #define ARM_GIC_ICCRPR 0x14 // Running Priority Register
58 #define ARM_GIC_ICCPIR 0x18 // Highest Pending Interrupt Register
59 #define ARM_GIC_ICCABPR 0x1C // Aliased Binary Point Register
60 #define ARM_GIC_ICCIIDR 0xFC // Identification Register
61
62 #define ARM_GIC_ICDSGIR_FILTER_TARGETLIST 0x0
63 #define ARM_GIC_ICDSGIR_FILTER_EVERYONEELSE 0x1
64 #define ARM_GIC_ICDSGIR_FILTER_ITSELF 0x2
65
66 // Bit-masks to configure the CPU Interface Control register
67 #define ARM_GIC_ICCICR_ENABLE_SECURE 0x01
68 #define ARM_GIC_ICCICR_ENABLE_NS 0x02
69 #define ARM_GIC_ICCICR_ACK_CTL 0x04
70 #define ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ 0x08
71 #define ARM_GIC_ICCICR_USE_SBPR 0x10
72
73 // Bit Mask for GICC_IIDR
74 #define ARM_GIC_ICCIIDR_GET_PRODUCT_ID(IccIidr) (((IccIidr) >> 20) & 0xFFF)
75 #define ARM_GIC_ICCIIDR_GET_ARCH_VERSION(IccIidr) (((IccIidr) >> 16) & 0xF)
76 #define ARM_GIC_ICCIIDR_GET_REVISION(IccIidr) (((IccIidr) >> 12) & 0xF)
77 #define ARM_GIC_ICCIIDR_GET_IMPLEMENTER(IccIidr) ((IccIidr) & 0xFFF)
78
79 UINTN
80 EFIAPI
81 ArmGicGetInterfaceIdentification (
82 IN INTN GicInterruptInterfaceBase
83 );
84
85 //
86 // GIC Secure interfaces
87 //
88 VOID
89 EFIAPI
90 ArmGicSetupNonSecure (
91 IN UINTN MpId,
92 IN INTN GicDistributorBase,
93 IN INTN GicInterruptInterfaceBase
94 );
95
96 VOID
97 EFIAPI
98 ArmGicSetSecureInterrupts (
99 IN UINTN GicDistributorBase,
100 IN UINTN* GicSecureInterruptMask,
101 IN UINTN GicSecureInterruptMaskSize
102 );
103
104 VOID
105 EFIAPI
106 ArmGicEnableInterruptInterface (
107 IN INTN GicInterruptInterfaceBase
108 );
109
110 VOID
111 EFIAPI
112 ArmGicDisableInterruptInterface (
113 IN INTN GicInterruptInterfaceBase
114 );
115
116 VOID
117 EFIAPI
118 ArmGicEnableDistributor (
119 IN INTN GicDistributorBase
120 );
121
122 VOID
123 EFIAPI
124 ArmGicDisableDistributor (
125 IN INTN GicDistributorBase
126 );
127
128 UINTN
129 EFIAPI
130 ArmGicGetMaxNumInterrupts (
131 IN INTN GicDistributorBase
132 );
133
134 VOID
135 EFIAPI
136 ArmGicSendSgiTo (
137 IN INTN GicDistributorBase,
138 IN INTN TargetListFilter,
139 IN INTN CPUTargetList,
140 IN INTN SgiId
141 );
142
143 UINTN
144 EFIAPI
145 ArmGicAcknowledgeInterrupt (
146 IN UINTN GicInterruptInterfaceBase
147 );
148
149 VOID
150 EFIAPI
151 ArmGicEndOfInterrupt (
152 IN UINTN GicInterruptInterfaceBase,
153 IN UINTN Source
154 );
155
156 UINTN
157 EFIAPI
158 ArmGicSetPriorityMask (
159 IN INTN GicInterruptInterfaceBase,
160 IN INTN PriorityMask
161 );
162
163 VOID
164 EFIAPI
165 ArmGicEnableInterrupt (
166 IN UINTN GicDistributorBase,
167 IN UINTN Source
168 );
169
170 VOID
171 EFIAPI
172 ArmGicDisableInterrupt (
173 IN UINTN GicDistributorBase,
174 IN UINTN Source
175 );
176
177 BOOLEAN
178 EFIAPI
179 ArmGicIsInterruptEnabled (
180 IN UINTN GicDistributorBase,
181 IN UINTN Source
182 );
183
184 #endif