/* This internal function extracts segment number and bus number data from address, and retrieves the corresponding PCI Root Bridge I/O Protocol instance. */
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL* PciSegmentLibSearchForRootBridge(IN UINT64 Address)
/* This internal function extracts segment number and bus number data from address, and retrieves the corresponding PCI Root Bridge I/O Protocol instance. */
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL* PciSegmentLibSearchForRootBridge(IN UINT64 Address)
{
  UINTN   Index;
  UINT64  SegmentNumber;
  UINT64  BusNumber;
  for (Index = 0; Index < mNumberOfPciRootBridges; Index++) {
    SegmentNumber = BitFieldRead64 (Address, 32, 63);
    if (SegmentNumber == mPciRootBridgeData[Index].SegmentNumber) {
      BusNumber = BitFieldRead64 (Address, 20, 27);
      if ((BusNumber >= mPciRootBridgeData[Index].MinBusNumber) && (BusNumber <= mPciRootBridgeData[Index].MaxBusNumber)) {
        return mPciRootBridgeData[Index].PciRootBridgeIo;
      }
    }
  }
  return NULL;
}