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