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.23 2022/05/28 10:36:23 andvar 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 #ifndef _KERNEL
   48 #include <stdint.h>
   49 #endif
   50 
   51 /*
   52  * Power Switches:
   53  *
   54  * Power switches are devices on the system that are used by the system
   55  * operator to cause certain types of power management events to happen.
   56  * This may be the closing of a laptop lid, the pressing of a power button,
   57  * or some other type of user-initiated hardware event.
   58  *
   59  * We define the following types of power switches:
   60  *
   61  *      Power button            This is the "on/off" button on a system,
   62  *                              or another button which provides a similar
   63  *                              function.  If there is no power management
   64  *                              daemon present, an event on this button will
   65  *                              cause a semi-graceful shutdown of the system
   66  *                              to occur.  This kind of button doesn't keep
   67  *                              state; we only know (care) if an event occurs.
   68  *
   69  *      Reset button            This is the "reset" button on a system, or
   70  *                              another button which provides a similar
   71  *                              function.  If there is no power management
   72  *                              daemon present, an event on this button will
   73  *                              cause a semi-graceful reboot of the system
   74  *                              to occur.  This kind of button doesn't keep
   75  *                              state; we only know (care) if an event occurs.
   76  *
   77  *      Sleep button            This is a button which is dedicated to a
   78  *                              "sleep" function.  This kind of button doesn't
   79  *                              keep state; we only know (care) if an event
   80  *                              occurs.
   81  *
   82  *      Lid switch              This is e.g. the lid of a laptop.  This kind
   83  *                              of switch has state.  We know if it is open
   84  *                              or closed.
   85  *
   86  *      Radio switch            This is e.g. the switch of the transmitter
   87  *                              of a wifi interface. We know if it is
   88  *                              on or off.
   89  *
   90  */
   91 
   92 #define PSWITCH_TYPE_POWER      0       /* power button */
   93 #define PSWITCH_TYPE_SLEEP      1       /* sleep button */
   94 #define PSWITCH_TYPE_LID        2       /* lid switch */
   95 #define PSWITCH_TYPE_RESET      3       /* reset button */
   96 #define PSWITCH_TYPE_ACADAPTER  4       /* AC adapter presence */
   97 #define PSWITCH_TYPE_HOTKEY     5       /* hotkey button */
   98 #define         PSWITCH_HK_DISPLAY_CYCLE        "display-cycle"
   99 #define         PSWITCH_HK_LOCK_SCREEN          "lock-screen"
  100 #define         PSWITCH_HK_BATTERY_INFO         "battery-info"
  101 #define         PSWITCH_HK_EJECT_BUTTON         "eject-button"
  102 #define         PSWITCH_HK_ZOOM_BUTTON          "zoom-button"
  103 #define         PSWITCH_HK_VENDOR_BUTTON        "vendor-button"
  104 #ifndef THINKPAD_NORMAL_HOTKEYS
  105 #define         PSWITCH_HK_FNF1_BUTTON          "fnf1-button"
  106 #define         PSWITCH_HK_WIRELESS_BUTTON      "wireless-button"
  107 #define         PSWITCH_HK_WWAN_BUTTON          "wWAN-button"
  108 #define         PSWITCH_HK_POINTER_BUTTON       "pointer-button"
  109 #define         PSWITCH_HK_FNF10_BUTTON         "fnf10-button"
  110 #define         PSWITCH_HK_FNF11_BUTTON         "fnf11-button"
  111 #define         PSWITCH_HK_BRIGHTNESS_UP        "brightness-up"
  112 #define         PSWITCH_HK_BRIGHTNESS_DOWN      "brightness-down"
  113 #define         PSWITCH_HK_THINKLIGHT           "thinklight"
  114 #define         PSWITCH_HK_VOLUME_UP            "volume-up"
  115 #define         PSWITCH_HK_VOLUME_DOWN          "volume-down"
  116 #define         PSWITCH_HK_VOLUME_MUTE          "volume-mute"
  117 #define         PSWITCH_HK_STAR_BUTTON          "star-button"
  118 #define         PSWITCH_HK_SCISSORS_BUTTON      "scissors-button"
  119 #define         PSWITCH_HK_BLUETOOTH_BUTTON     "bluetooth-button"
  120 #define         PSWITCH_HK_KEYBOARD_BUTTON      "keyboard-button"
  121 #endif /* THINKPAD_NORMAL_HOTKEYS */
  122 #define PSWITCH_TYPE_RADIO      6       /* radio switch */
  123 
  124 #define PSWITCH_EVENT_PRESSED   0       /* button pressed, lid closed, AC off */
  125 #define PSWITCH_EVENT_RELEASED  1       /* button released, lid open, AC on */
  126 
  127 /*
  128  * This structure describes the state of a power switch.
  129  */
  130 struct pswitch_state {
  131         char    psws_name[16];          /* power switch name */
  132         int32_t psws_type;              /* type of switch (qualifier) */
  133         int32_t psws_state;             /* state of the switch/event */
  134 };
  135 
  136 /*
  137  * envsys(4) events:
  138  *
  139  * envsys events are sent by the sysmon envsys framework when
  140  * a warning or critical condition happens in a sensor.
  141  *
  142  * We define the following types of envsys events:
  143  *
  144  *      sensor temperature      To handle temperature sensors.
  145  *
  146  *      sensor voltage          To handle voltage sensors (AC/DC).
  147  *
  148  *      sensor power            To handle power sensors (W/Ampere).
  149  *
  150  *      sensor resistance       To handle resistance sensors (Ohms).
  151  *
  152  *      sensor battery          To handle battery sensors (Ah/Wh).
  153  *
  154  *      sensor fan              To handle fan sensors.
  155  *
  156  *      sensor drive            To handle drive sensors.
  157  *
  158  *      sensor indicator        To handle indicator/integer sensors.
  159  */
  160 
  161 #define PENVSYS_TYPE_TEMP               10
  162 #define PENVSYS_TYPE_VOLTAGE            11
  163 #define PENVSYS_TYPE_POWER              12
  164 #define PENVSYS_TYPE_RESISTANCE         13
  165 #define PENVSYS_TYPE_BATTERY            14
  166 #define PENVSYS_TYPE_FAN                15
  167 #define PENVSYS_TYPE_DRIVE              16
  168 #define PENVSYS_TYPE_INDICATOR          17
  169 
  170 /*
  171  * The following events apply for temperatures, power, resistance,
  172  * voltages, battery and fan sensors:
  173  *
  174  *      PENVSYS_EVENT_CRITICAL          A critical limit.
  175  *
  176  *      PENVSYS_EVENT_CRITOVER          A critical over limit.
  177  *
  178  *      PENVSYS_EVENT_CRITUNDER         A critical under limit.
  179  *
  180  *      PENVSYS_EVENT_WARNOVER          A warning under limit.
  181  *
  182  *      PENVSYS_EVENT_WARNUNDER         A warning over limit.
  183  *
  184  * The folowing event applies to all sensors, when the state is
  185  * valid or the warning or critical limit is not valid anymore:
  186  *
  187  *      PENVSYS_EVENT_NORMAL            Normal state in the sensor.
  188  */
  189 
  190 #define PENVSYS_EVENT_NORMAL            90
  191 #define PENVSYS_EVENT_CRITICAL          100
  192 #define PENVSYS_EVENT_CRITOVER          110
  193 #define PENVSYS_EVENT_CRITUNDER         120
  194 #define PENVSYS_EVENT_WARNOVER          130
  195 #define PENVSYS_EVENT_WARNUNDER         140
  196 
  197 /*
  198  * The following events apply for battery sensors:
  199  *
  200  *      PENVSYS_EVENT_BATT_CRIT         User critical capacity.
  201  *
  202  *      PENVSYS_EVENT_BATT_WARN         User warning capacity.
  203  *
  204  *      PENVSYS_EVENT_BATT_HIGH         User high capacity.
  205  *
  206  *      PENVSYS_EVENT_BATT_MAX          User maximum capacity.
  207  *
  208  *      PENVSYS_EVENT_LOW_POWER         AC Adapter is OFF and all batteries
  209  *                                      are discharged.
  210  */
  211 
  212 #define PENVSYS_EVENT_BATT_CRIT         170
  213 #define PENVSYS_EVENT_BATT_WARN         175
  214 #define PENVSYS_EVENT_BATT_HIGH         177
  215 #define PENVSYS_EVENT_BATT_MAX          178
  216 #define PENVSYS_EVENT_LOW_POWER         180
  217 
  218 /*
  219  * The following event apply for battery state and drive sensors:
  220  *
  221  *      PENVSYS_EVENT_STATE_CHANGED     State has changed.
  222  *
  223  */
  224 #define PENVSYS_EVENT_STATE_CHANGED     190
  225 
  226 /*
  227  * The following events are used internally to associate multiple
  228  * external states with a single event monitor
  229  */
  230 #define PENVSYS_EVENT_LIMITS            200
  231 #define PENVSYS_EVENT_CAPACITY          210
  232 
  233 /*
  234  * The following pseudo-event is used to force refreshing of a
  235  * sensor that provides rnd(4) entropy, even if the sensor is not
  236  * otherwise being monitored.
  237  */
  238 #define PENVSYS_EVENT_NULL              220
  239 
  240 /*
  241  * This structure defines the properties of an envsys event.
  242  */
  243 struct penvsys_state {
  244         char    pes_dvname[16];         /* device name */
  245         char    pes_sensname[32];       /* sensor name */
  246         char    pes_statedesc[64];      /* sensor state description */
  247         int32_t pes_type;               /* envsys power type */
  248 };
  249 
  250 /*
  251  * Power management event messages:
  252  *
  253  * We ensure that a message is always exactly 32 bytes long, so that
  254  * userland doesn't need to issue multiple reads to get a single event.
  255  */
  256 #define POWER_EVENT_MSG_SIZE    32
  257 
  258 #define POWER_EVENT_SWITCH_STATE_CHANGE         0
  259 #define POWER_EVENT_ENVSYS_STATE_CHANGE         1
  260 
  261 typedef struct power_event {
  262         int32_t         pev_type;       /* power event type */
  263         union {
  264                 int32_t  _pev_d_space[(POWER_EVENT_MSG_SIZE /
  265                                        sizeof(int32_t)) - 1];
  266 
  267                 /*
  268                  * This field is used for:
  269                  *
  270                  *      POWER_EVENT_SWITCH_STATE_CHANGE
  271                  */
  272                 struct pswitch_state _pev_d_switch;
  273         } _pev_data;
  274 } power_event_t;
  275 
  276 #define pev_switch      _pev_data._pev_d_switch
  277 
  278 #define POWER_EVENT_RECVDICT    _IOWR('P', 1, struct plistref)
  279 
  280 /*
  281  * POWER_IOC_GET_TYPE:
  282  *
  283  *      Get the power management back-end type.
  284  */
  285 struct power_type {
  286         char    power_type[32];
  287 };
  288 #define POWER_IOC_GET_TYPE      _IOR('P', 0, struct power_type)
  289 
  290 #ifdef _KERNEL
  291 /*
  292  * so the kernel can provide binary compat for applications
  293  * built when POWER_IOC_GET_TYPE was incorrectly defined as:
  294  */
  295 #define POWER_IOC_GET_TYPE_WITH_LOSSAGE _IOR('P', 0, sizeof(struct power_type))
  296 #endif
  297 
  298 #endif /* _SYS_POWER_H_ */

Cache object: 2bbe4801a26cf33e80e5c27eb0e78948


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