]>
Commit | Line | Data |
---|---|---|
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 | |
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 | |
26 | typedef 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 | |
36 | typedef EFI_DEVICE_IO_PROTOCOL EFI_DEVICE_IO_INTERFACE;\r | |
37 | \r | |
d1f95000 | 38 | typedef 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 | |
64 | typedef\r | |
65 | EFI_STATUS\r | |
66 | (EFIAPI *EFI_DEVICE_IO) (\r | |
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 | |
74 | typedef 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 | |
93 | typedef\r | |
94 | EFI_STATUS\r | |
95 | (EFIAPI *EFI_PCI_DEVICE_PATH) (\r | |
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 | |
101 | typedef 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 | |
125 | typedef\r | |
126 | EFI_STATUS\r | |
127 | (EFIAPI *EFI_IO_MAP) (\r | |
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 | |
146 | typedef\r | |
147 | EFI_STATUS\r | |
148 | (EFIAPI *EFI_IO_UNMAP) (\r | |
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 | |
170 | typedef\r | |
171 | EFI_STATUS\r | |
172 | (EFIAPI *EFI_IO_ALLOCATE_BUFFER) (\r | |
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 | |
189 | typedef\r | |
190 | EFI_STATUS\r | |
191 | (EFIAPI *EFI_IO_FLUSH) (\r | |
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 | |
208 | typedef\r | |
209 | EFI_STATUS\r | |
210 | (EFIAPI *EFI_IO_FREE_BUFFER) (\r | |
211 | IN EFI_DEVICE_IO_PROTOCOL *This,\r | |
212 | IN UINTN Pages,\r | |
213 | IN EFI_PHYSICAL_ADDRESS HostAddress\r | |
214 | );\r | |
215 | \r | |
216 | struct _EFI_DEVICE_IO_PROTOCOL {\r | |
217 | EFI_IO_ACCESS Mem;\r | |
218 | EFI_IO_ACCESS Io;\r | |
219 | EFI_IO_ACCESS Pci;\r | |
220 | EFI_IO_MAP Map;\r | |
221 | EFI_PCI_DEVICE_PATH PciDevicePath;\r | |
222 | EFI_IO_UNMAP Unmap;\r | |
223 | EFI_IO_ALLOCATE_BUFFER AllocateBuffer;\r | |
224 | EFI_IO_FLUSH Flush;\r | |
225 | EFI_IO_FREE_BUFFER FreeBuffer;\r | |
226 | };\r | |
227 | \r | |
228 | extern EFI_GUID gEfiDeviceIoProtocolGuid;\r | |
229 | \r | |
230 | #endif\r |