2010-03-11 16:51:01 +03:00
|
|
|
/* $NetBSD: sysmon_power.c,v 1.44 2010/03/11 13:51:01 jruoho Exp $ */
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
/*-
|
2007-10-07 01:58:40 +04:00
|
|
|
* Copyright (c) 2007 Juan Romero Pardines.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
2007-10-07 01:58:40 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
2003-04-17 05:02:21 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (c) 2003 Wasabi Systems, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Written by Jason R. Thorpe for Wasabi Systems, Inc.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed for the NetBSD Project by
|
|
|
|
* Wasabi Systems, Inc.
|
|
|
|
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
|
|
|
* or promote products derived from this software without specific prior
|
|
|
|
* written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Power management framework for sysmon.
|
|
|
|
*
|
|
|
|
* We defer to a power management daemon running in userspace, since
|
|
|
|
* power management is largely a policy issue. This merely provides
|
|
|
|
* for power management event notification to that daemon.
|
|
|
|
*/
|
|
|
|
|
2003-07-14 19:47:00 +04:00
|
|
|
#include <sys/cdefs.h>
|
2010-03-11 16:51:01 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.44 2010/03/11 13:51:01 jruoho Exp $");
|
2003-07-14 19:47:00 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
#include "opt_compat_netbsd.h"
|
2003-04-17 05:02:21 +04:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/reboot.h>
|
|
|
|
#include <sys/systm.h>
|
2003-04-18 05:31:34 +04:00
|
|
|
#include <sys/poll.h>
|
|
|
|
#include <sys/select.h>
|
|
|
|
#include <sys/vnode.h>
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
#include <sys/condvar.h>
|
|
|
|
#include <sys/mutex.h>
|
2007-10-07 01:58:40 +04:00
|
|
|
#include <sys/kmem.h>
|
2007-07-15 19:27:53 +04:00
|
|
|
#include <sys/proc.h>
|
2007-12-09 23:57:19 +03:00
|
|
|
#include <sys/device.h>
|
2003-04-17 05:02:21 +04:00
|
|
|
|
|
|
|
#include <dev/sysmon/sysmonvar.h>
|
2007-08-17 20:52:52 +04:00
|
|
|
#include <prop/proplib.h>
|
2003-04-17 05:02:21 +04:00
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
/*
|
|
|
|
* Singly linked list for dictionaries to be stored/sent.
|
|
|
|
*/
|
|
|
|
struct power_event_dictionary {
|
|
|
|
SLIST_ENTRY(power_event_dictionary) pev_dict_head;
|
|
|
|
prop_dictionary_t dict;
|
|
|
|
int flags;
|
|
|
|
};
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
struct power_event_description {
|
|
|
|
int type;
|
|
|
|
const char *desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Available events for power switches.
|
|
|
|
*/
|
|
|
|
static const struct power_event_description pswitch_event_desc[] = {
|
|
|
|
{ PSWITCH_EVENT_PRESSED, "pressed" },
|
|
|
|
{ PSWITCH_EVENT_RELEASED, "released" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Available script names for power switches.
|
|
|
|
*/
|
|
|
|
static const struct power_event_description pswitch_type_desc[] = {
|
|
|
|
{ PSWITCH_TYPE_POWER, "power_button" },
|
|
|
|
{ PSWITCH_TYPE_SLEEP, "sleep_button" },
|
2007-08-07 18:03:00 +04:00
|
|
|
{ PSWITCH_TYPE_LID, "lid_switch" },
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{ PSWITCH_TYPE_RESET, "reset_button" },
|
|
|
|
{ PSWITCH_TYPE_ACADAPTER, "acadapter" },
|
2007-12-22 21:35:13 +03:00
|
|
|
{ PSWITCH_TYPE_HOTKEY, "hotkey_button" },
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Available events for envsys(4).
|
|
|
|
*/
|
|
|
|
static const struct power_event_description penvsys_event_desc[] = {
|
|
|
|
{ PENVSYS_EVENT_NORMAL, "normal" },
|
|
|
|
{ PENVSYS_EVENT_CRITICAL, "critical" },
|
|
|
|
{ PENVSYS_EVENT_CRITOVER, "critical-over" },
|
|
|
|
{ PENVSYS_EVENT_CRITUNDER, "critical-under" },
|
|
|
|
{ PENVSYS_EVENT_WARNOVER, "warning-over" },
|
|
|
|
{ PENVSYS_EVENT_WARNUNDER, "warning-under" },
|
2009-06-08 04:55:35 +04:00
|
|
|
{ PENVSYS_EVENT_BATT_CRIT, "critical-capacity" },
|
|
|
|
{ PENVSYS_EVENT_BATT_WARN, "warning-capacity" },
|
2010-02-16 01:32:04 +03:00
|
|
|
{ PENVSYS_EVENT_BATT_HIGH, "high-capacity" },
|
|
|
|
{ PENVSYS_EVENT_BATT_MAX, "maximum-capacity" },
|
2007-09-04 20:54:02 +04:00
|
|
|
{ PENVSYS_EVENT_STATE_CHANGED, "state-changed" },
|
2007-10-11 03:25:39 +04:00
|
|
|
{ PENVSYS_EVENT_LOW_POWER, "low-power" },
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{ -1, NULL }
|
|
|
|
};
|
2003-04-17 05:02:21 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
/*
|
|
|
|
* Available script names for envsys(4).
|
|
|
|
*/
|
|
|
|
static const struct power_event_description penvsys_type_desc[] = {
|
|
|
|
{ PENVSYS_TYPE_BATTERY, "sensor_battery" },
|
|
|
|
{ PENVSYS_TYPE_DRIVE, "sensor_drive" },
|
|
|
|
{ PENVSYS_TYPE_FAN, "sensor_fan" },
|
2007-07-02 19:18:30 +04:00
|
|
|
{ PENVSYS_TYPE_INDICATOR, "sensor_indicator" },
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{ PENVSYS_TYPE_POWER, "sensor_power" },
|
|
|
|
{ PENVSYS_TYPE_RESISTANCE, "sensor_resistance" },
|
|
|
|
{ PENVSYS_TYPE_TEMP, "sensor_temperature" },
|
|
|
|
{ PENVSYS_TYPE_VOLTAGE, "sensor_voltage" },
|
|
|
|
{ -1, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
#define SYSMON_MAX_POWER_EVENTS 32
|
2007-10-07 01:58:40 +04:00
|
|
|
#define SYSMON_POWER_DICTIONARY_BUSY 0x01
|
2007-11-10 12:32:24 +03:00
|
|
|
#define SYSMON_POWER_DICTIONARY_READY 0x02
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
static power_event_t sysmon_power_event_queue[SYSMON_MAX_POWER_EVENTS];
|
|
|
|
static int sysmon_power_event_queue_head;
|
|
|
|
static int sysmon_power_event_queue_tail;
|
|
|
|
static int sysmon_power_event_queue_count;
|
2007-10-07 01:58:40 +04:00
|
|
|
|
|
|
|
static SLIST_HEAD(, power_event_dictionary) pev_dict_list =
|
|
|
|
SLIST_HEAD_INITIALIZER(&pev_dict_list);
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
static struct selinfo sysmon_power_event_queue_selinfo;
|
2007-10-07 01:58:40 +04:00
|
|
|
static struct lwp *sysmon_power_daemon;
|
|
|
|
|
|
|
|
static kmutex_t sysmon_power_event_queue_mtx;
|
|
|
|
static kcondvar_t sysmon_power_event_queue_cv;
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
static char sysmon_power_type[32];
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
static int sysmon_power_make_dictionary(prop_dictionary_t, void *, int, int);
|
|
|
|
static int sysmon_power_daemon_task(struct power_event_dictionary *,
|
|
|
|
void *, int);
|
|
|
|
static void sysmon_power_destroy_dictionary(struct power_event_dictionary *);
|
2003-04-18 05:31:34 +04:00
|
|
|
|
2006-06-08 08:23:34 +04:00
|
|
|
#define SYSMON_NEXT_EVENT(x) (((x) + 1) % SYSMON_MAX_POWER_EVENTS)
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
/*
|
|
|
|
* sysmon_power_init:
|
|
|
|
*
|
|
|
|
* Initializes the mutexes and condition variables in the
|
|
|
|
* boot process via init_main.c.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_power_init(void)
|
|
|
|
{
|
2007-12-05 10:06:50 +03:00
|
|
|
mutex_init(&sysmon_power_event_queue_mtx, MUTEX_DEFAULT, IPL_NONE);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
cv_init(&sysmon_power_event_queue_cv, "smpower");
|
2008-03-01 17:16:49 +03:00
|
|
|
selinit(&sysmon_power_event_queue_selinfo);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
/*
|
|
|
|
* sysmon_queue_power_event:
|
|
|
|
*
|
2010-03-11 16:51:01 +03:00
|
|
|
* Enqueue a power event for the power management daemon. Returns
|
2003-04-18 05:31:34 +04:00
|
|
|
* non-zero if we were able to enqueue a power event.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sysmon_queue_power_event(power_event_t *pev)
|
|
|
|
{
|
2007-09-03 05:29:51 +04:00
|
|
|
KASSERT(mutex_owned(&sysmon_power_event_queue_mtx));
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
if (sysmon_power_event_queue_count == SYSMON_MAX_POWER_EVENTS)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return 0;
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
sysmon_power_event_queue[sysmon_power_event_queue_head] = *pev;
|
|
|
|
sysmon_power_event_queue_head =
|
|
|
|
SYSMON_NEXT_EVENT(sysmon_power_event_queue_head);
|
|
|
|
sysmon_power_event_queue_count++;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return 1;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_get_power_event:
|
|
|
|
*
|
|
|
|
* Get a power event from the queue. Returns non-zero if there
|
|
|
|
* is an event available.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
sysmon_get_power_event(power_event_t *pev)
|
|
|
|
{
|
2007-09-03 05:29:51 +04:00
|
|
|
KASSERT(mutex_owned(&sysmon_power_event_queue_mtx));
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
if (sysmon_power_event_queue_count == 0)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return 0;
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
*pev = sysmon_power_event_queue[sysmon_power_event_queue_tail];
|
|
|
|
sysmon_power_event_queue_tail =
|
|
|
|
SYSMON_NEXT_EVENT(sysmon_power_event_queue_tail);
|
|
|
|
sysmon_power_event_queue_count--;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return 1;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_power_event_queue_flush:
|
|
|
|
*
|
|
|
|
* Flush the event queue, and reset all state.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sysmon_power_event_queue_flush(void)
|
|
|
|
{
|
2007-09-03 05:29:51 +04:00
|
|
|
KASSERT(mutex_owned(&sysmon_power_event_queue_mtx));
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
sysmon_power_event_queue_head = 0;
|
|
|
|
sysmon_power_event_queue_tail = 0;
|
|
|
|
sysmon_power_event_queue_count = 0;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_power_daemon_task:
|
|
|
|
*
|
|
|
|
* Assign required power event members and sends a signal
|
|
|
|
* to the process to notify that an event was enqueued succesfully.
|
|
|
|
*/
|
|
|
|
static int
|
2007-10-07 01:58:40 +04:00
|
|
|
sysmon_power_daemon_task(struct power_event_dictionary *ped,
|
|
|
|
void *pev_data, int event)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{
|
|
|
|
power_event_t pev;
|
|
|
|
int rv, error = 0;
|
|
|
|
|
2007-11-10 12:32:24 +03:00
|
|
|
if (!ped || !ped->dict || !pev_data)
|
2007-10-06 06:49:46 +04:00
|
|
|
return EINVAL;
|
2007-09-03 05:29:51 +04:00
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
switch (event) {
|
2007-10-07 01:58:40 +04:00
|
|
|
/*
|
|
|
|
* Power switch events.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
case PSWITCH_EVENT_PRESSED:
|
|
|
|
case PSWITCH_EVENT_RELEASED:
|
|
|
|
{
|
|
|
|
|
|
|
|
struct sysmon_pswitch *pswitch =
|
|
|
|
(struct sysmon_pswitch *)pev_data;
|
|
|
|
|
|
|
|
pev.pev_type = POWER_EVENT_SWITCH_STATE_CHANGE;
|
|
|
|
#ifdef COMPAT_40
|
|
|
|
pev.pev_switch.psws_state = event;
|
|
|
|
pev.pev_switch.psws_type = pswitch->smpsw_type;
|
|
|
|
|
|
|
|
if (pswitch->smpsw_name) {
|
|
|
|
(void)strlcpy(pev.pev_switch.psws_name,
|
|
|
|
pswitch->smpsw_name,
|
|
|
|
sizeof(pev.pev_switch.psws_name));
|
|
|
|
}
|
|
|
|
#endif
|
2007-10-07 01:58:40 +04:00
|
|
|
error = sysmon_power_make_dictionary(ped->dict,
|
|
|
|
pswitch,
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
event,
|
|
|
|
pev.pev_type);
|
2007-10-07 01:58:40 +04:00
|
|
|
if (error) {
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
goto out;
|
2007-10-07 01:58:40 +04:00
|
|
|
}
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
/*
|
|
|
|
* ENVSYS events.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
case PENVSYS_EVENT_NORMAL:
|
|
|
|
case PENVSYS_EVENT_CRITICAL:
|
|
|
|
case PENVSYS_EVENT_CRITUNDER:
|
|
|
|
case PENVSYS_EVENT_CRITOVER:
|
|
|
|
case PENVSYS_EVENT_WARNUNDER:
|
|
|
|
case PENVSYS_EVENT_WARNOVER:
|
2009-06-08 04:55:35 +04:00
|
|
|
case PENVSYS_EVENT_BATT_CRIT:
|
|
|
|
case PENVSYS_EVENT_BATT_WARN:
|
2010-02-16 01:32:04 +03:00
|
|
|
case PENVSYS_EVENT_BATT_HIGH:
|
|
|
|
case PENVSYS_EVENT_BATT_MAX:
|
2007-09-04 20:54:02 +04:00
|
|
|
case PENVSYS_EVENT_STATE_CHANGED:
|
2007-10-11 03:25:39 +04:00
|
|
|
case PENVSYS_EVENT_LOW_POWER:
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{
|
|
|
|
struct penvsys_state *penvsys =
|
|
|
|
(struct penvsys_state *)pev_data;
|
|
|
|
|
|
|
|
pev.pev_type = POWER_EVENT_ENVSYS_STATE_CHANGE;
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
error = sysmon_power_make_dictionary(ped->dict,
|
|
|
|
penvsys,
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
event,
|
|
|
|
pev.pev_type);
|
2007-10-07 01:58:40 +04:00
|
|
|
if (error) {
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
goto out;
|
2007-10-07 01:58:40 +04:00
|
|
|
}
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
error = ENOTTY;
|
2007-10-07 01:58:40 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
/*
|
|
|
|
* Enqueue the event.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
rv = sysmon_queue_power_event(&pev);
|
|
|
|
if (rv == 0) {
|
|
|
|
printf("%s: WARNING: state change event %d lost; "
|
|
|
|
"queue full\n", __func__, pev.pev_type);
|
2007-10-07 01:58:40 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
} else {
|
2007-10-07 01:58:40 +04:00
|
|
|
/*
|
2007-11-10 12:32:24 +03:00
|
|
|
* Notify the daemon that an event is ready and its
|
|
|
|
* dictionary is ready to be fetched.
|
2007-10-07 01:58:40 +04:00
|
|
|
*/
|
2007-11-10 12:32:24 +03:00
|
|
|
ped->flags |= SYSMON_POWER_DICTIONARY_READY;
|
|
|
|
SLIST_INSERT_HEAD(&pev_dict_list, ped, pev_dict_head);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
cv_broadcast(&sysmon_power_event_queue_cv);
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2008-03-01 17:16:49 +03:00
|
|
|
selnotify(&sysmon_power_event_queue_selinfo, 0, 0);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
out:
|
|
|
|
return error;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonopen_power:
|
|
|
|
*
|
|
|
|
* Open the system monitor device.
|
|
|
|
*/
|
|
|
|
int
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
sysmonopen_power(dev_t dev, int flag, int mode, struct lwp *l)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
if (sysmon_power_daemon != NULL)
|
|
|
|
error = EBUSY;
|
|
|
|
else {
|
2007-07-15 19:27:53 +04:00
|
|
|
sysmon_power_daemon = l;
|
2003-04-18 05:31:34 +04:00
|
|
|
sysmon_power_event_queue_flush();
|
|
|
|
}
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return error;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonclose_power:
|
|
|
|
*
|
|
|
|
* Close the system monitor device.
|
|
|
|
*/
|
|
|
|
int
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
sysmonclose_power(dev_t dev, int flag, int mode, struct lwp *l)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
int count;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
count = sysmon_power_event_queue_count;
|
|
|
|
sysmon_power_daemon = NULL;
|
|
|
|
sysmon_power_event_queue_flush();
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
if (count)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
printf("WARNING: %d power event%s lost by exiting daemon\n",
|
|
|
|
count, count > 1 ? "s" : "");
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return 0;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonread_power:
|
|
|
|
*
|
|
|
|
* Read the system monitor device.
|
|
|
|
*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
sysmonread_power(dev_t dev, struct uio *uio, int flags)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
power_event_t pev;
|
2008-09-06 01:58:32 +04:00
|
|
|
int rv;
|
2003-04-18 05:31:34 +04:00
|
|
|
|
|
|
|
/* We only allow one event to be read at a time. */
|
|
|
|
if (uio->uio_resid != POWER_EVENT_MSG_SIZE)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return EINVAL;
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
|
|
|
for (;;) {
|
|
|
|
if (sysmon_get_power_event(&pev)) {
|
2008-09-06 01:58:32 +04:00
|
|
|
rv = uiomove(&pev, POWER_EVENT_MSG_SIZE, uio);
|
|
|
|
break;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
if (flags & IO_NDELAY) {
|
2008-09-06 01:58:32 +04:00
|
|
|
rv = EWOULDBLOCK;
|
|
|
|
break;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
cv_wait(&sysmon_power_event_queue_cv,
|
|
|
|
&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2008-09-06 01:58:32 +04:00
|
|
|
|
|
|
|
return rv;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonpoll_power:
|
|
|
|
*
|
|
|
|
* Poll the system monitor device.
|
|
|
|
*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
sysmonpoll_power(dev_t dev, int events, struct lwp *l)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
int revents;
|
|
|
|
|
|
|
|
revents = events & (POLLOUT | POLLWRNORM);
|
|
|
|
|
|
|
|
/* Attempt to save some work. */
|
|
|
|
if ((events & (POLLIN | POLLRDNORM)) == 0)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return revents;
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
if (sysmon_power_event_queue_count)
|
|
|
|
revents |= events & (POLLIN | POLLRDNORM);
|
|
|
|
else
|
2005-12-11 15:16:03 +03:00
|
|
|
selrecord(l, &sysmon_power_event_queue_selinfo);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return revents;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
filt_sysmon_power_rdetach(struct knote *kn)
|
|
|
|
{
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
SLIST_REMOVE(&sysmon_power_event_queue_selinfo.sel_klist,
|
|
|
|
kn, knote, kn_selnext);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2006-11-16 04:32:37 +03:00
|
|
|
filt_sysmon_power_read(struct knote *kn, long hint)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
kn->kn_data = sysmon_power_event_queue_count;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return kn->kn_data > 0;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct filterops sysmon_power_read_filtops =
|
|
|
|
{ 1, NULL, filt_sysmon_power_rdetach, filt_sysmon_power_read };
|
|
|
|
|
|
|
|
static const struct filterops sysmon_power_write_filtops =
|
|
|
|
{ 1, NULL, filt_sysmon_power_rdetach, filt_seltrue };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonkqfilter_power:
|
|
|
|
*
|
|
|
|
* Kqueue filter for the system monitor device.
|
|
|
|
*/
|
|
|
|
int
|
2006-11-16 04:32:37 +03:00
|
|
|
sysmonkqfilter_power(dev_t dev, struct knote *kn)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
struct klist *klist;
|
|
|
|
|
|
|
|
switch (kn->kn_filter) {
|
|
|
|
case EVFILT_READ:
|
|
|
|
klist = &sysmon_power_event_queue_selinfo.sel_klist;
|
|
|
|
kn->kn_fop = &sysmon_power_read_filtops;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EVFILT_WRITE:
|
|
|
|
klist = &sysmon_power_event_queue_selinfo.sel_klist;
|
|
|
|
kn->kn_fop = &sysmon_power_write_filtops;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2007-12-05 20:19:46 +03:00
|
|
|
return EINVAL;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
SLIST_INSERT_HEAD(klist, kn, kn_selnext);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
2003-04-18 05:31:34 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return 0;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonioctl_power:
|
|
|
|
*
|
2010-03-11 16:51:01 +03:00
|
|
|
* Perform a power management control request.
|
2003-04-18 05:31:34 +04:00
|
|
|
*/
|
|
|
|
int
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
sysmonioctl_power(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
switch (cmd) {
|
|
|
|
case POWER_IOC_GET_TYPE:
|
2009-11-06 21:28:10 +03:00
|
|
|
case POWER_IOC_GET_TYPE_WITH_LOSSAGE:
|
2003-04-18 05:31:34 +04:00
|
|
|
{
|
|
|
|
struct power_type *power_type = (void *) data;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
(void)strlcpy(power_type->power_type,
|
|
|
|
sysmon_power_type,
|
|
|
|
sizeof(power_type->power_type));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case POWER_EVENT_RECVDICT:
|
|
|
|
{
|
|
|
|
struct plistref *plist = (struct plistref *)data;
|
2007-10-07 01:58:40 +04:00
|
|
|
struct power_event_dictionary *ped;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
/*
|
|
|
|
* Get the first dictionary enqueued and mark it
|
|
|
|
* as busy.
|
|
|
|
*/
|
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
|
|
|
ped = SLIST_FIRST(&pev_dict_list);
|
2007-11-10 12:32:24 +03:00
|
|
|
if (!ped || !ped->dict) {
|
2007-10-07 01:58:40 +04:00
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
error = ENOTSUP;
|
|
|
|
break;
|
|
|
|
}
|
2007-10-07 01:58:40 +04:00
|
|
|
|
2007-11-10 12:32:24 +03:00
|
|
|
if ((ped->flags & SYSMON_POWER_DICTIONARY_READY) == 0) {
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
if (ped->flags & SYSMON_POWER_DICTIONARY_BUSY) {
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
|
|
|
error = EBUSY;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
ped->flags |= SYSMON_POWER_DICTIONARY_BUSY;
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Send it now.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
error = prop_dictionary_copyout_ioctl(plist,
|
|
|
|
cmd,
|
2007-10-07 01:58:40 +04:00
|
|
|
ped->dict);
|
|
|
|
|
2007-09-25 23:27:08 +04:00
|
|
|
/*
|
2007-10-07 01:58:40 +04:00
|
|
|
* Remove the dictionary now that we don't need it.
|
2007-09-25 23:27:08 +04:00
|
|
|
*/
|
2007-10-07 01:58:40 +04:00
|
|
|
mutex_enter(&sysmon_power_event_queue_mtx);
|
|
|
|
ped->flags &= ~SYSMON_POWER_DICTIONARY_BUSY;
|
2007-11-10 12:32:24 +03:00
|
|
|
ped->flags &= ~SYSMON_POWER_DICTIONARY_READY;
|
2007-10-07 01:58:40 +04:00
|
|
|
SLIST_REMOVE_HEAD(&pev_dict_list, pev_dict_head);
|
|
|
|
mutex_exit(&sysmon_power_event_queue_mtx);
|
|
|
|
sysmon_power_destroy_dictionary(ped);
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
error = ENOTTY;
|
|
|
|
}
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_power_make_dictionary:
|
|
|
|
*
|
2007-10-07 01:58:40 +04:00
|
|
|
* Adds the properties for an event in a dictionary.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
|
|
|
int
|
2007-10-07 01:58:40 +04:00
|
|
|
sysmon_power_make_dictionary(prop_dictionary_t dict, void *power_data,
|
|
|
|
int event, int type)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{
|
2007-10-07 01:58:40 +04:00
|
|
|
int i;
|
2007-09-25 23:27:08 +04:00
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
KASSERT(mutex_owned(&sysmon_power_event_queue_mtx));
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
/*
|
|
|
|
* create the dictionary for a power switch event.
|
|
|
|
*/
|
|
|
|
case POWER_EVENT_SWITCH_STATE_CHANGE:
|
|
|
|
{
|
|
|
|
const struct power_event_description *peevent =
|
|
|
|
pswitch_event_desc;
|
|
|
|
const struct power_event_description *petype =
|
|
|
|
pswitch_type_desc;
|
|
|
|
struct sysmon_pswitch *smpsw =
|
|
|
|
(struct sysmon_pswitch *)power_data;
|
|
|
|
const char *pwrtype = "pswitch";
|
|
|
|
|
|
|
|
#define SETPROP(key, str) \
|
|
|
|
do { \
|
2007-10-07 01:58:40 +04:00
|
|
|
if ((str) && !prop_dictionary_set_cstring(dict, \
|
2007-09-25 23:27:08 +04:00
|
|
|
(key), \
|
|
|
|
(str))) { \
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
printf("%s: failed to set %s\n", __func__, (str)); \
|
|
|
|
return EINVAL; \
|
|
|
|
} \
|
|
|
|
} while (/* CONSTCOND */ 0)
|
|
|
|
|
2007-10-11 03:25:39 +04:00
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
SETPROP("driver-name", smpsw->smpsw_name);
|
|
|
|
|
|
|
|
for (i = 0; peevent[i].type != -1; i++)
|
|
|
|
if (peevent[i].type == event)
|
|
|
|
break;
|
|
|
|
|
|
|
|
SETPROP("powerd-event-name", peevent[i].desc);
|
|
|
|
|
|
|
|
for (i = 0; petype[i].type != -1; i++)
|
|
|
|
if (petype[i].type == smpsw->smpsw_type)
|
|
|
|
break;
|
|
|
|
|
|
|
|
SETPROP("powerd-script-name", petype[i].desc);
|
|
|
|
SETPROP("power-type", pwrtype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* create a dictionary for power envsys event.
|
|
|
|
*/
|
|
|
|
case POWER_EVENT_ENVSYS_STATE_CHANGE:
|
|
|
|
{
|
|
|
|
const struct power_event_description *peevent =
|
|
|
|
penvsys_event_desc;
|
|
|
|
const struct power_event_description *petype =
|
|
|
|
penvsys_type_desc;
|
|
|
|
struct penvsys_state *pes =
|
|
|
|
(struct penvsys_state *)power_data;
|
|
|
|
const char *pwrtype = "envsys";
|
|
|
|
|
|
|
|
SETPROP("driver-name", pes->pes_dvname);
|
|
|
|
SETPROP("sensor-name", pes->pes_sensname);
|
2007-09-04 20:54:02 +04:00
|
|
|
SETPROP("state-description", pes->pes_statedesc);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
for (i = 0; peevent[i].type != -1; i++)
|
|
|
|
if (peevent[i].type == event)
|
|
|
|
break;
|
|
|
|
|
|
|
|
SETPROP("powerd-event-name", peevent[i].desc);
|
|
|
|
|
|
|
|
for (i = 0; petype[i].type != -1; i++)
|
|
|
|
if (petype[i].type == pes->pes_type)
|
|
|
|
break;
|
|
|
|
|
|
|
|
SETPROP("powerd-script-name", petype[i].desc);
|
|
|
|
SETPROP("power-type", pwrtype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
return ENOTSUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
2007-09-25 23:27:08 +04:00
|
|
|
/*
|
|
|
|
* sysmon_power_destroy_dictionary:
|
|
|
|
*
|
2007-10-07 01:58:40 +04:00
|
|
|
* Destroys a power_event_dictionary object and all its
|
|
|
|
* properties in the dictionary.
|
2007-09-25 23:27:08 +04:00
|
|
|
*/
|
|
|
|
static void
|
2007-10-07 01:58:40 +04:00
|
|
|
sysmon_power_destroy_dictionary(struct power_event_dictionary *ped)
|
2007-09-25 23:27:08 +04:00
|
|
|
{
|
|
|
|
prop_object_iterator_t iter;
|
|
|
|
prop_object_t obj;
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
KASSERT(ped != NULL);
|
|
|
|
KASSERT((ped->flags & SYSMON_POWER_DICTIONARY_BUSY) == 0);
|
|
|
|
|
|
|
|
iter = prop_dictionary_iterator(ped->dict);
|
2007-09-25 23:27:08 +04:00
|
|
|
if (iter == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
2007-10-07 01:58:40 +04:00
|
|
|
prop_dictionary_remove(ped->dict,
|
2007-09-25 23:27:08 +04:00
|
|
|
prop_dictionary_keysym_cstring_nocopy(obj));
|
|
|
|
prop_object_iterator_reset(iter);
|
|
|
|
}
|
|
|
|
|
|
|
|
prop_object_iterator_release(iter);
|
2007-10-07 01:58:40 +04:00
|
|
|
prop_object_release(ped->dict);
|
|
|
|
|
|
|
|
kmem_free(ped, sizeof(*ped));
|
2007-09-25 23:27:08 +04:00
|
|
|
}
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
/*
|
|
|
|
* sysmon_power_settype:
|
|
|
|
*
|
|
|
|
* Sets the back-end power management type. This information can
|
|
|
|
* be used by the power management daemon.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_power_settype(const char *type)
|
|
|
|
{
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Don't bother locking this; it's going to be set
|
|
|
|
* during autoconfiguration, and then only read from
|
|
|
|
* then on.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
(void)strlcpy(sysmon_power_type, type, sizeof(sysmon_power_type));
|
|
|
|
}
|
|
|
|
|
|
|
|
#define PENVSYS_SHOWSTATE(str) \
|
|
|
|
do { \
|
|
|
|
printf("%s: %s limit on '%s'\n", \
|
|
|
|
pes->pes_dvname, (str), pes->pes_sensname); \
|
|
|
|
} while (/* CONSTCOND */ 0)
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_penvsys_event:
|
|
|
|
*
|
|
|
|
* Puts an event onto the sysmon power queue and sends the
|
2007-10-07 01:58:40 +04:00
|
|
|
* appropiate event if the daemon is running, otherwise a
|
|
|
|
* message is shown.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_penvsys_event(struct penvsys_state *pes, int event)
|
|
|
|
{
|
2007-10-07 01:58:40 +04:00
|
|
|
struct power_event_dictionary *ped;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
const char *mystr = NULL;
|
|
|
|
|
2007-10-06 06:49:46 +04:00
|
|
|
KASSERT(pes != NULL);
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
if (sysmon_power_daemon != NULL) {
|
|
|
|
/*
|
|
|
|
* Create a dictionary for the new event.
|
|
|
|
*/
|
2007-10-07 02:07:42 +04:00
|
|
|
ped = kmem_zalloc(sizeof(*ped), KM_NOSLEEP);
|
|
|
|
if (!ped)
|
|
|
|
return;
|
2007-10-07 01:58:40 +04:00
|
|
|
ped->dict = prop_dictionary_create();
|
|
|
|
|
|
|
|
if (sysmon_power_daemon_task(ped, pes, event) == 0)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
return;
|
2007-10-07 01:58:40 +04:00
|
|
|
}
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
|
|
|
switch (pes->pes_type) {
|
|
|
|
case PENVSYS_TYPE_BATTERY:
|
|
|
|
switch (event) {
|
2007-10-11 03:25:39 +04:00
|
|
|
case PENVSYS_EVENT_LOW_POWER:
|
|
|
|
printf("sysmon: LOW POWER! SHUTTING DOWN.\n");
|
|
|
|
cpu_reboot(RB_POWERDOWN, NULL);
|
|
|
|
break;
|
2007-09-04 20:54:02 +04:00
|
|
|
case PENVSYS_EVENT_STATE_CHANGED:
|
|
|
|
printf("%s: state changed on '%s' to '%s'\n",
|
|
|
|
pes->pes_dvname, pes->pes_sensname,
|
|
|
|
pes->pes_statedesc);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
break;
|
2009-06-08 04:55:35 +04:00
|
|
|
case PENVSYS_EVENT_BATT_CRIT:
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mystr = "critical capacity";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
2009-06-08 04:55:35 +04:00
|
|
|
case PENVSYS_EVENT_BATT_WARN:
|
2008-08-22 15:27:50 +04:00
|
|
|
mystr = "warning capacity";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
2010-02-16 01:32:04 +03:00
|
|
|
case PENVSYS_EVENT_BATT_HIGH:
|
|
|
|
mystr = "high capacity";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
|
|
|
case PENVSYS_EVENT_BATT_MAX:
|
|
|
|
mystr = "maximum capacity";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
case PENVSYS_EVENT_NORMAL:
|
2007-09-04 20:54:02 +04:00
|
|
|
printf("%s: normal capacity on '%s'\n",
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
pes->pes_dvname, pes->pes_sensname);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
2007-07-02 19:18:30 +04:00
|
|
|
case PENVSYS_TYPE_FAN:
|
|
|
|
case PENVSYS_TYPE_INDICATOR:
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
case PENVSYS_TYPE_TEMP:
|
|
|
|
case PENVSYS_TYPE_POWER:
|
|
|
|
case PENVSYS_TYPE_RESISTANCE:
|
|
|
|
case PENVSYS_TYPE_VOLTAGE:
|
|
|
|
switch (event) {
|
|
|
|
case PENVSYS_EVENT_CRITICAL:
|
|
|
|
mystr = "critical";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
|
|
|
case PENVSYS_EVENT_CRITOVER:
|
|
|
|
mystr = "critical over";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
|
|
|
case PENVSYS_EVENT_CRITUNDER:
|
|
|
|
mystr = "critical under";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
|
|
|
case PENVSYS_EVENT_WARNOVER:
|
|
|
|
mystr = "warning over";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
|
|
|
case PENVSYS_EVENT_WARNUNDER:
|
|
|
|
mystr = "warning under";
|
|
|
|
PENVSYS_SHOWSTATE(mystr);
|
|
|
|
break;
|
|
|
|
case PENVSYS_EVENT_NORMAL:
|
|
|
|
printf("%s: normal state on '%s'\n",
|
|
|
|
pes->pes_dvname, pes->pes_sensname);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("%s: unknown event\n", __func__);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case PENVSYS_TYPE_DRIVE:
|
|
|
|
switch (event) {
|
2007-09-04 20:54:02 +04:00
|
|
|
case PENVSYS_EVENT_STATE_CHANGED:
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
printf("%s: state changed on '%s' to '%s'\n",
|
|
|
|
pes->pes_dvname, pes->pes_sensname,
|
|
|
|
pes->pes_statedesc);
|
2008-02-29 21:07:11 +03:00
|
|
|
break;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
case PENVSYS_EVENT_NORMAL:
|
|
|
|
printf("%s: normal state on '%s' (%s)\n",
|
|
|
|
pes->pes_dvname, pes->pes_sensname,
|
|
|
|
pes->pes_statedesc);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
printf("%s: unknown power type\n", __func__);
|
|
|
|
break;
|
|
|
|
}
|
2003-04-18 05:31:34 +04:00
|
|
|
}
|
|
|
|
|
2003-04-17 05:02:21 +04:00
|
|
|
/*
|
|
|
|
* sysmon_pswitch_register:
|
|
|
|
*
|
|
|
|
* Register a power switch device.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sysmon_pswitch_register(struct sysmon_pswitch *smpsw)
|
|
|
|
{
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
/* nada */
|
|
|
|
return 0;
|
2003-04-17 05:02:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_pswitch_unregister:
|
|
|
|
*
|
|
|
|
* Unregister a power switch device.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_pswitch_unregister(struct sysmon_pswitch *smpsw)
|
|
|
|
{
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
/* nada */
|
2003-04-17 05:02:21 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_pswitch_event:
|
|
|
|
*
|
|
|
|
* Register an event on a power switch device.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_pswitch_event(struct sysmon_pswitch *smpsw, int event)
|
|
|
|
{
|
2007-10-07 01:58:40 +04:00
|
|
|
struct power_event_dictionary *ped = NULL;
|
2007-10-06 06:49:46 +04:00
|
|
|
|
|
|
|
KASSERT(smpsw != NULL);
|
|
|
|
|
2007-12-09 23:27:42 +03:00
|
|
|
/*
|
|
|
|
* For pnp specific events, we don't care if the power daemon
|
|
|
|
* is running or not
|
|
|
|
*/
|
|
|
|
if (smpsw->smpsw_type == PSWITCH_TYPE_LID) {
|
|
|
|
switch (event) {
|
|
|
|
case PSWITCH_EVENT_PRESSED:
|
|
|
|
pmf_event_inject(NULL, PMFE_CHASSIS_LID_CLOSE);
|
|
|
|
break;
|
|
|
|
case PSWITCH_EVENT_RELEASED:
|
|
|
|
pmf_event_inject(NULL, PMFE_CHASSIS_LID_OPEN);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-07 01:58:40 +04:00
|
|
|
if (sysmon_power_daemon != NULL) {
|
|
|
|
/*
|
|
|
|
* Create a new dictionary for the event.
|
|
|
|
*/
|
2007-10-07 02:07:42 +04:00
|
|
|
ped = kmem_zalloc(sizeof(*ped), KM_NOSLEEP);
|
|
|
|
if (!ped)
|
|
|
|
return;
|
2007-10-07 01:58:40 +04:00
|
|
|
ped->dict = prop_dictionary_create();
|
|
|
|
|
|
|
|
if (sysmon_power_daemon_task(ped, smpsw, event) == 0)
|
2003-05-20 03:24:55 +04:00
|
|
|
return;
|
2007-10-07 01:58:40 +04:00
|
|
|
}
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
2003-04-17 05:02:21 +04:00
|
|
|
switch (smpsw->smpsw_type) {
|
2003-04-18 05:31:34 +04:00
|
|
|
case PSWITCH_TYPE_POWER:
|
|
|
|
if (event != PSWITCH_EVENT_PRESSED) {
|
2003-04-17 05:02:21 +04:00
|
|
|
/* just ignore it */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt a somewhat graceful shutdown of the system,
|
|
|
|
* as if the user has issued a reboot(2) call with
|
|
|
|
* RB_POWERDOWN.
|
|
|
|
*/
|
|
|
|
printf("%s: power button pressed, shutting down!\n",
|
|
|
|
smpsw->smpsw_name);
|
|
|
|
cpu_reboot(RB_POWERDOWN, NULL);
|
|
|
|
break;
|
|
|
|
|
2003-04-21 00:48:27 +04:00
|
|
|
case PSWITCH_TYPE_RESET:
|
|
|
|
if (event != PSWITCH_EVENT_PRESSED) {
|
|
|
|
/* just ignore it */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Attempt a somewhat graceful reboot of the system,
|
|
|
|
* as if the user had issued a reboot(2) call.
|
|
|
|
*/
|
|
|
|
printf("%s: reset button pressed, rebooting!\n",
|
|
|
|
smpsw->smpsw_name);
|
|
|
|
cpu_reboot(0, NULL);
|
|
|
|
break;
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
case PSWITCH_TYPE_SLEEP:
|
|
|
|
if (event != PSWITCH_EVENT_PRESSED) {
|
2003-04-17 05:02:21 +04:00
|
|
|
/* just ignore it */
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Try to enter a "sleep" state.
|
|
|
|
*/
|
|
|
|
/* XXX */
|
|
|
|
printf("%s: sleep button pressed.\n", smpsw->smpsw_name);
|
|
|
|
break;
|
|
|
|
|
2007-12-22 21:35:13 +03:00
|
|
|
case PSWITCH_TYPE_HOTKEY:
|
|
|
|
/*
|
|
|
|
* Eat up the event, there's nothing we can do
|
|
|
|
*/
|
|
|
|
break;
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
case PSWITCH_TYPE_LID:
|
2003-04-17 05:02:21 +04:00
|
|
|
switch (event) {
|
2003-04-18 05:31:34 +04:00
|
|
|
case PSWITCH_EVENT_PRESSED:
|
2003-04-17 05:02:21 +04:00
|
|
|
/*
|
|
|
|
* Try to enter a "standby" state.
|
|
|
|
*/
|
|
|
|
/* XXX */
|
|
|
|
printf("%s: lid closed.\n", smpsw->smpsw_name);
|
|
|
|
break;
|
|
|
|
|
2003-04-18 05:31:34 +04:00
|
|
|
case PSWITCH_EVENT_RELEASED:
|
2003-04-17 05:02:21 +04:00
|
|
|
/*
|
|
|
|
* Come out of "standby" state.
|
|
|
|
*/
|
|
|
|
/* XXX */
|
|
|
|
printf("%s: lid opened.\n", smpsw->smpsw_name);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("%s: unknown lid switch event: %d\n",
|
|
|
|
smpsw->smpsw_name, event);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2004-05-03 11:43:37 +04:00
|
|
|
case PSWITCH_TYPE_ACADAPTER:
|
|
|
|
switch (event) {
|
|
|
|
case PSWITCH_EVENT_PRESSED:
|
|
|
|
/*
|
2004-05-22 15:32:50 +04:00
|
|
|
* Come out of power-save state.
|
2004-05-03 11:43:37 +04:00
|
|
|
*/
|
2008-05-10 18:01:32 +04:00
|
|
|
aprint_normal("%s: AC adapter online.\n",
|
|
|
|
smpsw->smpsw_name);
|
2004-05-03 11:43:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PSWITCH_EVENT_RELEASED:
|
|
|
|
/*
|
2004-05-22 15:32:50 +04:00
|
|
|
* Try to enter a power-save state.
|
2004-05-03 11:43:37 +04:00
|
|
|
*/
|
2008-05-10 18:01:32 +04:00
|
|
|
aprint_normal("%s: AC adapter offline.\n",
|
|
|
|
smpsw->smpsw_name);
|
2004-05-03 11:43:37 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2003-04-17 05:02:21 +04:00
|
|
|
}
|
|
|
|
}
|