2 Device IO protocol as defined in the EFI 1.0 specification.
4 Device IO is used to abstract hardware access to devices. It includes
5 memory mapped IO, IO, PCI Config space, and DMA.
7 Copyright (c) 2006, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef __DEVICE_IO_H__
19 #define __DEVICE_IO_H__
21 #define EFI_DEVICE_IO_PROTOCOL_GUID \
23 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
26 typedef struct _EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL
;
29 // Protocol GUID name defined in EFI1.1.
31 #define DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL_GUID
34 // Protocol defined in EFI1.1.
36 typedef EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_INTERFACE
;
50 Enables a driver to access device registers in the appropriate memory or I/O space.
52 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
53 @param Width Signifies the width of the I/O operations.
54 @param Address The base address of the I/O operations.
55 @param Count The number of I/O operations to perform.
56 @param Buffer For read operations, the destination buffer to store the results. For write
57 operations, the source buffer to write data from.
59 @retval EFI_SUCCESS The data was read from or written to the device.
60 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
61 @retval EFI_INVALID_PARAMETER Width is invalid.
66 (EFIAPI
*EFI_DEVICE_IO
) (
67 IN EFI_DEVICE_IO_PROTOCOL
*This
,
68 IN EFI_IO_WIDTH Width
,
80 Provides an EFI Device Path for a PCI device with the given PCI configuration space address.
82 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
83 @param PciAddress The PCI configuration space address of the device whose Device Path
84 is going to be returned.
85 @param PciDevicePath A pointer to the pointer for the EFI Device Path for PciAddress.
86 Memory for the Device Path is allocated from the pool.
88 @retval EFI_SUCCESS The PciDevicePath returns a pointer to a valid EFI Device Path.
89 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
90 @retval EFI_UNSUPPORTED The PciAddress does not map to a valid EFI Device Path.
95 (EFIAPI
*EFI_PCI_DEVICE_PATH
) (
96 IN EFI_DEVICE_IO_PROTOCOL
*This
,
98 IN OUT EFI_DEVICE_PATH_PROTOCOL
**PciDevicePath
104 EfiBusMasterCommonBuffer
105 } EFI_IO_OPERATION_TYPE
;
108 Provides the device-specific addresses needed to access system memory.
110 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
111 @param Operation Indicates if the bus master is going to read or write to system memory.
112 @param HostAddress The system memory address to map to the device.
113 @param NumberOfBytes On input the number of bytes to map.
114 @param DeviceAddress The resulting map address for the bus master device to use to access the
116 @param Mapping A resulting value to pass to Unmap().
118 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
119 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
120 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
121 @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
122 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
127 (EFIAPI
*EFI_IO_MAP
) (
128 IN EFI_DEVICE_IO_PROTOCOL
*This
,
129 IN EFI_IO_OPERATION_TYPE Operation
,
130 IN EFI_PHYSICAL_ADDRESS
*HostAddress
,
131 IN OUT UINTN
*NumberOfBytes
,
132 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
137 Completes the Map() operation and releases any corresponding resources.
139 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
140 @param Mapping A resulting value to pass to Unmap().
142 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
143 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
148 (EFIAPI
*EFI_IO_UNMAP
) (
149 IN EFI_DEVICE_IO_PROTOCOL
*This
,
154 Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
156 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
157 @param Type The type allocation to perform.
158 @param MemoryType The type of memory to allocate, EfiBootServicesData or
159 EfiRuntimeServicesData.
160 @param Pages The number of pages to allocate.
161 @param HostAddress A pointer to store the base address of the allocated range.
163 @retval EFI_SUCCESS The requested memory pages were allocated.
164 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
165 @retval EFI_INVALID_PARAMETER The requested memory type is invalid.
166 @retval EFI_UNSUPPORTED The requested HostAddress is not supported on
172 (EFIAPI
*EFI_IO_ALLOCATE_BUFFER
) (
173 IN EFI_DEVICE_IO_PROTOCOL
*This
,
174 IN EFI_ALLOCATE_TYPE Type
,
175 IN EFI_MEMORY_TYPE MemoryType
,
177 IN OUT EFI_PHYSICAL_ADDRESS
*HostAddress
181 Flushes any posted write data to the device.
183 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
185 @retval EFI_SUCCESS The buffers were flushed.
186 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
191 (EFIAPI
*EFI_IO_FLUSH
) (
192 IN EFI_DEVICE_IO_PROTOCOL
*This
196 Frees pages that were allocated with AllocateBuffer().
198 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
199 @param Pages The number of pages to free.
200 @param HostAddress The base address of the range to free.
202 @retval EFI_SUCCESS The requested memory pages were allocated.
203 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
205 @retval EFI_INVALID_PARAMETER HostAddress is not page aligned or Pages is invalid.
210 (EFIAPI
*EFI_IO_FREE_BUFFER
) (
211 IN EFI_DEVICE_IO_PROTOCOL
*This
,
213 IN EFI_PHYSICAL_ADDRESS HostAddress
216 struct _EFI_DEVICE_IO_PROTOCOL
{
221 EFI_PCI_DEVICE_PATH PciDevicePath
;
223 EFI_IO_ALLOCATE_BUFFER AllocateBuffer
;
225 EFI_IO_FREE_BUFFER FreeBuffer
;
228 extern EFI_GUID gEfiDeviceIoProtocolGuid
;