/* Return the linear address for the physical address. */
UINTN PciSegmentLibVirtualAddress(IN UINTN Address)
/* Return the linear address for the physical address. */
UINTN PciSegmentLibVirtualAddress(IN UINTN Address)
{
  UINTN  Index;
  if (!EfiGoneVirtual ()) {
    return Address;
  }
  if (mDxeRuntimePciSegmentLibRegistrationTable[mDxeRuntimePciSegmentLibLastRuntimeRange].PhysicalAddress == (Address & (~(UINTN)EFI_PAGE_MASK))) {
    return (Address & EFI_PAGE_MASK) + mDxeRuntimePciSegmentLibRegistrationTable[mDxeRuntimePciSegmentLibLastRuntimeRange].VirtualAddress;
  }
  for (Index = 0; Index < mDxeRuntimePciSegmentLibNumberOfRuntimeRanges; Index++) {
    if (mDxeRuntimePciSegmentLibRegistrationTable[Index].PhysicalAddress == (Address & (~(UINTN)EFI_PAGE_MASK))) {
      mDxeRuntimePciSegmentLibLastRuntimeRange = Index;
      return (Address & EFI_PAGE_MASK) + mDxeRuntimePciSegmentLibRegistrationTable[Index].VirtualAddress;
    }
  }
  ASSERT (FALSE);
  CpuBreakpoint ();
  return Address;
}