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