FreeBSD kernel kern code
kern_cpu.c File Reference
#include <sys/cdefs.h>
#include <sys/param.h>
#include <sys/bus.h>
#include <sys/cpu.h>
#include <sys/eventhandler.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/sbuf.h>
#include <sys/sched.h>
#include <sys/smp.h>
#include <sys/sysctl.h>
#include <sys/systm.h>
#include <sys/sx.h>
#include <sys/timetc.h>
#include <sys/taskqueue.h>
#include "cpufreq_if.h"
Include dependency graph for kern_cpu.c:

Go to the source code of this file.

Data Structures

struct  cf_saved_freq
 
struct  cpufreq_softc
 
struct  cf_setting_array
 

Macros

#define CF_MAX_LEVELS   64
 
#define CF_MTX_INIT(x)   sx_init((x), "cpufreq lock")
 
#define CF_MTX_LOCK(x)   sx_xlock((x))
 
#define CF_MTX_UNLOCK(x)   sx_xunlock((x))
 
#define CF_MTX_ASSERT(x)   sx_assert((x), SX_XLOCKED)
 
#define CF_DEBUG(msg...)
 

Functions

 __FBSDID ("$BSDSUniX$")
 
 TAILQ_HEAD (cf_setting_lst, cf_setting_array)
 
static int cpufreq_attach (device_t dev)
 
static void cpufreq_startup_task (void *ctx, int pending)
 
static int cpufreq_detach (device_t dev)
 
static int cf_set_method (device_t dev, const struct cf_level *level, int priority)
 
static int cf_get_method (device_t dev, struct cf_level *level)
 
static int cf_levels_method (device_t dev, struct cf_level *levels, int *count)
 
static int cpufreq_insert_abs (struct cpufreq_softc *sc, struct cf_setting *sets, int count)
 
static int cpufreq_expand_set (struct cpufreq_softc *sc, struct cf_setting_array *set_arr)
 
static struct cf_level * cpufreq_dup_set (struct cpufreq_softc *sc, struct cf_level *dup, struct cf_setting *set)
 
static int cpufreq_curr_sysctl (SYSCTL_HANDLER_ARGS)
 
static int cpufreq_levels_sysctl (SYSCTL_HANDLER_ARGS)
 
static int cpufreq_settings_sysctl (SYSCTL_HANDLER_ARGS)
 
 DRIVER_MODULE (cpufreq, cpu, cpufreq_driver, cpufreq_dc, 0, 0)
 
 TUNABLE_INT ("debug.cpufreq.lowest",&cf_lowest_freq)
 
 TUNABLE_INT ("debug.cpufreq.verbose",&cf_verbose)
 
static SYSCTL_NODE (_debug, OID_AUTO, cpufreq, CTLFLAG_RD, NULL,"cpufreq debugging")
 
 SYSCTL_INT (_debug_cpufreq, OID_AUTO, lowest, CTLFLAG_RW,&cf_lowest_freq, 1,"Don't provide levels below this frequency.")
 
 SYSCTL_INT (_debug_cpufreq, OID_AUTO, verbose, CTLFLAG_RW,&cf_verbose, 1,"Print verbose debugging messages")
 
int cpufreq_register (device_t dev)
 
int cpufreq_unregister (device_t dev)
 
int cpufreq_settings_changed (device_t dev)
 

Variables

struct cf_saved_freq sys_getcontext
 
static device_method_t cpufreq_methods []
 
static driver_t cpufreq_driver
 
static devclass_t cpufreq_dc
 
static int cf_lowest_freq
 
static int cf_verbose
 

Macro Definition Documentation

#define CF_DEBUG (   msg...)
Value:
do { \
printf("cpufreq: " msg); \
} while (0)
int printf(const char *fmt,...)
Definition: subr_prf.c:367
static int cf_verbose
Definition: kern_cpu.c:135

Definition at line 95 of file kern_cpu.c.

Referenced by cf_get_method(), cf_levels_method(), cf_set_method(), cpufreq_attach(), cpufreq_detach(), cpufreq_dup_set(), cpufreq_expand_set(), and cpufreq_insert_abs().

#define CF_MAX_LEVELS   64
#define CF_MTX_ASSERT (   x)    sx_assert((x), SX_XLOCKED)

Definition at line 93 of file kern_cpu.c.

Referenced by cpufreq_dup_set(), cpufreq_expand_set(), and cpufreq_insert_abs().

#define CF_MTX_INIT (   x)    sx_init((x), "cpufreq lock")

Definition at line 90 of file kern_cpu.c.

Referenced by cpufreq_attach().

#define CF_MTX_LOCK (   x)    sx_xlock((x))

Definition at line 91 of file kern_cpu.c.

Referenced by cf_get_method(), cf_levels_method(), and cf_set_method().

#define CF_MTX_UNLOCK (   x)    sx_xunlock((x))

Definition at line 92 of file kern_cpu.c.

Referenced by cf_get_method(), cf_levels_method(), and cf_set_method().

Function Documentation

__FBSDID ( "$BSDSUniX$"  )
static int cf_get_method ( device_t  dev,
struct cf_level *  level 
)
static
static int cf_levels_method ( device_t  dev,
struct cf_level *  levels,
int *  count 
)
static
static int cf_set_method ( device_t  dev,
const struct cf_level *  level,
int  priority 
)
static
static int cpufreq_curr_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 860 of file kern_cpu.c.

References CF_MAX_LEVELS, count, devclass_get_devices(), free(), levels, printf(), and sysctl_handle_int().

Referenced by cpufreq_attach().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpufreq_detach ( device_t  dev)
static

Definition at line 215 of file kern_cpu.c.

