/* Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is satisfied or after a defined duration. */
STATIC EFI_STATUS EFIAPI PciIoPollMem(IN EFI_PCI_IO_PROTOCOL *This, IN EFI_PCI_IO_PROTOCOL_WIDTH Width, IN UINT8 BarIndex, IN UINT64 Offset, IN UINT64 Mask, IN UINT64 Value, IN UINT64 Delay, OUT UINT64 *Result)
/* Reads from the memory space of a PCI controller. Returns either when the polling exit criteria is satisfied or after a defined duration. */
STATIC EFI_STATUS EFIAPI PciIoPollMem(IN EFI_PCI_IO_PROTOCOL *This, IN EFI_PCI_IO_PROTOCOL_WIDTH Width, IN UINT8 BarIndex, IN UINT64 Offset, IN UINT64 Mask, IN UINT64 Value, IN UINT64 Delay, OUT UINT64 *Result)
{
  NON_DISCOVERABLE_PCI_DEVICE        *Dev;
  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *Desc;
  UINTN                              Count;
  EFI_STATUS                         Status;
  if ((UINT32)Width > EfiPciIoWidthUint64) {
    return EFI_INVALID_PARAMETER;
  }
  if (Result == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  Dev   = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
  Count = 1;
  Status = GetBarResource (Dev, BarIndex, &Desc);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if (Offset + (Count << (Width & 0x3)) > Desc->AddrLen) {
    return EFI_UNSUPPORTED;
  }
  ASSERT (FALSE);
  return EFI_UNSUPPORTED;
}