]>
Commit | Line | Data |
---|---|---|
c69dd9df | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006, Intel Corporation \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 | |
11 | \r | |
12 | Module Name:\r | |
13 | \r | |
14 | DeviceIo.h\r | |
15 | \r | |
16 | Abstract:\r | |
17 | \r | |
18 | Private Data definition for Device IO driver\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #ifndef _DEVICE_IO_H\r | |
23 | #define _DEVICE_IO_H\r | |
24 | \r | |
25 | \r | |
26 | \r | |
eea53ce1 | 27 | #define DEVICE_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 'e', 'v', 'I')\r |
c69dd9df | 28 | \r |
29 | #define MAX_COMMON_BUFFER 0x00000000FFFFFFFF\r | |
30 | \r | |
31 | typedef struct {\r | |
32 | UINTN Signature;\r | |
33 | EFI_HANDLE Handle;\r | |
34 | EFI_DEVICE_IO_PROTOCOL DeviceIo;\r | |
35 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;\r | |
36 | EFI_DEVICE_PATH_PROTOCOL *DevicePath;\r | |
37 | UINT16 PrimaryBus;\r | |
38 | UINT16 SubordinateBus;\r | |
39 | } DEVICE_IO_PRIVATE_DATA;\r | |
40 | \r | |
41 | #define DEVICE_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DEVICE_IO_PRIVATE_DATA, DeviceIo, DEVICE_IO_PRIVATE_DATA_SIGNATURE)\r | |
42 | \r | |
43 | EFI_STATUS\r | |
44 | DeviceIoConstructor (\r | |
45 | IN EFI_HANDLE Handle,\r | |
46 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,\r | |
47 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r | |
48 | IN UINT16 PrimaryBus,\r | |
49 | IN UINT16 SubordinateBus\r | |
50 | )\r | |
51 | /*++\r | |
52 | \r | |
53 | Routine Description:\r | |
54 | \r | |
55 | Initialize and install a Device IO protocol on a empty device path handle.\r | |
56 | \r | |
57 | Arguments:\r | |
58 | \r | |
59 | Handle - Handle of PCI RootBridge IO instance\r | |
60 | PciRootBridgeIo - PCI RootBridge IO instance\r | |
61 | DevicePath - Device Path of PCI RootBridge IO instance\r | |
62 | PrimaryBus - Primary Bus\r | |
63 | SubordinateBus - Subordinate Bus\r | |
64 | \r | |
65 | Returns:\r | |
66 | \r | |
67 | EFI_SUCCESS - This driver is added to ControllerHandle. \r | |
68 | EFI_ALREADY_STARTED - This driver is already running on ControllerHandle. \r | |
69 | Others - This driver does not support this device.\r | |
70 | \r | |
71 | --*/\r | |
72 | ;\r | |
73 | \r | |
74 | EFI_STATUS\r | |
75 | EFIAPI\r | |
76 | DeviceIoMemRead (\r | |
77 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
78 | IN EFI_IO_WIDTH Width,\r | |
79 | IN UINT64 Address,\r | |
80 | IN UINTN Count,\r | |
81 | IN OUT VOID *Buffer\r | |
82 | )\r | |
83 | /*++\r | |
84 | \r | |
85 | Routine Description:\r | |
86 | \r | |
87 | Perform reading memory mapped I/O space of device.\r | |
88 | \r | |
89 | Arguments:\r | |
90 | \r | |
91 | This - A pointer to EFI_DEVICE_IO protocol instance. \r | |
92 | Width - Width of I/O operations.\r | |
93 | Address - The base address of I/O operations. \r | |
94 | Count - The number of I/O operations to perform. \r | |
95 | Bytes moves is Width size * Count, starting at Address. \r | |
96 | Buffer - The destination buffer to store results.\r | |
97 | \r | |
98 | Returns:\r | |
99 | \r | |
100 | EFI_SUCCESS - The data was read from the device. \r | |
101 | EFI_INVALID_PARAMETER - Width is invalid.\r | |
102 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r | |
103 | \r | |
104 | --*/\r | |
105 | ;\r | |
106 | \r | |
107 | EFI_STATUS\r | |
108 | EFIAPI\r | |
109 | DeviceIoMemWrite (\r | |
110 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
111 | IN EFI_IO_WIDTH Width,\r | |
112 | IN UINT64 Address,\r | |
113 | IN UINTN Count,\r | |
114 | IN OUT VOID *Buffer\r | |
115 | )\r | |
116 | /*++\r | |
117 | \r | |
118 | Routine Description:\r | |
119 | \r | |
120 | Perform writing memory mapped I/O space of device.\r | |
121 | \r | |
122 | Arguments:\r | |
123 | \r | |
124 | This - A pointer to EFI_DEVICE_IO protocol instance. \r | |
125 | Width - Width of I/O operations. \r | |
126 | Address - The base address of I/O operations. \r | |
127 | Count - The number of I/O operations to perform. \r | |
128 | Bytes moves is Width size * Count, starting at Address. \r | |
129 | Buffer - The source buffer of data to be written.\r | |
130 | \r | |
131 | Returns:\r | |
132 | \r | |
133 | EFI_SUCCESS - The data was written to the device.\r | |
134 | EFI_INVALID_PARAMETER - Width is invalid.\r | |
135 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r | |
136 | \r | |
137 | --*/\r | |
138 | ;\r | |
139 | \r | |
140 | EFI_STATUS\r | |
141 | EFIAPI\r | |
142 | DeviceIoIoRead (\r | |
143 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
144 | IN EFI_IO_WIDTH Width,\r | |
145 | IN UINT64 Address,\r | |
146 | IN UINTN Count,\r | |
147 | IN OUT VOID *Buffer\r | |
148 | )\r | |
149 | /*++\r | |
150 | \r | |
151 | Routine Description:\r | |
152 | \r | |
153 | Perform reading I/O space of device.\r | |
154 | \r | |
155 | Arguments:\r | |
156 | \r | |
157 | This - A pointer to EFI_DEVICE_IO protocol instance. \r | |
158 | Width - Width of I/O operations.\r | |
159 | Address - The base address of I/O operations. \r | |
160 | Count - The number of I/O operations to perform. \r | |
161 | Bytes moves is Width size * Count, starting at Address. \r | |
162 | Buffer - The destination buffer to store results.\r | |
163 | \r | |
164 | Returns:\r | |
165 | \r | |
166 | EFI_SUCCESS - The data was read from the device.\r | |
167 | EFI_INVALID_PARAMETER - Width is invalid.\r | |
168 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r | |
169 | \r | |
170 | --*/\r | |
171 | ;\r | |
172 | \r | |
173 | EFI_STATUS\r | |
174 | EFIAPI\r | |
175 | DeviceIoIoWrite (\r | |
176 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
177 | IN EFI_IO_WIDTH Width,\r | |
178 | IN UINT64 Address,\r | |
179 | IN UINTN Count,\r | |
180 | IN OUT VOID *Buffer\r | |
181 | )\r | |
182 | /*++\r | |
183 | \r | |
184 | Routine Description:\r | |
185 | \r | |
186 | Perform writing I/O space of device.\r | |
187 | \r | |
188 | Arguments:\r | |
189 | \r | |
190 | This - A pointer to EFI_DEVICE_IO protocol instance. \r | |
191 | Width - Width of I/O operations.\r | |
192 | Address - The base address of I/O operations.\r | |
193 | Count - The number of I/O operations to perform. \r | |
194 | Bytes moves is Width size * Count, starting at Address. \r | |
195 | Buffer - The source buffer of data to be written.\r | |
196 | \r | |
197 | Returns:\r | |
198 | \r | |
199 | EFI_SUCCESS - The data was written to the device.\r | |
200 | EFI_INVALID_PARAMETER - Width is invalid.\r | |
201 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r | |
202 | \r | |
203 | --*/\r | |
204 | ;\r | |
205 | \r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | DeviceIoPciRead (\r | |
209 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
210 | IN EFI_IO_WIDTH Width,\r | |
211 | IN UINT64 Address,\r | |
212 | IN UINTN Count,\r | |
213 | IN OUT VOID *Buffer\r | |
214 | )\r | |
215 | /*++\r | |
216 | \r | |
217 | Routine Description:\r | |
218 | \r | |
219 | Perform reading PCI configuration space of device\r | |
220 | \r | |
221 | Arguments:\r | |
222 | \r | |
223 | This - A pointer to EFI_DEVICE_IO protocol instance. \r | |
224 | Width - Width of I/O operations. \r | |
225 | Address - The base address of I/O operations. \r | |
226 | Count - The number of I/O operations to perform. \r | |
227 | Bytes moves is Width size * Count, starting at Address. \r | |
228 | Buffer - The destination buffer to store results.\r | |
229 | \r | |
230 | Returns:\r | |
231 | \r | |
232 | EFI_SUCCESS - The data was read from the device.\r | |
233 | EFI_INVALID_PARAMETER - Width is invalid.\r | |
234 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r | |
235 | \r | |
236 | --*/\r | |
237 | ;\r | |
238 | \r | |
239 | EFI_STATUS\r | |
240 | EFIAPI\r | |
241 | DeviceIoPciWrite (\r | |
242 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
243 | IN EFI_IO_WIDTH Width,\r | |
244 | IN UINT64 Address,\r | |
245 | IN UINTN Count,\r | |
246 | IN OUT VOID *Buffer\r | |
247 | )\r | |
248 | /*++\r | |
249 | \r | |
250 | Routine Description:\r | |
251 | \r | |
252 | Perform writing PCI configuration space of device.\r | |
253 | \r | |
254 | Arguments:\r | |
255 | \r | |
256 | This - A pointer to EFI_DEVICE_IO protocol instance. \r | |
257 | Width - Width of I/O operations. \r | |
258 | Address - The base address of I/O operations. \r | |
259 | Count - The number of I/O operations to perform. \r | |
260 | Bytes moves is Width size * Count, starting at Address. \r | |
261 | Buffer - The source buffer of data to be written.\r | |
262 | \r | |
263 | Returns:\r | |
264 | \r | |
265 | EFI_SUCCESS - The data was written to the device.\r | |
266 | EFI_INVALID_PARAMETER - Width is invalid.\r | |
267 | EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.\r | |
268 | \r | |
269 | --*/\r | |
270 | ;\r | |
271 | \r | |
272 | EFI_STATUS\r | |
273 | EFIAPI\r | |
274 | DeviceIoPciDevicePath (\r | |
275 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
276 | IN UINT64 Address,\r | |
277 | IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath\r | |
278 | )\r | |
279 | /*++\r | |
280 | \r | |
281 | Routine Description:\r | |
282 | \r | |
283 | Append a PCI device path node to another device path.\r | |
284 | \r | |
285 | Arguments:\r | |
286 | \r | |
287 | This - A pointer to EFI_DEVICE_IO_PROTOCOL. \r | |
288 | Address - PCI bus,device, function.\r | |
289 | PciDevicePath - PCI device path.\r | |
290 | \r | |
291 | Returns:\r | |
292 | \r | |
293 | Pointer to the appended PCI device path.\r | |
294 | \r | |
295 | --*/\r | |
296 | ;\r | |
297 | \r | |
298 | EFI_STATUS\r | |
299 | EFIAPI\r | |
300 | DeviceIoMap (\r | |
301 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
302 | IN EFI_IO_OPERATION_TYPE Operation,\r | |
303 | IN EFI_PHYSICAL_ADDRESS *HostAddress,\r | |
304 | IN OUT UINTN *NumberOfBytes,\r | |
305 | OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r | |
306 | OUT VOID **Mapping\r | |
307 | )\r | |
308 | /*++\r | |
309 | \r | |
310 | Routine Description:\r | |
311 | \r | |
312 | Provides the device-specific addresses needed to access system memory.\r | |
313 | \r | |
314 | Arguments:\r | |
315 | \r | |
316 | This - A pointer to the EFI_DEVICE_IO_INTERFACE instance. \r | |
317 | Operation - Indicates if the bus master is going to read or write to system memory. \r | |
318 | HostAddress - The system memory address to map to the device.\r | |
319 | NumberOfBytes - On input the number of bytes to map. On output the number of bytes\r | |
320 | that were mapped.\r | |
321 | DeviceAddress - The resulting map address for the bus master device to use to access the\r | |
322 | hosts HostAddress.\r | |
323 | Mapping - A resulting value to pass to Unmap().\r | |
324 | \r | |
325 | Returns:\r | |
326 | \r | |
327 | EFI_SUCCESS - The range was mapped for the returned NumberOfBytes. \r | |
328 | EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined. \r | |
329 | EFI_UNSUPPORTED - The HostAddress cannot be mapped as a common buffer.\r | |
330 | EFI_DEVICE_ERROR - The system hardware could not map the requested address. \r | |
331 | EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.\r | |
332 | \r | |
333 | --*/\r | |
334 | ;\r | |
335 | \r | |
336 | EFI_STATUS\r | |
337 | EFIAPI\r | |
338 | DeviceIoUnmap (\r | |
339 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
340 | IN VOID *Mapping\r | |
341 | )\r | |
342 | /*++\r | |
343 | \r | |
344 | Routine Description:\r | |
345 | \r | |
346 | Completes the Map() operation and releases any corresponding resources.\r | |
347 | \r | |
348 | Arguments:\r | |
349 | \r | |
350 | This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r | |
351 | Mapping - The mapping value returned from Map().\r | |
352 | \r | |
353 | Returns:\r | |
354 | \r | |
355 | EFI_SUCCESS - The range was unmapped.\r | |
356 | EFI_DEVICE_ERROR - The data was not committed to the target system memory.\r | |
357 | \r | |
358 | --*/\r | |
359 | ;\r | |
360 | \r | |
361 | EFI_STATUS\r | |
362 | EFIAPI\r | |
363 | DeviceIoAllocateBuffer (\r | |
364 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
365 | IN EFI_ALLOCATE_TYPE Type,\r | |
366 | IN EFI_MEMORY_TYPE MemoryType,\r | |
367 | IN UINTN Pages,\r | |
368 | IN OUT EFI_PHYSICAL_ADDRESS *HostAddress\r | |
369 | )\r | |
370 | /*++\r | |
371 | \r | |
372 | Routine Description:\r | |
373 | \r | |
374 | Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.\r | |
375 | \r | |
376 | Arguments:\r | |
377 | \r | |
378 | This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r | |
379 | Type - The type allocation to perform.\r | |
380 | MemoryType - The type of memory to allocate, EfiBootServicesData or\r | |
381 | EfiRuntimeServicesData.\r | |
382 | Pages - The number of pages to allocate.\r | |
383 | HostAddress - A pointer to store the base address of the allocated range.\r | |
384 | \r | |
385 | Returns:\r | |
386 | \r | |
387 | EFI_SUCCESS - The requested memory pages were allocated.\r | |
388 | EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.\r | |
389 | EFI_INVALID_PARAMETER - The requested memory type is invalid.\r | |
390 | EFI_UNSUPPORTED - The requested PhysicalAddress is not supported on\r | |
391 | this platform.\r | |
392 | \r | |
393 | --*/\r | |
394 | ;\r | |
395 | \r | |
396 | EFI_STATUS\r | |
397 | EFIAPI\r | |
398 | DeviceIoFlush (\r | |
399 | IN EFI_DEVICE_IO_PROTOCOL *This\r | |
400 | )\r | |
401 | /*++\r | |
402 | \r | |
403 | Routine Description:\r | |
404 | \r | |
405 | Flushes any posted write data to the device.\r | |
406 | \r | |
407 | Arguments:\r | |
408 | \r | |
409 | This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r | |
410 | \r | |
411 | Returns:\r | |
412 | \r | |
413 | EFI_SUCCESS - The buffers were flushed.\r | |
414 | EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error.\r | |
415 | \r | |
416 | --*/\r | |
417 | ;\r | |
418 | \r | |
419 | EFI_STATUS\r | |
420 | EFIAPI\r | |
421 | DeviceIoFreeBuffer (\r | |
422 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
423 | IN UINTN Pages,\r | |
424 | IN EFI_PHYSICAL_ADDRESS HostAddress\r | |
425 | )\r | |
426 | /*++\r | |
427 | \r | |
428 | Routine Description:\r | |
429 | \r | |
430 | Frees pages that were allocated with AllocateBuffer().\r | |
431 | \r | |
432 | Arguments:\r | |
433 | \r | |
434 | This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.\r | |
435 | Pages - The number of pages to free.\r | |
436 | HostAddress - The base address of the range to free.\r | |
437 | \r | |
438 | Returns:\r | |
439 | \r | |
440 | EFI_SUCCESS - The requested memory pages were freed.\r | |
441 | EFI_NOT_FOUND - The requested memory pages were not allocated with\r | |
442 | AllocateBuffer(). \r | |
443 | EFI_INVALID_PARAMETER - HostAddress is not page aligned or Pages is invalid.\r | |
444 | \r | |
445 | --*/\r | |
446 | ;\r | |
447 | \r | |
448 | #endif\r | |
449 | \r |