libdvfs  2.0
A light library to set CPU governor and freqency
dvfs_context.h
Go to the documentation of this file.
1 /*
2  * libdvfs - A light library to set CPU governor and frequency
3  * Copyright (C) 2013-2014 Universite de Versailles
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include <stdbool.h>
22 
23 #include "dvfs_unit.h"
24 #include "dvfs_core.h"
25 
26 
43 typedef struct {
44  unsigned int nb_units;
46 } dvfs_ctx;
47 
61 int dvfs_start(dvfs_ctx** ppCtx, bool seq);
62 
74 int dvfs_stop(dvfs_ctx *ctx);
75 
76 #define DVFS_TB_UNAVAILABLE 0
77 #define DVFS_TB_AVAILABLE 1
85 int dvfs_has_TB();
86 
96 int dvfs_set_gov(const dvfs_ctx *ctx, const char *gov);
97 
108 int dvfs_set_freq(dvfs_ctx *ctx, unsigned int freq);
109 
122 int dvfs_get_core(const dvfs_ctx *ctx, const dvfs_core **ppCore, unsigned int core_id);
123 
135 int dvfs_get_unit_by_id(const dvfs_ctx* ctx, const dvfs_unit** ppUnit, unsigned int index);
136 
148 int dvfs_get_unit_by_core(const dvfs_ctx *ctx, const dvfs_core *core, const dvfs_unit **ppUnit);
149 
159 int dvfs_get_nb_units(const dvfs_ctx* ctx, unsigned int *pNb);
DVFS Context.
Definition: dvfs_context.h:43
dvfs_unit ** units
DVFS units we are handling.
Definition: dvfs_context.h:45
int dvfs_stop(dvfs_ctx *ctx)
Frees the memory associated to a DVFS context and restores the DVFS control to its state before calli...
Definition: dvfs_context.c:122
A DVFS unit.
Definition: dvfs_unit.h:40
int dvfs_set_gov(const dvfs_ctx *ctx, const char *gov)
Sets the provided governor on all the DVFS units.
Definition: dvfs_context.c:172
Structures and functions related to DVFS units (group of cores running at the same frequency)...
Structures and functions to change frequency at the scale of a CPU core.
unsigned int nb_units
Number of DVFS units on the system.
Definition: dvfs_context.h:44
int dvfs_get_unit_by_core(const dvfs_ctx *ctx, const dvfs_core *core, const dvfs_unit **ppUnit)
Gets the DVFS unit associated with the given core.
Definition: dvfs_context.c:256
int dvfs_get_core(const dvfs_ctx *ctx, const dvfs_core **ppCore, unsigned int core_id)
Gets the dvfs_core structure associated to the given core id.
Definition: dvfs_context.c:215
Represents on core.
Definition: dvfs_core.h:36
int dvfs_start(dvfs_ctx **ppCtx, bool seq)
Starts controlling DVFS on the system.
Definition: dvfs_context.c:36
int dvfs_set_freq(dvfs_ctx *ctx, unsigned int freq)
Sets the given frequency on all the DVFS units.
Definition: dvfs_context.c:194
int dvfs_get_nb_units(const dvfs_ctx *ctx, unsigned int *pNb)
Gets the number of DVFS units available in this context.
Definition: dvfs_context.c:282
int dvfs_get_unit_by_id(const dvfs_ctx *ctx, const dvfs_unit **ppUnit, unsigned int index)
Gets the DVFS unit associated to the given index.
Definition: dvfs_context.c:238