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.
25 InitializePciIoInstance (
26 PCI_IO_DEVICE
*PciIoDevice
30 Verifies access to a PCI Base Address Register (BAR)
32 @param PciIoDevice Pci device instance
33 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
34 base address for the memory or I/O operation to perform.
35 @param Type Operation type could be memory or I/O
36 @param Width Signifies the width of the memory or I/O operations.
37 @param Count The number of memory or I/O operations to perform.
38 @param Offset The offset within the PCI configuration space for the PCI controller.
40 @retval EFI_INVALID_PARAMETER Invalid Width/BarIndex or Bar type.
41 @retval EFI_SUCCESS Success Operation.
44 PciIoVerifyBarAccess (
45 PCI_IO_DEVICE
*PciIoDevice
,
48 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
54 Verifies access to a PCI Config Header
56 @param PciIoDevice Pci device instance
57 @param Width Signifies the width of the memory or I/O operations.
58 @param Count The number of memory or I/O operations to perform.
59 @param Offset The offset within the PCI configuration space for the PCI controller.
61 @retval EFI_INVALID_PARAMETER Invalid Width.
62 @retval EFI_UNSUPPORTED Offset overflow.
63 @retval EFI_SUCCESS Success operation.
66 PciIoVerifyConfigAccess (
67 PCI_IO_DEVICE
*PciIoDevice
,
68 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
74 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
75 satisfied or after a defined duration.
77 @param This Pointer to protocol instance of EFI_PCI_IO_PROTOCOL
78 @param Width Signifies the width of the memory or I/O operations.
79 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
80 base address for the memory or I/O operation to perform.
81 @param Offset The offset within the PCI configuration space for the PCI controller.
82 @param Mask Mask used for the polling criteria.
83 @param Value The comparison value used for the polling exit criteria.
84 @param Delay The number of 100 ns units to poll.
85 @param Result Pointer to the last value read from the memory location.
87 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
88 @retval EFI_TIMEOUT Delay expired before a match occurred.
89 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
90 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
95 IN EFI_PCI_IO_PROTOCOL
*This
,
96 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
106 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
107 satisfied or after a defined duration.
109 @param This A pointer to the EFI_PCI_IO_PROTOCOL.
110 @param Width Signifies the width of the memory or I/O operations.
111 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
112 base address for the memory or I/O operation to perform.
113 @param Offset The offset within the selected BAR to start the memory or I/O operation.
114 @param Mask Mask used for the polling criteria.
115 @param Value The comparison value used for the polling exit criteria.
116 @param Delay The number of 100 ns units to poll.
117 @param Result Pointer to the last value read from the memory location.
119 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
120 @retval EFI_TIMEOUT Delay expired before a match occurred.
121 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
122 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
128 IN EFI_PCI_IO_PROTOCOL
*This
,
129 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
139 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
141 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
142 @param Width Signifies the width of the memory or I/O operations.
143 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
144 base address for the memory or I/O operation to perform.
145 @param Offset The offset within the selected BAR to start the memory or I/O operation.
146 @param Count The number of memory or I/O operations to perform.
147 @param Buffer For read operations, the destination buffer to store the results. For write
148 operations, the source buffer to write data from.
150 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
151 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
152 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
153 valid for the PCI BAR specified by BarIndex.
154 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
155 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
161 IN EFI_PCI_IO_PROTOCOL
*This
,
162 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
170 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
172 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
173 @param Width Signifies the width of the memory or I/O operations.
174 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
175 base address for the memory or I/O operation to perform.
176 @param Offset The offset within the selected BAR to start the memory or I/O operation.
177 @param Count The number of memory or I/O operations to perform.
178 @param Buffer For read operations, the destination buffer to store the results. For write
179 operations, the source buffer to write data from.
181 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
182 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
183 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
184 valid for the PCI BAR specified by BarIndex.
185 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
186 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
192 IN EFI_PCI_IO_PROTOCOL
*This
,
193 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
201 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
203 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
204 @param Width Signifies the width of the memory or I/O operations.
205 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
206 base address for the memory or I/O operation to perform.
207 @param Offset The offset within the selected BAR to start the memory or I/O operation.
208 @param Count The number of memory or I/O operations to perform.
209 @param Buffer For read operations, the destination buffer to store the results. For write
210 operations, the source buffer to write data from.
212 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
213 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
214 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
215 valid for the PCI BAR specified by BarIndex.
216 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
217 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
223 IN EFI_PCI_IO_PROTOCOL
*This
,
224 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
232 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
234 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
235 @param Width Signifies the width of the memory or I/O operations.
236 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
237 base address for the memory or I/O operation to perform.
238 @param Offset The offset within the selected BAR to start the memory or I/O operation.
239 @param Count The number of memory or I/O operations to perform.
240 @param Buffer For read operations, the destination buffer to store the results. For write
241 operations, the source buffer to write data from.
243 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
244 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
245 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
246 valid for the PCI BAR specified by BarIndex.
247 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
248 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
254 IN EFI_PCI_IO_PROTOCOL
*This
,
255 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
263 Enable a PCI driver to access PCI controller registers in PCI configuration space.
265 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
266 @param Width Signifies the width of the memory operations.
267 @param Offset The offset within the PCI configuration space for the PCI controller.
268 @param Count The number of PCI configuration operations to perform.
269 @param Buffer For read operations, the destination buffer to store the results. For write
270 operations, the source buffer to write data from.
273 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
274 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
275 valid for the PCI configuration header of the PCI controller.
276 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
277 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
283 IN EFI_PCI_IO_PROTOCOL
*This
,
284 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
291 Enable a PCI driver to access PCI controller registers in PCI configuration space.
293 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
294 @param Width Signifies the width of the memory operations.
295 @param Offset The offset within the PCI configuration space for the PCI controller.
296 @param Count The number of PCI configuration operations to perform.
297 @param Buffer For read operations, the destination buffer to store the results. For write
298 operations, the source buffer to write data from.
301 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
302 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
303 valid for the PCI configuration header of the PCI controller.
304 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
305 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
311 IN EFI_PCI_IO_PROTOCOL
*This
,
312 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
319 Enables a PCI driver to copy one region of PCI memory space to another region of PCI
322 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
323 @param Width Signifies the width of the memory operations.
324 @param DestBarIndex The BAR index in the standard PCI Configuration header to use as the
325 base address for the memory operation to perform.
326 @param DestOffset The destination offset within the BAR specified by DestBarIndex to
327 start the memory writes for the copy operation.
328 @param SrcBarIndex The BAR index in the standard PCI Configuration header to use as the
329 base address for the memory operation to perform.
330 @param SrcOffset The source offset within the BAR specified by SrcBarIndex to start
331 the memory reads for the copy operation.
332 @param Count The number of memory operations to perform. Bytes moved is Width
333 size * Count, starting at DestOffset and SrcOffset.
335 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
336 @retval EFI_UNSUPPORTED DestBarIndex not valid for this PCI controller.
337 @retval EFI_UNSUPPORTED SrcBarIndex not valid for this PCI controller.
338 @retval EFI_UNSUPPORTED The address range specified by DestOffset, Width, and Count
339 is not valid for the PCI BAR specified by DestBarIndex.
340 @retval EFI_UNSUPPORTED The address range specified by SrcOffset, Width, and Count is
341 not valid for the PCI BAR specified by SrcBarIndex.
342 @retval EFI_INVALID_PARAMETER Width is invalid.
343 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
349 IN EFI_PCI_IO_PROTOCOL
*This
,
350 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
351 IN UINT8 DestBarIndex
,
352 IN UINT64 DestOffset
,
353 IN UINT8 SrcBarIndex
,
359 Provides the PCI controller-Cspecific addresses needed to access system memory.
361 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
362 @param Operation Indicates if the bus master is going to read or write to system memory.
363 @param HostAddress The system memory address to map to the PCI controller.
364 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
366 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
367 access the hosts HostAddress.
368 @param Mapping A resulting value to pass to Unmap().
370 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
371 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
372 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
373 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
374 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
380 IN EFI_PCI_IO_PROTOCOL
*This
,
381 IN EFI_PCI_IO_PROTOCOL_OPERATION Operation
,
382 IN VOID
*HostAddress
,
383 IN OUT UINTN
*NumberOfBytes
,
384 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
389 Completes the Map() operation and releases any corresponding resources.
391 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
392 @param Mapping The mapping value returned from Map().
394 @retval EFI_SUCCESS The range was unmapped.
395 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
401 IN EFI_PCI_IO_PROTOCOL
*This
,
406 Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer
409 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
410 @param Type This parameter is not used and must be ignored.
411 @param MemoryType The type of memory to allocate, EfiBootServicesData or
412 EfiRuntimeServicesData.
413 @param Pages The number of pages to allocate.
414 @param HostAddress A pointer to store the base system memory address of the
416 @param Attributes The requested bit mask of attributes for the allocated range.
418 @retval EFI_SUCCESS The requested memory pages were allocated.
419 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
420 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
421 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
422 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
427 PciIoAllocateBuffer (
428 IN EFI_PCI_IO_PROTOCOL
*This
,
429 IN EFI_ALLOCATE_TYPE Type
,
430 IN EFI_MEMORY_TYPE MemoryType
,
432 OUT VOID
**HostAddress
,
437 Frees memory that was allocated with AllocateBuffer().
439 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
440 @param Pages The number of pages to free.
441 @param HostAddress The base system memory address of the allocated range.
443 @retval EFI_SUCCESS The requested memory pages were freed.
444 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
445 was not allocated with AllocateBuffer().
451 IN EFI_PCI_IO_PROTOCOL
*This
,
457 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
459 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
461 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
462 bridge to system memory.
463 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
464 host bridge due to a hardware error.
470 IN EFI_PCI_IO_PROTOCOL
*This
474 Retrieves this PCI controller's current PCI bus number, device number, and function number.
476 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
477 @param SegmentNumber The PCI controller's current PCI segment number.
478 @param BusNumber The PCI controller's current PCI bus number.
479 @param DeviceNumber The PCI controller's current PCI device number.
480 @param FunctionNumber The PCI controller's current PCI function number.
482 @retval EFI_SUCCESS The PCI controller location was returned.
483 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
489 IN EFI_PCI_IO_PROTOCOL
*This
,
497 Check BAR type for PCI resource.
499 @param PciIoDevice PCI device instance
500 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
501 base address for the memory or I/O operation to perform.
502 @param BarType Memory or I/O
504 @return whether Pci device's bar type is same with input BarType.
508 IN PCI_IO_DEVICE
*PciIoDevice
,
514 Set/Disable new attributes to a Root Bridge
516 @param PciIoDevice Pci device instance
517 @param Attributes New attribute want to be set
518 @param Operation Set or Disable
520 @retval EFI_UNSUPPORTED If root bridge does not support change attribute
521 @retval EFI_SUCCESS Success operation.
524 ModifyRootBridgeAttributes (
525 IN PCI_IO_DEVICE
*PciIoDevice
,
526 IN UINT64 Attributes
,
527 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
531 Check whether this device can be enable/disable to snoop
533 @param PciIoDevice Pci device instance
534 @param Operation Enable/Disable
536 @retval EFI_UNSUPPORTED Pci device is not GFX device or not support snoop
537 @retval EFI_SUCCESS Snoop can be supported.
540 SupportPaletteSnoopAttributes (
541 IN PCI_IO_DEVICE
*PciIoDevice
,
542 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
546 Performs an operation on the attributes that this PCI controller supports. The operations include
547 getting the set of supported attributes, retrieving the current attributes, setting the current
548 attributes, enabling attributes, and disabling attributes.
550 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
551 @param Operation The operation to perform on the attributes for this PCI controller.
552 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
554 @param Result A pointer to the result mask of attributes that are returned for the Get
555 and Supported operations.
557 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
558 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
559 @retval EFI_UNSUPPORTED one or more of the bits set in
560 Attributes are not supported by this PCI controller or one of
561 its parent bridges when Operation is Set, Enable or Disable.
567 IN EFI_PCI_IO_PROTOCOL
* This
,
568 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
569 IN UINT64 Attributes
,
570 OUT UINT64
*Result OPTIONAL
574 Gets the attributes that this PCI controller supports setting on a BAR using
575 SetBarAttributes(), and retrieves the list of resource descriptors for a BAR.
577 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
578 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
579 base address for resource range. The legal range for this field is 0..5.
580 @param Supports A pointer to the mask of attributes that this PCI controller supports
581 setting for this BAR with SetBarAttributes().
582 @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current
583 configuration of this BAR of the PCI controller.
585 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI
586 controller supports are returned in Supports. If Resources
587 is not NULL, then the ACPI 2.0 resource descriptors that the PCI
588 controller is currently using are returned in Resources.
589 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
590 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
591 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate
597 PciIoGetBarAttributes (
598 IN EFI_PCI_IO_PROTOCOL
* This
,
600 OUT UINT64
*Supports
, OPTIONAL
601 OUT VOID
**Resources OPTIONAL
605 Sets the attributes for a range of a BAR on a PCI controller.
607 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
608 @param Attributes The mask of attributes to set for the resource range specified by
609 BarIndex, Offset, and Length.
610 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
611 base address for resource range. The legal range for this field is 0..5.
612 @param Offset A pointer to the BAR relative base address of the resource range to be
613 modified by the attributes specified by Attributes.
614 @param Length A pointer to the length of the resource range to be modified by the
615 attributes specified by Attributes.
617 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
618 range specified by BarIndex, Offset, and Length were
619 set on the PCI controller, and the actual resource range is returned
620 in Offset and Length.
621 @retval EFI_INVALID_PARAMETER Offset or Length is NULL.
622 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
623 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
624 resource range specified by BarIndex, Offset, and
630 PciIoSetBarAttributes (
631 IN EFI_PCI_IO_PROTOCOL
*This
,
632 IN UINT64 Attributes
,
634 IN OUT UINT64
*Offset
,
635 IN OUT UINT64
*Length
639 Program parent bridge's attribute recurrently.
641 @param PciIoDevice Child Pci device instance
642 @param Operation The operation to perform on the attributes for this PCI controller.
643 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
646 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
647 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
648 @retval EFI_UNSUPPORTED one or more of the bits set in
649 Attributes are not supported by this PCI controller or one of
650 its parent bridges when Operation is Set, Enable or Disable.
654 UpStreamBridgesAttributes (
655 IN PCI_IO_DEVICE
*PciIoDevice
,
656 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
661 Test whether two Pci device has same parent bridge.
663 @param PciDevice1 the frist pci device for testing
664 @param PciDevice2 the second pci device for testing
666 @return whether two Pci device has same parent bridge.
669 PciDevicesOnTheSamePath (
670 IN PCI_IO_DEVICE
*PciDevice1
,
671 IN PCI_IO_DEVICE
*PciDevice2