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.2 2003/04/20 20:48:27 thorpej 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 
   88 #define PSWITCH_EVENT_PRESSED   0       /* button pressed */
   89 #define PSWITCH_EVENT_RELEASED  1       /* button released */
   90 
   91 #define PSWITCH_STATE_PRESSED   0       /* button pressed/lid closed */
   92 #define PSWITCH_STATE_RELEASED  1       /* button released/lid open */
   93 #define PSWITCH_STATE_UNKNOWN   -1
   94 
   95 /*
   96  * This structure describes the state of a power switch.  It is used
   97  * by the POWER_IOC_GET_SWSTATE ioctl, as well as in power mangement
   98  * event messages.
   99  */
  100 struct pswitch_state {
  101         char    psws_name[16];          /* power switch name */
  102         int32_t psws_type;              /* type of switch (qualifier) */
  103         int32_t psws_state;             /* state of the switch/event */
  104 };
  105 
  106 /*
  107  * Power management event messages:
  108  *
  109  * We ensure that a message is always exactly 32 bytes long, so that
  110  * userland doesn't need to issue multiple reads to get a single event.
  111  */
  112 #define POWER_EVENT_MSG_SIZE    32
  113 
  114 #define POWER_EVENT_SWITCH_STATE_CHANGE         0
  115 
  116 typedef struct {
  117         int32_t         pev_type;       /* power event type */
  118         union {
  119                 int32_t _pev_d_space[(POWER_EVENT_MSG_SIZE /
  120                                       sizeof(int32_t)) - 1];
  121 
  122                 /*
  123                  * This field is used for:
  124                  *
  125                  *      POWER_EVENT_SWITCH_STATE_CHANGE
  126                  */
  127                 struct pswitch_state _pev_d_switch;
  128         } _pev_data;
  129 } power_event_t;
  130 
  131 #define pev_switch      _pev_data._pev_d_switch
  132 
  133 /*
  134  * POWER_IOC_GET_TYPE:
  135  *
  136  *      Get the power management back-end type.
  137  */
  138 struct power_type {
  139         char    power_type[32];
  140 };
  141 #define POWER_IOC_GET_TYPE       _IOR('P', 0, sizeof(struct power_type))
  142 
  143 #endif /* _SYS_POWER_H_ */

Cache object: e47f1fea34184638f2a07133e99e6b59


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