/* Retrieve the max bus number that is assigned to the Root Bridge hierarchy. It can support the case that there are multiple bus ranges. */
UINT16 PciGetMaxBusNumber(IN PCI_IO_DEVICE *Bridge)
/* Retrieve the max bus number that is assigned to the Root Bridge hierarchy. It can support the case that there are multiple bus ranges. */
UINT16 PciGetMaxBusNumber(IN PCI_IO_DEVICE *Bridge)
{
  PCI_IO_DEVICE                      *RootBridge;
  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *BusNumberRanges;
  UINT64                             MaxNumberInRange;
  RootBridge = Bridge;
  while (RootBridge->Parent != NULL) {
    RootBridge = RootBridge->Parent;
  }
  MaxNumberInRange = 0;
  BusNumberRanges = RootBridge->BusNumberRanges;
  while (BusNumberRanges->Desc != ACPI_END_TAG_DESCRIPTOR) {
    MaxNumberInRange = BusNumberRanges->AddrRangeMin + BusNumberRanges->AddrLen - 1;
    BusNumberRanges++;
  }
  return (UINT16)MaxNumberInRange;
}