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.4 2005/12/11 12:25:20 christos 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 #define PSWITCH_TYPE_POWER      0       /* power button */
   84 #define PSWITCH_TYPE_SLEEP      1       /* sleep button */
   85 #define PSWITCH_TYPE_LID        2       /* lid switch */
   86 #define PSWITCH_TYPE_RESET      3       /* reset button */
   87 #define PSWITCH_TYPE_ACADAPTER  4       /* AC adapter presence */
   88 
   89 #define PSWITCH_EVENT_PRESSED   0       /* button pressed, lid closed,
   90                                            AC adapter online */
   91 #define PSWITCH_EVENT_RELEASED  1       /* button released, lid open,
   92                                            AC adapter offline */
   93 
   94 #define PSWITCH_STATE_PRESSED   0       /* button pressed/lid closed */
   95 #define PSWITCH_STATE_RELEASED  1       /* button released/lid open */
   96 #define PSWITCH_STATE_UNKNOWN   -1
   97 
   98 /*
   99  * This structure describes the state of a power switch.  It is used
  100  * by the POWER_IOC_GET_SWSTATE ioctl, as well as in power mangement
  101  * event messages.
  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  * Power management event messages:
  111  *
  112  * We ensure that a message is always exactly 32 bytes long, so that
  113  * userland doesn't need to issue multiple reads to get a single event.
  114  */
  115 #define POWER_EVENT_MSG_SIZE    32
  116 
  117 #define POWER_EVENT_SWITCH_STATE_CHANGE         0
  118 
  119 typedef struct {
  120         int32_t         pev_type;       /* power event type */
  121         union {
  122                 int32_t _pev_d_space[(POWER_EVENT_MSG_SIZE /
  123                                       sizeof(int32_t)) - 1];
  124 
  125                 /*
  126                  * This field is used for:
  127                  *
  128                  *      POWER_EVENT_SWITCH_STATE_CHANGE
  129                  */
  130                 struct pswitch_state _pev_d_switch;
  131         } _pev_data;
  132 } power_event_t;
  133 
  134 #define pev_switch      _pev_data._pev_d_switch
  135 
  136 /*
  137  * POWER_IOC_GET_TYPE:
  138  *
  139  *      Get the power management back-end type.
  140  */
  141 struct power_type {
  142         char    power_type[32];
  143 };
  144 #define POWER_IOC_GET_TYPE       _IOR('P', 0, sizeof(struct power_type))
  145 
  146 #endif /* _SYS_POWER_H_ */

Cache object: b8691d02518ca98a98fe5ababfb00342


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