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