/* Computes and returns the elapsed ticks since PreviousTick. The value of PreviousTick is overwritten with the current performance counter value. */
UINT64 XhcGetElapsedTicks(IN OUT UINT64 *PreviousTick)
/* Computes and returns the elapsed ticks since PreviousTick. The value of PreviousTick is overwritten with the current performance counter value. */
UINT64 XhcGetElapsedTicks(IN OUT UINT64 *PreviousTick)
{
  UINT64  CurrentTick;
  UINT64  Delta;
  CurrentTick = GetPerformanceCounter ();
  if (mXhciPerformanceCounterStartValue < mXhciPerformanceCounterEndValue) {
    if (*PreviousTick > CurrentTick) {
      Delta = (mXhciPerformanceCounterEndValue - *PreviousTick) + CurrentTick;
    } else {
      Delta = CurrentTick - *PreviousTick;
    }
  } else {
    if (*PreviousTick < CurrentTick) {
      Delta = (mXhciPerformanceCounterStartValue - CurrentTick) + *PreviousTick;
    } else {
      Delta = *PreviousTick - CurrentTick;
    }
  }
  *PreviousTick = CurrentTick;
  return Delta;
}