mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-14 19:02:02 +00:00
For arch specific codes, we use arch_xxx() to name the function. So, rename cpu_ticks/cpu_tickrate/set_hw_timeout/init_hw_timer to follow this convention. Then, use arch interface to set timeout value in update_physical_timer(). Furthermore, remove hw_timer.h and move its contents into common/ timer.h. Tracked-On: #8792 Signed-off-by: Yi Y Sun <yi.y.sun@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
37 lines
631 B
C
37 lines
631 B
C
/*
|
|
* Copyright (C) 2021 Intel Corporation.
|
|
*
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
|
*/
|
|
|
|
#include <common/ticks.h>
|
|
|
|
/* arch_cpu_ticks() and arch_cpu_tickrate() are provided in arch specific modules */
|
|
|
|
uint64_t us_to_ticks(uint32_t us)
|
|
{
|
|
return (((uint64_t)us * (uint64_t)arch_cpu_tickrate()) / 1000UL);
|
|
}
|
|
|
|
uint64_t ticks_to_us(uint64_t ticks)
|
|
{
|
|
uint64_t us = 0UL;
|
|
uint64_t khz = arch_cpu_tickrate();
|
|
|
|
if (khz != 0U) {
|
|
us = (ticks * 1000UL) / (uint64_t)khz;
|
|
}
|
|
|
|
return us;
|
|
}
|
|
|
|
uint64_t ticks_to_ms(uint64_t ticks)
|
|
{
|
|
return ticks / (uint64_t)arch_cpu_tickrate();
|
|
}
|
|
|
|
uint64_t cpu_ticks(void)
|
|
{
|
|
return arch_cpu_ticks();
|
|
}
|