/* Determine if a PCI BAR is IO or MMIO. */
STATIC EFI_STATUS GetBarType(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, OUT VIRTIO_1_0_BAR_TYPE *BarType)
/* Determine if a PCI BAR is IO or MMIO. */
STATIC EFI_STATUS GetBarType(IN EFI_PCI_IO_PROTOCOL *PciIo, IN UINT8 BarIndex, OUT VIRTIO_1_0_BAR_TYPE *BarType)
{
  EFI_STATUS  Status;
  VOID        *Resources;
  Status = PciIo->GetBarAttributes (PciIo, BarIndex, NULL, &Resources);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  Status = EFI_UNSUPPORTED;
  if (*(UINT8 *)Resources == ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR) {
    EFI_ACPI_QWORD_ADDRESS_SPACE_DESCRIPTOR  *Descriptor;
    Descriptor = Resources;
    switch (Descriptor->ResType) {
      case ACPI_ADDRESS_SPACE_TYPE_MEM:
        *BarType = Virtio10BarTypeMem;
        Status   = EFI_SUCCESS;
        break;
      case ACPI_ADDRESS_SPACE_TYPE_IO:
        *BarType = Virtio10BarTypeIo;
        Status   = EFI_SUCCESS;
        break;
      default:
        break;
    }
  }
  FreePool (Resources);
  return Status;
}