1 /* Northwestern University */
2 /* (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> */
4 #include "palacios/vmm_time.h"
5 #include "palacios/vmm.h"
8 void v3_init_time(struct guest_info * info) {
9 struct vm_time * time_state = &(info->time_state);
11 time_state->cpu_freq = V3_CPU_KHZ();
13 time_state->guest_tsc = 0;
14 time_state->cached_host_tsc = 0;
15 // time_state->pending_cycles = 0;
17 INIT_LIST_HEAD(&(time_state->timers));
18 time_state->num_timers = 0;
22 int v3_add_timer(struct guest_info * info, struct vm_timer_ops * ops, void * private_data) {
23 struct vm_timer * timer = NULL;
24 timer = (struct vm_timer *)V3_Malloc(sizeof(struct vm_timer));
25 V3_ASSERT(timer != NULL);
28 timer->private_data = private_data;
30 list_add(&(timer->timer_link), &(info->time_state.timers));
31 info->time_state.num_timers++;
37 int v3_remove_timer(struct guest_info * info, struct vm_timer * timer) {
38 list_del(&(timer->timer_link));
39 info->time_state.num_timers--;
47 void v3_update_time(struct guest_info * info, ullong_t cycles) {
48 struct vm_timer * tmp_timer;
50 info->time_state.guest_tsc += cycles;
52 list_for_each_entry(tmp_timer, &(info->time_state.timers), timer_link) {
53 tmp_timer->ops->update_time(cycles, info->time_state.cpu_freq, tmp_timer->private_data);
58 //info->time_state.pending_cycles = 0;