/* Sets the attributes for a range of a BAR on a PCI controller. */
STATIC EFI_STATUS EFIAPI PciIoSetBarAttributes(IN EFI_PCI_IO_PROTOCOL *This, IN UINT64 Attributes, IN UINT8 BarIndex, IN OUT UINT64 *Offset, IN OUT UINT64 *Length)
/* Sets the attributes for a range of a BAR on a PCI controller. */
STATIC EFI_STATUS EFIAPI PciIoSetBarAttributes(IN EFI_PCI_IO_PROTOCOL *This, IN UINT64 Attributes, IN UINT8 BarIndex, IN OUT UINT64 *Offset, IN OUT UINT64 *Length)
{
  NON_DISCOVERABLE_PCI_DEVICE        *Dev;
  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR  *Desc;
  EFI_PCI_IO_PROTOCOL_WIDTH          Width;
  UINTN                              Count;
  EFI_STATUS                         Status;
  if ((Attributes & (~DEV_SUPPORTED_ATTRIBUTES)) != 0) {
    return EFI_UNSUPPORTED;
  }
  if ((Offset == NULL) || (Length == NULL)) {
    return EFI_INVALID_PARAMETER;
  }
  Dev   = NON_DISCOVERABLE_PCI_DEVICE_FROM_PCI_IO (This);
  Width = EfiPciIoWidthUint8;
  Count = (UINT32)*Length;
  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;
}