]> git.proxmox.com Git - mirror_edk2.git/blob - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h
9bfd065b1a2bbf31b78a17d420b6d82f498c9f81
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / InternalIsaBus.h
1 /**@file
2 The header file for ISA bus driver
3
4 Copyright (c) 2006 - 2007, Intel Corporation. <BR>
5 All rights reserved. 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 _EFI_ISA_BUS_H
16 #define _EFI_ISA_BUS_H
17
18
19 #include <PiDxe.h>
20 #include <FrameworkDxe.h>
21
22 #include <Protocol/PciIo.h>
23 #include <Protocol/ComponentName.h>
24 #include <Protocol/IsaIo.h>
25 #include <Protocol/DevicePath.h>
26 #include <Protocol/IsaAcpi.h>
27 #include <Protocol/DriverBinding.h>
28 #include <Protocol/GenericMemoryTest.h>
29 #include <Guid/StatusCodeDataTypeId.h>
30
31 #include <Library/DebugLib.h>
32 #include <Library/UefiDriverEntryPoint.h>
33 #include <Library/UefiLib.h>
34 #include <Library/DevicePathLib.h>
35 #include <Library/BaseMemoryLib.h>
36 #include <Library/MemoryAllocationLib.h>
37 #include <Library/UefiBootServicesTableLib.h>
38 #include <Library/ReportStatusCodeLib.h>
39 #include <Library/PcdLib.h>
40
41 #include "ComponentName.h"
42
43 //
44 // Global Variables
45 //
46 extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver;
47
48 extern EFI_ISA_IO_PROTOCOL IsaIoInterface;
49
50 //
51 // 8237 DMA registers
52 //
53 #define R_8237_DMA_BASE_CA_CH0 0x00
54 #define R_8237_DMA_BASE_CA_CH1 0x02
55 #define R_8237_DMA_BASE_CA_CH2 0x04
56 #define R_8237_DMA_BASE_CA_CH3 0xd6
57 #define R_8237_DMA_BASE_CA_CH5 0xc4
58 #define R_8237_DMA_BASE_CA_CH6 0xc8
59 #define R_8237_DMA_BASE_CA_CH7 0xcc
60
61 #define R_8237_DMA_BASE_CC_CH0 0x01
62 #define R_8237_DMA_BASE_CC_CH1 0x03
63 #define R_8237_DMA_BASE_CC_CH2 0x05
64 #define R_8237_DMA_BASE_CC_CH3 0xd7
65 #define R_8237_DMA_BASE_CC_CH5 0xc6
66 #define R_8237_DMA_BASE_CC_CH6 0xca
67 #define R_8237_DMA_BASE_CC_CH7 0xce
68
69 #define R_8237_DMA_MEM_LP_CH0 0x87
70 #define R_8237_DMA_MEM_LP_CH1 0x83
71 #define R_8237_DMA_MEM_LP_CH2 0x81
72 #define R_8237_DMA_MEM_LP_CH3 0x82
73 #define R_8237_DMA_MEM_LP_CH5 0x8B
74 #define R_8237_DMA_MEM_LP_CH6 0x89
75 #define R_8237_DMA_MEM_LP_CH7 0x8A
76
77
78 #define R_8237_DMA_COMMAND_CH0_3 0x08
79 #define R_8237_DMA_COMMAND_CH4_7 0xd0
80 #define B_8237_DMA_COMMAND_GAP 0x10
81 #define B_8237_DMA_COMMAND_CGE 0x04
82
83
84 #define R_8237_DMA_STA_CH0_3 0xd8
85 #define R_8237_DMA_STA_CH4_7 0xd0
86
87 #define R_8237_DMA_WRSMSK_CH0_3 0x0a
88 #define R_8237_DMA_WRSMSK_CH4_7 0xd4
89 #define B_8237_DMA_WRSMSK_CMS 0x04
90
91
92 #define R_8237_DMA_CHMODE_CH0_3 0x0b
93 #define R_8237_DMA_CHMODE_CH4_7 0xd6
94 #define V_8237_DMA_CHMODE_DEMAND 0x00
95 #define V_8237_DMA_CHMODE_SINGLE 0x40
96 #define V_8237_DMA_CHMODE_CASCADE 0xc0
97 #define B_8237_DMA_CHMODE_DECREMENT 0x20
98 #define B_8237_DMA_CHMODE_INCREMENT 0x00
99 #define B_8237_DMA_CHMODE_AE 0x10
100 #define V_8237_DMA_CHMODE_VERIFY 0
101 #define V_8237_DMA_CHMODE_IO2MEM 0x04
102 #define V_8237_DMA_CHMODE_MEM2IO 0x08
103
104 #define R_8237_DMA_CBPR_CH0_3 0x0c
105 #define R_8237_DMA_CBPR_CH4_7 0xd8
106
107 #define R_8237_DMA_MCR_CH0_3 0x0d
108 #define R_8237_DMA_MCR_CH4_7 0xda
109
110 #define R_8237_DMA_CLMSK_CH0_3 0x0e
111 #define R_8237_DMA_CLMSK_CH4_7 0xdc
112
113 #define R_8237_DMA_WRMSK_CH0_3 0x0f
114 #define R_8237_DMA_WRMSK_CH4_7 0xde
115
116 typedef enum {
117 IsaAccessTypeUnknown,
118 IsaAccessTypeIo,
119 IsaAccessTypeMem,
120 IsaAccessTypeMaxType
121 } ISA_ACCESS_TYPE;
122
123 //
124 // 16 MB Memory Range
125 //
126 #define ISA_MAX_MEMORY_ADDRESS 0x1000000
127 //
128 // 64K I/O Range
129 //
130 #define ISA_MAX_IO_ADDRESS 0x10000
131
132 typedef struct {
133 UINT8 Address;
134 UINT8 Page;
135 UINT8 Count;
136 } EFI_ISA_DMA_REGISTERS;
137
138 //
139 // ISA I/O Device Structure
140 //
141 #define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')
142
143 typedef struct {
144 UINT32 Signature;
145 EFI_HANDLE Handle;
146 EFI_ISA_IO_PROTOCOL IsaIo;
147 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
148 EFI_PCI_IO_PROTOCOL *PciIo;
149 } ISA_IO_DEVICE;
150
151 #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
152
153 //
154 // Mapping structure for performing ISA DMA to a buffer above 16 MB
155 //
156 typedef struct {
157 EFI_ISA_IO_PROTOCOL_OPERATION Operation;
158 UINTN NumberOfBytes;
159 UINTN NumberOfPages;
160 EFI_PHYSICAL_ADDRESS HostAddress;
161 EFI_PHYSICAL_ADDRESS MappedHostAddress;
162 } ISA_MAP_INFO;
163
164 //
165 // EFI Driver Binding Protocol Interface Functions
166 //
167
168 EFI_STATUS
169 EFIAPI
170 IsaBusControllerDriverSupported (
171 IN EFI_DRIVER_BINDING_PROTOCOL * This,
172 IN EFI_HANDLE Controller,
173 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
174 )
175 /**
176
177 Routine Description:
178
179 This function checks to see if a controller can be managed by the ISA Bus
180 Driver. This is done by checking to see if the controller supports the
181 EFI_PCI_IO_PROTOCOL protocol, and then looking at the PCI Configuration
182 Header to see if the device is a PCI to ISA bridge. The class code of
183 PCI to ISA bridge: Base class 06h, Sub class 01h Interface 00h
184
185 Arguments:
186
187 This - The EFI_DRIVER_BINDING_PROTOCOL instance.
188 Controller - The handle of the device to check.
189 RemainingDevicePath - A pointer to the remaining portion of a device path.
190
191 Returns:
192
193 EFI_SUCCESS - The device is supported by this driver.
194 EFI_UNSUPPORTED - The device is not supported by this driver.
195
196 **/
197 ;
198
199 EFI_STATUS
200 EFIAPI
201 IsaBusControllerDriverStart (
202 IN EFI_DRIVER_BINDING_PROTOCOL * This,
203 IN EFI_HANDLE Controller,
204 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
205 )
206 /**
207
208 Routine Description:
209
210 This function tells the ISA Bus Driver to start managing a PCI to ISA
211 Bridge controller.
212
213 Arguments:
214
215 This - The EFI_DRIVER_BINDING_PROTOCOL instance.
216 Controller - A handle to the device being started.
217 RemainingDevicePath - A pointer to the remaining portion of a device path.
218
219 Returns:
220
221 EFI_SUCCESS - The device was started.
222 EFI_UNSUPPORTED - The device is not supported.
223 EFI_DEVICE_ERROR - The device could not be started due to a device error.
224 EFI_ALREADY_STARTED - The device has already been started.
225 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
226 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
227 resources.
228
229 **/
230 ;
231
232 EFI_STATUS
233 EFIAPI
234 IsaBusControllerDriverStop (
235 IN EFI_DRIVER_BINDING_PROTOCOL * This,
236 IN EFI_HANDLE Controller,
237 IN UINTN NumberOfChildren,
238 IN EFI_HANDLE * ChildHandleBuffer OPTIONAL
239 )
240 /**
241
242 Routine Description:
243
244 This function tells the ISA Bus Driver to stop managing a PCI to ISA
245 Bridge controller.
246
247 Arguments:
248
249 This - The EFI_DRIVER_BINDING_PROTOCOL instance.
250 Controller - A handle to the device being stopped.
251 NumberOfChindren - The number of child device handles in ChildHandleBuffer.
252 ChildHandleBuffer - An array of child handles to be freed.
253
254
255 Returns:
256
257 EFI_SUCCESS - The device was stopped.
258 EFI_DEVICE_ERROR - The device could not be stopped due to a device error.
259 EFI_NOT_STARTED - The device has not been started.
260 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
261 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
262 resources.
263
264 **/
265 ;
266
267 //
268 // Function Prototypes
269 //
270
271 EFI_STATUS
272 IsaCreateDevice (
273 IN EFI_DRIVER_BINDING_PROTOCOL *This,
274 IN EFI_HANDLE Controller,
275 IN EFI_PCI_IO_PROTOCOL *PciIo,
276 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,
277 IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList,
278 OUT EFI_DEVICE_PATH_PROTOCOL **ChildDevicePath
279 )
280 /**
281
282 Routine Description:
283
284 Create ISA device found by IsaPnpProtocol
285
286 Arguments:
287
288 This - The EFI_DRIVER_BINDING_PROTOCOL instance.
289 Controller - The handle of ISA bus controller(PCI to ISA bridge)
290 PciIo - The Pointer to the PCI protocol
291 ParentDevicePath - Device path of the ISA bus controller
292 IsaDeviceResourceList - The resource list of the ISA device
293 ChildDevicePath - The pointer to the child device.
294
295 Returns:
296
297 EFI_SUCCESS - Create the child device.
298 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
299 resources.
300 EFI_DEVICE_ERROR - Can not create child device.
301
302 **/
303 ;
304
305 EFI_STATUS
306 InitializeIsaIoInstance (
307 IN ISA_IO_DEVICE *IsaIoDevice,
308 IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDevice
309 )
310 /**
311
312 Routine Description:
313
314 Initializes an ISA I/O Instance
315
316 Arguments:
317
318 IsaIoDevice - The iso device to be initialized.
319 IsaDevice - The resource list.
320
321 Returns:
322
323 EFI_SUCCESS - Initial success.
324
325 **/
326 ;
327
328 #endif