]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/IsaIoDxe/IsaDriver.h
IntelFrameworkModulePkg IsaIoDxe: Remove a redundant protocol
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaIoDxe / IsaDriver.h
1 /** @file
2 The header file for ISA driver
3
4 Copyright (c) 2010 - 2018, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _ISA_DRIVER_H_
16 #define _ISA_DRIVER_H_
17
18
19 #include <Uefi.h>
20
21 #include <Protocol/PciIo.h>
22 #include <Protocol/SuperIo.h>
23 #include <Protocol/ComponentName.h>
24 #include <Protocol/IsaIo.h>
25 #include <Protocol/DevicePath.h>
26 #include <Protocol/DriverBinding.h>
27 #include <Guid/StatusCodeDataTypeId.h>
28
29 #include <Library/DebugLib.h>
30 #include <Library/UefiDriverEntryPoint.h>
31 #include <Library/UefiLib.h>
32 #include <Library/DevicePathLib.h>
33 #include <Library/BaseMemoryLib.h>
34 #include <Library/MemoryAllocationLib.h>
35 #include <Library/UefiBootServicesTableLib.h>
36 #include <Library/ReportStatusCodeLib.h>
37 #include <Library/PcdLib.h>
38 #include <IndustryStandard/Acpi.h>
39
40 #include "ComponentName.h"
41
42 //
43 // 8237 DMA registers
44 //
45 #define R_8237_DMA_BASE_CA_CH0 0x00
46 #define R_8237_DMA_BASE_CA_CH1 0x02
47 #define R_8237_DMA_BASE_CA_CH2 0x04
48 #define R_8237_DMA_BASE_CA_CH3 0xd6
49 #define R_8237_DMA_BASE_CA_CH5 0xc4
50 #define R_8237_DMA_BASE_CA_CH6 0xc8
51 #define R_8237_DMA_BASE_CA_CH7 0xcc
52
53 #define R_8237_DMA_BASE_CC_CH0 0x01
54 #define R_8237_DMA_BASE_CC_CH1 0x03
55 #define R_8237_DMA_BASE_CC_CH2 0x05
56 #define R_8237_DMA_BASE_CC_CH3 0xd7
57 #define R_8237_DMA_BASE_CC_CH5 0xc6
58 #define R_8237_DMA_BASE_CC_CH6 0xca
59 #define R_8237_DMA_BASE_CC_CH7 0xce
60
61 #define R_8237_DMA_MEM_LP_CH0 0x87
62 #define R_8237_DMA_MEM_LP_CH1 0x83
63 #define R_8237_DMA_MEM_LP_CH2 0x81
64 #define R_8237_DMA_MEM_LP_CH3 0x82
65 #define R_8237_DMA_MEM_LP_CH5 0x8B
66 #define R_8237_DMA_MEM_LP_CH6 0x89
67 #define R_8237_DMA_MEM_LP_CH7 0x8A
68
69
70 #define R_8237_DMA_COMMAND_CH0_3 0x08
71 #define R_8237_DMA_COMMAND_CH4_7 0xd0
72 #define B_8237_DMA_COMMAND_GAP 0x10
73 #define B_8237_DMA_COMMAND_CGE 0x04
74
75
76 #define R_8237_DMA_STA_CH0_3 0xd8
77 #define R_8237_DMA_STA_CH4_7 0xd0
78
79 #define R_8237_DMA_WRSMSK_CH0_3 0x0a
80 #define R_8237_DMA_WRSMSK_CH4_7 0xd4
81 #define B_8237_DMA_WRSMSK_CMS 0x04
82
83
84 #define R_8237_DMA_CHMODE_CH0_3 0x0b
85 #define R_8237_DMA_CHMODE_CH4_7 0xd6
86 #define V_8237_DMA_CHMODE_DEMAND 0x00
87 #define V_8237_DMA_CHMODE_SINGLE 0x40
88 #define V_8237_DMA_CHMODE_CASCADE 0xc0
89 #define B_8237_DMA_CHMODE_DECREMENT 0x20
90 #define B_8237_DMA_CHMODE_INCREMENT 0x00
91 #define B_8237_DMA_CHMODE_AE 0x10
92 #define V_8237_DMA_CHMODE_VERIFY 0
93 #define V_8237_DMA_CHMODE_IO2MEM 0x04
94 #define V_8237_DMA_CHMODE_MEM2IO 0x08
95
96 #define R_8237_DMA_CBPR_CH0_3 0x0c
97 #define R_8237_DMA_CBPR_CH4_7 0xd8
98
99 #define R_8237_DMA_MCR_CH0_3 0x0d
100 #define R_8237_DMA_MCR_CH4_7 0xda
101
102 #define R_8237_DMA_CLMSK_CH0_3 0x0e
103 #define R_8237_DMA_CLMSK_CH4_7 0xdc
104
105 #define R_8237_DMA_WRMSK_CH0_3 0x0f
106 #define R_8237_DMA_WRMSK_CH4_7 0xde
107
108 typedef enum {
109 IsaAccessTypeUnknown,
110 IsaAccessTypeIo,
111 IsaAccessTypeMem,
112 IsaAccessTypeMaxType
113 } ISA_ACCESS_TYPE;
114
115 typedef struct {
116 UINT8 Address;
117 UINT8 Page;
118 UINT8 Count;
119 } EFI_ISA_DMA_REGISTERS;
120
121 //
122 // ISA I/O Device Structure
123 //
124 #define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')
125
126 typedef struct {
127 UINT32 Signature;
128 EFI_HANDLE Handle;
129 EFI_ISA_IO_PROTOCOL IsaIo;
130 EFI_PCI_IO_PROTOCOL *PciIo;
131 } ISA_IO_DEVICE;
132
133 #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
134
135 //
136 // Mapping structure for performing ISA DMA to a buffer above 16 MB
137 //
138 typedef struct {
139 EFI_ISA_IO_PROTOCOL_OPERATION Operation;
140 UINTN NumberOfBytes;
141 UINTN NumberOfPages;
142 EFI_PHYSICAL_ADDRESS HostAddress;
143 EFI_PHYSICAL_ADDRESS MappedHostAddress;
144 } ISA_MAP_INFO;
145
146 //
147 // EFI Driver Binding Protocol Interface Functions
148 //
149
150 /**
151 Tests to see if a controller can be managed by the ISA Driver.
152
153 How the Start() function of a driver is implemented can affect how the Supported() function is implemented.
154
155 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
156 @param[in] Controller The handle of the controller to test.
157 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
158
159 @retval EFI_SUCCESS The device is supported by this driver.
160 @retval EFI_ALREADY_STARTED The device is already being managed by this driver.
161 @retval EFI_ACCESS_DENIED The device is already being managed by a different driver
162 or an application that requires exclusive access.
163 @retval EFI_UNSUPPORTED The device is is not supported by this driver.
164
165 **/
166 EFI_STATUS
167 EFIAPI
168 IsaIoDriverSupported (
169 IN EFI_DRIVER_BINDING_PROTOCOL *This,
170 IN EFI_HANDLE Controller,
171 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
172 );
173
174 /**
175 Start this driver on ControllerHandle.
176
177 The Start() function is designed to be invoked from the EFI boot service ConnectController().
178 As a result, much of the error checking on the parameters to Start() has been moved into this
179 common boot service. It is legal to call Start() from other locations, but the following calling
180 restrictions must be followed or the system behavior will not be deterministic.
181 1. ControllerHandle must be a valid EFI_HANDLE.
182 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
183 EFI_DEVICE_PATH_PROTOCOL.
184 3. Prior to calling Start(), the Supported() function for the driver specified by This must
185 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
186
187 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
188 @param[in] ControllerHandle The handle of the controller to start. This handle
189 must support a protocol interface that supplies
190 an I/O abstraction to the driver.
191 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.
192 This parameter is ignored by device drivers, and is optional for bus drivers.
193
194 @retval EFI_SUCCESS The device was started.
195 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.
196 Currently not implemented.
197 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
198 @retval Others The driver failded to start the device.
199 **/
200 EFI_STATUS
201 EFIAPI
202 IsaIoDriverStart (
203 IN EFI_DRIVER_BINDING_PROTOCOL *This,
204 IN EFI_HANDLE Controller,
205 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
206 );
207
208 /**
209 Stop this driver on ControllerHandle.
210
211 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
212 As a result, much of the error checking on the parameters to Stop() has been moved
213 into this common boot service. It is legal to call Stop() from other locations,
214 but the following calling restrictions must be followed or the system behavior will not be deterministic.
215 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
216 same driver's Start() function.
217 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
218 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
219 Start() function, and the Start() function must have called OpenProtocol() on
220 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
221
222 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
223 @param[in] ControllerHandle A handle to the device being stopped. The handle must
224 support a bus specific I/O protocol for the driver
225 to use to stop the device.
226 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
227 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
228 if NumberOfChildren is 0.
229
230 @retval EFI_SUCCESS The device was stopped.
231 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
232 **/
233 EFI_STATUS
234 EFIAPI
235 IsaIoDriverStop (
236 IN EFI_DRIVER_BINDING_PROTOCOL * This,
237 IN EFI_HANDLE Controller,
238 IN UINTN NumberOfChildren,
239 IN EFI_HANDLE * ChildHandleBuffer OPTIONAL
240 );
241
242 //
243 // Function Prototypes
244 //
245
246 /**
247 Initializes an ISA I/O Instance
248
249 @param[in] IsaIoDevice The isa device to be initialized.
250 @param[in] DevicePath The device path of the isa device.
251 @param[in] Resources The ACPI resource list.
252
253 **/
254 VOID
255 InitializeIsaIoInstance (
256 IN ISA_IO_DEVICE *IsaIoDevice,
257 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
258 IN ACPI_RESOURCE_HEADER_PTR Resources
259 );
260
261 #endif
262