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