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 extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver
;
48 extern EFI_ISA_IO_PROTOCOL IsaIoInterface
;
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
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
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
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
84 #define R_8237_DMA_STA_CH0_3 0xd8
85 #define R_8237_DMA_STA_CH4_7 0xd0
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
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
104 #define R_8237_DMA_CBPR_CH0_3 0x0c
105 #define R_8237_DMA_CBPR_CH4_7 0xd8
107 #define R_8237_DMA_MCR_CH0_3 0x0d
108 #define R_8237_DMA_MCR_CH4_7 0xda
110 #define R_8237_DMA_CLMSK_CH0_3 0x0e
111 #define R_8237_DMA_CLMSK_CH4_7 0xdc
113 #define R_8237_DMA_WRMSK_CH0_3 0x0f
114 #define R_8237_DMA_WRMSK_CH4_7 0xde
117 IsaAccessTypeUnknown
,
124 // 16 MB Memory Range
126 #define ISA_MAX_MEMORY_ADDRESS 0x1000000
130 #define ISA_MAX_IO_ADDRESS 0x10000
136 } EFI_ISA_DMA_REGISTERS
;
139 // ISA I/O Device Structure
141 #define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')
146 EFI_ISA_IO_PROTOCOL IsaIo
;
147 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
148 EFI_PCI_IO_PROTOCOL
*PciIo
;
151 #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
154 // Mapping structure for performing ISA DMA to a buffer above 16 MB
157 EFI_ISA_IO_PROTOCOL_OPERATION Operation
;
160 EFI_PHYSICAL_ADDRESS HostAddress
;
161 EFI_PHYSICAL_ADDRESS MappedHostAddress
;
165 // EFI Driver Binding Protocol Interface Functions
170 IsaBusControllerDriverSupported (
171 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
172 IN EFI_HANDLE Controller
,
173 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
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
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.
193 EFI_SUCCESS - The device is supported by this driver.
194 EFI_UNSUPPORTED - The device is not supported by this driver.
201 IsaBusControllerDriverStart (
202 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
203 IN EFI_HANDLE Controller
,
204 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
210 This function tells the ISA Bus Driver to start managing a PCI to ISA
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.
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
234 IsaBusControllerDriverStop (
235 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
236 IN EFI_HANDLE Controller
,
237 IN UINTN NumberOfChildren
,
238 IN EFI_HANDLE
* ChildHandleBuffer OPTIONAL
244 This function tells the ISA Bus Driver to stop managing a PCI to ISA
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.
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
268 // Function Prototypes
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
284 Create ISA device found by IsaPnpProtocol
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.
297 EFI_SUCCESS - Create the child device.
298 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
300 EFI_DEVICE_ERROR - Can not create child device.
306 InitializeIsaIoInstance (
307 IN ISA_IO_DEVICE
*IsaIoDevice
,
308 IN EFI_ISA_ACPI_RESOURCE_LIST
*IsaDevice
314 Initializes an ISA I/O Instance
318 IsaIoDevice - The iso device to be initialized.
319 IsaDevice - The resource list.
323 EFI_SUCCESS - Initial success.