3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef _EFI_PCI_IO_PROTOCOL_H
16 #define _EFI_PCI_IO_PROTOCOL_H
19 Initializes a PCI I/O Instance
21 @param PciIoDevice Pci device instance
23 @retval EFI_SUCCESS Success operation
26 InitializePciIoInstance (
27 PCI_IO_DEVICE
*PciIoDevice
32 Verifies access to a PCI Base Address Register (BAR)
34 @param PciIoDevice Pci device instance
35 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
36 base address for the memory or I/O operation to perform.
37 @param Type Operation type could be memory or I/O
38 @param Width Signifies the width of the memory or I/O operations.
39 @param Count The number of memory or I/O operations to perform.
40 @param Offset The offset within the PCI configuration space for the PCI controller.
42 @retval EFI_INVALID_PARAMETER Invalid Width/BarIndex or Bar type.
43 @retval EFI_SUCCESS Success Operation.
46 PciIoVerifyBarAccess (
47 PCI_IO_DEVICE
*PciIoDevice
,
50 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
57 Verifies access to a PCI Config Header
59 @param PciIoDevice Pci device instance
60 @param Width Signifies the width of the memory or I/O operations.
61 @param Count The number of memory or I/O operations to perform.
62 @param Offset The offset within the PCI configuration space for the PCI controller.
64 @retval EFI_INVALID_PARAMETER Invalid Width
65 @retval EFI_UNSUPPORTED Offset overflow
66 @retval EFI_SUCCESS Success operation
69 PciIoVerifyConfigAccess (
70 PCI_IO_DEVICE
*PciIoDevice
,
71 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
78 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
79 satisfied or after a defined duration.
81 @param This Pointer to protocol instance of EFI_PCI_IO_PROTOCOL
82 @param Width Signifies the width of the memory or I/O operations.
83 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
84 base address for the memory or I/O operation to perform.
85 @param Offset The offset within the PCI configuration space for the PCI controller.
86 @param Mask Mask used for the polling criteria.
87 @param Value The comparison value used for the polling exit criteria.
88 @param Delay The number of 100 ns units to poll.
89 @param Result Pointer to the last value read from the memory location.
91 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
92 @retval EFI_TIMEOUT Delay expired before a match occurred.
93 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
94 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
99 IN EFI_PCI_IO_PROTOCOL
*This
,
100 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
111 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
112 satisfied or after a defined duration.
114 @param This A pointer to the EFI_PCI_IO_PROTOCOL.
115 @param Width Signifies the width of the memory or I/O operations.
116 @param Address The base address of the memory or I/O operations.
117 @param Mask Mask used for the polling criteria.
118 @param Value The comparison value used for the polling exit criteria.
119 @param Delay The number of 100 ns units to poll.
120 @param Result Pointer to the last value read from the memory location.
122 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
123 @retval EFI_TIMEOUT Delay expired before a match occurred.
124 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
125 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
131 IN EFI_PCI_IO_PROTOCOL
*This
,
132 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
143 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
145 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
146 @param Width Signifies the width of the memory or I/O operations.
147 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
148 base address for the memory or I/O operation to perform.
149 @param Offset The offset within the selected BAR to start the memory or I/O operation.
150 @param Count The number of memory or I/O operations to perform.
151 @param Buffer For read operations, the destination buffer to store the results. For write
152 operations, the source buffer to write data from.
154 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
155 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
156 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
157 valid for the PCI BAR specified by BarIndex.
158 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
159 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
165 IN EFI_PCI_IO_PROTOCOL
*This
,
166 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
175 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
177 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
178 @param Width Signifies the width of the memory or I/O operations.
179 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
180 base address for the memory or I/O operation to perform.
181 @param Offset The offset within the selected BAR to start the memory or I/O operation.
182 @param Count The number of memory or I/O operations to perform.
183 @param Buffer For read operations, the destination buffer to store the results. For write
184 operations, the source buffer to write data from.
186 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
187 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
188 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
189 valid for the PCI BAR specified by BarIndex.
190 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
191 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
197 IN EFI_PCI_IO_PROTOCOL
*This
,
198 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
207 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
209 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
210 @param Width Signifies the width of the memory or I/O operations.
211 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
212 base address for the memory or I/O operation to perform.
213 @param Offset The offset within the selected BAR to start the memory or I/O operation.
214 @param Count The number of memory or I/O operations to perform.
215 @param Buffer For read operations, the destination buffer to store the results. For write
216 operations, the source buffer to write data from.
218 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
219 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
220 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
221 valid for the PCI BAR specified by BarIndex.
222 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
223 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
229 IN EFI_PCI_IO_PROTOCOL
*This
,
230 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
239 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
241 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
242 @param Width Signifies the width of the memory or I/O operations.
243 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
244 base address for the memory or I/O operation to perform.
245 @param Offset The offset within the selected BAR to start the memory or I/O operation.
246 @param Count The number of memory or I/O operations to perform.
247 @param Buffer For read operations, the destination buffer to store the results. For write
248 operations, the source buffer to write data from.
250 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
251 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
252 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
253 valid for the PCI BAR specified by BarIndex.
254 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
255 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
261 IN EFI_PCI_IO_PROTOCOL
*This
,
262 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
271 Enable a PCI driver to access PCI controller registers in PCI configuration space.
273 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
274 @param Width Signifies the width of the memory operations.
275 @param Offset The offset within the PCI configuration space for the PCI controller.
276 @param Count The number of PCI configuration operations to perform.
277 @param Buffer For read operations, the destination buffer to store the results. For write
278 operations, the source buffer to write data from.
281 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
282 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
283 valid for the PCI configuration header of the PCI controller.
284 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
285 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
291 IN EFI_PCI_IO_PROTOCOL
*This
,
292 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
300 Enable a PCI driver to access PCI controller registers in PCI configuration space.
302 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
303 @param Width Signifies the width of the memory operations.
304 @param Offset The offset within the PCI configuration space for the PCI controller.
305 @param Count The number of PCI configuration operations to perform.
306 @param Buffer For read operations, the destination buffer to store the results. For write
307 operations, the source buffer to write data from.
310 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
311 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
312 valid for the PCI configuration header of the PCI controller.
313 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
314 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
320 IN EFI_PCI_IO_PROTOCOL
*This
,
321 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
329 Enables a PCI driver to copy one region of PCI memory space to another region of PCI
332 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
333 @param Width Signifies the width of the memory operations.
334 @param DestBarIndex The BAR index in the standard PCI Configuration header to use as the
335 base address for the memory operation to perform.
336 @param DestOffset The destination offset within the BAR specified by DestBarIndex to
337 start the memory writes for the copy operation.
338 @param SrcBarIndex The BAR index in the standard PCI Configuration header to use as the
339 base address for the memory operation to perform.
340 @param SrcOffset The source offset within the BAR specified by SrcBarIndex to start
341 the memory reads for the copy operation.
342 @param Count The number of memory operations to perform. Bytes moved is Width
343 size * Count, starting at DestOffset and SrcOffset.
345 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
346 @retval EFI_UNSUPPORTED DestBarIndex not valid for this PCI controller.
347 @retval EFI_UNSUPPORTED SrcBarIndex not valid for this PCI controller.
348 @retval EFI_UNSUPPORTED The address range specified by DestOffset, Width, and Count
349 is not valid for the PCI BAR specified by DestBarIndex.
350 @retval EFI_UNSUPPORTED The address range specified by SrcOffset, Width, and Count is
351 not valid for the PCI BAR specified by SrcBarIndex.
352 @retval EFI_INVALID_PARAMETER Width is invalid.
353 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
359 IN EFI_PCI_IO_PROTOCOL
*This
,
360 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
361 IN UINT8 DestBarIndex
,
362 IN UINT64 DestOffset
,
363 IN UINT8 SrcBarIndex
,
370 Provides the PCI controller-Cspecific addresses needed to access system memory.
372 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
373 @param Operation Indicates if the bus master is going to read or write to system memory.
374 @param HostAddress The system memory address to map to the PCI controller.
375 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
377 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
378 access the hosts HostAddress.
379 @param Mapping A resulting value to pass to Unmap().
381 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
382 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
383 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
384 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
385 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
391 IN EFI_PCI_IO_PROTOCOL
*This
,
392 IN EFI_PCI_IO_PROTOCOL_OPERATION Operation
,
393 IN VOID
*HostAddress
,
394 IN OUT UINTN
*NumberOfBytes
,
395 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
401 Completes the Map() operation and releases any corresponding resources.
403 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
404 @param Mapping The mapping value returned from Map().
406 @retval EFI_SUCCESS The range was unmapped.
407 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
413 IN EFI_PCI_IO_PROTOCOL
*This
,
419 Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer
422 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
423 @param Type This parameter is not used and must be ignored.
424 @param MemoryType The type of memory to allocate, EfiBootServicesData or
425 EfiRuntimeServicesData.
426 @param Pages The number of pages to allocate.
427 @param HostAddress A pointer to store the base system memory address of the
429 @param Attributes The requested bit mask of attributes for the allocated range.
431 @retval EFI_SUCCESS The requested memory pages were allocated.
432 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
433 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
434 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
435 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
440 PciIoAllocateBuffer (
441 IN EFI_PCI_IO_PROTOCOL
*This
,
442 IN EFI_ALLOCATE_TYPE Type
,
443 IN EFI_MEMORY_TYPE MemoryType
,
445 OUT VOID
**HostAddress
,
451 Frees memory that was allocated with AllocateBuffer().
453 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
454 @param Pages The number of pages to free.
455 @param HostAddress The base system memory address of the allocated range.
457 @retval EFI_SUCCESS The requested memory pages were freed.
458 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
459 was not allocated with AllocateBuffer().
465 IN EFI_PCI_IO_PROTOCOL
*This
,
472 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
474 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
476 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
477 bridge to system memory.
478 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
479 host bridge due to a hardware error.
485 IN EFI_PCI_IO_PROTOCOL
*This
490 Retrieves this PCI controller's current PCI bus number, device number, and function number.
492 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
493 @param SegmentNumber The PCI controller's current PCI segment number.
494 @param BusNumber The PCI controller's current PCI bus number.
495 @param DeviceNumber The PCI controller's current PCI device number.
496 @param FunctionNumber The PCI controller's current PCI function number.
498 @retval EFI_SUCCESS The PCI controller location was returned.
499 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
505 IN EFI_PCI_IO_PROTOCOL
*This
,
514 Check BAR type for PCI resource.
516 @param PciIoDevice PCI device instance
517 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
518 base address for the memory or I/O operation to perform.
519 @param BarType Memory or I/O
521 @return whether Pci device's bar type is same with input BarType.
525 IN PCI_IO_DEVICE
*PciIoDevice
,
532 Set/Disable new attributes to a Root Bridge
534 @param PciIoDevice Pci device instance
535 @param Attributes New attribute want to be set
536 @param Operation Set or Disable
538 @retval EFI_UNSUPPORTED If root bridge does not support change attribute
539 @retval EFI_SUCCESS Success operation.
542 ModifyRootBridgeAttributes (
543 IN PCI_IO_DEVICE
*PciIoDevice
,
544 IN UINT64 Attributes
,
545 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
550 Check whether this device can be enable/disable to snoop
552 @param PciIoDevice Pci device instance
553 @param Operation Enable/Disable
555 @retval EFI_UNSUPPORTED Pci device is not GFX device or not support snoop
556 @retval EFI_SUCCESS Snoop can be supported.
559 SupportPaletteSnoopAttributes (
560 IN PCI_IO_DEVICE
*PciIoDevice
,
561 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
566 Performs an operation on the attributes that this PCI controller supports. The operations include
567 getting the set of supported attributes, retrieving the current attributes, setting the current
568 attributes, enabling attributes, and disabling attributes.
570 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
571 @param Operation The operation to perform on the attributes for this PCI controller.
572 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
574 @param Result A pointer to the result mask of attributes that are returned for the Get
575 and Supported operations.
577 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
578 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
579 @retval EFI_UNSUPPORTED one or more of the bits set in
580 Attributes are not supported by this PCI controller or one of
581 its parent bridges when Operation is Set, Enable or Disable.
587 IN EFI_PCI_IO_PROTOCOL
* This
,
588 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
589 IN UINT64 Attributes
,
590 OUT UINT64
*Result OPTIONAL
595 Gets the attributes that this PCI controller supports setting on a BAR using
596 SetBarAttributes(), and retrieves the list of resource descriptors for a BAR.
598 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
599 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
600 base address for resource range. The legal range for this field is 0..5.
601 @param Supports A pointer to the mask of attributes that this PCI controller supports
602 setting for this BAR with SetBarAttributes().
603 @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current
604 configuration of this BAR of the PCI controller.
606 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI
607 controller supports are returned in Supports. If Resources
608 is not NULL, then the ACPI 2.0 resource descriptors that the PCI
609 controller is currently using are returned in Resources.
610 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
611 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
612 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate
618 PciIoGetBarAttributes (
619 IN EFI_PCI_IO_PROTOCOL
* This
,
621 OUT UINT64
*Supports
, OPTIONAL
622 OUT VOID
**Resources OPTIONAL
627 Sets the attributes for a range of a BAR on a PCI controller.
629 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
630 @param Attributes The mask of attributes to set for the resource range specified by
631 BarIndex, Offset, and Length.
632 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
633 base address for resource range. The legal range for this field is 0..5.
634 @param Offset A pointer to the BAR relative base address of the resource range to be
635 modified by the attributes specified by Attributes.
636 @param Length A pointer to the length of the resource range to be modified by the
637 attributes specified by Attributes.
639 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
640 range specified by BarIndex, Offset, and Length were
641 set on the PCI controller, and the actual resource range is returned
642 in Offset and Length.
643 @retval EFI_INVALID_PARAMETER Offset or Length is NULL.
644 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
645 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
646 resource range specified by BarIndex, Offset, and
652 PciIoSetBarAttributes (
653 IN EFI_PCI_IO_PROTOCOL
*This
,
654 IN UINT64 Attributes
,
656 IN OUT UINT64
*Offset
,
657 IN OUT UINT64
*Length
662 Program parent bridge's attribute recurrently.
664 @param PciIoDevice Child Pci device instance
665 @param Operation The operation to perform on the attributes for this PCI controller.
666 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
669 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
670 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
671 @retval EFI_UNSUPPORTED one or more of the bits set in
672 Attributes are not supported by this PCI controller or one of
673 its parent bridges when Operation is Set, Enable or Disable.
677 UpStreamBridgesAttributes (
678 IN PCI_IO_DEVICE
*PciIoDevice
,
679 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
685 Test whether two Pci device has same parent bridge.
687 @param PciDevice1 the frist pci device for testing
688 @param PciDevice2 the second pci device for testing
690 @return whether two Pci device has same parent bridge.
693 PciDevicesOnTheSamePath (
694 IN PCI_IO_DEVICE
*PciDevice1
,
695 IN PCI_IO_DEVICE
*PciDevice2