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/power.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: power.h,v 1.12 2008/08/22 11:27:50 pgoyette Exp $      */
    2 
    3 /*
    4  * Copyright (c) 2003 Wasabi Systems, Inc.
    5  * All rights reserved.
    6  *
    7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
    8  *
    9  * Redistribution and use in source and binary forms, with or without
   10  * modification, are permitted provided that the following conditions
   11  * are met:
   12  * 1. Redistributions of source code must retain the above copyright
   13  *    notice, this list of conditions and the following disclaimer.
   14  * 2. Redistributions in binary form must reproduce the above copyright
   15  *    notice, this list of conditions and the following disclaimer in the
   16  *    documentation and/or other materials provided with the distribution.
   17  * 3. All advertising materials mentioning features or use of this software
   18  *    must display the following acknowledgement:
   19  *      This product includes software developed for the NetBSD Project by
   20  *      Wasabi Systems, Inc.
   21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
   22  *    or promote products derived from this software without specific prior
   23  *    written permission.
   24  *
   25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
   26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
   27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
   29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   35  * POSSIBILITY OF SUCH DAMAGE.
   36  */
   37 
   38 /*
   39  * Definitions for power management.
   40  */
   41 
   42 #ifndef _SYS_POWER_H_
   43 #define _SYS_POWER_H_
   44 
   45 #include <sys/ioccom.h>
   46 
   47 /*
   48  * Power Switches:
   49  *
   50  * Power switches are devices on the system that are used by the system
   51  * operator to cause certain types of power management events to happen.
   52  * This may be the closing of a laptop lid, the pressing of a power button,
   53  * or some other type of user-initiated hardware event.
   54  *
   55  * We define the following types of power switches:
   56  *
   57  *      Power button            This is the "on/off" button on a system,
   58  *                              or another button which provides a similar
   59  *                              function.  If there is no power management
   60  *                              daemon present, an event on this button will
   61  *                              cause a semi-graceful shutdown of the system
   62  *                              to occur.  This kind of button doesn't keep
   63  *                              state; we only know (care) if an event occurs.
   64  *
   65  *      Reset button            This is the "reset" button on a system, or
   66  *                              another button which provides a similar
   67  *                              function.  If there is no power management
   68  *                              daemon present, an event on this button will
   69  *                              cause a semi-graceful reboot of the system
   70  *                              to occur.  This kind of button doesn't keep
   71  *                              state; we only know (care) if an event occurs.
   72  *
   73  *      Sleep button            This is a button which is dedicated to a
   74  *                              "sleep" function.  This kind of button doesn't
   75  *                              keep state; we only know (care) if an event
   76  *                              occurs.
   77  *
   78  *      Lid switch              This is e.g. the lid of a laptop.  This kind
   79  *                              of switch has state.  We know if it is open
   80  *                              or closed.
   81  *
   82  */
   83 
   84 #define PSWITCH_TYPE_POWER      0       /* power button */
   85 #define PSWITCH_TYPE_SLEEP      1       /* sleep button */
   86 #define PSWITCH_TYPE_LID        2       /* lid switch */
   87 #define PSWITCH_TYPE_RESET      3       /* reset button */
   88 #define PSWITCH_TYPE_ACADAPTER  4       /* AC adapter presence */
   89 #define PSWITCH_TYPE_HOTKEY     5       /* hotkey button */
   90 #define         PSWITCH_HK_DISPLAY_CYCLE        "display-cycle"
   91 #define         PSWITCH_HK_LOCK_SCREEN          "lock-screen"
   92 #define         PSWITCH_HK_BATTERY_INFO         "battery-info"
   93 #define         PSWITCH_HK_EJECT_BUTTON         "eject-button"
   94 #define         PSWITCH_HK_ZOOM_BUTTON          "zoom-button"
   95 #define         PSWITCH_HK_VENDOR_BUTTON        "vendor-button"
   96 
   97 #define PSWITCH_EVENT_PRESSED   0       /* button pressed, lid closed, AC off */
   98 #define PSWITCH_EVENT_RELEASED  1       /* button released, lid open, AC on */
   99 
  100 /*
  101  * This structure describes the state of a power switch.
  102  */
  103 struct pswitch_state {
  104         char    psws_name[16];          /* power switch name */
  105         int32_t psws_type;              /* type of switch (qualifier) */
  106         int32_t psws_state;             /* state of the switch/event */
  107 };
  108 
  109 /*
  110  * envsys(4) events:
  111  *
  112  * envsys events are sent by the sysmon envsys framework when
  113  * a warning or critical condition happens in a sensor.
  114  *
  115  * We define the folowing types of envsys events:
  116  *
  117  *      sensor temperature      To handle temperature sensors.
  118  *
  119  *      sensor voltage          To handle voltage sensors (AC/DC).
  120  *
  121  *      sensor power            To handle power sensors (W/Ampere).
  122  *
  123  *      sensor resistance       To handle resistance sensors (Ohms).
  124  *
  125  *      sensor battery          To handle battery sensors (Ah/Wh).
  126  *
  127  *      sensor fan              To handle fan sensors.
  128  *
  129  *      sensor drive            To handle drive sensors.
  130  *
  131  *      sensor indicator        To handle indicator/integer sensors.
  132  */
  133 
  134 #define PENVSYS_TYPE_TEMP               10
  135 #define PENVSYS_TYPE_VOLTAGE            11
  136 #define PENVSYS_TYPE_POWER              12
  137 #define PENVSYS_TYPE_RESISTANCE         13
  138 #define PENVSYS_TYPE_BATTERY            14
  139 #define PENVSYS_TYPE_FAN                15
  140 #define PENVSYS_TYPE_DRIVE              16
  141 #define PENVSYS_TYPE_INDICATOR          17
  142 
  143 /*
  144  * The following events apply for temperatures, power, resistance, 
  145  * voltages, battery and fan sensors:
  146  *
  147  *      PENVSYS_EVENT_CRITICAL          A critical limit.
  148  *
  149  *      PENVSYS_EVENT_CRITOVER          A critical over limit.
  150  *
  151  *      PENVSYS_EVENT_CRITUNDER         A critical under limit.
  152  *
  153  *      PENVSYS_EVENT_WARNOVER          A warning under limit.
  154  *
  155  *      PENVSYS_EVENT_WARNUNDER         A warning over limit.
  156  *
  157  * The following events apply to the same except for batteries:
  158  *
  159  *      PENVSYS_EVENT_USER_CRITMAX      User critical max limit.
  160  *
  161  *      PENVSYS_EVENT_USER_CRITMIN      User critical min limit.
  162  *
  163  *      PENVSYS_EVENT_USER_WARNMAX      User warning max limit.
  164  *
  165  *      PENVSYS_EVENT_USER_WARNMIN      User warning min limit.
  166  *
  167  * The folowing event apply to all sensors, when the state is
  168  * valid or the warning or critical limit is not valid anymore:
  169  *
  170  *      PENVSYS_EVENT_NORMAL            Normal state in the sensor.
  171  */
  172 
  173 #define PENVSYS_EVENT_NORMAL            90
  174 #define PENVSYS_EVENT_CRITICAL          100
  175 #define PENVSYS_EVENT_CRITOVER          110
  176 #define PENVSYS_EVENT_CRITUNDER         120
  177 #define PENVSYS_EVENT_WARNOVER          130
  178 #define PENVSYS_EVENT_WARNUNDER         140
  179 #define PENVSYS_EVENT_USER_CRITMAX      150
  180 #define PENVSYS_EVENT_USER_WARNMAX      155
  181 #define PENVSYS_EVENT_USER_CRITMIN      160
  182 #define PENVSYS_EVENT_USER_WARNMIN      165
  183 
  184 /*
  185  * The following events apply for battery sensors:
  186  *
  187  *      PENVSYS_EVENT_BATT_USERCAP      User critical capacity.
  188  *
  189  *      PENVSYS_EVENT_BATT_USERWARN     User warning capacity.
  190  *
  191  *      PENVSYS_EVENT_LOW_POWER         AC Adapter is OFF and all batteries
  192  *                                      are discharged.
  193  */
  194 
  195 #define PENVSYS_EVENT_BATT_USERCAP      170
  196 #define PENVSYS_EVENT_BATT_USERWARN     175
  197 #define PENVSYS_EVENT_LOW_POWER         180
  198 
  199 /*
  200  * The following event apply for battery state and drive sensors:
  201  *
  202  *      PENVSYS_EVENT_STATE_CHANGED     State has changed.
  203  *
  204  */
  205 #define PENVSYS_EVENT_STATE_CHANGED     190
  206 
  207 /*
  208  * The following events are used internally to associate multiple
  209  * external states with a single event monitor
  210  */
  211 #define PENVSYS_EVENT_HW_LIMITS         200
  212 #define PENVSYS_EVENT_USER_LIMITS       210
  213 #define PENVSYS_EVENT_BATT_USER_LIMITS  220
  214 
  215 /*
  216  * This structure defines the properties of an envsys event.
  217  */
  218 struct penvsys_state {
  219         char    pes_dvname[16];         /* device name */
  220         char    pes_sensname[32];       /* sensor name */
  221         char    pes_statedesc[64];      /* sensor state description */
  222         int32_t pes_type;               /* envsys power type */
  223 };
  224 
  225 /*
  226  * Power management event messages:
  227  *
  228  * We ensure that a message is always exactly 32 bytes long, so that
  229  * userland doesn't need to issue multiple reads to get a single event.
  230  */
  231 #define POWER_EVENT_MSG_SIZE    32
  232 
  233 #define POWER_EVENT_SWITCH_STATE_CHANGE         0
  234 #define POWER_EVENT_ENVSYS_STATE_CHANGE         1
  235 
  236 typedef struct power_event {
  237         int32_t         pev_type;       /* power event type */
  238         union {
  239                 int32_t  _pev_d_space[(POWER_EVENT_MSG_SIZE /
  240                                        sizeof(int32_t)) - 1];
  241 
  242                 /*
  243                  * This field is used for:
  244                  *
  245                  *      POWER_EVENT_SWITCH_STATE_CHANGE
  246                  */
  247                 struct pswitch_state _pev_d_switch;
  248         } _pev_data;
  249 } power_event_t;
  250 
  251 #define pev_switch      _pev_data._pev_d_switch
  252 
  253 #define POWER_EVENT_RECVDICT    _IOWR('P', 1, struct plistref)
  254 
  255 /*
  256  * POWER_IOC_GET_TYPE:
  257  *
  258  *      Get the power management back-end type.
  259  */
  260 struct power_type {
  261         char    power_type[32];
  262 };
  263 #define POWER_IOC_GET_TYPE       _IOR('P', 0, sizeof(struct power_type))
  264 
  265 #endif /* _SYS_POWER_H_ */

Cache object: 9a88c7d30565f4a0748698a7b0af0744


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