libdvfs  2.0
A light library to set CPU governor and freqency
Data Structures | Macros | Functions
dvfs_context.h File Reference

Describes all the structures and functions related to the whole DVFS context (the whole system). More...

Go to the source code of this file.

Data Structures

struct  dvfs_ctx
 DVFS Context. More...
 

Macros

#define DVFS_TB_UNAVAILABLE   0
 TurboBoost is not available, see dvfs_has_TB()
 
#define DVFS_TB_AVAILABLE   1
 TurboBoost is available, see dvfs_has_TB()
 

Functions

int dvfs_start (dvfs_ctx **ppCtx, bool seq)
 Starts controlling DVFS on the system. More...
 
int dvfs_stop (dvfs_ctx *ctx)
 Frees the memory associated to a DVFS context and restores the DVFS control to its state before calling dvfs_start. More...
 
int dvfs_has_TB ()
 Returns true if one of the DVFS unit on the system allows TurboBoost. More...
 
int dvfs_set_gov (const dvfs_ctx *ctx, const char *gov)
 Sets the provided governor on all the DVFS units. More...
 
int dvfs_set_freq (dvfs_ctx *ctx, unsigned int freq)
 Sets the given frequency on all the DVFS units. More...
 
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. More...
 
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. More...
 
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. More...
 
int dvfs_get_nb_units (const dvfs_ctx *ctx, unsigned int *pNb)
 Gets the number of DVFS units available in this context. More...
 

Detailed Description

Describes all the structures and functions related to the whole DVFS context (the whole system).

This is the entry point of the library.

See also
dvfs_unit

Function Documentation

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.

Parameters
ctxThe DVFS context as provided by dvfs_start()
ppCoreThe dvfs_core structure associated to the core or NULL if the core id is not found.
core_idThe core id.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx or ppCore are NULL.
DVFS_ERROR_INVALID_CORE_IDif the core ID is not valid.
int dvfs_get_nb_units ( const dvfs_ctx ctx,
unsigned int *  pNb 
)

Gets the number of DVFS units available in this context.

Parameters
ctxThe DVFS context as provided by dvfs_start()
pNbWill be filled with the number of DVFS unit available
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx or pNb are NULL.
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.

Parameters
ctxThe DVFS context as provided by dvfs_start()
coreThe core structure.
ppUnitThe DVFS unit in charge of this core.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx or core or ppUnit are NULL.
DVFS_ERROR_CORE_UNIT_MISMATCHif the unit can not be find.
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.

Parameters
ctxThe DVFS context as provided by dvfs_start()
ppUnitWill be filled with the DVFS unit.
indexThe index of the DVFS unit to get
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx or core or ppUnit are NULL.
DVFS_ERROR_INVALID_INDEXif index does not match any DVFS unit.
int dvfs_has_TB ( )

Returns true if one of the DVFS unit on the system allows TurboBoost.

Returns
Return values
DVFS_TB_AVAILABLEif TurboBoost is available on one of the DVFS unit.
DVFS_TB_UNAVAILABLEif TurboBoost is not available.
DVFS_ERROR_FILE_FAILEDif the information could not be read (likely because /proc/cpuinfo is not available), or can't be opened.
int dvfs_set_freq ( dvfs_ctx ctx,
unsigned int  freq 
)

Sets the given frequency on all the DVFS units.

The effects are unknown if the current governor is not "userspace".

Parameters
ctxThe DVFS context as provided by dvfs_start()
freqThe new frequency to set.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx is NULL.
int dvfs_set_gov ( const dvfs_ctx ctx,
const char *  gov 
)

Sets the provided governor on all the DVFS units.

Parameters
ctxThe DVFS context as provided by dvfs_start
govThe new governor to set
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx or gov are NULL.
int dvfs_start ( dvfs_ctx **  ppCtx,
bool  seq 
)

Starts controlling DVFS on the system.

Parameters
ppCtxthe new DVFS context used in the various functions.
seqTells if the frequency transitions must be synchronized or not.
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ppCtx is NULL.
DVFS_ERROR_MEM_ALLOC_FAILEDif memory allocation failed.
DVFS_ERROR_RELATED_CORE_UNAVAILABLEthe related core information is not available
See also
dvfs_stop()
int dvfs_stop ( dvfs_ctx ctx)

Frees the memory associated to a DVFS context and restores the DVFS control to its state before calling dvfs_start.

Parameters
ctxthe context
Returns
Return values
DVFS_SUCCESSif everything goes right.
DVFS_ERROR_INVALID_ARGif ctx is NULL.
See also
dvfs_start()