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