1 #include "palacios/vmm_time.h"
2 #include "palacios/vmm.h"
5 void v3_init_time(struct vm_time * time_state) {
9 time_state->cpu_freq = cpu_khz;
11 PrintDebug("CPU KHZ = HI=%x LO=%x\n", (uint_t)(cpu_khz >> 32), (uint_t)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) {
26 list_add(&(timer->timer_link), &(info->time_state.timers));
27 info->time_state.num_timers++;
32 int remove_timer(struct guest_info * info, struct vm_timer * timer) {
33 list_del(&(timer->timer_link));
34 info->time_state.num_timers--;
40 void update_timers(struct guest_info * info) {
41 struct vm_timer * tmp_timer;
43 list_for_each_entry(tmp_timer, &(info->time_state.timers), timer_link) {
44 tmp_timer->ops.update_time(info->time_state.pending_cycles, info->time_state.cpu_freq, tmp_timer->private_data);
48 info->time_state.pending_cycles = 0;