Fix warnings generated by GCC.
[edk2.git] / DuetPkg / PciRootBridgeNoEnumerationDxe / DeviceIo.h
blobcae532563c41fbfa1d8414b2fdd564dc01bca873
1 /*++
3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 Module Name:
14 DeviceIo.h
16 Abstract:
18 Private Data definition for Device IO driver
20 --*/
22 #ifndef _DEVICE_IO_H
23 #define _DEVICE_IO_H
27 #define DEVICE_IO_PRIVATE_DATA_SIGNATURE SIGNATURE_32 ('d', 'e', 'v', 'I')
29 #define MAX_COMMON_BUFFER 0x00000000FFFFFFFF
31 typedef struct {
32 UINTN Signature;
33 EFI_HANDLE Handle;
34 EFI_DEVICE_IO_PROTOCOL DeviceIo;
35 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
36 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
37 UINT16 PrimaryBus;
38 UINT16 SubordinateBus;
39 } DEVICE_IO_PRIVATE_DATA;
41 #define DEVICE_IO_PRIVATE_DATA_FROM_THIS(a) CR (a, DEVICE_IO_PRIVATE_DATA, DeviceIo, DEVICE_IO_PRIVATE_DATA_SIGNATURE)
43 EFI_STATUS
44 DeviceIoConstructor (
45 IN EFI_HANDLE Handle,
46 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo,
47 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
48 IN UINT16 PrimaryBus,
49 IN UINT16 SubordinateBus
51 /*++
53 Routine Description:
55 Initialize and install a Device IO protocol on a empty device path handle.
57 Arguments:
59 Handle - Handle of PCI RootBridge IO instance
60 PciRootBridgeIo - PCI RootBridge IO instance
61 DevicePath - Device Path of PCI RootBridge IO instance
62 PrimaryBus - Primary Bus
63 SubordinateBus - Subordinate Bus
65 Returns:
67 EFI_SUCCESS - This driver is added to ControllerHandle.
68 EFI_ALREADY_STARTED - This driver is already running on ControllerHandle.
69 Others - This driver does not support this device.
71 --*/
74 EFI_STATUS
75 EFIAPI
76 DeviceIoMemRead (
77 IN EFI_DEVICE_IO_PROTOCOL *This,
78 IN EFI_IO_WIDTH Width,
79 IN UINT64 Address,
80 IN UINTN Count,
81 IN OUT VOID *Buffer
83 /*++
85 Routine Description:
87 Perform reading memory mapped I/O space of device.
89 Arguments:
91 This - A pointer to EFI_DEVICE_IO protocol instance.
92 Width - Width of I/O operations.
93 Address - The base address of I/O operations.
94 Count - The number of I/O operations to perform.
95 Bytes moves is Width size * Count, starting at Address.
96 Buffer - The destination buffer to store results.
98 Returns:
100 EFI_SUCCESS - The data was read from the device.
101 EFI_INVALID_PARAMETER - Width is invalid.
102 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
104 --*/
107 EFI_STATUS
108 EFIAPI
109 DeviceIoMemWrite (
110 IN EFI_DEVICE_IO_PROTOCOL *This,
111 IN EFI_IO_WIDTH Width,
112 IN UINT64 Address,
113 IN UINTN Count,
114 IN OUT VOID *Buffer
116 /*++
118 Routine Description:
120 Perform writing memory mapped I/O space of device.
122 Arguments:
124 This - A pointer to EFI_DEVICE_IO protocol instance.
125 Width - Width of I/O operations.
126 Address - The base address of I/O operations.
127 Count - The number of I/O operations to perform.
128 Bytes moves is Width size * Count, starting at Address.
129 Buffer - The source buffer of data to be written.
131 Returns:
133 EFI_SUCCESS - The data was written to the device.
134 EFI_INVALID_PARAMETER - Width is invalid.
135 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
137 --*/
140 EFI_STATUS
141 EFIAPI
142 DeviceIoIoRead (
143 IN EFI_DEVICE_IO_PROTOCOL *This,
144 IN EFI_IO_WIDTH Width,
145 IN UINT64 Address,
146 IN UINTN Count,
147 IN OUT VOID *Buffer
149 /*++
151 Routine Description:
153 Perform reading I/O space of device.
155 Arguments:
157 This - A pointer to EFI_DEVICE_IO protocol instance.
158 Width - Width of I/O operations.
159 Address - The base address of I/O operations.
160 Count - The number of I/O operations to perform.
161 Bytes moves is Width size * Count, starting at Address.
162 Buffer - The destination buffer to store results.
164 Returns:
166 EFI_SUCCESS - The data was read from the device.
167 EFI_INVALID_PARAMETER - Width is invalid.
168 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
170 --*/
173 EFI_STATUS
174 EFIAPI
175 DeviceIoIoWrite (
176 IN EFI_DEVICE_IO_PROTOCOL *This,
177 IN EFI_IO_WIDTH Width,
178 IN UINT64 Address,
179 IN UINTN Count,
180 IN OUT VOID *Buffer
182 /*++
184 Routine Description:
186 Perform writing I/O space of device.
188 Arguments:
190 This - A pointer to EFI_DEVICE_IO protocol instance.
191 Width - Width of I/O operations.
192 Address - The base address of I/O operations.
193 Count - The number of I/O operations to perform.
194 Bytes moves is Width size * Count, starting at Address.
195 Buffer - The source buffer of data to be written.
197 Returns:
199 EFI_SUCCESS - The data was written to the device.
200 EFI_INVALID_PARAMETER - Width is invalid.
201 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
203 --*/
206 EFI_STATUS
207 EFIAPI
208 DeviceIoPciRead (
209 IN EFI_DEVICE_IO_PROTOCOL *This,
210 IN EFI_IO_WIDTH Width,
211 IN UINT64 Address,
212 IN UINTN Count,
213 IN OUT VOID *Buffer
215 /*++
217 Routine Description:
219 Perform reading PCI configuration space of device
221 Arguments:
223 This - A pointer to EFI_DEVICE_IO protocol instance.
224 Width - Width of I/O operations.
225 Address - The base address of I/O operations.
226 Count - The number of I/O operations to perform.
227 Bytes moves is Width size * Count, starting at Address.
228 Buffer - The destination buffer to store results.
230 Returns:
232 EFI_SUCCESS - The data was read from the device.
233 EFI_INVALID_PARAMETER - Width is invalid.
234 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
236 --*/
239 EFI_STATUS
240 EFIAPI
241 DeviceIoPciWrite (
242 IN EFI_DEVICE_IO_PROTOCOL *This,
243 IN EFI_IO_WIDTH Width,
244 IN UINT64 Address,
245 IN UINTN Count,
246 IN OUT VOID *Buffer
248 /*++
250 Routine Description:
252 Perform writing PCI configuration space of device.
254 Arguments:
256 This - A pointer to EFI_DEVICE_IO protocol instance.
257 Width - Width of I/O operations.
258 Address - The base address of I/O operations.
259 Count - The number of I/O operations to perform.
260 Bytes moves is Width size * Count, starting at Address.
261 Buffer - The source buffer of data to be written.
263 Returns:
265 EFI_SUCCESS - The data was written to the device.
266 EFI_INVALID_PARAMETER - Width is invalid.
267 EFI_OUT_OF_RESOURCES - The request could not be completed due to lack of resources.
269 --*/
272 EFI_STATUS
273 EFIAPI
274 DeviceIoPciDevicePath (
275 IN EFI_DEVICE_IO_PROTOCOL *This,
276 IN UINT64 Address,
277 IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath
279 /*++
281 Routine Description:
283 Append a PCI device path node to another device path.
285 Arguments:
287 This - A pointer to EFI_DEVICE_IO_PROTOCOL.
288 Address - PCI bus,device, function.
289 PciDevicePath - PCI device path.
291 Returns:
293 Pointer to the appended PCI device path.
295 --*/
298 EFI_STATUS
299 EFIAPI
300 DeviceIoMap (
301 IN EFI_DEVICE_IO_PROTOCOL *This,
302 IN EFI_IO_OPERATION_TYPE Operation,
303 IN EFI_PHYSICAL_ADDRESS *HostAddress,
304 IN OUT UINTN *NumberOfBytes,
305 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
306 OUT VOID **Mapping
308 /*++
310 Routine Description:
312 Provides the device-specific addresses needed to access system memory.
314 Arguments:
316 This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
317 Operation - Indicates if the bus master is going to read or write to system memory.
318 HostAddress - The system memory address to map to the device.
319 NumberOfBytes - On input the number of bytes to map. On output the number of bytes
320 that were mapped.
321 DeviceAddress - The resulting map address for the bus master device to use to access the
322 hosts HostAddress.
323 Mapping - A resulting value to pass to Unmap().
325 Returns:
327 EFI_SUCCESS - The range was mapped for the returned NumberOfBytes.
328 EFI_INVALID_PARAMETER - The Operation or HostAddress is undefined.
329 EFI_UNSUPPORTED - The HostAddress cannot be mapped as a common buffer.
330 EFI_DEVICE_ERROR - The system hardware could not map the requested address.
331 EFI_OUT_OF_RESOURCES - The request could not be completed due to a lack of resources.
333 --*/
336 EFI_STATUS
337 EFIAPI
338 DeviceIoUnmap (
339 IN EFI_DEVICE_IO_PROTOCOL *This,
340 IN VOID *Mapping
342 /*++
344 Routine Description:
346 Completes the Map() operation and releases any corresponding resources.
348 Arguments:
350 This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
351 Mapping - The mapping value returned from Map().
353 Returns:
355 EFI_SUCCESS - The range was unmapped.
356 EFI_DEVICE_ERROR - The data was not committed to the target system memory.
358 --*/
361 EFI_STATUS
362 EFIAPI
363 DeviceIoAllocateBuffer (
364 IN EFI_DEVICE_IO_PROTOCOL *This,
365 IN EFI_ALLOCATE_TYPE Type,
366 IN EFI_MEMORY_TYPE MemoryType,
367 IN UINTN Pages,
368 IN OUT EFI_PHYSICAL_ADDRESS *HostAddress
370 /*++
372 Routine Description:
374 Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
376 Arguments:
378 This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
379 Type - The type allocation to perform.
380 MemoryType - The type of memory to allocate, EfiBootServicesData or
381 EfiRuntimeServicesData.
382 Pages - The number of pages to allocate.
383 HostAddress - A pointer to store the base address of the allocated range.
385 Returns:
387 EFI_SUCCESS - The requested memory pages were allocated.
388 EFI_OUT_OF_RESOURCES - The memory pages could not be allocated.
389 EFI_INVALID_PARAMETER - The requested memory type is invalid.
390 EFI_UNSUPPORTED - The requested PhysicalAddress is not supported on
391 this platform.
393 --*/
396 EFI_STATUS
397 EFIAPI
398 DeviceIoFlush (
399 IN EFI_DEVICE_IO_PROTOCOL *This
401 /*++
403 Routine Description:
405 Flushes any posted write data to the device.
407 Arguments:
409 This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
411 Returns:
413 EFI_SUCCESS - The buffers were flushed.
414 EFI_DEVICE_ERROR - The buffers were not flushed due to a hardware error.
416 --*/
419 EFI_STATUS
420 EFIAPI
421 DeviceIoFreeBuffer (
422 IN EFI_DEVICE_IO_PROTOCOL *This,
423 IN UINTN Pages,
424 IN EFI_PHYSICAL_ADDRESS HostAddress
426 /*++
428 Routine Description:
430 Frees pages that were allocated with AllocateBuffer().
432 Arguments:
434 This - A pointer to the EFI_DEVICE_IO_INTERFACE instance.
435 Pages - The number of pages to free.
436 HostAddress - The base address of the range to free.
438 Returns:
440 EFI_SUCCESS - The requested memory pages were freed.
441 EFI_NOT_FOUND - The requested memory pages were not allocated with
442 AllocateBuffer().
443 EFI_INVALID_PARAMETER - HostAddress is not page aligned or Pages is invalid.
445 --*/
448 #endif