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

Go to the source code of this file.

Functions

STATIC EFI_STATUS ProtoDevTransferConfig (IN EFI_PCI_IO_PROTOCOL *PciIo, IN EFI_PCI_IO_PROTOCOL_CONFIG TransferFunction, IN UINT16 ConfigOffset, IN OUT UINT8 *Buffer, IN UINT16 Size)
 
STATIC RETURN_STATUS EFIAPI ProtoDevReadConfig (IN PCI_CAP_DEV *PciDevice, IN UINT16 SourceOffset, OUT VOID *DestinationBuffer, IN UINT16 Size)
 
STATIC RETURN_STATUS EFIAPI ProtoDevWriteConfig (IN PCI_CAP_DEV *PciDevice, IN UINT16 DestinationOffset, IN VOID *SourceBuffer, IN UINT16 Size)
 
EFI_STATUS EFIAPI PciCapPciIoDeviceInit (IN EFI_PCI_IO_PROTOCOL *PciIo, OUT PCI_CAP_DEV **PciDevice)
 
VOID EFIAPI PciCapPciIoDeviceUninit (IN PCI_CAP_DEV *PciDevice)
 

Detailed Description

Plug an EFI_PCI_IO_PROTOCOL backend into PciCapLib, for config space access.

Copyright (C) 2018, Red Hat, Inc.

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

Definition in file UefiPciCapPciIoLib.c.

Function Documentation

◆ PciCapPciIoDeviceInit()

EFI_STATUS EFIAPI PciCapPciIoDeviceInit ( IN EFI_PCI_IO_PROTOCOL PciIo,
OUT PCI_CAP_DEV **  PciDevice 
)

Create a PCI_CAP_DEV object from an EFI_PCI_IO_PROTOCOL instance. The config space accessors are based upon EFI_PCI_IO_PROTOCOL.Pci.Read() and EFI_PCI_IO_PROTOCOL.Pci.Write().

Parameters
[in]PciIoEFI_PCI_IO_PROTOCOL representation of the PCI device.
[out]PciDeviceThe PCI_CAP_DEV object constructed as described above. PciDevice can be passed to the PciCapLib APIs.
Return values
EFI_SUCCESSPciDevice has been constructed and output.
EFI_OUT_OF_RESOURCESMemory allocation failed.

Definition at line 208 of file UefiPciCapPciIoLib.c.

◆ PciCapPciIoDeviceUninit()

VOID EFIAPI PciCapPciIoDeviceUninit ( IN PCI_CAP_DEV PciDevice)

Free the resources used by PciDevice.

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

Definition at line 237 of file UefiPciCapPciIoLib.c.

◆ ProtoDevReadConfig()

STATIC RETURN_STATUS EFIAPI ProtoDevReadConfig ( 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).

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

ProtoDevReadConfig() returns an unspecified error if accessing Size bytes from SourceOffset exceeds the config space limit of the PCI device. Fewer than Size bytes may have been read in this case.

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.
Returns
Error codes propagated from EFI_PCI_IO_PROTOCOL.Pci.Read(). Fewer than Size bytes may have been read.

Definition at line 124 of file UefiPciCapPciIoLib.c.

◆ ProtoDevTransferConfig()

STATIC EFI_STATUS ProtoDevTransferConfig ( IN EFI_PCI_IO_PROTOCOL PciIo,
IN EFI_PCI_IO_PROTOCOL_CONFIG  TransferFunction,
IN UINT16  ConfigOffset,
IN OUT UINT8 *  Buffer,
IN UINT16  Size 
)

Transfer bytes between the config space of a given PCI device and a memory buffer.

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

Parameters
[in]PciIoThe EFI_PCI_IO_PROTOCOL representation of the PCI device.
[in]TransferFunctionThe EFI_PCI_IO_PROTOCOL_CONFIG function that implements the transfer. The direction of the transfer is inherent to TransferFunction. TransferFunction() is required to return an unspecified error if any sub-transfer within Size bytes from ConfigOffset exceeds the config space limit of the PCI device.
[in]ConfigOffsetThe offset in the config space of the PCI device at which the transfer should commence.
[in,out]BufferThe memory buffer where the transfer should occur.
[in]SizeThe number of bytes to transfer.
Return values
EFI_SUCCESSSize bytes have been transferred between config space and Buffer.
Returns
Error codes propagated from TransferFunction(). Fewer than Size bytes may have been transferred.

Definition at line 47 of file UefiPciCapPciIoLib.c.

◆ ProtoDevWriteConfig()

STATIC RETURN_STATUS EFIAPI ProtoDevWriteConfig ( 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).

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

ProtoDevWriteConfig() returns an unspecified error if accessing Size bytes at DestinationOffset exceeds the config space limit of the PCI device. Fewer than Size bytes may have been written in this case.

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.
Returns
Error codes propagated from EFI_PCI_IO_PROTOCOL.Pci.Write(). Fewer than Size bytes may have been written.

Definition at line 173 of file UefiPciCapPciIoLib.c.