d1f95000 |
1 | /** @file\r |
2 | PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification.\r |
3 | \r |
4 | PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O, \r |
5 | and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform \r |
6 | defferent types of bus mastering DMA\r |
7 | \r |
8 | Copyright (c) 2006, Intel Corporation \r |
9 | All rights reserved. This program and the accompanying materials \r |
10 | are licensed and made available under the terms and conditions of the BSD License \r |
11 | which accompanies this distribution. The full text of the license may be found at \r |
12 | http://opensource.org/licenses/bsd-license.php \r |
13 | \r |
14 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r |
15 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r |
16 | \r |
d1f95000 |
17 | **/\r |
18 | \r |
19 | #ifndef __PCI_ROOT_BRIDGE_IO_H__\r |
20 | #define __PCI_ROOT_BRIDGE_IO_H__\r |
21 | \r |
22 | #define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \\r |
23 | { \\r |
24 | 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r |
25 | }\r |
26 | \r |
27 | typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;\r |
28 | \r |
29 | typedef enum {\r |
30 | EfiPciWidthUint8,\r |
31 | EfiPciWidthUint16,\r |
32 | EfiPciWidthUint32,\r |
33 | EfiPciWidthUint64,\r |
34 | EfiPciWidthFifoUint8,\r |
35 | EfiPciWidthFifoUint16,\r |
36 | EfiPciWidthFifoUint32,\r |
37 | EfiPciWidthFifoUint64,\r |
38 | EfiPciWidthFillUint8,\r |
39 | EfiPciWidthFillUint16,\r |
40 | EfiPciWidthFillUint32,\r |
41 | EfiPciWidthFillUint64,\r |
42 | EfiPciWidthMaximum\r |
43 | } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;\r |
44 | \r |
45 | typedef enum {\r |
46 | EfiPciOperationBusMasterRead,\r |
47 | EfiPciOperationBusMasterWrite,\r |
48 | EfiPciOperationBusMasterCommonBuffer,\r |
49 | EfiPciOperationBusMasterRead64,\r |
50 | EfiPciOperationBusMasterWrite64,\r |
51 | EfiPciOperationBusMasterCommonBuffer64,\r |
52 | EfiPciOperationMaximum\r |
53 | } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;\r |
54 | \r |
55 | #define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001\r |
56 | #define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002\r |
57 | #define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004\r |
58 | #define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008\r |
59 | #define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010\r |
60 | #define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020\r |
61 | #define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040\r |
62 | #define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080\r |
63 | #define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800\r |
64 | #define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000\r |
65 | #define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000\r |
66 | \r |
67 | #define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE)\r |
68 | \r |
69 | #define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)\r |
70 | \r |
71 | #define EFI_PCI_ADDRESS(bus, dev, func, reg) \\r |
72 | ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))\r |
73 | \r |
74 | typedef struct {\r |
75 | UINT8 Register;\r |
76 | UINT8 Function;\r |
77 | UINT8 Device;\r |
78 | UINT8 Bus;\r |
79 | UINT32 ExtendedRegister;\r |
80 | } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;\r |
81 | \r |
82 | /** \r |
83 | Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is\r |
84 | satisfied or after a defined duration.\r |
85 | \r |
86 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
87 | @param Width Signifies the width of the memory or I/O operations.\r |
88 | @param Address The base address of the memory or I/O operations. \r |
89 | @param Mask Mask used for the polling criteria.\r |
90 | @param Value The comparison value used for the polling exit criteria.\r |
91 | @param Delay The number of 100 ns units to poll.\r |
92 | @param Result Pointer to the last value read from the memory location.\r |
93 | \r |
94 | @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.\r |
95 | @retval EFI_TIMEOUT Delay expired before a match occurred.\r |
96 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r |
97 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
98 | \r |
99 | **/\r |
100 | typedef\r |
101 | EFI_STATUS\r |
102 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) (\r |
103 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
104 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r |
105 | IN UINT64 Address,\r |
106 | IN UINT64 Mask,\r |
107 | IN UINT64 Value,\r |
108 | IN UINT64 Delay,\r |
109 | OUT UINT64 *Result\r |
110 | );\r |
111 | \r |
112 | /** \r |
113 | Enables a PCI driver to access PCI controller registers in the PCI root bridge memory space.\r |
114 | \r |
115 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
116 | @param Width Signifies the width of the memory operations.\r |
117 | @param Address The base address of the memory operations. \r |
118 | @param Count The number of memory operations to perform.\r |
119 | @param Buffer For read operations, the destination buffer to store the results. For write\r |
120 | operations, the source buffer to write data from. \r |
121 | \r |
122 | @retval EFI_SUCCESS The data was read from or written to the PCI root bridge. \r |
123 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r |
124 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
125 | \r |
126 | **/\r |
127 | typedef\r |
128 | EFI_STATUS\r |
129 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) (\r |
130 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
131 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r |
132 | IN UINT64 Address,\r |
133 | IN UINTN Count,\r |
134 | IN OUT VOID *Buffer\r |
135 | );\r |
136 | \r |
137 | typedef struct {\r |
138 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read;\r |
139 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write;\r |
140 | } EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;\r |
141 | \r |
142 | /** \r |
143 | Enables a PCI driver to copy one region of PCI root bridge memory space to another region of PCI\r |
144 | root bridge memory space. \r |
145 | \r |
146 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.\r |
147 | @param Width Signifies the width of the memory operations.\r |
148 | @param DestAddress The destination address of the memory operation. \r |
149 | @param SrcAddress The source address of the memory operation. \r |
150 | @param Count The number of memory operations to perform. \r |
151 | \r |
152 | @retval EFI_SUCCESS The data was copied from one memory region to another memory region. \r |
153 | @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.\r |
154 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r |
155 | \r |
156 | **/\r |
157 | typedef\r |
158 | EFI_STATUS\r |
159 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) (\r |
160 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
161 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r |
162 | IN UINT64 DestAddress,\r |
163 | IN UINT64 SrcAddress,\r |
164 | IN UINTN Count\r |
165 | );\r |
166 | \r |
167 | /** \r |
168 | Provides the PCI controller-Cspecific addresses required to access system memory from a\r |
169 | DMA bus master. \r |
170 | \r |
171 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
172 | @param Operation Indicates if the bus master is going to read or write to system memory.\r |
173 | @param HostAddress The system memory address to map to the PCI controller.\r |
174 | @param NumberOfBytes On input the number of bytes to map. On output the number of bytes\r |
175 | that were mapped. \r |
176 | @param DeviceAddress The resulting map address for the bus master PCI controller to use to\r |
177 | access the hosts HostAddress. \r |
178 | @param Mapping A resulting value to pass to Unmap().\r |
179 | \r |
180 | @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r |
181 | @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer. \r |
182 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
183 | @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r |
184 | @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r |
185 | \r |
186 | **/\r |
187 | typedef\r |
188 | EFI_STATUS\r |
189 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) (\r |
190 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
191 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,\r |
192 | IN VOID *HostAddress,\r |
193 | IN OUT UINTN *NumberOfBytes,\r |
194 | OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r |
195 | OUT VOID **Mapping\r |
196 | );\r |
197 | \r |
198 | /** \r |
199 | Completes the Map() operation and releases any corresponding resources.\r |
200 | \r |
201 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
202 | @param Mapping The mapping value returned from Map().\r |
203 | \r |
204 | @retval EFI_SUCCESS The range was unmapped.\r |
205 | @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().\r |
206 | @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r |
207 | \r |
208 | **/\r |
209 | typedef\r |
210 | EFI_STATUS\r |
211 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) (\r |
212 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
213 | IN VOID *Mapping\r |
214 | );\r |
215 | \r |
216 | /** \r |
217 | Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer or\r |
218 | EfiPciOperationBusMasterCommonBuffer64 mapping. \r |
219 | \r |
220 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
221 | @param Type This parameter is not used and must be ignored.\r |
222 | @param MemoryType The type of memory to allocate, EfiBootServicesData or\r |
223 | EfiRuntimeServicesData. \r |
224 | @param Pages The number of pages to allocate. \r |
225 | @param HostAddress A pointer to store the base system memory address of the\r |
226 | allocated range. \r |
227 | @param Attributes The requested bit mask of attributes for the allocated range.\r |
228 | \r |
229 | @retval EFI_SUCCESS The requested memory pages were allocated.\r |
230 | @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are\r |
231 | MEMORY_WRITE_COMBINE and MEMORY_CACHED. \r |
232 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r |
233 | @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. \r |
234 | \r |
235 | **/\r |
236 | typedef\r |
237 | EFI_STATUS\r |
238 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) (\r |
239 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
240 | IN EFI_ALLOCATE_TYPE Type,\r |
241 | IN EFI_MEMORY_TYPE MemoryType,\r |
242 | IN UINTN Pages,\r |
243 | IN OUT VOID **HostAddress,\r |
244 | IN UINT64 Attributes\r |
245 | );\r |
246 | \r |
247 | /** \r |
248 | Frees memory that was allocated with AllocateBuffer().\r |
249 | \r |
250 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
251 | @param Pages The number of pages to free. \r |
252 | @param HostAddress The base system memory address of the allocated range. \r |
253 | \r |
254 | @retval EFI_SUCCESS The requested memory pages were freed.\r |
255 | @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages\r |
256 | was not allocated with AllocateBuffer().\r |
257 | \r |
258 | **/\r |
259 | typedef\r |
260 | EFI_STATUS\r |
261 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) (\r |
262 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
263 | IN UINTN Pages,\r |
264 | IN VOID *HostAddress\r |
265 | );\r |
266 | \r |
267 | /** \r |
268 | Flushes all PCI posted write transactions from a PCI host bridge to system memory.\r |
269 | \r |
270 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
271 | \r |
272 | @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host\r |
273 | bridge to system memory. \r |
274 | @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI\r |
275 | host bridge due to a hardware error. \r |
276 | \r |
277 | **/\r |
278 | typedef\r |
279 | EFI_STATUS\r |
280 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) (\r |
281 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This\r |
282 | );\r |
283 | \r |
284 | /** \r |
285 | Gets the attributes that a PCI root bridge supports setting with SetAttributes(), and the\r |
286 | attributes that a PCI root bridge is currently using. \r |
287 | \r |
288 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
289 | @param Supports A pointer to the mask of attributes that this PCI root bridge supports\r |
290 | setting with SetAttributes(). \r |
291 | @param Attributes A pointer to the mask of attributes that this PCI root bridge is currently\r |
292 | using. \r |
293 | \r |
294 | @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI root \r |
295 | bridge supports is returned in Supports. If Attributes is \r |
296 | not NULL, then the attributes that the PCI root bridge is currently\r |
297 | using is returned in Attributes. \r |
298 | @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.\r |
299 | \r |
300 | \r |
301 | **/\r |
302 | typedef\r |
303 | EFI_STATUS\r |
304 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) (\r |
305 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
306 | OUT UINT64 *Supports,\r |
307 | OUT UINT64 *Attributes\r |
308 | );\r |
309 | \r |
310 | /** \r |
311 | Sets attributes for a resource range on a PCI root bridge.\r |
312 | \r |
313 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
314 | @param Attributes The mask of attributes to set.\r |
315 | @param ResourceBase A pointer to the base address of the resource range to be modified by the\r |
316 | attributes specified by Attributes.\r |
317 | @param ResourceLength A pointer to the length of the resource range to be modified by the\r |
318 | attributes specified by Attributes. \r |
319 | \r |
320 | @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource \r |
321 | range specified by ResourceBase and ResourceLength \r |
322 | were set on the PCI root bridge, and the actual resource range is\r |
323 | returned in ResuourceBase and ResourceLength. \r |
324 | @retval EFI_UNSUPPORTED A bit is set in Attributes that is not supported by the PCI Root\r |
325 | Bridge. \r |
326 | @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the \r |
327 | resource range specified by BaseAddress and Length. \r |
328 | @retval EFI_INVALID_PARAMETER One or more parameters are invalid. \r |
329 | \r |
330 | **/\r |
331 | typedef\r |
332 | EFI_STATUS\r |
333 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) (\r |
334 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
335 | IN UINT64 Attributes,\r |
336 | IN OUT UINT64 *ResourceBase,\r |
337 | IN OUT UINT64 *ResourceLength\r |
338 | );\r |
339 | \r |
340 | /** \r |
341 | Retrieves the current resource settings of this PCI root bridge in the form of a set of ACPI 2.0\r |
342 | resource descriptors. \r |
343 | \r |
344 | @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r |
345 | @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current\r |
346 | configuration of this PCI root bridge. \r |
347 | \r |
348 | @retval EFI_SUCCESS The current configuration of this PCI root bridge was returned in\r |
349 | Resources. \r |
350 | @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge could not be\r |
351 | retrieved. \r |
352 | \r |
353 | **/\r |
354 | typedef\r |
355 | EFI_STATUS\r |
356 | (EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) (\r |
357 | IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r |
358 | OUT VOID **Resources\r |
359 | );\r |
360 | \r |
361 | struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {\r |
362 | EFI_HANDLE ParentHandle;\r |
363 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem;\r |
364 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo;\r |
365 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem;\r |
366 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io;\r |
367 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci;\r |
368 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem;\r |
369 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map;\r |
370 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap;\r |
371 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;\r |
372 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer;\r |
373 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush;\r |
374 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes;\r |
375 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes;\r |
376 | EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration;\r |
377 | UINT32 SegmentNumber;\r |
378 | };\r |
379 | \r |
380 | extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;\r |
381 | \r |
382 | #endif\r |