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