1 #include "palacios/vmm_time.h"
2 #include "palacios/vmm.h"
5 void v3_init_time(struct vm_time * time_state) {
7 time_state->cpu_freq = V3_CPU_KHZ();
9 time_state->guest_tsc = 0;
10 time_state->cached_host_tsc = 0;
11 // time_state->pending_cycles = 0;
13 INIT_LIST_HEAD(&(time_state->timers));
14 time_state->num_timers = 0;
18 int v3_add_timer(struct guest_info * info, struct vm_timer_ops * ops, void * private_data) {
19 struct vm_timer * timer = NULL;
20 timer = (struct vm_timer *)V3_Malloc(sizeof(struct vm_timer));
21 V3_ASSERT(timer != NULL);
24 timer->private_data = private_data;
26 list_add(&(timer->timer_link), &(info->time_state.timers));
27 info->time_state.num_timers++;
33 int v3_remove_timer(struct guest_info * info, struct vm_timer * timer) {
34 list_del(&(timer->timer_link));
35 info->time_state.num_timers--;
43 void v3_update_time(struct guest_info * info, ullong_t cycles) {
44 struct vm_timer * tmp_timer;
46 info->time_state.guest_tsc += cycles;
48 list_for_each_entry(tmp_timer, &(info->time_state.timers), timer_link) {
49 tmp_timer->ops->update_time(cycles, info->time_state.cpu_freq, tmp_timer->private_data);
54 //info->time_state.pending_cycles = 0;