acrn-hypervisor/hypervisor/lib/udelay.c
Junjie Mao ffc0b27db4 HV: lib: make the argument to udelay unsigned
The parameter to udelay is the microseconds to wait for, which should be an
unsigned integer.

Signed-off-by: Junjie Mao <junjie.mao@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
2018-07-03 10:18:06 +08:00

21 lines
363 B
C

/*
* Copyright (C) 2018 Intel Corporation. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <hv_lib.h>
void udelay(uint32_t us)
{
uint64_t dest_tsc, delta_tsc;
/* Calculate number of ticks to wait */
delta_tsc = US_TO_TICKS(us);
dest_tsc = rdtsc() + delta_tsc;
/* Loop until time expired */
while
(rdtsc() < dest_tsc);
}