acrn-hypervisor/hypervisor/lib/udelay.c
David B. Kinder f4122d99c5 license: Replace license text with SPDX tag
Replace the BSD-3-Clause boiler plate license text with an SPDX tag.

Fixes: #189

Signed-off-by: David B. Kinder <david.b.kinder@intel.com>
2018-06-01 10:43:06 +08:00

21 lines
377 B
C

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