2018-03-07 20:57:14 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2018 Intel Corporation. All rights reserved.
|
|
|
|
*
|
2018-05-26 01:49:13 +08:00
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2018-03-07 20:57:14 +08:00
|
|
|
*/
|
|
|
|
|
2018-09-27 14:05:54 +08:00
|
|
|
#include <hypervisor.h>
|
2018-03-07 20:57:14 +08:00
|
|
|
|
2018-07-02 21:14:15 +08:00
|
|
|
void udelay(uint32_t us)
|
2018-03-07 20:57:14 +08:00
|
|
|
{
|
|
|
|
uint64_t dest_tsc, delta_tsc;
|
|
|
|
|
|
|
|
/* Calculate number of ticks to wait */
|
2018-07-03 03:41:02 +08:00
|
|
|
delta_tsc = us_to_ticks(us);
|
2018-03-07 20:57:14 +08:00
|
|
|
dest_tsc = rdtsc() + delta_tsc;
|
|
|
|
|
|
|
|
/* Loop until time expired */
|
2018-07-11 10:59:31 +08:00
|
|
|
while (rdtsc() < dest_tsc) {
|
|
|
|
}
|
2018-03-07 20:57:14 +08:00
|
|
|
}
|