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.


P-State (DVFS) control host interface
[palacios.git] / palacios / src / interfaces / vmm_pstate_ctrl.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) 2014, the V3VEE Project <http://www.v3vee.org>
11  * all rights reserved.
12  *
13  * Author: Kyle C. Hale <kh@u.northwestern.edu>
14  *         Shiva Rao <shiva.rao.717@gmail.com>
15  *         Peter Dinda <pdinda@northwestern.edu>
16  *
17  * This is free software.  you are permitted to use,
18  * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
19  */
20
21 #include <palacios/vmm.h>
22
23 #include <interfaces/vmm_pstate_ctrl.h>
24
25 static struct v3_host_pstate_ctrl_iface *pstate_ctrl_hooks = 0;
26
27
28 void V3_Init_Pstate_Ctrl(struct v3_host_pstate_ctrl_iface *hooks)
29 {
30     pstate_ctrl_hooks = hooks;
31
32     PrintDebug(VM_NONE, VCORE_NONE, "V3 host p-state control interface inited\n");
33
34     return;
35 }
36
37
38 void v3_get_cpu_pstate_chars(struct v3_cpu_pstate_chars *chars)
39 {
40     if (pstate_ctrl_hooks && pstate_ctrl_hooks->get_chars) { 
41         pstate_ctrl_hooks->get_chars(chars);
42     }
43 }
44
45
46 void v3_acquire_pstate_ctrl(uint32_t type)
47 {
48     if (pstate_ctrl_hooks && pstate_ctrl_hooks->acquire) { 
49         pstate_ctrl_hooks->acquire(type);
50     }
51 }
52
53
54 uint8_t v3_get_cpu_pstate(void)
55 {
56     if (pstate_ctrl_hooks && pstate_ctrl_hooks->get_pstate) { 
57         return pstate_ctrl_hooks->get_pstate();
58     } else {
59         return 0;
60     }
61 }
62
63 void    v3_set_cpu_pstate (uint8_t p)
64 {
65     if (pstate_ctrl_hooks && pstate_ctrl_hooks->set_pstate) { 
66         pstate_ctrl_hooks->set_pstate(p);
67     }
68 }
69
70 uint64_t v3_get_cpu_freq(void)
71 {
72     if (pstate_ctrl_hooks && pstate_ctrl_hooks->get_freq) { 
73         return pstate_ctrl_hooks->get_freq();
74     } else {
75         return 0;
76     }
77 }
78
79 void    v3_set_cpu_freq(uint64_t f)
80 {
81     if (pstate_ctrl_hooks && pstate_ctrl_hooks->set_freq) { 
82         pstate_ctrl_hooks->set_freq(f);
83     }
84 }
85
86 // If using direct control, relinquish
87 void v3_release_pstate_control()
88 {
89     if (pstate_ctrl_hooks && pstate_ctrl_hooks->release) { 
90         pstate_ctrl_hooks->release();
91     }
92 }