Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


*** empty log message ***
[palacios.git] / palacios / src / palacios / vmm_time.c
1 #include "palacios/vmm_time.h"
2 #include "palacios/vmm.h"
3
4
5 void v3_init_time(struct vm_time * time_state) {
6   ullong_t cpu_khz = 0;
7
8   V3_CPU_KHZ(cpu_khz);
9   time_state->cpu_freq = cpu_khz;
10
11   PrintDebug("CPU KHZ = HI=%x LO=%x\n", (uint_t)(cpu_khz >> 32), (uint_t)cpu_khz);
12  
13   time_state->guest_tsc = 0;
14   time_state->cached_host_tsc = 0;
15   // time_state->pending_cycles = 0;
16   
17   INIT_LIST_HEAD(&(time_state->timers));
18   time_state->num_timers = 0;
19 }
20
21
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);
26
27   timer->ops = ops;
28   timer->private_data = private_data;
29
30   list_add(&(timer->timer_link), &(info->time_state.timers));
31   info->time_state.num_timers++;
32
33   return 0;
34 }
35
36
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--;
40
41   V3_Free(timer);
42   return 0;
43 }
44
45
46
47 void v3_update_time(struct guest_info * info, ullong_t cycles) {
48   struct vm_timer * tmp_timer;
49   
50   info->time_state.guest_tsc += cycles;
51
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);
54   }
55   
56
57
58   //info->time_state.pending_cycles = 0;
59 }