/* Retrieves the descriptor for an I/O region containing a specified address. */
EFI_STATUS EFIAPI CoreGetIoSpaceDescriptor(IN EFI_PHYSICAL_ADDRESS BaseAddress, OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor)
/* Retrieves the descriptor for an I/O region containing a specified address. */
EFI_STATUS EFIAPI CoreGetIoSpaceDescriptor(IN EFI_PHYSICAL_ADDRESS BaseAddress, OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor)
{
  EFI_STATUS         Status;
  LIST_ENTRY         *StartLink;
  LIST_ENTRY         *EndLink;
  EFI_GCD_MAP_ENTRY  *Entry;
  if (Descriptor == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  CoreAcquireGcdIoLock ();
  Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdIoSpaceMap);
  if (EFI_ERROR (Status)) {
    Status = EFI_NOT_FOUND;
  } else {
    ASSERT (StartLink != NULL && EndLink != NULL);
    Entry = CR (StartLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
    BuildIoDescriptor (Descriptor, Entry);
  }
  CoreReleaseGcdIoLock ();
  return Status;
}