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