2 EFI PCI IO protocol functions declaration for PCI Bus module.
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #ifndef _EFI_PCI_IO_PROTOCOL_H_
10 #define _EFI_PCI_IO_PROTOCOL_H_
13 Initializes a PCI I/O Instance.
15 @param PciIoDevice Pci device instance.
19 InitializePciIoInstance (
20 IN PCI_IO_DEVICE
*PciIoDevice
24 Verifies access to a PCI Base Address Register (BAR).
26 @param PciIoDevice Pci device instance.
27 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
28 base address for the memory or I/O operation to perform.
29 @param Type Operation type could be memory or I/O.
30 @param Width Signifies the width of the memory or I/O operations.
31 @param Count The number of memory or I/O operations to perform.
32 @param Offset The offset within the PCI configuration space for the PCI controller.
34 @retval EFI_INVALID_PARAMETER Invalid Width/BarIndex or Bar type.
35 @retval EFI_SUCCESS Successfully verified.
39 PciIoVerifyBarAccess (
40 IN PCI_IO_DEVICE
*PciIoDevice
,
43 IN IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
49 Verifies access to a PCI Configuration Header.
51 @param PciIoDevice Pci device instance.
52 @param Width Signifies the width of the memory or I/O operations.
53 @param Count The number of memory or I/O operations to perform.
54 @param Offset The offset within the PCI configuration space for the PCI controller.
56 @retval EFI_INVALID_PARAMETER Invalid Width
57 @retval EFI_UNSUPPORTED Offset overflowed.
58 @retval EFI_SUCCESS Successfully verified.
62 PciIoVerifyConfigAccess (
63 IN PCI_IO_DEVICE
*PciIoDevice
,
64 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
70 Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is
71 satisfied or after a defined duration.
73 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
74 @param Width Signifies the width of the memory or I/O operations.
75 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
76 base address for the memory operation to perform.
77 @param Offset The offset within the selected BAR to start the memory operation.
78 @param Mask Mask used for the polling criteria.
79 @param Value The comparison value used for the polling exit criteria.
80 @param Delay The number of 100 ns units to poll.
81 @param Result Pointer to the last value read from the memory location.
83 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
84 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
85 @retval EFI_UNSUPPORTED Offset is not valid for the BarIndex of this PCI controller.
86 @retval EFI_TIMEOUT Delay expired before a match occurred.
87 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
88 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
94 IN EFI_PCI_IO_PROTOCOL
*This
,
95 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
105 Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is
106 satisfied or after a defined duration.
108 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
109 @param Width Signifies the width of the memory or I/O operations.
110 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
111 base address for the memory operation to perform.
112 @param Offset The offset within the selected BAR to start the memory operation.
113 @param Mask Mask used for the polling criteria.
114 @param Value The comparison value used for the polling exit criteria.
115 @param Delay The number of 100 ns units to poll.
116 @param Result Pointer to the last value read from the memory location.
118 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
119 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
120 @retval EFI_UNSUPPORTED Offset is not valid for the BarIndex of this PCI controller.
121 @retval EFI_TIMEOUT Delay expired before a match occurred.
122 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
123 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
129 IN EFI_PCI_IO_PROTOCOL
*This
,
130 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
140 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
142 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
143 @param Width Signifies the width of the memory or I/O operations.
144 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
145 base address for the memory or I/O operation to perform.
146 @param Offset The offset within the selected BAR to start the memory or I/O operation.
147 @param Count The number of memory or I/O operations to perform.
148 @param Buffer For read operations, the destination buffer to store the results. For write
149 operations, the source buffer to write data from.
151 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
152 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
153 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
154 valid for the PCI BAR specified by BarIndex.
155 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
156 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
162 IN EFI_PCI_IO_PROTOCOL
*This
,
163 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
171 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
173 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
174 @param Width Signifies the width of the memory or I/O operations.
175 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
176 base address for the memory or I/O operation to perform.
177 @param Offset The offset within the selected BAR to start the memory or I/O operation.
178 @param Count The number of memory or I/O operations to perform.
179 @param Buffer For read operations, the destination buffer to store the results. For write
180 operations, the source buffer to write data from.
182 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
183 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
184 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
185 valid for the PCI BAR specified by BarIndex.
186 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
187 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
193 IN EFI_PCI_IO_PROTOCOL
*This
,
194 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
202 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
204 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
205 @param Width Signifies the width of the memory or I/O operations.
206 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
207 base address for the memory or I/O operation to perform.
208 @param Offset The offset within the selected BAR to start the memory or I/O operation.
209 @param Count The number of memory or I/O operations to perform.
210 @param Buffer For read operations, the destination buffer to store the results. For write
211 operations, the source buffer to write data from.
213 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
214 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
215 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
216 valid for the PCI BAR specified by BarIndex.
217 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
218 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
224 IN EFI_PCI_IO_PROTOCOL
*This
,
225 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
233 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
235 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
236 @param Width Signifies the width of the memory or I/O operations.
237 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
238 base address for the memory or I/O operation to perform.
239 @param Offset The offset within the selected BAR to start the memory or I/O operation.
240 @param Count The number of memory or I/O operations to perform.
241 @param Buffer For read operations, the destination buffer to store the results. For write
242 operations, the source buffer to write data from.
244 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
245 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
246 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
247 valid for the PCI BAR specified by BarIndex.
248 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
249 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
255 IN EFI_PCI_IO_PROTOCOL
*This
,
256 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
264 Enable a PCI driver to access PCI controller registers in PCI configuration space.
266 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
267 @param Width Signifies the width of the memory operations.
268 @param Offset The offset within the PCI configuration space for the PCI controller.
269 @param Count The number of PCI configuration operations to perform.
270 @param Buffer For read operations, the destination buffer to store the results. For write
271 operations, the source buffer to write data from.
274 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
275 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
276 valid for the PCI configuration header of the PCI controller.
277 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
278 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
284 IN EFI_PCI_IO_PROTOCOL
*This
,
285 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
292 Enable a PCI driver to access PCI controller registers in PCI configuration space.
294 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
295 @param Width Signifies the width of the memory operations.
296 @param Offset The offset within the PCI configuration space for the PCI controller.
297 @param Count The number of PCI configuration operations to perform.
298 @param Buffer For read operations, the destination buffer to store the results. For write
299 operations, the source buffer to write data from.
302 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
303 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
304 valid for the PCI configuration header of the PCI controller.
305 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
306 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
312 IN EFI_PCI_IO_PROTOCOL
*This
,
313 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
320 Enables a PCI driver to copy one region of PCI memory space to another region of PCI
323 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
324 @param Width Signifies the width of the memory operations.
325 @param DestBarIndex The BAR index in the standard PCI Configuration header to use as the
326 base address for the memory operation to perform.
327 @param DestOffset The destination offset within the BAR specified by DestBarIndex to
328 start the memory writes for the copy operation.
329 @param SrcBarIndex The BAR index in the standard PCI Configuration header to use as the
330 base address for the memory operation to perform.
331 @param SrcOffset The source offset within the BAR specified by SrcBarIndex to start
332 the memory reads for the copy operation.
333 @param Count The number of memory operations to perform. Bytes moved is Width
334 size * Count, starting at DestOffset and SrcOffset.
336 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
337 @retval EFI_UNSUPPORTED DestBarIndex not valid for this PCI controller.
338 @retval EFI_UNSUPPORTED SrcBarIndex not valid for this PCI controller.
339 @retval EFI_UNSUPPORTED The address range specified by DestOffset, Width, and Count
340 is not valid for the PCI BAR specified by DestBarIndex.
341 @retval EFI_UNSUPPORTED The address range specified by SrcOffset, Width, and Count is
342 not valid for the PCI BAR specified by SrcBarIndex.
343 @retval EFI_INVALID_PARAMETER Width is invalid.
344 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
350 IN EFI_PCI_IO_PROTOCOL
*This
,
351 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
352 IN UINT8 DestBarIndex
,
353 IN UINT64 DestOffset
,
354 IN UINT8 SrcBarIndex
,
360 Provides the PCI controller-specific addresses needed to access system memory.
362 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
363 @param Operation Indicates if the bus master is going to read or write to system memory.
364 @param HostAddress The system memory address to map to the PCI controller.
365 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
367 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
368 access the hosts HostAddress.
369 @param Mapping A resulting value to pass to Unmap().
371 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
372 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
373 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
374 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
375 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
381 IN EFI_PCI_IO_PROTOCOL
*This
,
382 IN EFI_PCI_IO_PROTOCOL_OPERATION Operation
,
383 IN VOID
*HostAddress
,
384 IN OUT UINTN
*NumberOfBytes
,
385 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
390 Completes the Map() operation and releases any corresponding resources.
392 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
393 @param Mapping The mapping value returned from Map().
395 @retval EFI_SUCCESS The range was unmapped.
396 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
402 IN EFI_PCI_IO_PROTOCOL
*This
,
407 Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer
408 or EfiPciOperationBusMasterCommonBuffer64 mapping.
410 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
411 @param Type This parameter is not used and must be ignored.
412 @param MemoryType The type of memory to allocate, EfiBootServicesData or
413 EfiRuntimeServicesData.
414 @param Pages The number of pages to allocate.
415 @param HostAddress A pointer to store the base system memory address of the
417 @param Attributes The requested bit mask of attributes for the allocated range.
419 @retval EFI_SUCCESS The requested memory pages were allocated.
420 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
421 MEMORY_WRITE_COMBINE, MEMORY_CACHED and DUAL_ADDRESS_CYCLE.
422 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
423 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
428 PciIoAllocateBuffer (
429 IN EFI_PCI_IO_PROTOCOL
*This
,
430 IN EFI_ALLOCATE_TYPE Type
,
431 IN EFI_MEMORY_TYPE MemoryType
,
433 OUT VOID
**HostAddress
,
438 Frees memory that was allocated with AllocateBuffer().
440 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
441 @param Pages The number of pages to free.
442 @param HostAddress The base system memory address of the allocated range.
444 @retval EFI_SUCCESS The requested memory pages were freed.
445 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
446 was not allocated with AllocateBuffer().
452 IN EFI_PCI_IO_PROTOCOL
*This
,
458 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
460 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
462 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
463 bridge to system memory.
464 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
465 host bridge due to a hardware error.
471 IN EFI_PCI_IO_PROTOCOL
*This
475 Retrieves this PCI controller's current PCI bus number, device number, and function number.
477 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
478 @param SegmentNumber The PCI controller's current PCI segment number.
479 @param BusNumber The PCI controller's current PCI bus number.
480 @param DeviceNumber The PCI controller's current PCI device number.
481 @param FunctionNumber The PCI controller's current PCI function number.
483 @retval EFI_SUCCESS The PCI controller location was returned.
484 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
490 IN EFI_PCI_IO_PROTOCOL
*This
,
498 Check BAR type for PCI resource.
500 @param PciIoDevice PCI device instance.
501 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
502 base address for the memory or I/O operation to perform.
503 @param BarType Memory or I/O.
505 @retval TRUE Pci device's bar type is same with input BarType.
506 @retval TRUE Pci device's bar type is not same with input BarType.
511 IN PCI_IO_DEVICE
*PciIoDevice
,
513 IN PCI_BAR_TYPE BarType
517 Set/Disable new attributes to a Root Bridge.
519 @param PciIoDevice Pci device instance.
520 @param Attributes New attribute want to be set.
521 @param Operation Set or Disable.
523 @retval EFI_UNSUPPORTED If root bridge does not support change attribute.
524 @retval EFI_SUCCESS Successfully set new attributes.
528 ModifyRootBridgeAttributes (
529 IN PCI_IO_DEVICE
*PciIoDevice
,
530 IN UINT64 Attributes
,
531 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
535 Check whether this device can be enable/disable to snoop.
537 @param PciIoDevice Pci device instance.
538 @param Operation Enable/Disable.
540 @retval EFI_UNSUPPORTED Pci device is not GFX device or not support snoop.
541 @retval EFI_SUCCESS Snoop can be supported.
545 SupportPaletteSnoopAttributes (
546 IN PCI_IO_DEVICE
*PciIoDevice
,
547 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
551 Performs an operation on the attributes that this PCI controller supports. The operations include
552 getting the set of supported attributes, retrieving the current attributes, setting the current
553 attributes, enabling attributes, and disabling attributes.
555 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
556 @param Operation The operation to perform on the attributes for this PCI controller.
557 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
559 @param Result A pointer to the result mask of attributes that are returned for the Get
560 and Supported operations.
562 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
563 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
564 @retval EFI_UNSUPPORTED one or more of the bits set in
565 Attributes are not supported by this PCI controller or one of
566 its parent bridges when Operation is Set, Enable or Disable.
572 IN EFI_PCI_IO_PROTOCOL
* This
,
573 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
574 IN UINT64 Attributes
,
575 OUT UINT64
*Result OPTIONAL
579 Gets the attributes that this PCI controller supports setting on a BAR using
580 SetBarAttributes(), and retrieves the list of resource descriptors for a BAR.
582 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
583 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
584 base address for resource range. The legal range for this field is 0..5.
585 @param Supports A pointer to the mask of attributes that this PCI controller supports
586 setting for this BAR with SetBarAttributes().
587 @param Resources A pointer to the resource descriptors that describe the current
588 configuration of this BAR of the PCI controller.
590 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI
591 controller supports are returned in Supports. If Resources
592 is not NULL, then the resource descriptors that the PCI
593 controller is currently using are returned in Resources.
594 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
595 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
596 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate
602 PciIoGetBarAttributes (
603 IN EFI_PCI_IO_PROTOCOL
* This
,
605 OUT UINT64
*Supports
, OPTIONAL
606 OUT VOID
**Resources OPTIONAL
610 Sets the attributes for a range of a BAR on a PCI controller.
612 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
613 @param Attributes The mask of attributes to set for the resource range specified by
614 BarIndex, Offset, and Length.
615 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
616 base address for resource range. The legal range for this field is 0..5.
617 @param Offset A pointer to the BAR relative base address of the resource range to be
618 modified by the attributes specified by Attributes.
619 @param Length A pointer to the length of the resource range to be modified by the
620 attributes specified by Attributes.
622 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
623 range specified by BarIndex, Offset, and Length were
624 set on the PCI controller, and the actual resource range is returned
625 in Offset and Length.
626 @retval EFI_INVALID_PARAMETER Offset or Length is NULL.
627 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
628 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
629 resource range specified by BarIndex, Offset, and
635 PciIoSetBarAttributes (
636 IN EFI_PCI_IO_PROTOCOL
*This
,
637 IN UINT64 Attributes
,
639 IN OUT UINT64
*Offset
,
640 IN OUT UINT64
*Length
645 Test whether two Pci devices has same parent bridge.
647 @param PciDevice1 The first pci device for testing.
648 @param PciDevice2 The second pci device for testing.
650 @retval TRUE Two Pci device has the same parent bridge.
651 @retval FALSE Two Pci device has not the same parent bridge.
655 PciDevicesOnTheSamePath (
656 IN PCI_IO_DEVICE
*PciDevice1
,
657 IN PCI_IO_DEVICE
*PciDevice2