References CF_DEBUG, devclass_get_count(), device_get_nameunit(), device_get_softc(), free(), and sysctl_ctx_free().

Here is the call graph for this function:

static struct cf_level * cpufreq_dup_set ( struct cpufreq_softc sc,
struct cf_level *  dup,
struct cf_setting *  set 
)
static

Definition at line 765 of file kern_cpu.c.

References CF_DEBUG, CF_MTX_ASSERT, device_get_nameunit(), free(), cpufreq_softc::lock, and malloc().

Referenced by cpufreq_expand_set().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpufreq_expand_set ( struct cpufreq_softc sc,
struct cf_setting_array set_arr 
)
static

Definition at line 709 of file kern_cpu.c.

References CF_DEBUG, CF_MTX_ASSERT, cf_setting_array::count, cpufreq_dup_set(), cpufreq_softc::lock, set, and cf_setting_array::sets.

Referenced by cf_levels_method().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpufreq_insert_abs ( struct cpufreq_softc sc,
struct cf_setting *  sets,
int  count 
)
static

Definition at line 667 of file kern_cpu.c.

References CF_DEBUG, CF_MTX_ASSERT, count, cf_saved_freq::level, cpufreq_softc::lock, and malloc().

Referenced by cf_levels_method().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpufreq_levels_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 915 of file kern_cpu.c.

References CF_MAX_LEVELS, count, levels, printf(), sbuf_cpy(), sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), sbuf_new(), sbuf_printf(), sbuf_trim(), set, and sysctl_handle_string().

Referenced by cpufreq_attach().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpufreq_register ( device_t  dev)
int cpufreq_settings_changed ( device_t  dev)

Definition at line 1059 of file kern_cpu.c.

References device_get_parent(), and device_get_unit().

Referenced by cpufreq_startup_task().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cpufreq_settings_sysctl ( SYSCTL_HANDLER_ARGS  )
static

Definition at line 956 of file kern_cpu.c.

References free(), malloc(), sbuf_cpy(), sbuf_data(), sbuf_delete(), sbuf_finish(), sbuf_len(), sbuf_new(), sbuf_printf(), sbuf_trim(), sets, and sysctl_handle_string().

Referenced by cpufreq_register().

Here is the call graph for this function:

Here is the caller graph for this function:

static void cpufreq_startup_task ( void *  ctx,
int  pending 
)
static

Definition at line 208 of file kern_cpu.c.

References cpufreq_settings_changed().

Referenced by cpufreq_attach().

Here is the call graph for this function:

Here is the caller graph for this function:

int cpufreq_unregister ( device_t  dev)

Definition at line 1024 of file kern_cpu.c.

References device_delete_child(), device_find_child(), device_get_children(), device_get_parent(), device_is_attached(), device_printf(), free(), and type.

Here is the call graph for this function:

DRIVER_MODULE ( cpufreq  ,
cpu  ,
cpufreq_driver  ,
cpufreq_dc  ,
,
 
)
SYSCTL_INT ( _debug_cpufreq  ,
OID_AUTO  ,
lowest  ,
CTLFLAG_RW  ,
cf_lowest_freq,
,
"Don't provide levels below this frequency."   
)
SYSCTL_INT ( _debug_cpufreq  ,
OID_AUTO  ,
verbose  ,
CTLFLAG_RW  ,
cf_verbose,
,
"Print verbose debugging messages"   
)
static SYSCTL_NODE ( _debug  ,
OID_AUTO  ,
cpufreq  ,
CTLFLAG_RD  ,
NULL  ,
"cpufreq debugging"   
)
static
TAILQ_HEAD ( cf_setting_lst  ,
cf_setting_array   
)
TUNABLE_INT ( "debug.cpufreq.lowest"  ,
cf_lowest_freq 
)
TUNABLE_INT ( "debug.cpufreq.verbose"  ,
cf_verbose 
)

Variable Documentation

int cf_lowest_freq
static

Definition at line 134 of file kern_cpu.c.

int cf_verbose
static

Definition at line 135 of file kern_cpu.c.

devclass_t cpufreq_dc
static

Definition at line 131 of file kern_cpu.c.

driver_t cpufreq_driver
static
Initial value:
= {
"cpufreq", cpufreq_methods, sizeof(struct cpufreq_softc)
}
static device_method_t cpufreq_methods[]
Definition: kern_cpu.c:118

Definition at line 128 of file kern_cpu.c.

device_method_t cpufreq_methods[]
static
Initial value:
= {
DEVMETHOD(cpufreq_set, cf_set_method),
DEVMETHOD(cpufreq_get, cf_get_method),
DEVMETHOD(cpufreq_levels, cf_levels_method),
{0, 0}
}
static int cpufreq_detach(device_t dev)
Definition: kern_cpu.c:215
static int cf_set_method(device_t dev, const struct cf_level *level, int priority)
Definition: kern_cpu.c:241
int device_probe(device_t dev)
Probe a device, and return this status.
Definition: subr_bus.c:2689
static int cf_get_method(device_t dev, struct cf_level *level)
Definition: kern_cpu.c:414
int bus_generic_probe(device_t dev)
Helper function for implementing DEVICE_PROBE()
Definition: subr_bus.c:3440
static int cpufreq_attach(device_t dev)
Definition: kern_cpu.c:146
int device_detach(device_t dev)
Detach a driver from a device.
Definition: subr_bus.c:2814
int device_attach(device_t dev)
Attach a device driver to a device.
Definition: subr_bus.c:2761
static int cf_levels_method(device_t dev, struct cf_level *levels, int *count)
Definition: kern_cpu.c:518

Definition at line 118 of file kern_cpu.c.

struct cf_saved_freq sys_getcontext