/* Get the resource associated with BAR number 'BarIndex'. */
STATIC EFI_STATUS GetBarResource(IN NON_DISCOVERABLE_PCI_DEVICE *Dev, IN UINT8 BarIndex, OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptor)
/* Get the resource associated with BAR number 'BarIndex'. */
STATIC EFI_STATUS GetBarResource(IN NON_DISCOVERABLE_PCI_DEVICE *Dev, IN UINT8 BarIndex, OUT EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR **Descriptor)
{
  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *Desc;
  if (BarIndex < Dev->BarOffset) {
    return EFI_NOT_FOUND;
  }
  BarIndex -= (UINT8)Dev->BarOffset;
  if (BarIndex >= Dev->BarCount) {
    return EFI_UNSUPPORTED;
  }
  for (Desc = Dev->Device->Resources;
       Desc->Desc != ACPI_END_TAG_DESCRIPTOR;
       Desc = (VOID *)((UINT8 *)Desc + Desc->Len + 3))
  {
    if (BarIndex == 0) {
      *Descriptor = Desc;
      return EFI_SUCCESS;
    }
    BarIndex -= 1;
  }
  return EFI_NOT_FOUND;
}