TianoCore EDK2 master
Loading...
Searching...
No Matches
BasePciCapPciSegmentLib.c File Reference

Go to the source code of this file.

Functions

STATIC RETURN_STATUS EFIAPI SegmentDevReadConfig (IN PCI_CAP_DEV *PciDevice, IN UINT16 SourceOffset, OUT VOID *DestinationBuffer, IN UINT16 Size)
 
STATIC RETURN_STATUS EFIAPI SegmentDevWriteConfig (IN PCI_CAP_DEV *PciDevice, IN UINT16 DestinationOffset, IN VOID *SourceBuffer, IN UINT16 Size)
 
RETURN_STATUS EFIAPI PciCapPciSegmentDeviceInit (IN PCI_CAP_DOMAIN MaxDomain, IN UINT16 Segment, IN UINT8 Bus, IN UINT8 Device, IN UINT8 Function, OUT PCI_CAP_DEV **PciDevice)
 
VOID EFIAPI PciCapPciSegmentDeviceUninit (IN PCI_CAP_DEV *PciDevice)
 

Detailed Description

Plug a PciSegmentLib backend into PciCapLib, for config space access.

Copyright (C) 2018, Red Hat, Inc.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file BasePciCapPciSegmentLib.c.

Function Documentation

◆ PciCapPciSegmentDeviceInit()

RETURN_STATUS EFIAPI PciCapPciSegmentDeviceInit ( IN PCI_CAP_DOMAIN  MaxDomain,
IN UINT16  Segment,
IN UINT8  Bus,
IN UINT8  Device,
IN UINT8  Function,
OUT PCI_CAP_DEV **  PciDevice 
)

Create a PCI_CAP_DEV object from the PCI Segment:Bus:Device.Function quadruplet. The config space accessors are based upon PciSegmentLib.

Parameters
[in]MaxDomainIf MaxDomain is PciCapExtended, then PciDevice->ReadConfig() and PciDevice->WriteConfig() will delegate extended config space accesses too to PciSegmentReadBuffer() and PciSegmentWriteBuffer(), respectively. Otherwise, PciDevice->ReadConfig() and PciDevice->WriteConfig() will reject accesses to extended config space with RETURN_UNSUPPORTED, without calling PciSegmentReadBuffer() or PciSegmentWriteBuffer(). By setting MaxDomain to PciCapNormal, the platform can prevent undefined PciSegmentLib behavior when the PCI root bridge under the PCI device at Segment:Bus:Device.Function doesn't support extended config space.
[in]Segment16-bit wide segment number.
[in]Bus8-bit wide bus number.
[in]Device5-bit wide device number.
[in]Function3-bit wide function number.
[out]PciDeviceThe PCI_CAP_DEV object constructed as described above. PciDevice can be passed to the PciCapLib APIs.
Return values
RETURN_SUCCESSPciDevice has been constructed and output.
RETURN_INVALID_PARAMETERDevice or Function does not fit in the permitted number of bits.
RETURN_OUT_OF_RESOURCESMemory allocation failed.

Definition at line 177 of file BasePciCapPciSegmentLib.c.

◆ PciCapPciSegmentDeviceUninit()

VOID EFIAPI PciCapPciSegmentDeviceUninit ( IN PCI_CAP_DEV PciDevice)

Free the resources used by PciDevice.

Parameters
[in]PciDeviceThe PCI_CAP_DEV object to free, originally produced by PciCapPciSegmentDeviceInit().

Definition at line 218 of file BasePciCapPciSegmentLib.c.

◆ SegmentDevReadConfig()

STATIC RETURN_STATUS EFIAPI SegmentDevReadConfig ( IN PCI_CAP_DEV PciDevice,
IN UINT16  SourceOffset,
OUT VOID *  DestinationBuffer,
IN UINT16  Size 
)

Read the config space of a given PCI device (both normal and extended).

SegmentDevReadConfig() performs as few config space accesses as possible (without attempting 64-bit wide accesses).

Parameters
[in]PciDeviceImplementation-specific unique representation of the PCI device in the PCI hierarchy.
[in]SourceOffsetSource offset in the config space of the PCI device to start reading from.
[out]DestinationBufferBuffer to store the read data to.
[in]SizeThe number of bytes to transfer.
Return values
RETURN_SUCCESSSize bytes have been transferred from config space to DestinationBuffer.
RETURN_UNSUPPORTEDAccessing Size bytes from SourceOffset exceeds the config space limit of the PCI device. Although PCI_CAP_DEV_READ_CONFIG allows reading fewer than Size bytes in this case, SegmentDevReadConfig() will read none.

Definition at line 45 of file BasePciCapPciSegmentLib.c.

◆ SegmentDevWriteConfig()

STATIC RETURN_STATUS EFIAPI SegmentDevWriteConfig ( IN PCI_CAP_DEV PciDevice,
IN UINT16  DestinationOffset,
IN VOID *  SourceBuffer,
IN UINT16  Size 
)

Write the config space of a given PCI device (both normal and extended).

SegmentDevWriteConfig() performs as few config space accesses as possible (without attempting 64-bit wide accesses).

Parameters
[in]PciDeviceImplementation-specific unique representation of the PCI device in the PCI hierarchy.
[in]DestinationOffsetDestination offset in the config space of the PCI device to start writing at.
[in]SourceBufferBuffer to read the data to be stored from.
[in]SizeThe number of bytes to transfer.
Return values
RETURN_SUCCESSSize bytes have been transferred from SourceBuffer to config space.
RETURN_UNSUPPORTEDAccessing Size bytes at DestinationOffset exceeds the config space limit of the PCI device. Although PCI_CAP_DEV_WRITE_CONFIG allows writing fewer than Size bytes in this case, SegmentDevWriteConfig() will write none.

Definition at line 106 of file BasePciCapPciSegmentLib.c.