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