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.


integrated new configuration system
[palacios.git] / palacios / src / palacios / vmm_time.c
1 /* 
2  * This file is part of the Palacios Virtual Machine Monitor developed
3  * by the V3VEE Project with funding from the United States National 
4  * Science Foundation and the Department of Energy.  
5  *
6  * The V3VEE Project is a joint project between Northwestern University
7  * and the University of New Mexico.  You can find out more at 
8  * http://www.v3vee.org
9  *
10  * Copyright (c) 2008, Jack Lange <jarusl@cs.northwestern.edu> 
11  * Copyright (c) 2008, The V3VEE Project <http://www.v3vee.org> 
12  * All rights reserved.
13  *
14  * Author: Jack Lange <jarusl@cs.northwestern.edu>
15  *
16  * This is free software.  You are permitted to use,
17  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
18  */
19
20 #include <palacios/vmm_time.h>
21 #include <palacios/vmm.h>
22 #include <palacios/vm_guest.h>
23
24 void v3_init_time(struct guest_info * info) {
25     struct vm_time * time_state = &(info->time_state);
26
27     time_state->cpu_freq = V3_CPU_KHZ();
28  
29     time_state->guest_tsc = 0;
30     time_state->cached_host_tsc = 0;
31     // time_state->pending_cycles = 0;
32   
33     INIT_LIST_HEAD(&(time_state->timers));
34     time_state->num_timers = 0;
35 }
36
37
38 int v3_add_timer(struct guest_info * info, struct vm_timer_ops * ops, void * private_data) {
39     struct vm_timer * timer = NULL;
40     timer = (struct vm_timer *)V3_Malloc(sizeof(struct vm_timer));
41     V3_ASSERT(timer != NULL);
42
43     timer->ops = ops;
44     timer->private_data = private_data;
45
46     list_add(&(timer->timer_link), &(info->time_state.timers));
47     info->time_state.num_timers++;
48
49     return 0;
50 }
51
52
53 int v3_remove_timer(struct guest_info * info, struct vm_timer * timer) {
54     list_del(&(timer->timer_link));
55     info->time_state.num_timers--;
56
57     V3_Free(timer);
58     return 0;
59 }
60
61
62
63 void v3_update_time(struct guest_info * info, ullong_t cycles) {
64     struct vm_timer * tmp_timer;
65   
66     info->time_state.guest_tsc += cycles;
67
68     list_for_each_entry(tmp_timer, &(info->time_state.timers), timer_link) {
69         tmp_timer->ops->update_time(cycles, info->time_state.cpu_freq, tmp_timer->private_data);
70     }
71   
72
73
74     //info->time_state.pending_cycles = 0;
75 }