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