/* Read the config space of a given PCI device (both normal and extended). */
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). */
STATIC RETURN_STATUS EFIAPI SegmentDevReadConfig(IN PCI_CAP_DEV *PciDevice, IN UINT16 SourceOffset, OUT VOID *DestinationBuffer, IN UINT16 Size)
{
  SEGMENT_DEV  *SegmentDev;
  UINT16       ConfigSpaceSize;
  UINT64       SourceAddress;
  SegmentDev      = SEGMENT_DEV_FROM_PCI_CAP_DEV (PciDevice);
  ConfigSpaceSize = (SegmentDev->MaxDomain == PciCapNormal ?
                     PCI_MAX_CONFIG_OFFSET : PCI_EXP_MAX_CONFIG_OFFSET);
  if (SourceOffset + Size > ConfigSpaceSize) {
    return RETURN_UNSUPPORTED;
  }
  SourceAddress = PCI_SEGMENT_LIB_ADDRESS (
                    SegmentDev->SegmentNr,
                    SegmentDev->BusNr,
                    SegmentDev->DeviceNr,
                    SegmentDev->FunctionNr,
                    SourceOffset
                    );
  PciSegmentReadBuffer (SourceAddress, Size, DestinationBuffer);
  return RETURN_SUCCESS;
}