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