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