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