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/envsys.h

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /* $NetBSD: envsys.h,v 1.23 2008/08/22 11:27:50 pgoyette Exp $ */
    2 
    3 /*-
    4  * Copyright (c) 1999, 2007 The NetBSD Foundation, Inc.
    5  * All rights reserved.
    6  *
    7  * This code is derived from software contributed to The NetBSD Foundation
    8  * by Tim Rightnour, Juan Romero Pardines and Bill Squier.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   13  * 1. Redistributions of source code must retain the above copyright
   14  *    notice, this list of conditions and the following disclaimer.
   15  * 2. Redistributions in binary form must reproduce the above copyright
   16  *    notice, this list of conditions and the following disclaimer in the
   17  *    documentation and/or other materials provided with the distribution.
   18  *
   19  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
   20  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   21  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   22  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
   23  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   29  * POSSIBILITY OF SUCH DAMAGE.
   30  */
   31 
   32 #ifndef _SYS_ENVSYS_H_
   33 #define _SYS_ENVSYS_H_
   34 
   35 #ifndef _KERNEL
   36 #include <stdbool.h>
   37 #endif
   38 
   39 #include <sys/ioccom.h>
   40 #include <sys/power.h>
   41 #include <sys/queue.h>
   42 
   43 /*
   44  * ENVironmental SYStem version 2 (aka ENVSYS 2)
   45  */
   46 
   47 #define ENVSYS_MAXSENSORS       512
   48 #define ENVSYS_DESCLEN          32
   49 
   50 /* struct used by a sensor */
   51 struct envsys_data {
   52         TAILQ_ENTRY(envsys_data)        sensors_head;
   53         uint32_t        sensor;         /* sensor number */
   54         uint32_t        units;          /* type of sensor */
   55         uint32_t        state;          /* sensor state */
   56         uint32_t        flags;          /* sensor flags */
   57         uint32_t        rpms;           /* for fans, nominal RPMs */
   58         int32_t         rfact;          /* for volts, factor x 10^4 */
   59         int32_t         value_cur;      /* current value */
   60         int32_t         value_max;      /* max value */
   61         int32_t         value_min;      /* min value */
   62         int32_t         value_avg;      /* avg value */
   63         int             upropset;       /* userland property set? */
   64         bool            monitor;        /* monitoring enabled/disabled */
   65         char            desc[ENVSYS_DESCLEN];   /* sensor description */
   66 };
   67 
   68 typedef struct envsys_data envsys_data_t;
   69 
   70 /* sensor units */
   71 enum envsys_units {
   72         ENVSYS_STEMP            = 0,    /* Temperature */
   73         ENVSYS_SFANRPM,                 /* Fan RPM */
   74         ENVSYS_SVOLTS_AC,               /* AC Volts */
   75         ENVSYS_SVOLTS_DC,               /* DC Volts */
   76         ENVSYS_SOHMS,                   /* Ohms */
   77         ENVSYS_SWATTS,                  /* Watts */
   78         ENVSYS_SAMPS,                   /* Ampere */
   79         ENVSYS_SWATTHOUR,               /* Watt hour */
   80         ENVSYS_SAMPHOUR,                /* Ampere hour */
   81         ENVSYS_INDICATOR,               /* Indicator */
   82         ENVSYS_INTEGER,                 /* Integer */
   83         ENVSYS_DRIVE,                   /* Drive */
   84         ENVSYS_BATTERY_CAPACITY,        /* Battery capacity */
   85         ENVSYS_BATTERY_CHARGE,          /* Battery charging/discharging */
   86         ENVSYS_NSENSORS
   87 };
   88 
   89 /* sensor states */
   90 enum envsys_states {
   91         ENVSYS_SVALID           = 10,   /* sensor state is valid */
   92         ENVSYS_SINVALID,                /* sensor state is invalid */
   93         ENVSYS_SCRITICAL,               /* sensor state is critical */
   94         ENVSYS_SCRITUNDER,              /* sensor state is critical under */
   95         ENVSYS_SCRITOVER,               /* sensor state is critical over */
   96         ENVSYS_SWARNUNDER,              /* sensor state is warn under */
   97         ENVSYS_SWARNOVER                /* sensor state is warn over */
   98 };
   99 
  100 /* sensor drive states */
  101 enum envsys_drive_states {
  102         ENVSYS_DRIVE_EMPTY      = 1,    /* drive is empty */
  103         ENVSYS_DRIVE_READY,             /* drive is ready */
  104         ENVSYS_DRIVE_POWERUP,           /* drive is powered up */
  105         ENVSYS_DRIVE_ONLINE,            /* drive is online */
  106         ENVSYS_DRIVE_IDLE,              /* drive is idle */
  107         ENVSYS_DRIVE_ACTIVE,            /* drive is active */
  108         ENVSYS_DRIVE_REBUILD,           /* drive is rebuilding */
  109         ENVSYS_DRIVE_POWERDOWN,         /* drive is powered down */
  110         ENVSYS_DRIVE_FAIL,              /* drive failed */
  111         ENVSYS_DRIVE_PFAIL,             /* drive is degraded */
  112         ENVSYS_DRIVE_MIGRATING,         /* drive is migrating */
  113         ENVSYS_DRIVE_OFFLINE,           /* drive is offline */
  114         ENVSYS_DRIVE_BUILD,             /* drive is building */
  115         ENVSYS_DRIVE_CHECK              /* drive is checking its state */
  116 };
  117 
  118 /* sensor battery capacity states */
  119 enum envsys_battery_capacity_states {
  120         ENVSYS_BATTERY_CAPACITY_NORMAL  = 1,    /* normal cap in battery */
  121         ENVSYS_BATTERY_CAPACITY_WARNING,        /* warning cap in battery */
  122         ENVSYS_BATTERY_CAPACITY_CRITICAL,       /* critical cap in battery */
  123         ENVSYS_BATTERY_CAPACITY_LOW             /* low cap in battery */
  124 };
  125 
  126 /* sensor flags */
  127 #define ENVSYS_FPERCENT         0x00000001      /* sensor wants a percentage */
  128 #define ENVSYS_FVALID_MAX       0x00000002      /* max value is ok */
  129 #define ENVSYS_FVALID_MIN       0x00000004      /* min value is ok */
  130 #define ENVSYS_FVALID_AVG       0x00000008      /* avg value is ok */
  131 #define ENVSYS_FCHANGERFACT     0x00000010      /* sensor can change rfact */
  132 
  133 /* monitoring flags */
  134 #define ENVSYS_FMONCRITICAL     0x00000020      /* monitor a critical state */
  135 #define ENVSYS_FMONCRITUNDER    0x00000040      /* monitor a critunder state */
  136 #define ENVSYS_FMONCRITOVER     0x00000080      /* monitor a critover state */
  137 #define ENVSYS_FMONWARNUNDER    0x00000100      /* monitor a warnunder state */
  138 #define ENVSYS_FMONWARNOVER     0x00000200      /* monitor a warnover state */
  139 #define ENVSYS_FMONSTCHANGED    0x00000400      /* monitor a battery/drive state */
  140 #define ENVSYS_FMONNOTSUPP      0x00000800      /* monitoring not supported */
  141 #define ENVSYS_FNEED_REFRESH    0x00001000      /* sensor needs refreshing */
  142 
  143 #define ENVSYS_GETDICTIONARY    _IOWR('E', 0, struct plistref)
  144 #define ENVSYS_SETDICTIONARY    _IOWR('E', 1, struct plistref)
  145 #define ENVSYS_REMOVEPROPS      _IOWR('E', 2, struct plistref)
  146 
  147 /*
  148  * Compatibility with old interface. Only ENVSYS_GTREDATA
  149  * and ENVSYS_GTREINFO ioctls are supported.
  150  */
  151 
  152 /* get sensor data */
  153 
  154 struct envsys_tre_data {
  155         u_int sensor;
  156         union {                         /* all data is given */
  157                 uint32_t data_us;       /* in microKelvins, */
  158                 int32_t data_s;         /* rpms, volts, amps, */
  159         } cur, min, max, avg;           /* ohms, watts, etc */
  160                                         /* see units below */
  161 
  162         uint32_t        warnflags;      /* warning flags */
  163         uint32_t        validflags;     /* sensor valid flags */
  164         u_int           units;          /* type of sensor */
  165 };
  166 typedef struct envsys_tre_data envsys_tre_data_t;
  167 
  168 /* flags for warnflags */
  169 #define ENVSYS_WARN_OK          0x00000000  /* All is well */
  170 #define ENVSYS_WARN_UNDER       0x00000001  /* an under condition */
  171 #define ENVSYS_WARN_CRITUNDER   0x00000002  /* a critical under condition */
  172 #define ENVSYS_WARN_OVER        0x00000004  /* an over condition */
  173 #define ENVSYS_WARN_CRITOVER    0x00000008  /* a critical over condition */
  174 
  175 /* drive status */
  176 #define ENVSYS_DRIVE_EMPTY      1
  177 #define ENVSYS_DRIVE_READY      2
  178 #define ENVSYS_DRIVE_POWERUP    3
  179 #define ENVSYS_DRIVE_ONLINE     4
  180 #define ENVSYS_DRIVE_IDLE       5
  181 #define ENVSYS_DRIVE_ACTIVE     6
  182 #define ENVSYS_DRIVE_REBUILD    7
  183 #define ENVSYS_DRIVE_POWERDOWN  8
  184 #define ENVSYS_DRIVE_FAIL       9
  185 #define ENVSYS_DRIVE_PFAIL      10
  186 
  187 #ifdef ENVSYSUNITNAMES
  188 static const char * const envsysunitnames[] = {
  189     "degC", "RPM", "VAC", "V", "Ohms", "W",
  190     "A", "Wh", "Ah", "bool", "integer", "drive", "Unk"
  191 };
  192 static const char * const envsysdrivestatus[] = {
  193     "unknown", "empty", "ready", "powering up", "online", "idle", "active",
  194     "rebuilding", "powering down", "failed", "degraded"
  195 };
  196 #endif
  197 
  198 
  199 /* flags for validflags */
  200 #define ENVSYS_FVALID           0x00000001  /* sensor is valid */
  201 #define ENVSYS_FCURVALID        0x00000002  /* cur for this sens is valid */
  202 #define ENVSYS_FMINVALID        0x00000004  /* min for this sens is valid */
  203 #define ENVSYS_FMAXVALID        0x00000008  /* max for this sens is valid */
  204 #define ENVSYS_FAVGVALID        0x00000010  /* avg for this sens is valid */
  205 #define ENVSYS_FFRACVALID       0x00000020  /* display fraction of max */
  206 
  207 #define ENVSYS_GTREDATA         _IOWR('E', 2, envsys_tre_data_t)
  208 
  209 /* set and check sensor info */
  210 
  211 struct envsys_basic_info {
  212         u_int   sensor;         /* sensor number */
  213         u_int   units;          /* type of sensor */
  214         char    desc[33];       /* sensor description */
  215         u_int   rfact;          /* for volts, (int)(factor x 10^4) */
  216         u_int   rpms;           /* for fans, set nominal RPMs */
  217         uint32_t validflags;    /* sensor valid flags */
  218 };
  219 typedef struct envsys_basic_info envsys_basic_info_t;
  220 
  221 #define ENVSYS_GTREINFO         _IOWR('E', 4, envsys_basic_info_t)
  222 
  223 #endif /* _SYS_ENVSYS_H_ */

Cache object: 5652be20e4689f333694f3da12cc5839


[ 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.