cpufreq - CPU frequency control framework
#include <sys/cpu.h>
int
cpufreq_levels (device_t dev struct cf_level *levels int *count);
int
cpufreq_set (device_t dev const struct cf_level *level int priority);
int
cpufreq_get (device_t dev struct cf_level *level);
int
Fo cpufreq_drv_settings
Fa device_t dev
Fa struct cf_setting *sets
Fa int *count
Fc Ft int
cpufreq_drv_type (device_t dev int *type);
int
cpufreq_drv_set (device_t dev const struct cf_setting *set);
int
cpufreq_drv_get (device_t dev struct cf_setting *set);
The frequency cannot be changed if TSC is in use as the timecounter. This is because the timecounter system needs to use a source that has a constant rate. The timecounter source can be changed with the kern.timecounter.hardware sysctl. Available modes are in kern.timecounter.choice sysctl entry.
The following device drivers offer relative frequency control and have an additive effect:
The
cpufreq_levels ();
method takes a
device and an empty array of
Fa levels .
The
Fa count
value should be set to the number of levels available and after the
function completes, will be set to the actual number of levels returned.
If there are more levels than
Fa count
will allow, it should return
Er E2BIG .
The
cpufreq_get ();
method takes a pointer to space to store a
Fa level .
After successful completion, the output will be the current active level
and is equal to one of the levels returned by
cpufreq_levels (.);
The
cpufreq_set ();
method takes a pointer a
Fa level
and attempts to activate it.
The
Fa priority
(i.e.,
CPUFREQ_PRIO_KERN
tells
whether to override previous settings while activating this level.
If
Fa priority
is higher than the current active level, that level will be saved and
overridden with the new level.
If a level is already saved, the new level is set without overwriting
the older saved level.
If
cpufreq_set ();
is called with a
NULL
Fa level ,
the saved level will be restored.
If there is no saved level,
cpufreq_set ();
will return
Er ENXIO .
If
Fa priority
is lower than the current active level's priority, this method returns
Er EPERM .
The
cpufreq_drv_settings ();
method returns an array of currently available settings, each of type
Vt struct cf_setting .
The driver should set unknown or irrelevant values to
CPUFREQ_VAL_UNKNOWN
All the following elements for each setting should be returned:
struct cf_setting { int freq; /* CPU clock in Mhz or 100ths of a percent. */ int volts; /* Voltage in mV. */ int power; /* Power consumed in mW. */ int lat; /* Transition latency in us. */ device_t dev; /* Driver providing this setting. */ };
On entry to this method, Fa count contains the number of settings that can be returned. On successful completion, the driver sets it to the actual number of settings returned. If the driver offers more settings than Fa count will allow, it should return Er E2BIG .
The
cpufreq_drv_type ();
method indicates the type of settings it offers, either
CPUFREQ_TYPE_ABSOLUTE
or
CPUFREQ_TYPE_RELATIVE
Additionally, the driver may set the
CPUFREQ_FLAG_INFO_ONLY
flag if the settings it provides are information for other drivers only
and cannot be passed to
cpufreq_drv_set ();
to activate them.
The
cpufreq_drv_set ();
method takes a driver setting and makes it active.
If the setting is invalid or not currently available, it should return
Er EINVAL .
The
cpufreq_drv_get ();
method returns the currently-active driver setting.
The
Vt struct cf_setting
returned must be valid for passing to
cpufreq_drv_set (,);
including all elements being filled out correctly.
If the driver cannot infer the current setting
(even by estimating it with
cpu_est_clockrate ());
then it should set all elements to
CPUFREQ_VAL_UNKNOWN
Notification of CPU and bus frequency changes is not implemented yet.
When multiple CPUs offer frequency control, they cannot be set to different levels and must all offer the same frequency settings.
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |