]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/PciRootBridgeIo.h
Code Scrub for Protocol and Ppi Definition
[mirror_edk2.git] / MdePkg / Include / Protocol / PciRootBridgeIo.h
CommitLineData
d1f95000 1/** @file\r
8a7d75b0 2 PCI Root Bridge I/O protocol as defined in the UEFI 2.0 specification.\r
d1f95000 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
4ca9b6c4 8 Copyright (c) 2006 - 2008, Intel Corporation \r
d1f95000 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
01aef47b 22#include <PiDxe.h>\r
23\r
d1f95000 24#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \\r
25 { \\r
26 0x2f707ebb, 0x4a1a, 0x11d4, {0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d } \\r
27 }\r
28\r
29typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;\r
30\r
31typedef enum {\r
32 EfiPciWidthUint8,\r
33 EfiPciWidthUint16,\r
34 EfiPciWidthUint32,\r
35 EfiPciWidthUint64,\r
36 EfiPciWidthFifoUint8,\r
37 EfiPciWidthFifoUint16,\r
38 EfiPciWidthFifoUint32,\r
39 EfiPciWidthFifoUint64,\r
40 EfiPciWidthFillUint8,\r
41 EfiPciWidthFillUint16,\r
42 EfiPciWidthFillUint32,\r
43 EfiPciWidthFillUint64,\r
44 EfiPciWidthMaximum\r
45} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;\r
46\r
47typedef enum {\r
48 EfiPciOperationBusMasterRead,\r
49 EfiPciOperationBusMasterWrite,\r
50 EfiPciOperationBusMasterCommonBuffer,\r
51 EfiPciOperationBusMasterRead64,\r
52 EfiPciOperationBusMasterWrite64,\r
53 EfiPciOperationBusMasterCommonBuffer64,\r
54 EfiPciOperationMaximum\r
55} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;\r
56\r
57#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001\r
58#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002\r
59#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004\r
60#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008\r
61#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010\r
62#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020\r
63#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040\r
64#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080\r
65#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800\r
66#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000\r
67#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000\r
68\r
69#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
70\r
71#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)\r
72\r
73#define EFI_PCI_ADDRESS(bus, dev, func, reg) \\r
74 ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))\r
75\r
76typedef struct {\r
77 UINT8 Register;\r
78 UINT8 Function;\r
79 UINT8 Device;\r
80 UINT8 Bus;\r
81 UINT32 ExtendedRegister;\r
82} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;\r
83\r
84/** \r
85 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is\r
86 satisfied or after a defined duration.\r
87 \r
88 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
89 @param Width Signifies the width of the memory or I/O operations.\r
90 @param Address The base address of the memory or I/O operations. \r
91 @param Mask Mask used for the polling criteria.\r
92 @param Value The comparison value used for the polling exit criteria.\r
93 @param Delay The number of 100 ns units to poll.\r
94 @param Result Pointer to the last value read from the memory location.\r
95 \r
96 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.\r
97 @retval EFI_TIMEOUT Delay expired before a match occurred.\r
98 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
99 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
100 \r
101**/\r
102typedef\r
103EFI_STATUS\r
8b13229b 104(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM)(\r
d1f95000 105 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
106 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r
107 IN UINT64 Address,\r
108 IN UINT64 Mask,\r
109 IN UINT64 Value,\r
110 IN UINT64 Delay,\r
111 OUT UINT64 *Result\r
112 );\r
113\r
114/** \r
115 Enables a PCI driver to access PCI controller registers in the PCI root bridge memory space.\r
116 \r
117 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
118 @param Width Signifies the width of the memory operations.\r
119 @param Address The base address of the memory operations. \r
120 @param Count The number of memory operations to perform.\r
121 @param Buffer For read operations, the destination buffer to store the results. For write\r
122 operations, the source buffer to write data from. \r
123 \r
124 @retval EFI_SUCCESS The data was read from or written to the PCI root bridge. \r
125 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
126 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
127 \r
128**/\r
129typedef\r
130EFI_STATUS\r
8b13229b 131(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM)(\r
d1f95000 132 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
133 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r
134 IN UINT64 Address,\r
135 IN UINTN Count,\r
136 IN OUT VOID *Buffer\r
137 );\r
138\r
139typedef struct {\r
140 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read;\r
141 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write;\r
142} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;\r
143\r
144/** \r
145 Enables a PCI driver to copy one region of PCI root bridge memory space to another region of PCI\r
146 root bridge memory space. \r
147 \r
148 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL instance.\r
149 @param Width Signifies the width of the memory operations.\r
150 @param DestAddress The destination address of the memory operation. \r
151 @param SrcAddress The source address of the memory operation. \r
152 @param Count The number of memory operations to perform. \r
153 \r
154 @retval EFI_SUCCESS The data was copied from one memory region to another memory region. \r
155 @retval EFI_INVALID_PARAMETER Width is invalid for this PCI root bridge.\r
156 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
157 \r
158**/\r
159typedef\r
160EFI_STATUS\r
8b13229b 161(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM)(\r
d1f95000 162 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
163 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,\r
164 IN UINT64 DestAddress,\r
165 IN UINT64 SrcAddress,\r
166 IN UINTN Count\r
167 );\r
168\r
169/** \r
170 Provides the PCI controller-Cspecific addresses required to access system memory from a\r
171 DMA bus master. \r
172 \r
173 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
174 @param Operation Indicates if the bus master is going to read or write to system memory.\r
175 @param HostAddress The system memory address to map to the PCI controller.\r
176 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes\r
177 that were mapped. \r
178 @param DeviceAddress The resulting map address for the bus master PCI controller to use to\r
179 access the hosts HostAddress. \r
180 @param Mapping A resulting value to pass to Unmap().\r
181 \r
182 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.\r
183 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer. \r
184 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
185 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.\r
186 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.\r
187 \r
188**/\r
189typedef\r
190EFI_STATUS\r
8b13229b 191(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP)(\r
d1f95000 192 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
193 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,\r
194 IN VOID *HostAddress,\r
195 IN OUT UINTN *NumberOfBytes,\r
196 OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,\r
197 OUT VOID **Mapping\r
198 );\r
199\r
200/** \r
201 Completes the Map() operation and releases any corresponding resources.\r
202 \r
203 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
204 @param Mapping The mapping value returned from Map().\r
205 \r
206 @retval EFI_SUCCESS The range was unmapped.\r
207 @retval EFI_INVALID_PARAMETER Mapping is not a value that was returned by Map().\r
208 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r
209 \r
210**/\r
211typedef\r
212EFI_STATUS\r
8b13229b 213(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP)(\r
d1f95000 214 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
215 IN VOID *Mapping\r
216 );\r
217\r
218/** \r
219 Allocates pages that are suitable for an EfiPciOperationBusMasterCommonBuffer or\r
220 EfiPciOperationBusMasterCommonBuffer64 mapping. \r
221 \r
222 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
223 @param Type This parameter is not used and must be ignored.\r
224 @param MemoryType The type of memory to allocate, EfiBootServicesData or\r
225 EfiRuntimeServicesData. \r
226 @param Pages The number of pages to allocate. \r
227 @param HostAddress A pointer to store the base system memory address of the\r
228 allocated range. \r
229 @param Attributes The requested bit mask of attributes for the allocated range.\r
230 \r
231 @retval EFI_SUCCESS The requested memory pages were allocated.\r
232 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are\r
233 MEMORY_WRITE_COMBINE and MEMORY_CACHED. \r
234 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
235 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. \r
236 \r
237**/\r
238typedef\r
239EFI_STATUS\r
8b13229b 240(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER)(\r
d1f95000 241 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
242 IN EFI_ALLOCATE_TYPE Type,\r
243 IN EFI_MEMORY_TYPE MemoryType,\r
244 IN UINTN Pages,\r
245 IN OUT VOID **HostAddress,\r
246 IN UINT64 Attributes\r
247 );\r
248\r
249/** \r
250 Frees memory that was allocated with AllocateBuffer().\r
251 \r
252 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
253 @param Pages The number of pages to free. \r
254 @param HostAddress The base system memory address of the allocated range. \r
255 \r
256 @retval EFI_SUCCESS The requested memory pages were freed.\r
257 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages\r
258 was not allocated with AllocateBuffer().\r
259 \r
260**/\r
261typedef\r
262EFI_STATUS\r
8b13229b 263(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER)(\r
d1f95000 264 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
265 IN UINTN Pages,\r
266 IN VOID *HostAddress\r
267 );\r
268\r
269/** \r
270 Flushes all PCI posted write transactions from a PCI host bridge to system memory.\r
271 \r
272 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
273 \r
274 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host\r
275 bridge to system memory. \r
276 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI\r
277 host bridge due to a hardware error. \r
278 \r
279**/\r
280typedef\r
281EFI_STATUS\r
8b13229b 282(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH)(\r
d1f95000 283 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This\r
284 );\r
285\r
286/** \r
287 Gets the attributes that a PCI root bridge supports setting with SetAttributes(), and the\r
288 attributes that a PCI root bridge is currently using. \r
289 \r
290 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
291 @param Supports A pointer to the mask of attributes that this PCI root bridge supports\r
292 setting with SetAttributes(). \r
293 @param Attributes A pointer to the mask of attributes that this PCI root bridge is currently\r
294 using. \r
295 \r
296 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI root \r
297 bridge supports is returned in Supports. If Attributes is \r
298 not NULL, then the attributes that the PCI root bridge is currently\r
299 using is returned in Attributes. \r
300 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.\r
301 \r
302 \r
303**/\r
304typedef\r
305EFI_STATUS\r
8b13229b 306(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES)(\r
d1f95000 307 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
308 OUT UINT64 *Supports,\r
309 OUT UINT64 *Attributes\r
310 );\r
311\r
312/** \r
313 Sets attributes for a resource range on a PCI root bridge.\r
314 \r
315 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
316 @param Attributes The mask of attributes to set.\r
317 @param ResourceBase A pointer to the base address of the resource range to be modified by the\r
318 attributes specified by Attributes.\r
319 @param ResourceLength A pointer to the length of the resource range to be modified by the\r
320 attributes specified by Attributes. \r
321 \r
322 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource \r
323 range specified by ResourceBase and ResourceLength \r
324 were set on the PCI root bridge, and the actual resource range is\r
325 returned in ResuourceBase and ResourceLength. \r
326 @retval EFI_UNSUPPORTED A bit is set in Attributes that is not supported by the PCI Root\r
327 Bridge. \r
328 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the \r
329 resource range specified by BaseAddress and Length. \r
330 @retval EFI_INVALID_PARAMETER One or more parameters are invalid. \r
331 \r
332**/\r
333typedef\r
334EFI_STATUS\r
8b13229b 335(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES)(\r
d1f95000 336 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
337 IN UINT64 Attributes,\r
338 IN OUT UINT64 *ResourceBase,\r
339 IN OUT UINT64 *ResourceLength\r
340 );\r
341\r
342/** \r
343 Retrieves the current resource settings of this PCI root bridge in the form of a set of ACPI 2.0\r
344 resource descriptors. \r
345 \r
346 @param This A pointer to the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
347 @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current\r
348 configuration of this PCI root bridge. \r
349 \r
350 @retval EFI_SUCCESS The current configuration of this PCI root bridge was returned in\r
351 Resources. \r
352 @retval EFI_UNSUPPORTED The current configuration of this PCI root bridge could not be\r
353 retrieved. \r
354 \r
355**/\r
356typedef\r
357EFI_STATUS\r
8b13229b 358(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION)(\r
d1f95000 359 IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *This,\r
360 OUT VOID **Resources\r
361 );\r
362\r
4ca9b6c4
LG
363/** \r
364 @par Protocol Description:\r
365 Provides the basic Memory, I/O, PCI configuration, and DMA interfaces that are \r
366 used to abstract accesses to PCI controllers behind a PCI Root Bridge Controller. \r
367 \r
368 @param ParentHandle\r
369 The EFI_HANDLE of the PCI Host Bridge of which this PCI Root Bridge is a member.\r
370\r
371 @param PollMem\r
372 Polls an address in memory mapped I/O space until an exit condition is met, \r
373 or a timeout occurs. \r
374\r
375 @param PollIo\r
376 Polls an address in I/O space until an exit condition is met, or a timeout occurs. \r
377\r
378 @param Mem.Read\r
379 Allows reads from memory mapped I/O space. \r
380\r
381 @param Mem.Write\r
382 Allows writes to memory mapped I/O space. \r
383\r
384 @param Io.Read\r
385 Allows reads from I/O space. \r
386\r
387 @param Io.Write\r
388 Allows writes to I/O space. \r
389\r
390 @param Pci.Read\r
391 Allows reads from PCI configuration space. \r
392\r
393 @param Pci.Write\r
394 Allows writes to PCI configuration space. \r
395\r
396 @param CopyMem\r
397 Allows one region of PCI root bridge memory space to be copied to another \r
398 region of PCI root bridge memory space. \r
399\r
400 @param Map\r
401 Provides the PCI controller's specific addresses needed to access system memory for DMA. \r
402\r
403 @param Unmap\r
404 Releases any resources allocated by Map(). \r
405\r
406 @param AllocateBuffer\r
407 Allocates pages that are suitable for a common buffer mapping. \r
408\r
409 @param FreeBuffer\r
410 Free pages that were allocated with AllocateBuffer(). \r
411\r
412 @param Flush\r
413 Flushes all PCI posted write transactions to system memory. \r
414\r
415 @param GetAttributes\r
416 Gets the attributes that a PCI root bridge supports setting with SetAttributes(), \r
417 and the attributes that a PCI root bridge is currently using. \r
418\r
419 @param SetAttributes\r
420 Sets attributes for a resource range on a PCI root bridge. \r
421\r
422 @param Configuration\r
423 Gets the current resource settings for this PCI root bridge. \r
424\r
425 @param SegmentNumber\r
426 The segment number that this PCI root bridge resides.\r
427\r
428**/\r
d1f95000 429struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {\r
430 EFI_HANDLE ParentHandle;\r
431 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem;\r
432 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo;\r
433 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem;\r
434 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io;\r
435 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci;\r
436 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem;\r
437 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map;\r
438 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap;\r
439 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;\r
440 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer;\r
441 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush;\r
442 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes;\r
443 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes;\r
444 EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration;\r
445 UINT32 SegmentNumber;\r
446};\r
447\r
448extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;\r
449\r
450#endif\r