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
31 Verifies access to a PCI Base Address Register (BAR)
33 @param PciIoDevice Pci device instance
34 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
35 base address for the memory or I/O operation to perform.
36 @param Type Operation type could be memory or I/O
37 @param Width Signifies the width of the memory or I/O operations.
38 @param Count The number of memory or I/O operations to perform.
39 @param Offset The offset within the PCI configuration space for the PCI controller.
41 @retval EFI_INVALID_PARAMETER Invalid Width/BarIndex or Bar type.
42 @retval EFI_SUCCESS Success Operation.
45 PciIoVerifyBarAccess (
46 PCI_IO_DEVICE
*PciIoDevice
,
49 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
55 Verifies access to a PCI Config Header
57 @param PciIoDevice Pci device instance
58 @param Width Signifies the width of the memory or I/O operations.
59 @param Count The number of memory or I/O operations to perform.
60 @param Offset The offset within the PCI configuration space for the PCI controller.
62 @retval EFI_INVALID_PARAMETER Invalid Width
63 @retval EFI_UNSUPPORTED Offset overflow
64 @retval EFI_SUCCESS Success operation
67 PciIoVerifyConfigAccess (
68 PCI_IO_DEVICE
*PciIoDevice
,
69 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
75 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
76 satisfied or after a defined duration.
78 @param This Pointer to protocol instance of EFI_PCI_IO_PROTOCOL
79 @param Width Signifies the width of the memory or I/O operations.
80 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
81 base address for the memory or I/O operation to perform.
82 @param Offset The offset within the PCI configuration space for the PCI controller.
83 @param Mask Mask used for the polling criteria.
84 @param Value The comparison value used for the polling exit criteria.
85 @param Delay The number of 100 ns units to poll.
86 @param Result Pointer to the last value read from the memory location.
88 @retval EFI_SUCCESS The last data returned from the access matched the poll exit criteria.
89 @retval EFI_TIMEOUT Delay expired before a match occurred.
90 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
91 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
96 IN EFI_PCI_IO_PROTOCOL
*This
,
97 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
107 Reads from the I/O space of a PCI Root Bridge. Returns when either the polling exit criteria is
108 satisfied or after a defined duration.
110 @param This A pointer to the EFI_PCI_IO_PROTOCOL.
111 @param Width Signifies the width of the memory or I/O operations.
112 @param Address The base address of the memory or I/O operations.
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_TIMEOUT Delay expired before a match occurred.
120 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
121 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
127 IN EFI_PCI_IO_PROTOCOL
*This
,
128 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
138 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
140 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
141 @param Width Signifies the width of the memory or I/O operations.
142 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
143 base address for the memory or I/O operation to perform.
144 @param Offset The offset within the selected BAR to start the memory or I/O operation.
145 @param Count The number of memory or I/O operations to perform.
146 @param Buffer For read operations, the destination buffer to store the results. For write
147 operations, the source buffer to write data from.
149 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
150 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
151 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
152 valid for the PCI BAR specified by BarIndex.
153 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
154 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
160 IN EFI_PCI_IO_PROTOCOL
*This
,
161 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
169 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
171 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
172 @param Width Signifies the width of the memory or I/O operations.
173 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
174 base address for the memory or I/O operation to perform.
175 @param Offset The offset within the selected BAR to start the memory or I/O operation.
176 @param Count The number of memory or I/O operations to perform.
177 @param Buffer For read operations, the destination buffer to store the results. For write
178 operations, the source buffer to write data from.
180 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
181 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
182 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
183 valid for the PCI BAR specified by BarIndex.
184 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
185 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
191 IN EFI_PCI_IO_PROTOCOL
*This
,
192 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
200 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
202 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
203 @param Width Signifies the width of the memory or I/O operations.
204 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
205 base address for the memory or I/O operation to perform.
206 @param Offset The offset within the selected BAR to start the memory or I/O operation.
207 @param Count The number of memory or I/O operations to perform.
208 @param Buffer For read operations, the destination buffer to store the results. For write
209 operations, the source buffer to write data from.
211 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
212 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
213 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
214 valid for the PCI BAR specified by BarIndex.
215 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
216 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
222 IN EFI_PCI_IO_PROTOCOL
*This
,
223 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
231 Enable a PCI driver to access PCI controller registers in the PCI memory or I/O space.
233 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
234 @param Width Signifies the width of the memory or I/O operations.
235 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
236 base address for the memory or I/O operation to perform.
237 @param Offset The offset within the selected BAR to start the memory or I/O operation.
238 @param Count The number of memory or I/O operations to perform.
239 @param Buffer For read operations, the destination buffer to store the results. For write
240 operations, the source buffer to write data from.
242 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
243 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
244 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
245 valid for the PCI BAR specified by BarIndex.
246 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
247 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
253 IN EFI_PCI_IO_PROTOCOL
*This
,
254 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
262 Enable a PCI driver to access PCI controller registers in PCI configuration space.
264 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
265 @param Width Signifies the width of the memory operations.
266 @param Offset The offset within the PCI configuration space for the PCI controller.
267 @param Count The number of PCI configuration operations to perform.
268 @param Buffer For read operations, the destination buffer to store the results. For write
269 operations, the source buffer to write data from.
272 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
273 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
274 valid for the PCI configuration header of the PCI controller.
275 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
276 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
282 IN EFI_PCI_IO_PROTOCOL
*This
,
283 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
290 Enable a PCI driver to access PCI controller registers in PCI configuration space.
292 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
293 @param Width Signifies the width of the memory operations.
294 @param Offset The offset within the PCI configuration space for the PCI controller.
295 @param Count The number of PCI configuration operations to perform.
296 @param Buffer For read operations, the destination buffer to store the results. For write
297 operations, the source buffer to write data from.
300 @retval EFI_SUCCESS The data was read from or written to the PCI controller.
301 @retval EFI_UNSUPPORTED The address range specified by Offset, Width, and Count is not
302 valid for the PCI configuration header of the PCI controller.
303 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
304 @retval EFI_INVALID_PARAMETER Buffer is NULL or Width is invalid.
310 IN EFI_PCI_IO_PROTOCOL
*This
,
311 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
318 Enables a PCI driver to copy one region of PCI memory space to another region of PCI
321 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
322 @param Width Signifies the width of the memory operations.
323 @param DestBarIndex The BAR index in the standard PCI Configuration header to use as the
324 base address for the memory operation to perform.
325 @param DestOffset The destination offset within the BAR specified by DestBarIndex to
326 start the memory writes for the copy operation.
327 @param SrcBarIndex The BAR index in the standard PCI Configuration header to use as the
328 base address for the memory operation to perform.
329 @param SrcOffset The source offset within the BAR specified by SrcBarIndex to start
330 the memory reads for the copy operation.
331 @param Count The number of memory operations to perform. Bytes moved is Width
332 size * Count, starting at DestOffset and SrcOffset.
334 @retval EFI_SUCCESS The data was copied from one memory region to another memory region.
335 @retval EFI_UNSUPPORTED DestBarIndex not valid for this PCI controller.
336 @retval EFI_UNSUPPORTED SrcBarIndex not valid for this PCI controller.
337 @retval EFI_UNSUPPORTED The address range specified by DestOffset, Width, and Count
338 is not valid for the PCI BAR specified by DestBarIndex.
339 @retval EFI_UNSUPPORTED The address range specified by SrcOffset, Width, and Count is
340 not valid for the PCI BAR specified by SrcBarIndex.
341 @retval EFI_INVALID_PARAMETER Width is invalid.
342 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
348 IN EFI_PCI_IO_PROTOCOL
*This
,
349 IN EFI_PCI_IO_PROTOCOL_WIDTH Width
,
350 IN UINT8 DestBarIndex
,
351 IN UINT64 DestOffset
,
352 IN UINT8 SrcBarIndex
,
358 Provides the PCI controller-Cspecific addresses needed to access system memory.
360 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
361 @param Operation Indicates if the bus master is going to read or write to system memory.
362 @param HostAddress The system memory address to map to the PCI controller.
363 @param NumberOfBytes On input the number of bytes to map. On output the number of bytes
365 @param DeviceAddress The resulting map address for the bus master PCI controller to use to
366 access the hosts HostAddress.
367 @param Mapping A resulting value to pass to Unmap().
369 @retval EFI_SUCCESS The range was mapped for the returned NumberOfBytes.
370 @retval EFI_UNSUPPORTED The HostAddress cannot be mapped as a common buffer.
371 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
372 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
373 @retval EFI_DEVICE_ERROR The system hardware could not map the requested address.
379 IN EFI_PCI_IO_PROTOCOL
*This
,
380 IN EFI_PCI_IO_PROTOCOL_OPERATION Operation
,
381 IN VOID
*HostAddress
,
382 IN OUT UINTN
*NumberOfBytes
,
383 OUT EFI_PHYSICAL_ADDRESS
*DeviceAddress
,
388 Completes the Map() operation and releases any corresponding resources.
390 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
391 @param Mapping The mapping value returned from Map().
393 @retval EFI_SUCCESS The range was unmapped.
394 @retval EFI_DEVICE_ERROR The data was not committed to the target system memory.
400 IN EFI_PCI_IO_PROTOCOL
*This
,
405 Allocates pages that are suitable for an EfiPciIoOperationBusMasterCommonBuffer
408 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
409 @param Type This parameter is not used and must be ignored.
410 @param MemoryType The type of memory to allocate, EfiBootServicesData or
411 EfiRuntimeServicesData.
412 @param Pages The number of pages to allocate.
413 @param HostAddress A pointer to store the base system memory address of the
415 @param Attributes The requested bit mask of attributes for the allocated range.
417 @retval EFI_SUCCESS The requested memory pages were allocated.
418 @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal attribute bits are
419 MEMORY_WRITE_COMBINE and MEMORY_CACHED.
420 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
421 @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated.
426 PciIoAllocateBuffer (
427 IN EFI_PCI_IO_PROTOCOL
*This
,
428 IN EFI_ALLOCATE_TYPE Type
,
429 IN EFI_MEMORY_TYPE MemoryType
,
431 OUT VOID
**HostAddress
,
436 Frees memory that was allocated with AllocateBuffer().
438 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
439 @param Pages The number of pages to free.
440 @param HostAddress The base system memory address of the allocated range.
442 @retval EFI_SUCCESS The requested memory pages were freed.
443 @retval EFI_INVALID_PARAMETER The memory range specified by HostAddress and Pages
444 was not allocated with AllocateBuffer().
450 IN EFI_PCI_IO_PROTOCOL
*This
,
456 Flushes all PCI posted write transactions from a PCI host bridge to system memory.
458 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
460 @retval EFI_SUCCESS The PCI posted write transactions were flushed from the PCI host
461 bridge to system memory.
462 @retval EFI_DEVICE_ERROR The PCI posted write transactions were not flushed from the PCI
463 host bridge due to a hardware error.
469 IN EFI_PCI_IO_PROTOCOL
*This
473 Retrieves this PCI controller's current PCI bus number, device number, and function number.
475 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
476 @param SegmentNumber The PCI controller's current PCI segment number.
477 @param BusNumber The PCI controller's current PCI bus number.
478 @param DeviceNumber The PCI controller's current PCI device number.
479 @param FunctionNumber The PCI controller's current PCI function number.
481 @retval EFI_SUCCESS The PCI controller location was returned.
482 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
488 IN EFI_PCI_IO_PROTOCOL
*This
,
496 Check BAR type for PCI resource.
498 @param PciIoDevice PCI device instance
499 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
500 base address for the memory or I/O operation to perform.
501 @param BarType Memory or I/O
503 @return whether Pci device's bar type is same with input BarType.
507 IN PCI_IO_DEVICE
*PciIoDevice
,
513 Set/Disable new attributes to a Root Bridge
515 @param PciIoDevice Pci device instance
516 @param Attributes New attribute want to be set
517 @param Operation Set or Disable
519 @retval EFI_UNSUPPORTED If root bridge does not support change attribute
520 @retval EFI_SUCCESS Success operation.
523 ModifyRootBridgeAttributes (
524 IN PCI_IO_DEVICE
*PciIoDevice
,
525 IN UINT64 Attributes
,
526 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
530 Check whether this device can be enable/disable to snoop
532 @param PciIoDevice Pci device instance
533 @param Operation Enable/Disable
535 @retval EFI_UNSUPPORTED Pci device is not GFX device or not support snoop
536 @retval EFI_SUCCESS Snoop can be supported.
539 SupportPaletteSnoopAttributes (
540 IN PCI_IO_DEVICE
*PciIoDevice
,
541 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
545 Performs an operation on the attributes that this PCI controller supports. The operations include
546 getting the set of supported attributes, retrieving the current attributes, setting the current
547 attributes, enabling attributes, and disabling attributes.
549 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
550 @param Operation The operation to perform on the attributes for this PCI controller.
551 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
553 @param Result A pointer to the result mask of attributes that are returned for the Get
554 and Supported operations.
556 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
557 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
558 @retval EFI_UNSUPPORTED one or more of the bits set in
559 Attributes are not supported by this PCI controller or one of
560 its parent bridges when Operation is Set, Enable or Disable.
566 IN EFI_PCI_IO_PROTOCOL
* This
,
567 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
568 IN UINT64 Attributes
,
569 OUT UINT64
*Result OPTIONAL
573 Gets the attributes that this PCI controller supports setting on a BAR using
574 SetBarAttributes(), and retrieves the list of resource descriptors for a BAR.
576 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
577 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
578 base address for resource range. The legal range for this field is 0..5.
579 @param Supports A pointer to the mask of attributes that this PCI controller supports
580 setting for this BAR with SetBarAttributes().
581 @param Resources A pointer to the ACPI 2.0 resource descriptors that describe the current
582 configuration of this BAR of the PCI controller.
584 @retval EFI_SUCCESS If Supports is not NULL, then the attributes that the PCI
585 controller supports are returned in Supports. If Resources
586 is not NULL, then the ACPI 2.0 resource descriptors that the PCI
587 controller is currently using are returned in Resources.
588 @retval EFI_INVALID_PARAMETER Both Supports and Attributes are NULL.
589 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
590 @retval EFI_OUT_OF_RESOURCES There are not enough resources available to allocate
596 PciIoGetBarAttributes (
597 IN EFI_PCI_IO_PROTOCOL
* This
,
599 OUT UINT64
*Supports
, OPTIONAL
600 OUT VOID
**Resources OPTIONAL
604 Sets the attributes for a range of a BAR on a PCI controller.
606 @param This A pointer to the EFI_PCI_IO_PROTOCOL instance.
607 @param Attributes The mask of attributes to set for the resource range specified by
608 BarIndex, Offset, and Length.
609 @param BarIndex The BAR index of the standard PCI Configuration header to use as the
610 base address for resource range. The legal range for this field is 0..5.
611 @param Offset A pointer to the BAR relative base address of the resource range to be
612 modified by the attributes specified by Attributes.
613 @param Length A pointer to the length of the resource range to be modified by the
614 attributes specified by Attributes.
616 @retval EFI_SUCCESS The set of attributes specified by Attributes for the resource
617 range specified by BarIndex, Offset, and Length were
618 set on the PCI controller, and the actual resource range is returned
619 in Offset and Length.
620 @retval EFI_INVALID_PARAMETER Offset or Length is NULL.
621 @retval EFI_UNSUPPORTED BarIndex not valid for this PCI controller.
622 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the attributes on the
623 resource range specified by BarIndex, Offset, and
629 PciIoSetBarAttributes (
630 IN EFI_PCI_IO_PROTOCOL
*This
,
631 IN UINT64 Attributes
,
633 IN OUT UINT64
*Offset
,
634 IN OUT UINT64
*Length
638 Program parent bridge's attribute recurrently.
640 @param PciIoDevice Child Pci device instance
641 @param Operation The operation to perform on the attributes for this PCI controller.
642 @param Attributes The mask of attributes that are used for Set, Enable, and Disable
645 @retval EFI_SUCCESS The operation on the PCI controller's attributes was completed.
646 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
647 @retval EFI_UNSUPPORTED one or more of the bits set in
648 Attributes are not supported by this PCI controller or one of
649 its parent bridges when Operation is Set, Enable or Disable.
653 UpStreamBridgesAttributes (
654 IN PCI_IO_DEVICE
*PciIoDevice
,
655 IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation
,
660 Test whether two Pci device has same parent bridge.
662 @param PciDevice1 the frist pci device for testing
663 @param PciDevice2 the second pci device for testing
665 @return whether two Pci device has same parent bridge.
668 PciDevicesOnTheSamePath (
669 IN PCI_IO_DEVICE
*PciDevice1
,
670 IN PCI_IO_DEVICE
*PciDevice2