]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/InternalIsaBus.h
Clean up the Isa related DXE in IntelFrameworkMoudlePkg.
[mirror_edk2.git] / IntelFrameworkModulePkg / Bus / Isa / IsaBusDxe / InternalIsaBus.h
CommitLineData
c3902377 1/*++\r
2\r
3e0578d2 3 Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
4 All rights reserved. This program and the accompanying materials\r
5 are licensed and made available under the terms and conditions of the BSD License\r
6 which accompanies this distribution. The full text of the license may be found at\r
7 http://opensource.org/licenses/bsd-license.php\r
8\r
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
c3902377 11\r
12Module Name:\r
13\r
14 IsaBus.h\r
15 \r
16Abstract:\r
17 \r
18 The header file for ISA bus driver\r
19 \r
20Revision History:\r
21\r
22--*/\r
23\r
24#ifndef _EFI_ISA_BUS_H\r
25#define _EFI_ISA_BUS_H\r
26\r
27//\r
c55fa8cc 28// The package level header files this module uses\r
c3902377 29//\r
c55fa8cc 30#include <PiDxe.h>\r
31#include <FrameworkDxe.h>\r
32//\r
33// The protocols, PPI and GUID defintions for this module\r
34//\r
35#include <Protocol/PciIo.h>\r
36#include <Protocol/ComponentName.h>\r
37#include <Protocol/IsaIo.h>\r
38#include <Protocol/DevicePath.h>\r
39#include <Protocol/IsaAcpi.h>\r
40#include <Protocol/DriverBinding.h>\r
41#include <Protocol/GenericMemoryTest.h>\r
42#include <Guid/StatusCodeDataTypeId.h>\r
43//\r
44// The Library classes this module consumes\r
45//\r
46#include <Library/DebugLib.h>\r
47#include <Library/UefiDriverEntryPoint.h>\r
48#include <Library/UefiLib.h>\r
49#include <Library/DevicePathLib.h>\r
50#include <Library/BaseMemoryLib.h>\r
51#include <Library/MemoryAllocationLib.h>\r
52#include <Library/UefiBootServicesTableLib.h>\r
53#include <Library/ReportStatusCodeLib.h>\r
54#include <Library/PcdLib.h>\r
c3902377 55\r
56#include "ComponentName.h"\r
57\r
c21fc3e8 58//\r
59// 8237 DMA registers\r
60//\r
61#define R_8237_DMA_BASE_CA_CH0 0x00\r
62#define R_8237_DMA_BASE_CA_CH1 0x02\r
63#define R_8237_DMA_BASE_CA_CH2 0x04\r
64#define R_8237_DMA_BASE_CA_CH3 0xd6\r
65#define R_8237_DMA_BASE_CA_CH5 0xc4\r
66#define R_8237_DMA_BASE_CA_CH6 0xc8\r
67#define R_8237_DMA_BASE_CA_CH7 0xcc\r
68\r
69#define R_8237_DMA_BASE_CC_CH0 0x01\r
70#define R_8237_DMA_BASE_CC_CH1 0x03\r
71#define R_8237_DMA_BASE_CC_CH2 0x05\r
72#define R_8237_DMA_BASE_CC_CH3 0xd7\r
73#define R_8237_DMA_BASE_CC_CH5 0xc6\r
74#define R_8237_DMA_BASE_CC_CH6 0xca\r
75#define R_8237_DMA_BASE_CC_CH7 0xce\r
76\r
77#define R_8237_DMA_MEM_LP_CH0 0x87\r
78#define R_8237_DMA_MEM_LP_CH1 0x83\r
79#define R_8237_DMA_MEM_LP_CH2 0x81\r
80#define R_8237_DMA_MEM_LP_CH3 0x82\r
81#define R_8237_DMA_MEM_LP_CH5 0x8B\r
82#define R_8237_DMA_MEM_LP_CH6 0x89\r
83#define R_8237_DMA_MEM_LP_CH7 0x8A\r
84\r
85\r
86#define R_8237_DMA_COMMAND_CH0_3 0x08\r
87#define R_8237_DMA_COMMAND_CH4_7 0xd0\r
88#define B_8237_DMA_COMMAND_GAP 0x10\r
89#define B_8237_DMA_COMMAND_CGE 0x04\r
90\r
91\r
92#define R_8237_DMA_STA_CH0_3 0xd8\r
93#define R_8237_DMA_STA_CH4_7 0xd0\r
94\r
95#define R_8237_DMA_WRSMSK_CH0_3 0x0a\r
96#define R_8237_DMA_WRSMSK_CH4_7 0xd4\r
97#define B_8237_DMA_WRSMSK_CMS 0x04\r
98\r
99\r
100#define R_8237_DMA_CHMODE_CH0_3 0x0b\r
101#define R_8237_DMA_CHMODE_CH4_7 0xd6\r
102#define V_8237_DMA_CHMODE_DEMAND 0x00\r
103#define V_8237_DMA_CHMODE_SINGLE 0x40\r
104#define V_8237_DMA_CHMODE_CASCADE 0xc0\r
105#define B_8237_DMA_CHMODE_DECREMENT 0x20\r
106#define B_8237_DMA_CHMODE_INCREMENT 0x00\r
107#define B_8237_DMA_CHMODE_AE 0x10\r
108#define V_8237_DMA_CHMODE_VERIFY 0\r
109#define V_8237_DMA_CHMODE_IO2MEM 0x04\r
110#define V_8237_DMA_CHMODE_MEM2IO 0x08\r
111\r
112#define R_8237_DMA_CBPR_CH0_3 0x0c\r
113#define R_8237_DMA_CBPR_CH4_7 0xd8\r
114\r
115#define R_8237_DMA_MCR_CH0_3 0x0d\r
116#define R_8237_DMA_MCR_CH4_7 0xda\r
117\r
118#define R_8237_DMA_CLMSK_CH0_3 0x0e\r
119#define R_8237_DMA_CLMSK_CH4_7 0xdc\r
120\r
121#define R_8237_DMA_WRMSK_CH0_3 0x0f\r
122#define R_8237_DMA_WRMSK_CH4_7 0xde\r
123\r
124\r
c3902377 125extern EFI_ISA_IO_PROTOCOL IsaIoInterface;\r
126\r
127typedef enum {\r
128 IsaAccessTypeUnknown,\r
129 IsaAccessTypeIo,\r
130 IsaAccessTypeMem,\r
131 IsaAccessTypeMaxType\r
132} ISA_ACCESS_TYPE;\r
133\r
134//\r
135// 16 MB Memory Range\r
136//\r
137#define ISA_MAX_MEMORY_ADDRESS 0x1000000\r
138//\r
139// 64K I/O Range\r
140//\r
141#define ISA_MAX_IO_ADDRESS 0x10000\r
142\r
143typedef struct {\r
144 UINT8 Address;\r
145 UINT8 Page;\r
146 UINT8 Count;\r
147} EFI_ISA_DMA_REGISTERS;\r
148\r
149//\r
150// ISA I/O Device Structure\r
151//\r
152#define ISA_IO_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('i', 's', 'a', 'i')\r
153\r
154typedef struct {\r
155 UINT32 Signature;\r
156 EFI_HANDLE Handle;\r
157 EFI_ISA_IO_PROTOCOL IsaIo;\r
158 EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r
159 EFI_PCI_IO_PROTOCOL *PciIo;\r
160} ISA_IO_DEVICE;\r
161\r
162#define ISA_IO_DEVICE_FROM_ISA_IO_THIS(a) CR (a, ISA_IO_DEVICE, IsaIo, ISA_IO_DEVICE_SIGNATURE)\r
163\r
164//\r
165// Global Variables\r
166//\r
167extern EFI_DRIVER_BINDING_PROTOCOL gIsaBusControllerDriver;\r
168\r
169//\r
170// Mapping structure for performing ISA DMA to a buffer above 16 MB\r
171//\r
172typedef struct {\r
173 EFI_ISA_IO_PROTOCOL_OPERATION Operation;\r
174 UINTN NumberOfBytes;\r
175 UINTN NumberOfPages;\r
176 EFI_PHYSICAL_ADDRESS HostAddress;\r
177 EFI_PHYSICAL_ADDRESS MappedHostAddress;\r
178} ISA_MAP_INFO;\r
179\r
180//\r
181// EFI Driver Binding Protocol Interface Functions\r
182//\r
183\r
184EFI_STATUS\r
185EFIAPI\r
186IsaBusControllerDriverSupported (\r
187 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
188 IN EFI_HANDLE Controller,\r
189 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
190 )\r
191/*++\r
192\r
193 Routine Description:\r
194 \r
195 This function checks to see if a controller can be managed by the ISA Bus \r
196 Driver. This is done by checking to see if the controller supports the \r
197 EFI_PCI_IO_PROTOCOL protocol, and then looking at the PCI Configuration \r
198 Header to see if the device is a PCI to ISA bridge. The class code of \r
199 PCI to ISA bridge: Base class 06h, Sub class 01h Interface 00h \r
200 \r
201 Arguments:\r
202 \r
203 This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
204 Controller - The handle of the device to check.\r
205 RemainingDevicePath - A pointer to the remaining portion of a device path.\r
206\r
207 Returns:\r
208 \r
209 EFI_SUCCESS - The device is supported by this driver.\r
210 EFI_UNSUPPORTED - The device is not supported by this driver.\r
211\r
212--*/\r
213;\r
214\r
215EFI_STATUS\r
216EFIAPI\r
217IsaBusControllerDriverStart (\r
218 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
219 IN EFI_HANDLE Controller,\r
220 IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL\r
221 )\r
222/*++\r
223\r
224 Routine Description:\r
225 \r
226 This function tells the ISA Bus Driver to start managing a PCI to ISA \r
227 Bridge controller. \r
228 \r
229 Arguments:\r
230 \r
231 This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
232 Controller - A handle to the device being started. \r
233 RemainingDevicePath - A pointer to the remaining portion of a device path.\r
234\r
235 Returns:\r
236 \r
237 EFI_SUCCESS - The device was started.\r
238 EFI_UNSUPPORTED - The device is not supported.\r
239 EFI_DEVICE_ERROR - The device could not be started due to a device error.\r
240 EFI_ALREADY_STARTED - The device has already been started.\r
241 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
242 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of \r
243 resources.\r
244 \r
245--*/\r
246;\r
247\r
248EFI_STATUS\r
249EFIAPI\r
250IsaBusControllerDriverStop (\r
251 IN EFI_DRIVER_BINDING_PROTOCOL * This,\r
252 IN EFI_HANDLE Controller,\r
253 IN UINTN NumberOfChildren,\r
254 IN EFI_HANDLE * ChildHandleBuffer OPTIONAL\r
255 )\r
256/*++\r
257\r
258 Routine Description:\r
259 \r
260 This function tells the ISA Bus Driver to stop managing a PCI to ISA \r
261 Bridge controller. \r
262 \r
263 Arguments:\r
264 \r
265 This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
266 Controller - A handle to the device being stopped.\r
267 NumberOfChindren - The number of child device handles in ChildHandleBuffer.\r
268 ChildHandleBuffer - An array of child handles to be freed.\r
269\r
270 \r
271 Returns:\r
272 \r
273 EFI_SUCCESS - The device was stopped.\r
274 EFI_DEVICE_ERROR - The device could not be stopped due to a device error.\r
275 EFI_NOT_STARTED - The device has not been started.\r
276 EFI_INVALID_PARAMETER - One of the parameters has an invalid value.\r
277 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of \r
278 resources.\r
279\r
280--*/\r
281;\r
282\r
283//\r
284// Function Prototypes\r
285//\r
286\r
287EFI_STATUS\r
288IsaCreateDevice (\r
289 IN EFI_DRIVER_BINDING_PROTOCOL *This,\r
290 IN EFI_HANDLE Controller,\r
291 IN EFI_PCI_IO_PROTOCOL *PciIo,\r
292 IN EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath,\r
293 IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDeviceResourceList,\r
294 OUT EFI_DEVICE_PATH_PROTOCOL **ChildDevicePath\r
295 )\r
296/*++\r
297\r
298 Routine Description:\r
299 \r
300 Create ISA device found by IsaPnpProtocol \r
301\r
302 Arguments:\r
303 \r
304 This - The EFI_DRIVER_BINDING_PROTOCOL instance.\r
305 Controller - The handle of ISA bus controller(PCI to ISA bridge)\r
306 PciIo - The Pointer to the PCI protocol \r
307 ParentDevicePath - Device path of the ISA bus controller\r
308 IsaDeviceResourceList - The resource list of the ISA device\r
309 ChildDevicePath - The pointer to the child device.\r
310\r
311 Returns:\r
312 \r
313 EFI_SUCCESS - Create the child device.\r
314 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of \r
315 resources.\r
316 EFI_DEVICE_ERROR - Can not create child device.\r
317 \r
318--*/\r
319;\r
320\r
321EFI_STATUS\r
322InitializeIsaIoInstance (\r
323 IN ISA_IO_DEVICE *IsaIoDevice,\r
324 IN EFI_ISA_ACPI_RESOURCE_LIST *IsaDevice\r
325 )\r
326/*++\r
327\r
328Routine Description:\r
329\r
330 Initializes an ISA I/O Instance\r
331\r
332Arguments:\r
333\r
334 IsaIoDevice - The iso device to be initialized.\r
335 IsaDevice - The resource list.\r
336 \r
337Returns:\r
338\r
339 EFI_SUCCESS - Initial success.\r
340 \r
341--*/\r
342;\r
343\r
344#endif\r