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