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