2 The header file for ISA bus driver
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
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.
15 #ifndef _EFI_ISA_BUS_H
16 #define _EFI_ISA_BUS_H
20 #include <FrameworkDxe.h>
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>
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>
41 #include "ComponentName.h"
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
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
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
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
77 #define R_8237_DMA_STA_CH0_3 0xd8
78 #define R_8237_DMA_STA_CH4_7 0xd0
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
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
97 #define R_8237_DMA_CBPR_CH0_3 0x0c
98 #define R_8237_DMA_CBPR_CH4_7 0xd8
100 #define R_8237_DMA_MCR_CH0_3 0x0d
101 #define R_8237_DMA_MCR_CH4_7 0xda
103 #define R_8237_DMA_CLMSK_CH0_3 0x0e
104 #define R_8237_DMA_CLMSK_CH4_7 0xdc
106 #define R_8237_DMA_WRMSK_CH0_3 0x0f
107 #define R_8237_DMA_WRMSK_CH4_7 0xde
110 extern EFI_ISA_IO_PROTOCOL IsaIoInterface
;
113 IsaAccessTypeUnknown
,
120 // 16 MB Memory Range
122 #define ISA_MAX_MEMORY_ADDRESS 0x1000000
126 #define ISA_MAX_IO_ADDRESS 0x10000
132 } EFI_ISA_DMA_REGISTERS
;
135 // ISA I/O Device Structure
137 #define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')
142 EFI_ISA_IO_PROTOCOL IsaIo
;
143 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
144 EFI_PCI_IO_PROTOCOL
*PciIo
;
147 #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
152 extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver
;
155 // Mapping structure for performing ISA DMA to a buffer above 16 MB
158 EFI_ISA_IO_PROTOCOL_OPERATION Operation
;
161 EFI_PHYSICAL_ADDRESS HostAddress
;
162 EFI_PHYSICAL_ADDRESS MappedHostAddress
;
166 // EFI Driver Binding Protocol Interface Functions
171 IsaBusControllerDriverSupported (
172 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
173 IN EFI_HANDLE Controller
,
174 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
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
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.
194 EFI_SUCCESS - The device is supported by this driver.
195 EFI_UNSUPPORTED - The device is not supported by this driver.
202 IsaBusControllerDriverStart (
203 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
204 IN EFI_HANDLE Controller
,
205 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
211 This function tells the ISA Bus Driver to start managing a PCI to ISA
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.
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
235 IsaBusControllerDriverStop (
236 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
237 IN EFI_HANDLE Controller
,
238 IN UINTN NumberOfChildren
,
239 IN EFI_HANDLE
* ChildHandleBuffer OPTIONAL
245 This function tells the ISA Bus Driver to stop managing a PCI to ISA
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.
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
269 // Function Prototypes
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
285 Create ISA device found by IsaPnpProtocol
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.
298 EFI_SUCCESS - Create the child device.
299 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
301 EFI_DEVICE_ERROR - Can not create child device.
307 InitializeIsaIoInstance (
308 IN ISA_IO_DEVICE
*IsaIoDevice
,
309 IN EFI_ISA_ACPI_RESOURCE_LIST
*IsaDevice
315 Initializes an ISA I/O Instance
319 IsaIoDevice - The iso device to be initialized.
320 IsaDevice - The resource list.
324 EFI_SUCCESS - Initial success.