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