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
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.
18 The header file for ISA bus driver
24 #ifndef _EFI_ISA_BUS_H
25 #define _EFI_ISA_BUS_H
29 #include <FrameworkDxe.h>
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>
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>
50 #include "ComponentName.h"
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
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
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
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
86 #define R_8237_DMA_STA_CH0_3 0xd8
87 #define R_8237_DMA_STA_CH4_7 0xd0
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
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
106 #define R_8237_DMA_CBPR_CH0_3 0x0c
107 #define R_8237_DMA_CBPR_CH4_7 0xd8
109 #define R_8237_DMA_MCR_CH0_3 0x0d
110 #define R_8237_DMA_MCR_CH4_7 0xda
112 #define R_8237_DMA_CLMSK_CH0_3 0x0e
113 #define R_8237_DMA_CLMSK_CH4_7 0xdc
115 #define R_8237_DMA_WRMSK_CH0_3 0x0f
116 #define R_8237_DMA_WRMSK_CH4_7 0xde
119 extern EFI_ISA_IO_PROTOCOL IsaIoInterface
;
122 IsaAccessTypeUnknown
,
129 // 16 MB Memory Range
131 #define ISA_MAX_MEMORY_ADDRESS 0x1000000
135 #define ISA_MAX_IO_ADDRESS 0x10000
141 } EFI_ISA_DMA_REGISTERS
;
144 // ISA I/O Device Structure
146 #define ISA_IO_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('i', 's', 'a', 'i')
151 EFI_ISA_IO_PROTOCOL IsaIo
;
152 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
153 EFI_PCI_IO_PROTOCOL
*PciIo
;
156 #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
161 extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver
;
164 // Mapping structure for performing ISA DMA to a buffer above 16 MB
167 EFI_ISA_IO_PROTOCOL_OPERATION Operation
;
170 EFI_PHYSICAL_ADDRESS HostAddress
;
171 EFI_PHYSICAL_ADDRESS MappedHostAddress
;
175 // EFI Driver Binding Protocol Interface Functions
180 IsaBusControllerDriverSupported (
181 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
182 IN EFI_HANDLE Controller
,
183 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
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
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.
203 EFI_SUCCESS - The device is supported by this driver.
204 EFI_UNSUPPORTED - The device is not supported by this driver.
211 IsaBusControllerDriverStart (
212 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
213 IN EFI_HANDLE Controller
,
214 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
220 This function tells the ISA Bus Driver to start managing a PCI to ISA
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.
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
244 IsaBusControllerDriverStop (
245 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
246 IN EFI_HANDLE Controller
,
247 IN UINTN NumberOfChildren
,
248 IN EFI_HANDLE
* ChildHandleBuffer OPTIONAL
254 This function tells the ISA Bus Driver to stop managing a PCI to ISA
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.
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
278 // Function Prototypes
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
294 Create ISA device found by IsaPnpProtocol
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.
307 EFI_SUCCESS - Create the child device.
308 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
310 EFI_DEVICE_ERROR - Can not create child device.
316 InitializeIsaIoInstance (
317 IN ISA_IO_DEVICE
*IsaIoDevice
,
318 IN EFI_ISA_ACPI_RESOURCE_LIST
*IsaDevice
324 Initializes an ISA I/O Instance
328 IsaIoDevice - The iso device to be initialized.
329 IsaDevice - The resource list.
333 EFI_SUCCESS - Initial success.