mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-19 12:12:16 +00:00
hv: timer: pass timer callback function parameter by pointer
Signed-off-by: Li, Fei1 <fei1.li@intel.com> Reviewed-by: Zhao Yakui <yakui.zhao@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com> Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
parent
dace32eca1
commit
be9f4ee9e6
@ -1908,7 +1908,7 @@ vlapic_msr(uint32_t msr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* interrupt context */
|
/* interrupt context */
|
||||||
static int tsc_periodic_time(uint64_t data)
|
static int tsc_periodic_time(void *data)
|
||||||
{
|
{
|
||||||
struct vcpu *vcpu = (struct vcpu *)data;
|
struct vcpu *vcpu = (struct vcpu *)data;
|
||||||
struct vlapic *vlapic;
|
struct vlapic *vlapic;
|
||||||
@ -1979,7 +1979,7 @@ vlapic_wrmsr(struct vcpu *vcpu, uint32_t msr, uint64_t val)
|
|||||||
|
|
||||||
vlapic->last_timer = update_timer(vlapic->last_timer,
|
vlapic->last_timer = update_timer(vlapic->last_timer,
|
||||||
tsc_periodic_time,
|
tsc_periodic_time,
|
||||||
(long)vcpu,
|
(void *)vcpu,
|
||||||
val);
|
val);
|
||||||
|
|
||||||
if (vlapic->last_timer < 0) {
|
if (vlapic->last_timer < 0) {
|
||||||
|
@ -41,12 +41,12 @@ uint64_t tsc_hz = 1000000000;
|
|||||||
|
|
||||||
struct timer {
|
struct timer {
|
||||||
timer_handle_t func; /* callback if time reached */
|
timer_handle_t func; /* callback if time reached */
|
||||||
uint64_t priv_data; /* func private data */
|
|
||||||
uint64_t deadline; /* tsc deadline to interrupt */
|
uint64_t deadline; /* tsc deadline to interrupt */
|
||||||
long handle; /* unique handle for user */
|
long handle; /* unique handle for user */
|
||||||
int pcpu_id; /* armed on which CPU */
|
int pcpu_id; /* armed on which CPU */
|
||||||
int id; /* timer ID, used by release */
|
int id; /* timer ID, used by release */
|
||||||
struct list_head node; /* link all timers */
|
struct list_head node; /* link all timers */
|
||||||
|
void *priv_data; /* func private data */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct per_cpu_timers {
|
struct per_cpu_timers {
|
||||||
@ -95,7 +95,7 @@ static void release_timer(struct timer *timer)
|
|||||||
struct per_cpu_timers *cpu_timer;
|
struct per_cpu_timers *cpu_timer;
|
||||||
|
|
||||||
cpu_timer = &per_cpu(cpu_timers, timer->pcpu_id);
|
cpu_timer = &per_cpu(cpu_timers, timer->pcpu_id);
|
||||||
timer->priv_data = 0;
|
timer->priv_data = NULL;
|
||||||
timer->func = NULL;
|
timer->func = NULL;
|
||||||
timer->deadline = 0;
|
timer->deadline = 0;
|
||||||
bitmap_set(timer->id, &cpu_timer->free_bitmap);
|
bitmap_set(timer->id, &cpu_timer->free_bitmap);
|
||||||
@ -243,7 +243,7 @@ static void init_timer_pool(void)
|
|||||||
for (j = 0; j < MAX_TIMER_ACTIONS; j++) {
|
for (j = 0; j < MAX_TIMER_ACTIONS; j++) {
|
||||||
timers_pool[j].id = j;
|
timers_pool[j].id = j;
|
||||||
timers_pool[j].pcpu_id = i;
|
timers_pool[j].pcpu_id = i;
|
||||||
timers_pool[j].priv_data = 0;
|
timers_pool[j].priv_data = NULL;
|
||||||
timers_pool[j].func = NULL;
|
timers_pool[j].func = NULL;
|
||||||
timers_pool[j].deadline = 0;
|
timers_pool[j].deadline = 0;
|
||||||
timers_pool[j].handle = -1UL;
|
timers_pool[j].handle = -1UL;
|
||||||
@ -323,7 +323,7 @@ int timer_softirq(int pcpu_id)
|
|||||||
* return: handle, this handle is unique and can be used to find back
|
* return: handle, this handle is unique and can be used to find back
|
||||||
* this added timer. handle will be invalid after timer expired
|
* this added timer. handle will be invalid after timer expired
|
||||||
*/
|
*/
|
||||||
long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline)
|
long add_timer(timer_handle_t func, void *data, uint64_t deadline)
|
||||||
{
|
{
|
||||||
struct timer *timer;
|
struct timer *timer;
|
||||||
struct per_cpu_timers *cpu_timer;
|
struct per_cpu_timers *cpu_timer;
|
||||||
@ -357,7 +357,7 @@ long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline)
|
|||||||
* update_timer existing timer. if not found, add new timer
|
* update_timer existing timer. if not found, add new timer
|
||||||
*/
|
*/
|
||||||
long
|
long
|
||||||
update_timer(long handle, timer_handle_t func, uint64_t data,
|
update_timer(long handle, timer_handle_t func, void *data,
|
||||||
uint64_t deadline)
|
uint64_t deadline)
|
||||||
{
|
{
|
||||||
struct timer *timer;
|
struct timer *timer;
|
||||||
|
@ -216,7 +216,7 @@ static void console_handler(void)
|
|||||||
shell_kick_session();
|
shell_kick_session();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int console_timer_callback(__unused uint64_t data)
|
static int console_timer_callback(__unused void *data)
|
||||||
{
|
{
|
||||||
/* Kick HV-Shell and Uart-Console tasks */
|
/* Kick HV-Shell and Uart-Console tasks */
|
||||||
console_handler();
|
console_handler();
|
||||||
@ -230,7 +230,7 @@ static int console_timer_callback(__unused uint64_t data)
|
|||||||
void console_setup_timer(void)
|
void console_setup_timer(void)
|
||||||
{
|
{
|
||||||
/* Start an one-shot timer */
|
/* Start an one-shot timer */
|
||||||
if (add_timer(console_timer_callback, 0,
|
if (add_timer(console_timer_callback, NULL,
|
||||||
rdtsc() + CYCLES_PER_MS * CONSOLE_KICK_TIMER_TIMEOUT) < 0)
|
rdtsc() + CYCLES_PER_MS * CONSOLE_KICK_TIMER_TIMEOUT) < 0)
|
||||||
pr_err("Failed to add console kick timer");
|
pr_err("Failed to add console kick timer");
|
||||||
}
|
}
|
||||||
|
@ -31,11 +31,11 @@
|
|||||||
#ifndef TIMER_H
|
#ifndef TIMER_H
|
||||||
#define TIMER_H
|
#define TIMER_H
|
||||||
|
|
||||||
typedef int (*timer_handle_t)(uint64_t);
|
typedef int (*timer_handle_t)(void *);
|
||||||
|
|
||||||
long add_timer(timer_handle_t func, uint64_t data, uint64_t deadline);
|
long add_timer(timer_handle_t func, void *data, uint64_t deadline);
|
||||||
bool cancel_timer(long handle, int pcpu_id);
|
bool cancel_timer(long handle, int pcpu_id);
|
||||||
long update_timer(long handle, timer_handle_t func, uint64_t data,
|
long update_timer(long handle, timer_handle_t func, void *data,
|
||||||
uint64_t deadline);
|
uint64_t deadline);
|
||||||
|
|
||||||
int timer_softirq(int pcpu_id);
|
int timer_softirq(int pcpu_id);
|
||||||
|
Loading…
Reference in New Issue
Block a user