]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Framework / Protocol / Legacy8259 / Legacy8259.h
1 /*++
2
3 Copyright (c) 1999 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12
13 Module Name:
14
15 Legacy8259.h
16
17 Abstract:
18
19 This protocol abstracts the 8259 interrupt controller. This includes
20 PCI IRQ routing need to program the PCI Interrupt Line register.
21
22 Revision History
23
24 The EFI Legacy 8259 Protocol is compliant with CSM spec 0.96.
25
26 --*/
27
28 #ifndef _EFI_LEGACY_8259_H
29 #define _EFI_LEGACY_8259_H
30
31 #define EFI_LEGACY_8259_PROTOCOL_GUID \
32 { \
33 0x38321dba, 0x4fe0, 0x4e17, 0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1 \
34 }
35
36 EFI_FORWARD_DECLARATION (EFI_LEGACY_8259_PROTOCOL);
37
38 typedef enum {
39 Efi8259Irq0,
40 Efi8259Irq1,
41 Efi8259Irq2,
42 Efi8259Irq3,
43 Efi8259Irq4,
44 Efi8259Irq5,
45 Efi8259Irq6,
46 Efi8259Irq7,
47 Efi8259Irq8,
48 Efi8259Irq9,
49 Efi8259Irq10,
50 Efi8259Irq11,
51 Efi8259Irq12,
52 Efi8259Irq13,
53 Efi8259Irq14,
54 Efi8259Irq15,
55 Efi8259IrqMax
56 } EFI_8259_IRQ;
57
58 typedef enum {
59 Efi8259LegacyMode,
60 Efi8259ProtectedMode,
61 Efi8259MaxMode
62 } EFI_8259_MODE;
63
64 typedef
65 EFI_STATUS
66 (EFIAPI *EFI_LEGACY_8259_SET_VECTOR_BASE) (
67 IN EFI_LEGACY_8259_PROTOCOL * This,
68 IN UINT8 MasterBase,
69 IN UINT8 SlaveBase
70 )
71 /*++
72
73 Routine Description:
74 Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
75 the legacy mode mask and the protected mode mask. The base address for the 8259
76 is different for legacy and protected mode, so two masks are required.
77
78 Arguments:
79 This - Protocol instance pointer.
80 MasterBase - The base vector for the Master PIC in the 8259 controller
81 Slavebase - The base vector for the Master PIC in the 8259 controller
82
83 Returns:
84 EFI_SUCCESS - The new bases were programmed
85 EFI_DEVICE_ERROR - A device erro occured programming the vector bases
86
87 --*/
88 ;
89
90 typedef
91 EFI_STATUS
92 (EFIAPI *EFI_LEGACY_8259_GET_MASK) (
93 IN EFI_LEGACY_8259_PROTOCOL * This,
94 OUT UINT16 *LegacyMask, OPTIONAL
95 OUT UINT16 *LegacyEdgeLevel, OPTIONAL
96 OUT UINT16 *ProtectedMask, OPTIONAL
97 OUT UINT16 *ProtectedEdgeLevel OPTIONAL
98 )
99 /*++
100
101 Routine Description:
102 Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
103 the legacy mode mask and the protected mode mask. The base address for the 8259
104 is different for legacy and protected mode, so two masks are required.
105
106 Arguments:
107 This - Protocol instance pointer.
108 LegacyMask - Bit 0 is Irq0 - Bit 15 is Irq15
109 LegacyEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
110 ProtectedMask - Bit 0 is Irq0 - Bit 15 is Irq15
111 ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
112
113 Returns:
114 EFI_SUCCESS - 8259 status returned
115 EFI_DEVICE_ERROR - Error reading 8259
116
117 --*/
118 ;
119
120 typedef
121 EFI_STATUS
122 (EFIAPI *EFI_LEGACY_8259_SET_MASK) (
123 IN EFI_LEGACY_8259_PROTOCOL * This,
124 IN UINT16 *LegacyMask, OPTIONAL
125 IN UINT16 *LegacyEdgeLevel, OPTIONAL
126 IN UINT16 *ProtectedMask, OPTIONAL
127 IN UINT16 *ProtectedEdgeLevel OPTIONAL
128 )
129 /*++
130
131 Routine Description:
132 Set the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
133 the legacy mode mask and the protected mode mask. The base address for the 8259
134 is different for legacy and protected mode, so two masks are required.
135 Also set the edge/level masks.
136
137 Arguments:
138 This - Protocol instance pointer.
139 LegacyMask - Bit 0 is Irq0 - Bit 15 is Irq15
140 LegacyEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
141 ProtectedMask - Bit 0 is Irq0 - Bit 15 is Irq15
142 ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
143
144 Returns:
145 EFI_SUCCESS - 8259 status returned
146 EFI_DEVICE_ERROR - Error reading 8259
147
148 --*/
149 ;
150
151 typedef
152 EFI_STATUS
153 (EFIAPI *EFI_LEGACY_8259_SET_MODE) (
154 IN EFI_LEGACY_8259_PROTOCOL * This,
155 IN EFI_8259_MODE Mode,
156 IN UINT16 *Mask, OPTIONAL
157 IN UINT16 *EdgeLevel OPTIONAL
158 )
159 /*++
160
161 Routine Description:
162 Set the 8259 mode of operation. The base address for the 8259 is different for
163 legacy and protected mode. The legacy mode requires the master 8259 to have a
164 master base of 0x08 and the slave base of 0x70. The protected mode base locations
165 are not defined. Interrupts must be masked by the caller before this function
166 is called. The interrupt mask from the current mode is saved. The interrupt
167 mask for the new mode is Mask, or if Mask does not exist the previously saved
168 mask is used.
169
170
171 Arguments:
172 This - Protocol instance pointer.
173 Mode - Mode of operation. i.e. real mode or protected mode
174 Mask - Optional interupt mask for the new mode.
175 EdgeLevel - Optional trigger mask for the new mode.
176
177 Returns:
178 EFI_SUCCESS - 8259 programmed
179 EFI_DEVICE_ERROR - Error writting to 8259
180
181 --*/
182 ;
183
184 typedef
185 EFI_STATUS
186 (EFIAPI *EFI_LEGACY_8259_GET_VECTOR) (
187 IN EFI_LEGACY_8259_PROTOCOL * This,
188 IN EFI_8259_IRQ Irq,
189 OUT UINT8 *Vector
190 )
191 /*++
192
193 Routine Description:
194 Convert from IRQ to processor interrupt vector number.
195
196 Arguments:
197 This - Protocol instance pointer.
198 Irq - 8259 IRQ0 - IRQ15
199 Vector - Processor vector number that matches Irq
200
201 Returns:
202 EFI_SUCCESS - The Vector matching Irq is returned
203 EFI_INVALID_PARAMETER - Irq not valid
204
205 --*/
206 ;
207
208 typedef
209 EFI_STATUS
210 (EFIAPI *EFI_LEGACY_8259_ENABLE_IRQ) (
211 IN EFI_LEGACY_8259_PROTOCOL * This,
212 IN EFI_8259_IRQ Irq,
213 IN BOOLEAN LevelTriggered
214 )
215 /*++
216
217 Routine Description:
218 Enable Irq by unmasking interrupt in 8259
219
220 Arguments:
221 This - Protocol instance pointer.
222 Irq - 8259 IRQ0 - IRQ15
223 LevelTriggered - TRUE if level triggered. FALSE if edge triggered.
224
225 Returns:
226 EFI_SUCCESS - Irq enabled on 8259
227 EFI_INVALID_PARAMETER - Irq not valid
228
229 --*/
230 ;
231
232 typedef
233 EFI_STATUS
234 (EFIAPI *EFI_LEGACY_8259_DISABLE_IRQ) (
235 IN EFI_LEGACY_8259_PROTOCOL * This,
236 IN EFI_8259_IRQ Irq
237 )
238 /*++
239
240 Routine Description:
241 Disable Irq by masking interrupt in 8259
242
243 Arguments:
244 This - Protocol instance pointer.
245 Irq - 8259 IRQ0 - IRQ15
246
247 Returns:
248 EFI_SUCCESS - Irq disabled on 8259
249 EFI_INVALID_PARAMETER - Irq not valid
250
251 --*/
252 ;
253
254 typedef
255 EFI_STATUS
256 (EFIAPI *EFI_LEGACY_8259_GET_INTERRUPT_LINE) (
257 IN EFI_LEGACY_8259_PROTOCOL * This,
258 IN EFI_HANDLE PciHandle,
259 OUT UINT8 *Vector
260 )
261 /*++
262
263 Routine Description:
264 PciHandle represents a PCI config space of a PCI function. Vector
265 represents Interrupt Pin (from PCI config space) and it is the data
266 that is programmed into the Interrupt Line (from the PCI config space)
267 register.
268
269 Arguments:
270 This - Protocol instance pointer.
271 PciHandle - PCI function to return vector for
272 Vector - Vector for fucntion that matches
273
274 Returns:
275 EFI_SUCCESS - A valid Vector is returned
276 EFI_INVALID_PARAMETER - PciHandle not valid
277
278 --*/
279 ;
280
281 typedef
282 EFI_STATUS
283 (EFIAPI *EFI_LEGACY_8259_END_OF_INTERRUPT) (
284 IN EFI_LEGACY_8259_PROTOCOL * This,
285 IN EFI_8259_IRQ Irq
286 )
287 /*++
288
289 Routine Description:
290 Send an EOI to 8259
291
292 Arguments:
293 This - Protocol instance pointer.
294 Irq - 8259 IRQ0 - IRQ15
295
296 Returns:
297 EFI_SUCCESS - EOI successfully sent to 8259
298 EFI_INVALID_PARAMETER - Irq not valid
299
300 --*/
301 ;
302
303 typedef struct _EFI_LEGACY_8259_PROTOCOL {
304 EFI_LEGACY_8259_SET_VECTOR_BASE SetVectorBase;
305 EFI_LEGACY_8259_GET_MASK GetMask;
306 EFI_LEGACY_8259_SET_MASK SetMask;
307 EFI_LEGACY_8259_SET_MODE SetMode;
308 EFI_LEGACY_8259_GET_VECTOR GetVector;
309 EFI_LEGACY_8259_ENABLE_IRQ EnableIrq;
310 EFI_LEGACY_8259_DISABLE_IRQ DisableIrq;
311 EFI_LEGACY_8259_GET_INTERRUPT_LINE GetInterruptLine;
312 EFI_LEGACY_8259_END_OF_INTERRUPT EndOfInterrupt;
313 } EFI_LEGACY_8259_PROTOCOL;
314
315 extern EFI_GUID gEfiLegacy8259ProtocolGuid;
316
317 #endif