]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h
ISA Bus code scrub.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / InternalIsaBus.h
CommitLineData
f8cd287b 1/**@file\r
c3902377 2 The header file for ISA bus driver\r
3 \r
6fcb2d91 4Copyright (c) 2006 - 2009, Intel Corporation. <BR>\r
f8cd287b 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
c3902377 12\r
f8cd287b 13**/\r
c3902377 14\r
6fcb2d91 15#ifndef _INTERNAL_ISA_BUS_H_\r
16#define _INTERNAL_ISA_BUS_H_\r
c3902377 17\r
ed7748fe 18\r
f423cbf1 19#include <Uefi.h>\r
ed7748fe 20\r
c55fa8cc 21#include <Protocol/PciIo.h>\r
22#include <Protocol/ComponentName.h>\r
23#include <Protocol/IsaIo.h>\r
24#include <Protocol/DevicePath.h>\r
25#include <Protocol/IsaAcpi.h>\r
26#include <Protocol/DriverBinding.h>\r
27#include <Protocol/GenericMemoryTest.h>\r
28#include <Guid/StatusCodeDataTypeId.h>\r
ed7748fe 29\r
c55fa8cc 30#include <Library/DebugLib.h>\r
31#include <Library/UefiDriverEntryPoint.h>\r
32#include <Library/UefiLib.h>\r
33#include <Library/DevicePathLib.h>\r
34#include <Library/BaseMemoryLib.h>\r
35#include <Library/MemoryAllocationLib.h>\r
36#include <Library/UefiBootServicesTableLib.h>\r
37#include <Library/ReportStatusCodeLib.h>\r
38#include <Library/PcdLib.h>\r
c3902377 39\r
40#include "ComponentName.h"\r
41\r
c21fc3e8 42//\r
43// 8237 DMA registers\r
44//\r
45#define R_8237_DMA_BASE_CA_CH0 0x00\r
46#define R_8237_DMA_BASE_CA_CH1 0x02\r
47#define R_8237_DMA_BASE_CA_CH2 0x04\r
48#define R_8237_DMA_BASE_CA_CH3 0xd6\r
49#define R_8237_DMA_BASE_CA_CH5 0xc4\r
50#define R_8237_DMA_BASE_CA_CH6 0xc8\r
51#define R_8237_DMA_BASE_CA_CH7 0xcc\r
52\r
53#define R_8237_DMA_BASE_CC_CH0 0x01\r
54#define R_8237_DMA_BASE_CC_CH1 0x03\r
55#define R_8237_DMA_BASE_CC_CH2 0x05\r
56#define R_8237_DMA_BASE_CC_CH3 0xd7\r
57#define R_8237_DMA_BASE_CC_CH5 0xc6\r
58#define R_8237_DMA_BASE_CC_CH6 0xca\r
59#define R_8237_DMA_BASE_CC_CH7 0xce\r
60\r
61#define R_8237_DMA_MEM_LP_CH0 0x87\r
62#define R_8237_DMA_MEM_LP_CH1 0x83\r
63#define R_8237_DMA_MEM_LP_CH2 0x81\r
64#define R_8237_DMA_MEM_LP_CH3 0x82\r
65#define R_8237_DMA_MEM_LP_CH5 0x8B\r
66#define R_8237_DMA_MEM_LP_CH6 0x89\r
67#define R_8237_DMA_MEM_LP_CH7 0x8A\r
68\r
69\r
70#define R_8237_DMA_COMMAND_CH0_3 0x08\r
71#define R_8237_DMA_COMMAND_CH4_7 0xd0\r
72#define B_8237_DMA_COMMAND_GAP 0x10\r
73#define B_8237_DMA_COMMAND_CGE 0x04\r
74\r
75\r
76#define R_8237_DMA_STA_CH0_3 0xd8\r
77#define R_8237_DMA_STA_CH4_7 0xd0\r
78\r
79#define R_8237_DMA_WRSMSK_CH0_3 0x0a\r
80#define R_8237_DMA_WRSMSK_CH4_7 0xd4\r
81#define B_8237_DMA_WRSMSK_CMS 0x04\r
82\r
83\r
84#define R_8237_DMA_CHMODE_CH0_3 0x0b\r
85#define R_8237_DMA_CHMODE_CH4_7 0xd6\r
86#define V_8237_DMA_CHMODE_DEMAND 0x00\r
87#define V_8237_DMA_CHMODE_SINGLE 0x40\r
88#define V_8237_DMA_CHMODE_CASCADE 0xc0\r
89#define B_8237_DMA_CHMODE_DECREMENT 0x20\r
90#define B_8237_DMA_CHMODE_INCREMENT 0x00\r
91#define B_8237_DMA_CHMODE_AE 0x10\r
92#define V_8237_DMA_CHMODE_VERIFY 0\r
93#define V_8237_DMA_CHMODE_IO2MEM 0x04\r
94#define V_8237_DMA_CHMODE_MEM2IO 0x08\r
95\r
96#define R_8237_DMA_CBPR_CH0_3 0x0c\r
97#define R_8237_DMA_CBPR_CH4_7 0xd8\r
98\r
99#define R_8237_DMA_MCR_CH0_3 0x0d\r
100#define R_8237_DMA_MCR_CH4_7 0xda\r
101\r
102#define R_8237_DMA_CLMSK_CH0_3 0x0e\r
103#define R_8237_DMA_CLMSK_CH4_7 0xdc\r
104\r
105#define R_8237_DMA_WRMSK_CH0_3 0x0f\r
106#define R_8237_DMA_WRMSK_CH4_7 0xde\r
107\r
c3902377 108typedef enum {\r
109 IsaAccessTypeUnknown,\r
110 IsaAccessTypeIo,\r
111 IsaAccessTypeMem,\r
112 IsaAccessTypeMaxType\r
113} ISA_ACCESS_TYPE;\r
114\r
115//\r
116// 16 MB Memory Range\r
117//\r
118#define ISA_MAX_MEMORY_ADDRESS 0x1000000\r
119//\r
120// 64K I/O Range\r
121//\r
122#define ISA_MAX_IO_ADDRESS 0x10000\r
123\r
124typedef struct {\r
125 UINT8 Address;\r
126 UINT8 Page;\r
127 UINT8 Count;\r
128} EFI_ISA_DMA_REGISTERS;\r
129\r
130//\r
131// ISA I/O Device Structure\r
132//\r
f02bd376 133#define ISA_IO_DEVICE_SIGNATURE SIGNATURE_32 ('i', 's', 'a', 'i')\r
c3902377 134\r
135typedef struct {\r
136 UINT32 Signature;\r
137 EFI_HANDLE Handle;\r
138 EFI_ISA_IO_PROTOCOL IsaIo;\r
139 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
140 EFI_PCI_IO_PROTOCOL *PciIo;\r
141} ISA_IO_DEVICE;\r
142\r
143#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r
144\r
c3902377 145//\r
146// Mapping structure for performing ISA DMA to a buffer above 16 MB\r
147//\r
148typedef struct {\r
149 EFI_ISA_IO_PROTOCOL_OPERATION Operation;\r
150 UINTN NumberOfBytes;\r
151 UINTN NumberOfPages;\r
152 EFI_PHYSICAL_ADDRESS HostAddress;\r
153 EFI_PHYSICAL_ADDRESS MappedHostAddress;\r
154} ISA_MAP_INFO;\r
155\r
156//\r
157// EFI Driver Binding Protocol Interface Functions\r
158//\r
159\r
6fcb2d91 160/** \r
161 Tests to see if a controller can be managed by the ISA Bus Driver. If a child device is provided, \r
162 it further tests to see if this driver supports creating a handle for the specified child device.\r
163\r
164 Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
165 How the Start() function of a driver is implemented can affect how the Supported() function is implemented.\r
166\r
167 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance. \r
168 @param[in] Controller The handle of the controller to test.\r
169 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path.\r
170 \r
171 @retval EFI_SUCCESS The device is supported by this driver.\r
172 @retval EFI_ALREADY_STARTED The device is already being managed by this driver.\r
173 @retval EFI_ACCESS_DENIED The device is already being managed by a different driver \r
174 or an application that requires exclusive access.\r
175 @retval EFI_UNSUPPORTED The device is is not supported by this driver.\r
176\r
177**/\r
c3902377 178EFI_STATUS\r
179EFIAPI\r
180IsaBusControllerDriverSupported (\r
181 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
182 IN EFI_HANDLE Controller,\r
183 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
6fcb2d91 184 );\r
c3902377 185\r
6fcb2d91 186/**\r
187 Start this driver on ControllerHandle. \r
c3902377 188 \r
6fcb2d91 189 Note that the ISA Bus driver always creates all of its child handles on the first call to Start().\r
190 The Start() function is designed to be invoked from the EFI boot service ConnectController(). \r
191 As a result, much of the error checking on the parameters to Start() has been moved into this \r
192 common boot service. It is legal to call Start() from other locations, but the following calling \r
193 restrictions must be followed or the system behavior will not be deterministic.\r
194 1. ControllerHandle must be a valid EFI_HANDLE.\r
195 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned\r
196 EFI_DEVICE_PATH_PROTOCOL.\r
197 3. Prior to calling Start(), the Supported() function for the driver specified by This must\r
198 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS. \r
199\r
200 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
201 @param[in] ControllerHandle The handle of the controller to start. This handle \r
202 must support a protocol interface that supplies \r
203 an I/O abstraction to the driver.\r
204 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. \r
205 This parameter is ignored by device drivers, and is optional for bus drivers.\r
206\r
207 @retval EFI_SUCCESS The device was started.\r
208 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.\r
209 Currently not implemented.\r
210 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
211 @retval Others The driver failded to start the device.\r
bcd70414 212**/\r
c3902377 213EFI_STATUS\r
214EFIAPI\r
215IsaBusControllerDriverStart (\r
216 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
217 IN EFI_HANDLE Controller,\r
218 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
6fcb2d91 219 );\r
c3902377 220\r
6fcb2d91 221/**\r
222 Stop this driver on ControllerHandle. \r
c3902377 223 \r
6fcb2d91 224 The Stop() function is designed to be invoked from the EFI boot service DisconnectController(). \r
225 As a result, much of the error checking on the parameters to Stop() has been moved \r
226 into this common boot service. It is legal to call Stop() from other locations, \r
227 but the following calling restrictions must be followed or the system behavior will not be deterministic.\r
228 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this\r
229 same driver's Start() function.\r
230 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid\r
231 EFI_HANDLE. In addition, all of these handles must have been created in this driver's\r
232 Start() function, and the Start() function must have called OpenProtocol() on\r
233 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.\r
c3902377 234 \r
6fcb2d91 235 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.\r
236 @param[in] ControllerHandle A handle to the device being stopped. The handle must \r
237 support a bus specific I/O protocol for the driver \r
238 to use to stop the device.\r
239 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.\r
240 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL \r
241 if NumberOfChildren is 0.\r
242\r
243 @retval EFI_SUCCESS The device was stopped.\r
244 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.\r
bcd70414 245**/\r
c3902377 246EFI_STATUS\r
247EFIAPI\r
248IsaBusControllerDriverStop (\r
249 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
250 IN EFI_HANDLE Controller,\r
251 IN UINTN NumberOfChildren,\r
252 IN EFI_HANDLE * ChildHandleBuffer OPTIONAL\r
6fcb2d91 253 );\r
c3902377 254\r
255//\r
256// Function Prototypes\r
257//\r
258\r
6fcb2d91 259/**\r
260 Create EFI Handle for a ISA device found via ISA ACPI Protocol \r
261\r
262 @param[in] This The EFI_DRIVER_BINDING_PROTOCOL instance.\r
263 @param[in] Controller The handle of ISA bus controller(PCI to ISA bridge)\r
264 @param[in] PciIo The Pointer to the PCI protocol \r
265 @param[in] ParentDevicePath Device path of the ISA bus controller\r
266 @param[in] IsaDeviceResourceList The resource list of the ISA device\r
267 @param[in] ChildDevicePath The pointer to the child device.\r
268\r
269 @retval EFI_SUCCESS The handle for the child device was created.\r
270 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
271 @retval EFI_DEVICE_ERROR The handle for the child device can not be created.\r
272**/\r
c3902377 273EFI_STATUS\r
274IsaCreateDevice (\r
275 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
276 IN EFI_HANDLE Controller,\r
277 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
278 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
279 IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList,\r
280 OUT EFI_DEVICE_PATH_PROTOCOL **ChildDevicePath\r
6fcb2d91 281 );\r
c3902377 282\r
6fcb2d91 283/**\r
284 Initializes an ISA I/O Instance\r
c3902377 285\r
6fcb2d91 286 @param[in] IsaIoDevice The iso device to be initialized.\r
287 @param[in] IsaDeviceResourceList The resource list.\r
c3902377 288 \r
6fcb2d91 289 @retval None\r
bcd70414 290**/\r
6fcb2d91 291VOID\r
c3902377 292InitializeIsaIoInstance (\r
293 IN ISA_IO_DEVICE *IsaIoDevice,\r
294 IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDevice\r
6fcb2d91 295 );\r
c3902377 296\r
297#endif\r
6fcb2d91 298\r