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