1 #ifndef __VMM_PSTATE_CTRL_H__
2 #define __VMM_PSTATE_CTRL_H__
5 * This file is part of the Palacios Virtual Machine Monitor developed
6 * by the V3VEE Project with funding from the United States National
7 * Science Foundation and the Department of Energy.
9 * The V3VEE Project is a joint project between Northwestern University
10 * and the University of New Mexico. You can find out more at
11 * http://www.v3vee.org
13 * Copyright (c) 2014, the V3VEE Project <http://www.v3vee.org>
14 * all rights reserved.
16 * Author: Kyle C. Hale <kh@u.northwestern.edu>
17 * Shiva Rao <shiva.rao.717@gmail.com>
18 * Peter Dinda <pdinda@northwestern.edu>
20 * This is free software. you are permitted to use,
21 * redistribute, and modify it as specified in the file "V3VEE_LICENSE".
24 #include <palacios/vmm_types.h>
26 struct v3_cpu_pstate_chars {
27 // bit mask of features this host implentation has
29 #define V3_PSTATE_EXTERNAL_CONTROL 1 // host will expose user control to Palacios
30 #define V3_PSTATE_DIRECT_CONTROL 2 // host will directly manipulate HW pstate if asked by Palacios
31 #define V3_PSTATE_INTERNAL_CONTROL 4 // host will deactivate its control so Palacios can manipulate hardware itself
32 uint32_t cur_mode; // current mode (0=>NONE - host control), else one of the above
33 uint64_t min_freq_khz; // minimum frequency that can be configed by EXTERANL_CONTROL
34 uint64_t max_freq_khz; // maximum frequency that can be configed by EXTERANL_CONTROL
35 uint64_t cur_freq_khz; // current selected frequency only meaningful under EXTERANL CONTROL
36 uint8_t min_pstate; // minimum pstate that can be configed by DIRECT_CONTROL
37 uint8_t max_pstate; // maximum pstate that can be configed by DIRECT_CONTROL
38 uint8_t cur_pstate; // current selected pstate only meaningful under DIRECT_CONTROL
42 struct v3_host_pstate_ctrl_iface {
43 // get characteristics of the implementation
44 void (*get_chars)(struct v3_cpu_pstate_chars *chars);
45 // acquire control on the caller's core
46 // ttype=V3_PSTATE_DIRECT_CONTROL or V3_PSTATE_INTERNAL_CONTROL or V3_PSTATE_EXTERNAL_CONTROL
47 void (*acquire)(uint32_t type);
48 void (*release)(void);
49 // pstate control applies if we have acquired DIRECT_CONTROL
50 void (*set_pstate)(uint8_t pstate);
51 uint8_t (*get_pstate)(void);
52 // freq control applies if we have acquired EXTERNAL_CONTROL
53 void (*set_freq)(uint64_t freq_khz);
54 uint64_t (*get_freq)(void);
55 // if we have INTERNAL_CONTROL, we do as we please
58 extern void V3_Init_Pstate_Ctrl (struct v3_host_pstate_ctrl_iface * palacios_pstate_ctrl);
62 // get characteristics of the calling core
63 void v3_get_cpu_pstate_chars(struct v3_cpu_pstate_chars *chars);
65 // Tell the host to acquire control over this core
66 void v3_acquire_pstate_ctrl(uint32_t type);
69 uint8_t v3_get_cpu_pstate(void);
70 void v3_set_cpu_pstate (uint8_t p);
72 // for EXTERANL_CONTROL
73 uint64_t v3_get_cpu_freq(void);
74 void v3_set_cpu_freq(uint64_t freq_khz);
76 // Tell the host to release control over this core
77 void v3_release_pstate_control();