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