]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Include/Protocol/DeviceIo.h
Fix a typo
[mirror_edk2.git] / MdePkg / Include / Protocol / DeviceIo.h
1 /** @file
2 Device IO protocol as defined in the EFI 1.10 specification.
3
4 Device IO is used to abstract hardware access to devices. It includes
5 memory mapped IO, IO, PCI Config space, and DMA.
6
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
12
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.
15
16 **/
17
18 #ifndef __DEVICE_IO_H__
19 #define __DEVICE_IO_H__
20
21 #define EFI_DEVICE_IO_PROTOCOL_GUID \
22 { \
23 0xaf6ac311, 0x84c3, 0x11d2, {0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b } \
24 }
25
26 typedef struct _EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL;
27
28 ///
29 /// Protocol GUID name defined in EFI1.1.
30 ///
31 #define DEVICE_IO_PROTOCOL EFI_DEVICE_IO_PROTOCOL_GUID
32
33 ///
34 /// Protocol defined in EFI1.1.
35 ///
36 typedef EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_INTERFACE;
37
38 typedef enum {
39 IO_UINT8 = 0,
40 IO_UINT16 = 1,
41 IO_UINT32 = 2,
42 IO_UINT64 = 3,
43 //
44 // Below enumerations are added in "Extensible Firmware Interface Specification,
45 // Version 1.10, Specification Update, Version 001".
46 //
47 MMIO_COPY_UINT8 = 4,
48 MMIO_COPY_UINT16 = 5,
49 MMIO_COPY_UINT32 = 6,
50 MMIO_COPY_UINT64 = 7
51 } EFI_IO_WIDTH;
52
53 /**
54 Enables a driver to access device registers in the appropriate memory or I/O space.
55
56 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
57 @param Width Signifies the width of the I/O operations.
58 @param Address The base address of the I/O operations.
59 @param Count The number of I/O operations to perform.
60 @param Buffer For read operations, the destination buffer to store the results. For write
61 operations, the source buffer to write data from. If
62 Width is MMIO_COPY_UINT8, MMIO_COPY_UINT16,
63 MMIO_COPY_UINT32, or MMIO_COPY_UINT64, then
64 Buffer is interpreted as a base address of an I/O operation such as Address.
65
66 @retval EFI_SUCCESS The data was read from or written to the device.
67 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
68 @retval EFI_INVALID_PARAMETER Width is invalid.
69
70 **/
71 typedef
72 EFI_STATUS
73 (EFIAPI *EFI_DEVICE_IO)(
74 IN EFI_DEVICE_IO_PROTOCOL *This,
75 IN EFI_IO_WIDTH Width,
76 IN UINT64 Address,
77 IN UINTN Count,
78 IN OUT VOID *Buffer
79 );
80
81 typedef struct {
82 EFI_DEVICE_IO Read;
83 EFI_DEVICE_IO Write;
84 } EFI_IO_ACCESS;
85
86 /**
87 Provides an EFI Device Path for a PCI device with the given PCI configuration space address.
88
89 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
90 @param PciAddress The PCI configuration space address of the device whose Device Path
91 is going to be returned.
92 @param PciDevicePath A pointer to the pointer for the EFI Device Path for PciAddress.
93 Memory for the Device Path is allocated from the pool.
94
95 @retval EFI_SUCCESS The PciDevicePath returns a pointer to a valid EFI Device Path.
96 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
97 @retval EFI_UNSUPPORTED The PciAddress does not map to a valid EFI Device Path.
98
99 **/
100 typedef
101 EFI_STATUS
102 (EFIAPI *EFI_PCI_DEVICE_PATH)(
103 IN EFI_DEVICE_IO_PROTOCOL *This,
104 IN UINT64 PciAddress,
105 IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath
106 );
107
108 typedef enum {
109 ///
110 /// A read operation from system memory by a bus master.
111 ///
112 EfiBusMasterRead,
113
114 ///
115 /// A write operation to system memory by a bus master.
116 ///
117 EfiBusMasterWrite,
118
119 ///
120 /// Provides both read and write access to system memory
121 /// by both the processor and a bus master. The buffer is
122 /// coherent from both the processor's and the bus master's
123 /// point of view.
124 ///
125 EfiBusMasterCommonBuffer
126 } EFI_IO_OPERATION_TYPE;
127
128 /**
129 Provides the device-specific addresses needed to access system memory.
130
131 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
132 @param Operation Indicates if the bus master is going to read or write to system memory.
133 @param HostAddress The system memory address to map to the device.
134 @param NumberOfBytes On input the number of bytes to map.
135 @param DeviceAddress The resulting map address for the bus master device to use to access the
136 hosts HostAddress.
137 @param Mapping A resulting value to pass to Unmap().
138
139 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
140 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
141 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
142 @retval EFI_INVALID_PARAMETER The Operation or HostAddress is undefined.
143 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
144
145 **/
146 typedef
147 EFI_STATUS
148 (EFIAPI *EFI_IO_MAP)(
149 IN EFI_DEVICE_IO_PROTOCOL *This,
150 IN EFI_IO_OPERATION_TYPE Operation,
151 IN EFI_PHYSICAL_ADDRESS *HostAddress,
152 IN OUT UINTN *NumberOfBytes,
153 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
154 OUT VOID **Mapping
155 );
156
157 /**
158 Completes the Map() operation and releases any corresponding resources.
159
160 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
161 @param Mapping A resulting value to pass to Unmap().
162
163 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
164 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
165
166 **/
167 typedef
168 EFI_STATUS
169 (EFIAPI *EFI_IO_UNMAP)(
170 IN EFI_DEVICE_IO_PROTOCOL *This,
171 IN VOID *Mapping
172 );
173
174 /**
175 Allocates pages that are suitable for an EFIBusMasterCommonBuffer mapping.
176
177 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
178 @param Type The type allocation to perform.
179 @param MemoryType The type of memory to allocate, EfiBootServicesData or
180 EfiRuntimeServicesData.
181 @param Pages The number of pages to allocate.
182 @param HostAddress A pointer to store the base address of the allocated range.
183
184 @retval EFI_SUCCESS The requested memory pages were allocated.
185 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
186 @retval EFI_INVALID_PARAMETER The requested memory type is invalid.
187 @retval EFI_UNSUPPORTED The requested HostAddress is not supported on
188 this platform.
189
190 **/
191 typedef
192 EFI_STATUS
193 (EFIAPI *EFI_IO_ALLOCATE_BUFFER)(
194 IN EFI_DEVICE_IO_PROTOCOL *This,
195 IN EFI_ALLOCATE_TYPE Type,
196 IN EFI_MEMORY_TYPE MemoryType,
197 IN UINTN Pages,
198 IN OUT EFI_PHYSICAL_ADDRESS *HostAddress
199 );
200
201 /**
202 Flushes any posted write data to the device.
203
204 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
205
206 @retval EFI_SUCCESS The buffers were flushed.
207 @retval EFI_DEVICE_ERROR The buffers were not flushed due to a hardware error.
208
209 **/
210 typedef
211 EFI_STATUS
212 (EFIAPI *EFI_IO_FLUSH)(
213 IN EFI_DEVICE_IO_PROTOCOL *This
214 );
215
216 /**
217 Frees pages that were allocated with AllocateBuffer().
218
219 @param This A pointer to the EFI_DEVICE_IO_INTERFACE instance.
220 @param Pages The number of pages to free.
221 @param HostAddress The base address of the range to free.
222
223 @retval EFI_SUCCESS The requested memory pages were allocated.
224 @retval EFI_NOT_FOUND The requested memory pages were not allocated with
225 AllocateBuffer().
226 @retval EFI_INVALID_PARAMETER HostAddress is not page aligned or Pages is invalid.
227
228 **/
229 typedef
230 EFI_STATUS
231 (EFIAPI *EFI_IO_FREE_BUFFER)(
232 IN EFI_DEVICE_IO_PROTOCOL *This,
233 IN UINTN Pages,
234 IN EFI_PHYSICAL_ADDRESS HostAddress
235 );
236
237 ///
238 /// This protocol provides the basic Memory, I/O, and PCI interfaces that
239 /// are used to abstract accesses to devices.
240 ///
241 struct _EFI_DEVICE_IO_PROTOCOL {
242 ///
243 /// Allows reads and writes to memory mapped I/O space.
244 ///
245 EFI_IO_ACCESS Mem;
246 ///
247 /// Allows reads and writes to I/O space.
248 ///
249 EFI_IO_ACCESS Io;
250 ///
251 /// Allows reads and writes to PCI configuration space.
252 ///
253 EFI_IO_ACCESS Pci;
254 EFI_IO_MAP Map;
255 EFI_PCI_DEVICE_PATH PciDevicePath;
256 EFI_IO_UNMAP Unmap;
257 EFI_IO_ALLOCATE_BUFFER AllocateBuffer;
258 EFI_IO_FLUSH Flush;
259 EFI_IO_FREE_BUFFER FreeBuffer;
260 };
261
262 extern EFI_GUID gEfiDeviceIoProtocolGuid;
263
264 #endif