mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-11-28 16:36:00 +00:00
hv: timer: rename functions to follow naming convention
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>
This commit is contained in:
@@ -51,9 +51,6 @@ Interfaces Design
|
||||
.. doxygenfunction:: cpu_ticks
|
||||
:project: Project ACRN
|
||||
|
||||
.. doxygenfunction:: cpu_tickrate
|
||||
:project: Project ACRN
|
||||
|
||||
.. doxygenfunction:: us_to_ticks
|
||||
:project: Project ACRN
|
||||
|
||||
|
||||
@@ -219,12 +219,12 @@ uint32_t get_tsc_khz(void)
|
||||
|
||||
/* external API */
|
||||
|
||||
uint64_t cpu_ticks(void)
|
||||
uint64_t arch_cpu_ticks(void)
|
||||
{
|
||||
return rdtsc();
|
||||
}
|
||||
|
||||
uint32_t cpu_tickrate(void)
|
||||
uint32_t arch_cpu_tickrate(void)
|
||||
{
|
||||
return tsc_khz;
|
||||
}
|
||||
|
||||
@@ -8,11 +8,11 @@
|
||||
#include <softirq.h>
|
||||
#include <irq.h>
|
||||
#include <logmsg.h>
|
||||
#include <timer.h>
|
||||
#include <asm/cpu.h>
|
||||
#include <asm/msr.h>
|
||||
#include <asm/irq.h>
|
||||
#include <asm/apicreg.h>
|
||||
#include <hw/hw_timer.h>
|
||||
|
||||
/* run in interrupt context */
|
||||
static void timer_expired_handler(__unused uint32_t irq, __unused void *data)
|
||||
@@ -20,12 +20,12 @@ static void timer_expired_handler(__unused uint32_t irq, __unused void *data)
|
||||
fire_softirq(SOFTIRQ_TIMER);
|
||||
}
|
||||
|
||||
void set_hw_timeout(uint64_t timeout)
|
||||
void arch_set_timer_count(uint64_t cnt)
|
||||
{
|
||||
msr_write(MSR_IA32_TSC_DEADLINE, timeout);
|
||||
msr_write(MSR_IA32_TSC_DEADLINE, cnt);
|
||||
}
|
||||
|
||||
void init_hw_timer(void)
|
||||
void arch_init_timer(void)
|
||||
{
|
||||
int32_t retval = 0;
|
||||
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
|
||||
#include <common/ticks.h>
|
||||
|
||||
/* cpu_ticks() and cpu_tickrate() are provided in arch specific modules */
|
||||
/* 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)cpu_tickrate()) / 1000UL);
|
||||
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 = cpu_tickrate();
|
||||
uint64_t khz = arch_cpu_tickrate();
|
||||
|
||||
if (khz != 0U) {
|
||||
us = (ticks * 1000UL) / (uint64_t)khz;
|
||||
@@ -27,5 +27,10 @@ uint64_t ticks_to_us(uint64_t ticks)
|
||||
|
||||
uint64_t ticks_to_ms(uint64_t ticks)
|
||||
{
|
||||
return ticks / (uint64_t)cpu_tickrate();
|
||||
return ticks / (uint64_t)arch_cpu_tickrate();
|
||||
}
|
||||
|
||||
uint64_t cpu_ticks(void)
|
||||
{
|
||||
return arch_cpu_ticks();
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
#include <trace.h>
|
||||
#include <asm/irq.h>
|
||||
#include <ticks.h>
|
||||
#include <hw/hw_timer.h>
|
||||
#include <timer.h>
|
||||
|
||||
#define MAX_TIMER_ACTIONS 32U
|
||||
#define MIN_TIMER_PERIOD_US 500U
|
||||
@@ -62,7 +62,7 @@ static inline void update_physical_timer(struct per_cpu_timers *cpu_timer)
|
||||
struct hv_timer, node);
|
||||
|
||||
/* it is okay to program a expired time */
|
||||
msr_write(MSR_IA32_TSC_DEADLINE, timer->timeout);
|
||||
arch_set_timer_count(timer->timeout);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -229,5 +229,5 @@ void timer_init(void)
|
||||
register_softirq(SOFTIRQ_TIMER, timer_softirq);
|
||||
}
|
||||
|
||||
init_hw_timer();
|
||||
arch_init_timer();
|
||||
}
|
||||
|
||||
@@ -12,9 +12,17 @@
|
||||
#define TICKS_PER_MS us_to_ticks(1000U)
|
||||
|
||||
/**
|
||||
* @brief Read current CPU tick count.
|
||||
* @brief Read current CPU tick count per arch.
|
||||
*
|
||||
* @remark On x86, this is the Time Stamp Counter (TSC) value of the current logical CPU.
|
||||
* @remark CPU tick count is arch specific. On x86, this is the Time Stamp Counter (TSC) value of
|
||||
* the current logical CPU.
|
||||
*
|
||||
* @return CPU ticks
|
||||
*/
|
||||
uint64_t arch_cpu_ticks(void);
|
||||
|
||||
/**
|
||||
* @brief Read current CPU tick count.
|
||||
*
|
||||
* @return CPU ticks
|
||||
*/
|
||||
@@ -23,11 +31,12 @@ uint64_t cpu_ticks(void);
|
||||
/**
|
||||
* @brief Get CPU tick frequency in KHz.
|
||||
*
|
||||
* @remark On x86, this is the Time Stamp Counter (TSC) frequency of the current logical CPU.
|
||||
* @remark CPU tick rate is arch specific. On x86, this is the Time Stamp Counter (TSC) frequency
|
||||
* of the current logical CPU.
|
||||
*
|
||||
* @return CPU frequency (KHz)
|
||||
*/
|
||||
uint32_t cpu_tickrate(void);
|
||||
uint32_t arch_cpu_tickrate(void);
|
||||
|
||||
/**
|
||||
* @brief Convert micro seconds to CPU ticks.
|
||||
|
||||
@@ -119,6 +119,18 @@ void del_timer(struct hv_timer *timer);
|
||||
*/
|
||||
void timer_init(void);
|
||||
|
||||
/**
|
||||
* @brief Set timeout value to arch specific timer.
|
||||
*
|
||||
* @param[in] cnt Timeout value to set.
|
||||
*/
|
||||
void arch_set_timer_count(uint64_t cnt);
|
||||
|
||||
/**
|
||||
* @brief Initialize arch specific timer.
|
||||
*/
|
||||
void arch_init_timer(void);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021 Intel Corporation.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef HW_TIMER_H
|
||||
#define HW_TIMER_H
|
||||
|
||||
#include <types.h>
|
||||
|
||||
void set_hw_timeout(uint64_t timeout);
|
||||
void init_hw_timer(void);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user