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
28 // The package level header files this module uses
31 #include <FrameworkDxe.h>
33 // The protocols, PPI and GUID defintions for this module
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>
44 // The Library classes this module consumes
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>
56 #include "ComponentName.h"
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
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
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
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
92 #define R_8237_DMA_STA_CH0_3 0xd8
93 #define R_8237_DMA_STA_CH4_7 0xd0
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
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
112 #define R_8237_DMA_CBPR_CH0_3 0x0c
113 #define R_8237_DMA_CBPR_CH4_7 0xd8
115 #define R_8237_DMA_MCR_CH0_3 0x0d
116 #define R_8237_DMA_MCR_CH4_7 0xda
118 #define R_8237_DMA_CLMSK_CH0_3 0x0e
119 #define R_8237_DMA_CLMSK_CH4_7 0xdc
121 #define R_8237_DMA_WRMSK_CH0_3 0x0f
122 #define R_8237_DMA_WRMSK_CH4_7 0xde
125 extern EFI_ISA_IO_PROTOCOL IsaIoInterface
;
128 IsaAccessTypeUnknown
,
135 // 16 MB Memory Range
137 #define ISA_MAX_MEMORY_ADDRESS 0x1000000
141 #define ISA_MAX_IO_ADDRESS 0x10000
147 } EFI_ISA_DMA_REGISTERS
;
150 // ISA I/O Device Structure
152 #define ISA_IO_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('i', 's', 'a', 'i')
157 EFI_ISA_IO_PROTOCOL IsaIo
;
158 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
159 EFI_PCI_IO_PROTOCOL
*PciIo
;
162 #define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)
167 extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver
;
170 // Mapping structure for performing ISA DMA to a buffer above 16 MB
173 EFI_ISA_IO_PROTOCOL_OPERATION Operation
;
176 EFI_PHYSICAL_ADDRESS HostAddress
;
177 EFI_PHYSICAL_ADDRESS MappedHostAddress
;
181 // EFI Driver Binding Protocol Interface Functions
186 IsaBusControllerDriverSupported (
187 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
188 IN EFI_HANDLE Controller
,
189 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
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
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.
209 EFI_SUCCESS - The device is supported by this driver.
210 EFI_UNSUPPORTED - The device is not supported by this driver.
217 IsaBusControllerDriverStart (
218 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
219 IN EFI_HANDLE Controller
,
220 IN EFI_DEVICE_PATH_PROTOCOL
* RemainingDevicePath OPTIONAL
226 This function tells the ISA Bus Driver to start managing a PCI to ISA
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.
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
250 IsaBusControllerDriverStop (
251 IN EFI_DRIVER_BINDING_PROTOCOL
* This
,
252 IN EFI_HANDLE Controller
,
253 IN UINTN NumberOfChildren
,
254 IN EFI_HANDLE
* ChildHandleBuffer OPTIONAL
260 This function tells the ISA Bus Driver to stop managing a PCI to ISA
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.
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
284 // Function Prototypes
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
300 Create ISA device found by IsaPnpProtocol
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.
313 EFI_SUCCESS - Create the child device.
314 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of
316 EFI_DEVICE_ERROR - Can not create child device.
322 InitializeIsaIoInstance (
323 IN ISA_IO_DEVICE
*IsaIoDevice
,
324 IN EFI_ISA_ACPI_RESOURCE_LIST
*IsaDevice
330 Initializes an ISA I/O Instance
334 IsaIoDevice - The iso device to be initialized.
335 IsaDevice - The resource list.
339 EFI_SUCCESS - Initial success.