The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/sys/cpu.h

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2005 Nate Lawson (SDG)
    3  * All rights reserved.
    4  *
    5  * Redistribution and use in source and binary forms, with or without
    6  * modification, are permitted provided that the following conditions
    7  * are met:
    8  * 1. Redistributions of source code must retain the above copyright
    9  *    notice, this list of conditions and the following disclaimer.
   10  * 2. Redistributions in binary form must reproduce the above copyright
   11  *    notice, this list of conditions and the following disclaimer in the
   12  *    documentation and/or other materials provided with the distribution.
   13  *
   14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   24  * SUCH DAMAGE.
   25  *
   26  * $FreeBSD: src/sys/sys/cpu.h,v 1.3.2.1 2005/02/25 21:17:21 njl Exp $
   27  */
   28 
   29 #ifndef _SYS_CPU_H_
   30 #define _SYS_CPU_H_
   31 
   32 /*
   33  * CPU device support.
   34  */
   35 
   36 #define CPU_IVAR_PCPU           1
   37 
   38 static __inline struct pcpu *cpu_get_pcpu(device_t dev)
   39 {
   40         uintptr_t v = 0;
   41         BUS_READ_IVAR(device_get_parent(dev), dev, CPU_IVAR_PCPU, &v);
   42         return ((struct pcpu *)v);
   43 }
   44 
   45 /*
   46  * CPU frequency control interface.
   47  */
   48 
   49 /* Each driver's CPU frequency setting is exported in this format. */
   50 struct cf_setting {
   51         int     freq;   /* CPU clock in Mhz or 100ths of a percent. */
   52         int     volts;  /* Voltage in mV. */
   53         int     power;  /* Power consumed in mW. */
   54         int     lat;    /* Transition latency in us. */
   55         device_t dev;   /* Driver providing this setting. */
   56         int     spec[4];/* Driver-specific storage for non-standard info. */
   57 };
   58 
   59 /* Maximum number of settings a given driver can have. */
   60 #define MAX_SETTINGS            24
   61 
   62 /* A combination of settings is a level. */
   63 struct cf_level {
   64         struct cf_setting       total_set;
   65         struct cf_setting       abs_set;
   66         struct cf_setting       rel_set[MAX_SETTINGS];
   67         int                     rel_count;
   68         TAILQ_ENTRY(cf_level)   link;
   69 };
   70 
   71 TAILQ_HEAD(cf_level_lst, cf_level);
   72 
   73 /* Drivers should set all unknown values to this. */
   74 #define CPUFREQ_VAL_UNKNOWN     (-1)
   75 
   76 /*
   77  * Every driver offers a type of CPU control.  Absolute levels are mutually
   78  * exclusive while relative levels modify the current absolute level.  There
   79  * may be multiple absolute and relative drivers available on a given
   80  * system.
   81  *
   82  * For example, consider a system with two absolute drivers that provide
   83  * frequency settings of 100, 200 and 300, 400 and a relative driver that
   84  * provides settings of 50%, 100%.  The cpufreq core would export frequency
   85  * levels of 50, 100, 150, 200, 300, 400.
   86  *
   87  * The "info only" flag signifies that settings returned by
   88  * CPUFREQ_DRV_SETTINGS cannot be passed to the CPUFREQ_DRV_SET method and
   89  * are only informational.  This is for some drivers that can return
   90  * information about settings but rely on another machine-dependent driver
   91  * for actually performing the frequency transition (e.g., ACPI performance
   92  * states of type "functional fixed hardware.")
   93  */
   94 #define CPUFREQ_TYPE_MASK       0xffff
   95 #define CPUFREQ_TYPE_RELATIVE   (1<<0)
   96 #define CPUFREQ_TYPE_ABSOLUTE   (1<<1)
   97 #define CPUFREQ_FLAG_INFO_ONLY  (1<<16)
   98 
   99 /*
  100  * When setting a level, the caller indicates the priority of this request.
  101  * Priorities determine, among other things, whether a level can be
  102  * overridden by other callers.  For example, if the user sets a level but
  103  * the system thermal driver needs to override it for emergency cooling,
  104  * the driver would use a higher priority.  Once the event has passed, the
  105  * driver would call cpufreq to resume any previous level.
  106  */
  107 #define CPUFREQ_PRIO_HIGHEST    1000000
  108 #define CPUFREQ_PRIO_KERN       1000
  109 #define CPUFREQ_PRIO_USER       100
  110 #define CPUFREQ_PRIO_LOWEST     0
  111 
  112 /*
  113  * Register and unregister a driver with the cpufreq core.  Once a driver
  114  * is registered, it must support calls to its CPUFREQ_GET, CPUFREQ_GET_LEVEL,
  115  * and CPUFREQ_SET methods.  It must also unregister before returning from
  116  * its DEVICE_DETACH method.
  117  */
  118 int     cpufreq_register(device_t dev);
  119 int     cpufreq_unregister(device_t dev);
  120 
  121 /* Allow values to be +/- a bit since sometimes we have to estimate. */
  122 #define CPUFREQ_CMP(x, y)       (abs((x) - (y)) < 25)
  123 
  124 /*
  125  * Machine-dependent functions.
  126  */
  127 
  128 /* Estimate the current clock rate for the given CPU id. */
  129 int     cpu_est_clockrate(int cpu_id, uint64_t *rate);
  130 
  131 #endif /* !_SYS_CPU_H_ */

Cache object: 4adead43df3eb23b94ac5c1f1cd9db99


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.