2 Device IO protocol as defined in the EFI 1.10 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 - 2008, 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
;
46 Enables a driver to access device registers in the appropriate memory or I/O space.
48 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
49 @param Width Signifies the width of the I/O operations.
50 @param Address The base address of the I/O operations.
51 @param Count The number of I/O operations to perform.
52 @param Buffer For read operations, the destination buffer to store the results. For write
53 operations, the source buffer to write data from.
55 @retval EFI_SUCCESS The data was read from or written to the device.
56 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
57 @retval EFI_INVALID_PARAMETER Width is invalid.
62 (EFIAPI
*EFI_DEVICE_IO
)(
63 IN EFI_DEVICE_IO_PROTOCOL
*This
,
64 IN EFI_IO_WIDTH Width
,
76 Provides an EFI Device Path for a PCI device with the given PCI configuration space address.
78 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
79 @param PciAddress The PCI configuration space address of the device whose Device Path
80 is going to be returned.
81 @param PciDevicePath A pointer to the pointer for the EFI Device Path for PciAddress.
82 Memory for the Device Path is allocated from the pool.
84 @retval EFI_SUCCESS The PciDevicePath returns a pointer to a valid EFI Device Path.
85 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
86 @retval EFI_UNSUPPORTED The PciAddress does not map to a valid EFI Device Path.
91 (EFIAPI
*EFI_PCI_DEVICE_PATH
)(
92 IN EFI_DEVICE_IO_PROTOCOL
*This
,
94 IN OUT EFI_DEVICE_PATH_PROTOCOL
**PciDevicePath
99 /// A read operation from system memory by a bus master.
104 /// A write operation to system memory by a bus master.
109 /// Provides both read and write access to system memory
110 /// by both the processor and a bus master. The buffer is
111 /// coherent from both the processor¡¯s and the bus master¡¯s
114 EfiBusMasterCommonBuffer
115 } EFI_IO_OPERATION_TYPE
;
118 Provides the device-specific addresses needed to access system memory.
120 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
121 @param Operation Indicates if the bus master is going to read or write to system memory.
122 @param HostAddress The system memory address to map to the device.
123 @param NumberOfBytes On input the number of bytes to map.
124 @param DeviceAddress The resulting map address for the bus master device to use to access the
126 @param Mapping A resulting value to pass to Unmap().
128 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
129 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
130 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
131 @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
132 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
137 (EFIAPI
*EFI_IO_MAP
)(
138 IN EFI_DEVICE_IO_PROTOCOL
*This
,
139 IN EFI_IO_OPERATION_TYPE Operation
,
140 IN EFI_PHYSICAL_ADDRESS
*HostAddress
,
141 IN OUT UINTN
*NumberOfBytes
,
142 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
147 Completes the Map() operation and releases any corresponding resources.
149 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
150 @param Mapping A resulting value to pass to Unmap().
152 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
153 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
158 (EFIAPI
*EFI_IO_UNMAP
)(
159 IN EFI_DEVICE_IO_PROTOCOL
*This
,
164 Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
166 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
167 @param Type The type allocation to perform.
168 @param MemoryType The type of memory to allocate, EfiBootServicesData or
169 EfiRuntimeServicesData.
170 @param Pages The number of pages to allocate.
171 @param HostAddress A pointer to store the base address of the allocated range.
173 @retval EFI_SUCCESS The requested memory pages were allocated.
174 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
175 @retval EFI_INVALID_PARAMETER The requested memory type is invalid.
176 @retval EFI_UNSUPPORTED The requested HostAddress is not supported on
182 (EFIAPI
*EFI_IO_ALLOCATE_BUFFER
)(
183 IN EFI_DEVICE_IO_PROTOCOL
*This
,
184 IN EFI_ALLOCATE_TYPE Type
,
185 IN EFI_MEMORY_TYPE MemoryType
,
187 IN OUT EFI_PHYSICAL_ADDRESS
*HostAddress
191 Flushes any posted write data to the device.
193 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
195 @retval EFI_SUCCESS The buffers were flushed.
196 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
201 (EFIAPI
*EFI_IO_FLUSH
)(
202 IN EFI_DEVICE_IO_PROTOCOL
*This
206 Frees pages that were allocated with AllocateBuffer().
208 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
209 @param Pages The number of pages to free.
210 @param HostAddress The base address of the range to free.
212 @retval EFI_SUCCESS The requested memory pages were allocated.
213 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
215 @retval EFI_INVALID_PARAMETER HostAddress is not page aligned or Pages is invalid.
220 (EFIAPI
*EFI_IO_FREE_BUFFER
)(
221 IN EFI_DEVICE_IO_PROTOCOL
*This
,
223 IN EFI_PHYSICAL_ADDRESS HostAddress
227 /// This protocol provides the basic Memory, I/O, and PCI interfaces that
228 /// are used to abstract accesses to devices.
230 struct _EFI_DEVICE_IO_PROTOCOL
{
232 /// Allows reads and writes to memory mapped I/O space.
236 /// Allows reads and writes to I/O space.
240 /// Allows reads and writes to PCI configuration space.
244 EFI_PCI_DEVICE_PATH PciDevicePath
;
246 EFI_IO_ALLOCATE_BUFFER AllocateBuffer
;
248 EFI_IO_FREE_BUFFER FreeBuffer
;
251 extern EFI_GUID gEfiDeviceIoProtocolGuid
;