]>
Commit | Line | Data |
---|---|---|
9a86fd33 HW |
1 | /** @file\r |
2 | Driver implementing the Tiano Legacy 8259 Protocol\r | |
3 | \r | |
c0185243 | 4 | Copyright (c) 2005 - 2019, Intel Corporation. All rights reserved.<BR>\r |
9a86fd33 HW |
5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
6 | \r | |
7 | **/\r | |
8 | \r | |
9 | #ifndef _8259_H__\r | |
10 | #define _8259_H__\r | |
11 | \r | |
9a86fd33 HW |
12 | #include <Protocol/Legacy8259.h>\r |
13 | #include <Protocol/PciIo.h>\r | |
14 | \r | |
15 | #include <Library/UefiBootServicesTableLib.h>\r | |
16 | #include <Library/DebugLib.h>\r | |
17 | #include <Library/IoLib.h>\r | |
18 | #include <Library/BaseLib.h>\r | |
19 | #include <Library/PcdLib.h>\r | |
20 | \r | |
21 | #include <IndustryStandard/Pci.h>\r | |
22 | \r | |
23 | // 8259 Hardware definitions\r | |
24 | \r | |
25 | #define LEGACY_MODE_BASE_VECTOR_MASTER 0x08\r | |
26 | #define LEGACY_MODE_BASE_VECTOR_SLAVE 0x70\r | |
27 | \r | |
28 | #define PROTECTED_MODE_BASE_VECTOR_MASTER 0x68\r | |
29 | #define PROTECTED_MODE_BASE_VECTOR_SLAVE 0x70\r | |
30 | \r | |
31 | #define LEGACY_8259_CONTROL_REGISTER_MASTER 0x20\r | |
32 | #define LEGACY_8259_MASK_REGISTER_MASTER 0x21\r | |
33 | #define LEGACY_8259_CONTROL_REGISTER_SLAVE 0xA0\r | |
34 | #define LEGACY_8259_MASK_REGISTER_SLAVE 0xA1\r | |
35 | #define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_MASTER 0x4D0\r | |
36 | #define LEGACY_8259_EDGE_LEVEL_TRIGGERED_REGISTER_SLAVE 0x4D1\r | |
37 | \r | |
38 | #define LEGACY_8259_EOI 0x20\r | |
39 | \r | |
40 | // Protocol Function Prototypes\r | |
41 | \r | |
42 | /**\r | |
43 | Sets the base address for the 8259 master and slave PICs.\r | |
44 | \r | |
45 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
46 | @param[in] MasterBase Interrupt vectors for IRQ0-IRQ7.\r | |
47 | @param[in] SlaveBase Interrupt vectors for IRQ8-IRQ15.\r | |
48 | \r | |
49 | @retval EFI_SUCCESS The 8259 PIC was programmed successfully.\r | |
50 | @retval EFI_DEVICE_ERROR There was an error while writing to the 8259 PIC.\r | |
51 | \r | |
52 | **/\r | |
53 | EFI_STATUS\r | |
54 | EFIAPI\r | |
55 | Interrupt8259SetVectorBase (\r | |
56 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
57 | IN UINT8 MasterBase,\r | |
58 | IN UINT8 SlaveBase\r | |
59 | );\r | |
60 | \r | |
61 | /**\r | |
62 | Gets the current 16-bit real mode and 32-bit protected-mode IRQ masks.\r | |
63 | \r | |
64 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
65 | @param[out] LegacyMask 16-bit mode interrupt mask for IRQ0-IRQ15.\r | |
66 | @param[out] LegacyEdgeLevel 16-bit mode edge/level mask for IRQ-IRQ15.\r | |
67 | @param[out] ProtectedMask 32-bit mode interrupt mask for IRQ0-IRQ15.\r | |
68 | @param[out] ProtectedEdgeLevel 32-bit mode edge/level mask for IRQ0-IRQ15.\r | |
69 | \r | |
70 | @retval EFI_SUCCESS The 8259 PIC was programmed successfully.\r | |
71 | @retval EFI_DEVICE_ERROR There was an error while reading the 8259 PIC.\r | |
72 | \r | |
73 | **/\r | |
74 | EFI_STATUS\r | |
75 | EFIAPI\r | |
76 | Interrupt8259GetMask (\r | |
77 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
78 | OUT UINT16 *LegacyMask, OPTIONAL\r | |
79 | OUT UINT16 *LegacyEdgeLevel, OPTIONAL\r | |
80 | OUT UINT16 *ProtectedMask, OPTIONAL\r | |
81 | OUT UINT16 *ProtectedEdgeLevel OPTIONAL\r | |
82 | );\r | |
83 | \r | |
84 | /**\r | |
85 | Sets the current 16-bit real mode and 32-bit protected-mode IRQ masks.\r | |
86 | \r | |
87 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
88 | @param[in] LegacyMask 16-bit mode interrupt mask for IRQ0-IRQ15.\r | |
89 | @param[in] LegacyEdgeLevel 16-bit mode edge/level mask for IRQ-IRQ15.\r | |
90 | @param[in] ProtectedMask 32-bit mode interrupt mask for IRQ0-IRQ15.\r | |
91 | @param[in] ProtectedEdgeLevel 32-bit mode edge/level mask for IRQ0-IRQ15.\r | |
92 | \r | |
93 | @retval EFI_SUCCESS The 8259 PIC was programmed successfully.\r | |
94 | @retval EFI_DEVICE_ERROR There was an error while writing the 8259 PIC.\r | |
95 | \r | |
96 | **/\r | |
97 | EFI_STATUS\r | |
98 | EFIAPI\r | |
99 | Interrupt8259SetMask (\r | |
100 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
101 | IN UINT16 *LegacyMask, OPTIONAL\r | |
102 | IN UINT16 *LegacyEdgeLevel, OPTIONAL\r | |
103 | IN UINT16 *ProtectedMask, OPTIONAL\r | |
104 | IN UINT16 *ProtectedEdgeLevel OPTIONAL\r | |
105 | );\r | |
106 | \r | |
107 | /**\r | |
108 | Sets the mode of the PICs.\r | |
109 | \r | |
110 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
111 | @param[in] Mode 16-bit real or 32-bit protected mode.\r | |
112 | @param[in] Mask The value with which to set the interrupt mask.\r | |
113 | @param[in] EdgeLevel The value with which to set the edge/level mask.\r | |
114 | \r | |
115 | @retval EFI_SUCCESS The mode was set successfully.\r | |
116 | @retval EFI_INVALID_PARAMETER The mode was not set.\r | |
117 | \r | |
118 | **/\r | |
119 | EFI_STATUS\r | |
120 | EFIAPI\r | |
121 | Interrupt8259SetMode (\r | |
122 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
123 | IN EFI_8259_MODE Mode,\r | |
124 | IN UINT16 *Mask, OPTIONAL\r | |
125 | IN UINT16 *EdgeLevel OPTIONAL\r | |
126 | );\r | |
127 | \r | |
128 | /**\r | |
129 | Translates the IRQ into a vector.\r | |
130 | \r | |
131 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
132 | @param[in] Irq IRQ0-IRQ15.\r | |
133 | @param[out] Vector The vector that is assigned to the IRQ.\r | |
134 | \r | |
135 | @retval EFI_SUCCESS The Vector that matches Irq was returned.\r | |
136 | @retval EFI_INVALID_PARAMETER Irq is not valid.\r | |
137 | \r | |
138 | **/\r | |
139 | EFI_STATUS\r | |
140 | EFIAPI\r | |
141 | Interrupt8259GetVector (\r | |
142 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
143 | IN EFI_8259_IRQ Irq,\r | |
144 | OUT UINT8 *Vector\r | |
145 | );\r | |
146 | \r | |
147 | /**\r | |
148 | Enables the specified IRQ.\r | |
149 | \r | |
150 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
151 | @param[in] Irq IRQ0-IRQ15.\r | |
152 | @param[in] LevelTriggered 0 = Edge triggered; 1 = Level triggered.\r | |
153 | \r | |
154 | @retval EFI_SUCCESS The Irq was enabled on the 8259 PIC.\r | |
155 | @retval EFI_INVALID_PARAMETER The Irq is not valid.\r | |
156 | \r | |
157 | **/\r | |
158 | EFI_STATUS\r | |
159 | EFIAPI\r | |
160 | Interrupt8259EnableIrq (\r | |
161 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
162 | IN EFI_8259_IRQ Irq,\r | |
163 | IN BOOLEAN LevelTriggered\r | |
164 | );\r | |
165 | \r | |
166 | /**\r | |
167 | Disables the specified IRQ.\r | |
168 | \r | |
169 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
170 | @param[in] Irq IRQ0-IRQ15.\r | |
171 | \r | |
172 | @retval EFI_SUCCESS The Irq was disabled on the 8259 PIC.\r | |
173 | @retval EFI_INVALID_PARAMETER The Irq is not valid.\r | |
174 | \r | |
175 | **/\r | |
176 | EFI_STATUS\r | |
177 | EFIAPI\r | |
178 | Interrupt8259DisableIrq (\r | |
179 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
180 | IN EFI_8259_IRQ Irq\r | |
181 | );\r | |
182 | \r | |
183 | /**\r | |
184 | Reads the PCI configuration space to get the interrupt number that is assigned to the card.\r | |
185 | \r | |
186 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
187 | @param[in] PciHandle PCI function for which to return the vector.\r | |
188 | @param[out] Vector IRQ number that corresponds to the interrupt line.\r | |
189 | \r | |
190 | @retval EFI_SUCCESS The interrupt line value was read successfully.\r | |
191 | \r | |
192 | **/\r | |
193 | EFI_STATUS\r | |
194 | EFIAPI\r | |
195 | Interrupt8259GetInterruptLine (\r | |
196 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
197 | IN EFI_HANDLE PciHandle,\r | |
198 | OUT UINT8 *Vector\r | |
199 | );\r | |
200 | \r | |
201 | /**\r | |
202 | Issues the End of Interrupt (EOI) commands to PICs.\r | |
203 | \r | |
204 | @param[in] This Indicates the EFI_LEGACY_8259_PROTOCOL instance.\r | |
205 | @param[in] Irq The interrupt for which to issue the EOI command.\r | |
206 | \r | |
207 | @retval EFI_SUCCESS The EOI command was issued.\r | |
208 | @retval EFI_INVALID_PARAMETER The Irq is not valid.\r | |
209 | \r | |
210 | **/\r | |
211 | EFI_STATUS\r | |
212 | EFIAPI\r | |
213 | Interrupt8259EndOfInterrupt (\r | |
214 | IN EFI_LEGACY_8259_PROTOCOL *This,\r | |
215 | IN EFI_8259_IRQ Irq\r | |
216 | );\r | |
217 | \r | |
218 | #endif\r |