2007-08-31 04:35:08 +04:00
|
|
|
/* $NetBSD: sysmon_envsys.c,v 1.50 2007/08/31 00:35:08 xtraeme 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
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2007 The NetBSD Foundation, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
* by Juan Romero Pardines.
|
|
|
|
*
|
|
|
|
* 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 by Juan Romero Pardines
|
|
|
|
* for the NetBSD Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``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 FOUNDATION OR CONTRIBUTORS
|
|
|
|
* 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.
|
|
|
|
*/
|
2000-11-05 07:06:13 +03:00
|
|
|
|
|
|
|
/*-
|
|
|
|
* Copyright (c) 2000 Zembu Labs, Inc.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Author: Jason R. Thorpe <thorpej@zembu.com>
|
|
|
|
*
|
|
|
|
* 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 by Zembu Labs, Inc.
|
|
|
|
* 4. Neither the name of Zembu Labs nor the names of its employees may
|
|
|
|
* be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY ZEMBU LABS, INC. ``AS IS'' AND ANY EXPRESS
|
|
|
|
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WAR-
|
|
|
|
* RANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DIS-
|
|
|
|
* CLAIMED. IN NO EVENT SHALL ZEMBU LABS 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
|
|
|
* Environmental sensor framework for sysmon, exported to userland
|
|
|
|
* with proplib(3).
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
|
2001-11-13 09:28:55 +03:00
|
|
|
#include <sys/cdefs.h>
|
2007-08-31 04:35:08 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.50 2007/08/31 00:35:08 xtraeme Exp $");
|
2001-11-13 09:28:55 +03:00
|
|
|
|
2000-11-05 07:06:13 +03:00
|
|
|
#include <sys/param.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/types.h>
|
2000-11-05 07:06:13 +03:00
|
|
|
#include <sys/conf.h>
|
|
|
|
#include <sys/errno.h>
|
2007-07-17 19:43:08 +04:00
|
|
|
#include <sys/fcntl.h>
|
2000-11-05 07:06:13 +03:00
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/proc.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/mutex.h>
|
|
|
|
#include <sys/kmem.h>
|
2000-11-05 07:06:13 +03:00
|
|
|
|
|
|
|
#include <dev/sysmon/sysmonvar.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 <dev/sysmon/sysmon_envsysvar.h>
|
|
|
|
#include <dev/sysmon/sysmon_taskq.h>
|
2000-11-05 07:06:13 +03: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"
|
|
|
|
|
|
|
|
struct sme_sensor_type {
|
|
|
|
int type;
|
|
|
|
int crittype;
|
|
|
|
const char *desc;
|
|
|
|
};
|
|
|
|
|
|
|
|
static const struct sme_sensor_type sme_sensor_type[] = {
|
|
|
|
{ ENVSYS_STEMP, PENVSYS_TYPE_TEMP, "Temperature" },
|
|
|
|
{ ENVSYS_SFANRPM, PENVSYS_TYPE_FAN, "Fan" },
|
|
|
|
{ ENVSYS_SVOLTS_AC, PENVSYS_TYPE_VOLTAGE, "Voltage AC" },
|
|
|
|
{ ENVSYS_SVOLTS_DC, PENVSYS_TYPE_VOLTAGE, "Voltage DC" },
|
|
|
|
{ ENVSYS_SOHMS, PENVSYS_TYPE_RESISTANCE,"Ohms" },
|
|
|
|
{ ENVSYS_SWATTS, PENVSYS_TYPE_POWER, "Watts" },
|
|
|
|
{ ENVSYS_SAMPS, PENVSYS_TYPE_POWER, "Ampere" },
|
|
|
|
{ ENVSYS_SWATTHOUR, PENVSYS_TYPE_BATTERY, "Watt hour" },
|
|
|
|
{ ENVSYS_SAMPHOUR, PENVSYS_TYPE_BATTERY, "Ampere hour" },
|
2007-07-02 19:18:30 +04:00
|
|
|
{ ENVSYS_INDICATOR, PENVSYS_TYPE_INDICATOR, "Indicator" },
|
2007-07-16 21:48:52 +04:00
|
|
|
{ ENVSYS_INTEGER, PENVSYS_TYPE_INDICATOR, "Integer" },
|
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
|
|
|
{ ENVSYS_DRIVE, PENVSYS_TYPE_DRIVE, "Drive" },
|
2007-07-22 22:17:02 +04:00
|
|
|
{ -1, -1, "unknown" }
|
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-08-31 03:44:32 +04:00
|
|
|
static const struct sme_sensor_type sme_sensor_state[] = {
|
|
|
|
{ ENVSYS_SVALID, -1, "valid" },
|
|
|
|
{ ENVSYS_SINVALID, -1, "invalid" },
|
|
|
|
{ ENVSYS_SCRITICAL, -1, "critical" },
|
|
|
|
{ ENVSYS_SCRITUNDER, -1, "critical-under" },
|
|
|
|
{ ENVSYS_SCRITOVER, -1, "critical-over" },
|
|
|
|
{ ENVSYS_SWARNUNDER, -1, "warning-under" },
|
|
|
|
{ ENVSYS_SWARNOVER, -1, "warning-over" },
|
|
|
|
{ -1, -1, "unknown" }
|
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
|
|
|
};
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-08-31 03:44:32 +04:00
|
|
|
static const struct sme_sensor_type sme_sensor_drive_state[] = {
|
|
|
|
{ ENVSYS_DRIVE_EMPTY, -1, "drive state is unknown" },
|
|
|
|
{ ENVSYS_DRIVE_READY, -1, "drive is ready" },
|
|
|
|
{ ENVSYS_DRIVE_POWERUP, -1, "drive is powering up" },
|
|
|
|
{ ENVSYS_DRIVE_ONLINE, -1, "drive is online" },
|
|
|
|
{ ENVSYS_DRIVE_IDLE, -1, "drive is idle" },
|
|
|
|
{ ENVSYS_DRIVE_ACTIVE, -1, "drive is active" },
|
|
|
|
{ ENVSYS_DRIVE_REBUILD, -1, "drive is rebuilding" },
|
|
|
|
{ ENVSYS_DRIVE_POWERDOWN, -1, "drive is powering down" },
|
|
|
|
{ ENVSYS_DRIVE_FAIL, -1, "drive failed" },
|
|
|
|
{ ENVSYS_DRIVE_PFAIL, -1, "drive degraded" },
|
|
|
|
{ -1, -1, "unknown" }
|
2007-07-19 04:12:47 +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
|
|
|
static prop_dictionary_t sme_propd;
|
|
|
|
static kcondvar_t sme_list_cv;
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-08-31 03:44:32 +04:00
|
|
|
kmutex_t sme_list_mtx, sme_event_mtx, sme_event_init_mtx;
|
2007-07-22 22:17:02 +04:00
|
|
|
kcondvar_t sme_event_cv;
|
|
|
|
|
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
|
|
|
#ifdef COMPAT_40
|
|
|
|
static u_int sysmon_envsys_next_sensor_index = 0;
|
|
|
|
static struct sysmon_envsys *sysmon_envsys_find_40(u_int);
|
|
|
|
#endif
|
2007-02-19 09:08:37 +03: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
|
|
|
static void sysmon_envsys_release(struct sysmon_envsys *);
|
2007-08-31 03:44:32 +04:00
|
|
|
static int sme_register_sensorname(struct sysmon_envsys *, envsys_data_t *);
|
2007-02-19 09:08:37 +03: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_envsys_init:
|
|
|
|
*
|
|
|
|
* + Initialize global mutexes, dictionary and the linked lists.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_init(void)
|
|
|
|
{
|
|
|
|
LIST_INIT(&sysmon_envsys_list);
|
|
|
|
LIST_INIT(&sme_events_list);
|
|
|
|
mutex_init(&sme_list_mtx, MUTEX_DRIVER, IPL_NONE);
|
|
|
|
mutex_init(&sme_event_mtx, MUTEX_DRIVER, IPL_NONE);
|
|
|
|
mutex_init(&sme_event_init_mtx, MUTEX_DRIVER, IPL_NONE);
|
|
|
|
cv_init(&sme_list_cv, "smefind");
|
2007-07-19 00:31:41 +04:00
|
|
|
cv_init(&sme_event_cv, "smeevent");
|
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
|
|
|
sme_propd = prop_dictionary_create();
|
|
|
|
}
|
2000-11-05 07:06:13 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonopen_envsys:
|
|
|
|
*
|
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
|
|
|
* + Open the system monitor device.
|
2000-11-05 07:06:13 +03: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
|
|
|
sysmonopen_envsys(dev_t dev, int flag, int mode, struct lwp *l)
|
2000-11-05 07:06:13 +03: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;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonclose_envsys:
|
|
|
|
*
|
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
|
|
|
* + Close the system monitor device.
|
2000-11-05 07:06:13 +03: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
|
|
|
sysmonclose_envsys(dev_t dev, int flag, int mode, struct lwp *l)
|
2000-11-05 07:06:13 +03:00
|
|
|
{
|
2002-01-04 01:35:53 +03:00
|
|
|
/* Nothing to do */
|
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;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmonioctl_envsys:
|
|
|
|
*
|
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
|
|
|
* + Perform an envsys control request.
|
2000-11-05 07:06:13 +03: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_envsys(dev_t dev, u_long cmd, void *data, int flag, struct lwp *l)
|
2000-11-05 07:06:13 +03: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
|
|
|
struct sysmon_envsys *sme = NULL;
|
2000-11-05 07:06:13 +03: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
|
|
|
#ifdef COMPAT_40
|
2000-11-05 07:06:13 +03:00
|
|
|
u_int oidx;
|
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
|
|
|
#endif
|
2000-11-05 07:06:13 +03:00
|
|
|
|
|
|
|
switch (cmd) {
|
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 ENVSYS_GETDICTIONARY:
|
2000-11-05 07:06:13 +03: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
|
|
|
struct plistref *plist = (struct plistref *)data;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update all sysmon envsys devices dictionaries with
|
|
|
|
* new data if it's different than we have currently
|
|
|
|
* in the dictionary.
|
|
|
|
*/
|
2007-07-21 21:18:00 +04:00
|
|
|
mutex_enter(&sme_list_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
|
|
|
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
|
2007-08-31 03:44:32 +04:00
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
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 = sme_update_dictionary(sme);
|
|
|
|
if (error) {
|
|
|
|
DPRINTF(("%s: sme_update_dictionary, "
|
|
|
|
"error=%d\n", __func__, error));
|
2007-08-31 03:44:32 +04:00
|
|
|
sme->sme_flags &= ~SME_FLAG_BUSY;
|
2007-07-21 21:18:00 +04:00
|
|
|
mutex_exit(&sme_list_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
|
|
|
return error;
|
|
|
|
}
|
2007-08-31 03:44:32 +04:00
|
|
|
sme->sme_flags &= ~SME_FLAG_BUSY;
|
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-07-21 21:18:00 +04:00
|
|
|
mutex_exit(&sme_list_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
|
|
|
/*
|
|
|
|
* Copy global dictionary to userland.
|
|
|
|
*/
|
|
|
|
error = prop_dictionary_copyout_ioctl(plist, cmd, sme_propd);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENVSYS_SETDICTIONARY:
|
|
|
|
{
|
|
|
|
const struct plistref *plist = (const struct plistref *)data;
|
|
|
|
prop_dictionary_t udict;
|
|
|
|
prop_object_t obj;
|
|
|
|
const char *devname = NULL;
|
2002-12-31 08:26:56 +03:00
|
|
|
|
2007-07-17 19:43:08 +04:00
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return EPERM;
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Get dictionary from userland.
|
|
|
|
*/
|
|
|
|
error = prop_dictionary_copyin_ioctl(plist, cmd, &udict);
|
2007-07-22 22:17:02 +04:00
|
|
|
if (error) {
|
|
|
|
DPRINTF(("%s: copyin_ioctl error=%d\n",
|
|
|
|
__func__, error));
|
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-07-22 22:17:02 +04:00
|
|
|
}
|
2002-12-31 08:26:56 +03: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
|
|
|
/*
|
|
|
|
* Parse "driver-name" key to obtain the driver we
|
|
|
|
* are searching for.
|
|
|
|
*/
|
|
|
|
obj = prop_dictionary_get(udict, "driver-name");
|
|
|
|
if (obj == NULL || prop_object_type(obj) != PROP_TYPE_STRING) {
|
|
|
|
DPRINTF(("%s: driver-name failed\n", __func__));
|
|
|
|
prop_object_release(udict);
|
|
|
|
error = EINVAL;
|
2002-12-31 08:26:56 +03:00
|
|
|
break;
|
|
|
|
}
|
2000-11-05 07:06:13 +03: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
|
|
|
/* driver name */
|
|
|
|
devname = prop_string_cstring_nocopy(obj);
|
|
|
|
|
|
|
|
/* find the correct sme device */
|
|
|
|
sme = sysmon_envsys_find(devname);
|
2000-11-05 07:06:13 +03:00
|
|
|
if (sme == NULL) {
|
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
|
|
|
DPRINTF(("%s: NULL sme\n", __func__));
|
|
|
|
prop_object_release(udict);
|
|
|
|
error = EINVAL;
|
2000-11-05 07:06:13 +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
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the correct array object with the string supplied
|
|
|
|
* by the userland dictionary.
|
|
|
|
*/
|
|
|
|
obj = prop_dictionary_get(sme_propd, devname);
|
|
|
|
if (prop_object_type(obj) != PROP_TYPE_ARRAY) {
|
|
|
|
DPRINTF(("%s: array device failed\n", __func__));
|
2007-07-23 21:51:16 +04:00
|
|
|
sysmon_envsys_release(sme);
|
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
|
|
|
prop_object_release(udict);
|
|
|
|
error = EINVAL;
|
|
|
|
break;
|
2000-11-05 07:06:13 +03: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
|
|
|
|
|
|
|
/* do the real work now */
|
|
|
|
error = sme_userset_dictionary(sme, udict, obj);
|
2000-11-05 07:06:13 +03:00
|
|
|
sysmon_envsys_release(sme);
|
|
|
|
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
|
|
|
/*
|
|
|
|
* Compatibility functions with the old interface, only
|
|
|
|
* implemented ENVSYS_GTREDATA and ENVSYS_GTREINFO; enough
|
|
|
|
* to make old applications work.
|
|
|
|
*/
|
|
|
|
#ifdef COMPAT_40
|
2000-11-05 07:06:13 +03:00
|
|
|
case ENVSYS_GTREDATA:
|
|
|
|
{
|
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 envsys_tre_data *tred = (void *)data;
|
|
|
|
envsys_data_t *edata = NULL;
|
2000-11-05 07:06:13 +03:00
|
|
|
|
|
|
|
tred->validflags = 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
|
|
|
sme = sysmon_envsys_find_40(tred->sensor);
|
2000-11-05 07:06:13 +03:00
|
|
|
if (sme == NULL)
|
|
|
|
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
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
mutex_enter(&sme_list_mtx);
|
2000-11-05 07:06:13 +03:00
|
|
|
oidx = tred->sensor;
|
|
|
|
tred->sensor = SME_SENSOR_IDX(sme, tred->sensor);
|
|
|
|
|
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
|
|
|
DPRINTFOBJ(("%s: sensor=%d oidx=%d dev=%s nsensors=%d\n",
|
|
|
|
__func__, tred->sensor, oidx, sme->sme_name,
|
|
|
|
sme->sme_nsensors));
|
2000-11-05 07:06:13 +03: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
|
|
|
edata = &sme->sme_sensor_data[tred->sensor];
|
|
|
|
|
|
|
|
if (tred->sensor < sme->sme_nsensors) {
|
|
|
|
if ((sme->sme_flags & SME_DISABLE_GTREDATA) == 0) {
|
|
|
|
error = (*sme->sme_gtredata)(sme, edata);
|
|
|
|
if (error) {
|
|
|
|
DPRINTF(("%s: sme_gtredata failed\n",
|
|
|
|
__func__));
|
2007-08-30 22:01:26 +04:00
|
|
|
mutex_exit(&sme_list_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
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* copy required values to the old interface */
|
|
|
|
tred->sensor = edata->sensor;
|
|
|
|
tred->cur.data_us = edata->value_cur;
|
|
|
|
tred->cur.data_s = edata->value_cur;
|
|
|
|
tred->max.data_us = edata->value_max;
|
|
|
|
tred->max.data_s = edata->value_max;
|
|
|
|
tred->min.data_us = edata->value_min;
|
|
|
|
tred->min.data_s = edata->value_min;
|
|
|
|
tred->avg.data_us = edata->value_avg;
|
|
|
|
tred->avg.data_s = edata->value_avg;
|
|
|
|
tred->units = edata->units;
|
|
|
|
|
2007-07-04 20:30:18 +04:00
|
|
|
tred->validflags |= ENVSYS_FVALID;
|
|
|
|
tred->validflags |= ENVSYS_FCURVALID;
|
|
|
|
|
|
|
|
if (edata->flags & ENVSYS_FPERCENT) {
|
|
|
|
tred->validflags |= ENVSYS_FMAXVALID;
|
|
|
|
tred->validflags |= ENVSYS_FFRACVALID;
|
|
|
|
}
|
|
|
|
|
2007-07-21 19:45:12 +04:00
|
|
|
if (edata->state == ENVSYS_SINVALID ||
|
2007-07-22 22:17:02 +04:00
|
|
|
edata->flags & ENVSYS_FNOTVALID) {
|
2007-07-04 20:30:18 +04:00
|
|
|
tred->validflags &= ~ENVSYS_FCURVALID;
|
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
|
|
|
tred->cur.data_us = tred->cur.data_s = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTFOBJ(("%s: sensor=%s tred->cur.data_s=%d\n",
|
|
|
|
__func__, edata->desc, tred->cur.data_s));
|
|
|
|
DPRINTFOBJ(("%s: tred->validflags=%d tred->units=%d"
|
|
|
|
" tred->sensor=%d\n", __func__, tred->validflags,
|
|
|
|
tred->units, tred->sensor));
|
2000-11-05 07:06:13 +03: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
|
|
|
tred->sensor = oidx;
|
2007-08-30 22:01:26 +04:00
|
|
|
mutex_exit(&sme_list_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
|
|
|
|
2000-11-05 07:06:13 +03:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ENVSYS_GTREINFO:
|
|
|
|
{
|
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 envsys_basic_info *binfo = (void *)data;
|
|
|
|
envsys_data_t *edata = NULL;
|
2000-11-05 07:06:13 +03:00
|
|
|
|
|
|
|
binfo->validflags = 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
|
|
|
sme = sysmon_envsys_find_40(binfo->sensor);
|
2000-11-05 07:06:13 +03:00
|
|
|
if (sme == NULL)
|
|
|
|
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
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
mutex_enter(&sme_list_mtx);
|
2000-11-05 07:06:13 +03:00
|
|
|
oidx = binfo->sensor;
|
|
|
|
binfo->sensor = SME_SENSOR_IDX(sme, binfo->sensor);
|
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
|
|
|
|
|
|
|
edata = &sme->sme_sensor_data[binfo->sensor];
|
|
|
|
|
2007-07-04 20:30:18 +04:00
|
|
|
binfo->validflags |= ENVSYS_FVALID;
|
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 (binfo->sensor < sme->sme_nsensors) {
|
|
|
|
binfo->units = edata->units;
|
|
|
|
(void)strlcpy(binfo->desc, edata->desc,
|
|
|
|
sizeof(binfo->desc));
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTFOBJ(("%s: binfo->units=%d binfo->validflags=%d\n",
|
|
|
|
__func__, binfo->units, binfo->validflags));
|
|
|
|
DPRINTFOBJ(("%s: binfo->desc=%s binfo->sensor=%d\n",
|
|
|
|
__func__, binfo->desc, binfo->sensor));
|
|
|
|
|
2000-11-05 07:06:13 +03:00
|
|
|
binfo->sensor = oidx;
|
2007-08-30 22:01:26 +04:00
|
|
|
mutex_exit(&sme_list_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
|
|
|
|
2000-11-05 07:06:13 +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
|
|
|
#endif /* COMPAT_40 */
|
2000-11-05 07:06:13 +03:00
|
|
|
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
|
|
|
break;
|
2000-11-05 07:06:13 +03: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;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_register:
|
|
|
|
*
|
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
|
|
|
* + Register an envsys device.
|
|
|
|
* + Create device dictionary.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
sysmon_envsys_register(struct sysmon_envsys *sme)
|
|
|
|
{
|
2007-08-30 22:01:26 +04:00
|
|
|
struct sme_dictionary {
|
|
|
|
SLIST_ENTRY(sme_dictionary) sme_dicts;
|
|
|
|
prop_dictionary_t dict;
|
|
|
|
size_t idx;
|
|
|
|
};
|
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 sysmon_envsys *lsme;
|
2007-08-30 22:01:26 +04:00
|
|
|
SLIST_HEAD(, sme_dictionary) sme_dict_list;
|
|
|
|
struct sme_dictionary *sd = NULL;
|
|
|
|
prop_array_t array;
|
|
|
|
envsys_data_t *edata = NULL;
|
|
|
|
int i, error = 0;
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
KASSERT(sme != NULL);
|
|
|
|
KASSERT(sme->sme_name != NULL);
|
|
|
|
KASSERT(sme->sme_sensor_data != NULL);
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* sme_nsensors is mandatory...
|
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-08-30 22:01:26 +04:00
|
|
|
if (!sme->sme_nsensors)
|
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;
|
2007-08-30 22:01:26 +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
|
|
|
/*
|
2007-08-30 22:01:26 +04:00
|
|
|
* sanity check: if SME_DISABLE_GTREDATA is not set,
|
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
|
|
|
* the sme_gtredata function callback must be non NULL.
|
|
|
|
*/
|
|
|
|
if ((sme->sme_flags & SME_DISABLE_GTREDATA) == 0) {
|
|
|
|
if (sme->sme_gtredata == NULL)
|
|
|
|
return EINVAL;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
/* create the sysmon envsys device array. */
|
|
|
|
array = prop_array_create();
|
|
|
|
if (array == NULL)
|
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the singly linked list to allocate N dictionaries.
|
|
|
|
*/
|
|
|
|
SLIST_INIT(&sme_dict_list);
|
|
|
|
for (i = 0; i < sme->sme_nsensors; i++) {
|
|
|
|
sd = kmem_zalloc(sizeof(*sd), KM_SLEEP);
|
|
|
|
sd->dict = prop_dictionary_create();
|
|
|
|
if (sd->dict == NULL) {
|
|
|
|
kmem_free(sd, sizeof(*sd));
|
|
|
|
error = ENOMEM;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
sd->idx = i;
|
|
|
|
SLIST_INSERT_HEAD(&sme_dict_list, sd, sme_dicts);
|
|
|
|
DPRINTF(("%s: creating dictionary [%d]\n", __func__, i));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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-08-30 22:01:26 +04:00
|
|
|
* Check if requested sysmon_envsys device is valid
|
|
|
|
* and does not exist already in the list.
|
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(&sme_list_mtx);
|
2007-08-30 22:01:26 +04:00
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
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
|
|
|
LIST_FOREACH(lsme, &sysmon_envsys_list, sme_list) {
|
|
|
|
if (strcmp(lsme->sme_name, sme->sme_name) == 0) {
|
|
|
|
error = EEXIST;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* Initialize the singly linked list for sensor descriptions.
|
|
|
|
*/
|
2007-08-31 03:44:32 +04:00
|
|
|
SLIST_INIT(&sme->sme_names_list);
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* Iterate over all sensors and create a dictionary per sensor,
|
|
|
|
* checking firstly if sensor description is unique.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < sme->sme_nsensors; i++) {
|
|
|
|
/*
|
|
|
|
* XXX:
|
|
|
|
*
|
|
|
|
* workaround for LKMs. First sensor used in a LKM
|
|
|
|
* gets the index sensor from all edata structs
|
|
|
|
* allocated in kernel. It is unknown to me why this
|
|
|
|
* value is not 0 when using a LKM.
|
|
|
|
*
|
|
|
|
* For now overwrite its index to 0.
|
|
|
|
*/
|
|
|
|
if (i == 0)
|
|
|
|
sme->sme_sensor_data[0].sensor = 0;
|
|
|
|
|
2007-08-31 01:31:28 +04:00
|
|
|
edata = &sme->sme_sensor_data[i];
|
|
|
|
/*
|
|
|
|
* Check if sensor description is unique.
|
|
|
|
*/
|
2007-08-31 03:44:32 +04:00
|
|
|
if (sme_register_sensorname(sme, edata))
|
2007-08-31 01:31:28 +04:00
|
|
|
continue;
|
|
|
|
|
|
|
|
SLIST_FOREACH(sd, &sme_dict_list, sme_dicts)
|
|
|
|
if (sd->idx == i)
|
|
|
|
break;
|
|
|
|
/*
|
|
|
|
* Create all objects in sensor's dictionary.
|
|
|
|
*/
|
|
|
|
sme_add_sensor_dictionary(sme, array, sd->dict, edata);
|
2007-08-30 22:01:26 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the array does not contain any object (sensor), there's
|
|
|
|
* no need to attach the driver.
|
|
|
|
*/
|
|
|
|
if (prop_array_count(array) == 0) {
|
|
|
|
error = EINVAL;
|
|
|
|
DPRINTF(("%s: empty array for '%s'\n", __func__,
|
|
|
|
sme->sme_name));
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the array into the global dictionary for the driver.
|
|
|
|
*
|
|
|
|
* <dict>
|
|
|
|
* <key>foo0</key>
|
|
|
|
* <array>
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
if (!prop_dictionary_set(sme_propd, sme->sme_name, array)) {
|
|
|
|
DPRINTF(("%s: prop_dictionary_set for '%s'\n", __func__,
|
|
|
|
sme->sme_name));
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-08-31 01:31:28 +04:00
|
|
|
* Add the device into the list.
|
2007-08-30 22:01:26 +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
|
|
|
#ifdef COMPAT_40
|
2000-11-05 07:06:13 +03:00
|
|
|
sme->sme_fsensor = sysmon_envsys_next_sensor_index;
|
|
|
|
sysmon_envsys_next_sensor_index += sme->sme_nsensors;
|
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
|
|
|
#endif
|
2007-08-30 22:01:26 +04:00
|
|
|
LIST_INSERT_HEAD(&sysmon_envsys_list, sme, sme_list);
|
2000-11-05 07:06:13 +03: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
|
|
|
out:
|
2007-08-30 22:01:26 +04:00
|
|
|
sme->sme_flags &= ~SME_FLAG_BUSY;
|
2007-08-31 03:44:32 +04:00
|
|
|
sme->sme_uniqsensors = 0;
|
2007-07-27 15:59:09 +04:00
|
|
|
mutex_exit(&sme_list_mtx);
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* Remove all items from the singly linked list, we don't
|
|
|
|
* need them anymore.
|
|
|
|
*/
|
|
|
|
out2:
|
|
|
|
while ((sd = SLIST_FIRST(&sme_dict_list)) != NULL) {
|
|
|
|
SLIST_REMOVE_HEAD(&sme_dict_list, sme_dicts);
|
|
|
|
prop_object_release(sd->dict);
|
|
|
|
kmem_free(sd, sizeof(*sd));
|
|
|
|
}
|
|
|
|
if (error) {
|
|
|
|
DPRINTF(("%s: failed to register '%s' (%d)\n",
|
|
|
|
__func__, sme->sme_name, error));
|
|
|
|
prop_object_release(array);
|
|
|
|
}
|
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;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_unregister:
|
|
|
|
*
|
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
|
|
|
* + Unregister an envsys device.
|
|
|
|
* + Unregister all events associated with this device.
|
|
|
|
* + Remove device dictionary.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_unregister(struct sysmon_envsys *sme)
|
|
|
|
{
|
2007-07-19 04:12:47 +04:00
|
|
|
struct sme_sensor_names *snames;
|
2007-07-21 19:16:58 +04:00
|
|
|
|
|
|
|
KASSERT(sme != NULL);
|
2000-11-05 07:06:13 +03: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(&sme_list_mtx);
|
2003-08-11 18:24:41 +04:00
|
|
|
while (sme->sme_flags & SME_FLAG_BUSY) {
|
2003-08-11 19:07:14 +04:00
|
|
|
sme->sme_flags |= SME_FLAG_WANTED;
|
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(&sme_list_cv, &sme_list_mtx);
|
|
|
|
}
|
2007-08-30 22:01:26 +04:00
|
|
|
LIST_REMOVE(sme, sme_list);
|
2007-07-19 04:12:47 +04:00
|
|
|
/*
|
2007-08-30 22:01:26 +04:00
|
|
|
* Remove all sensor descriptions from the singly linked list.
|
2007-07-19 04:12:47 +04:00
|
|
|
*/
|
2007-08-31 03:44:32 +04:00
|
|
|
while (!SLIST_EMPTY(&sme->sme_names_list)) {
|
|
|
|
snames = SLIST_FIRST(&sme->sme_names_list);
|
|
|
|
SLIST_REMOVE_HEAD(&sme->sme_names_list, sme_names);
|
2007-07-19 04:12:47 +04:00
|
|
|
kmem_free(snames, sizeof(*snames));
|
|
|
|
}
|
2007-08-31 03:44:32 +04:00
|
|
|
mutex_exit(&sme_list_mtx);
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* Unregister all events associated with this device.
|
|
|
|
*/
|
|
|
|
sme_event_unregister_all(sme);
|
|
|
|
/*
|
|
|
|
* Remove the device from the global dictionary.
|
|
|
|
*/
|
|
|
|
prop_dictionary_remove(sme_propd, sme->sme_name);
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_find:
|
|
|
|
*
|
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
|
|
|
* + Find an envsys device.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
struct sysmon_envsys *
|
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_envsys_find(const char *name)
|
2000-11-05 07:06:13 +03:00
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
|
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(&sme_list_mtx);
|
2003-08-11 18:24:41 +04:00
|
|
|
again:
|
2000-11-05 07:06:13 +03:00
|
|
|
for (sme = LIST_FIRST(&sysmon_envsys_list); sme != NULL;
|
|
|
|
sme = LIST_NEXT(sme, sme_list)) {
|
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 (strcmp(sme->sme_name, name) == 0) {
|
|
|
|
if (sme->sme_flags & SME_FLAG_BUSY) {
|
|
|
|
sme->sme_flags |= SME_FLAG_WANTED;
|
|
|
|
cv_wait(&sme_list_cv, &sme_list_mtx);
|
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
|
|
|
break;
|
2003-08-11 18:24:41 +04:00
|
|
|
}
|
2000-11-05 07:06:13 +03: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(&sme_list_mtx);
|
2003-08-11 18:24:41 +04:00
|
|
|
return sme;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_release:
|
|
|
|
*
|
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
|
|
|
* + Release an envsys device.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_release(struct sysmon_envsys *sme)
|
|
|
|
{
|
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(&sme_list_mtx);
|
2003-08-11 19:07:14 +04:00
|
|
|
if (sme->sme_flags & SME_FLAG_WANTED)
|
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(&sme_list_cv);
|
2003-08-11 19:07:14 +04:00
|
|
|
sme->sme_flags &= ~(SME_FLAG_BUSY | SME_FLAG_WANTED);
|
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(&sme_list_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* compatibility function */
|
|
|
|
#ifdef COMPAT_40
|
|
|
|
struct sysmon_envsys *
|
|
|
|
sysmon_envsys_find_40(u_int idx)
|
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
|
|
|
|
mutex_enter(&sme_list_mtx);
|
|
|
|
for (sme = LIST_FIRST(&sysmon_envsys_list); sme != NULL;
|
|
|
|
sme = LIST_NEXT(sme, sme_list)) {
|
|
|
|
if (idx >= sme->sme_fsensor &&
|
|
|
|
idx < (sme->sme_fsensor + sme->sme_nsensors))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
mutex_exit(&sme_list_mtx);
|
|
|
|
return sme;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-07-19 04:12:47 +04:00
|
|
|
/*
|
|
|
|
* sme_register_sensorname:
|
|
|
|
*
|
|
|
|
* + Registers a sensor name into the list maintained per device.
|
|
|
|
*/
|
|
|
|
static int
|
2007-08-31 03:44:32 +04:00
|
|
|
sme_register_sensorname(struct sysmon_envsys *sme, envsys_data_t *edata)
|
2007-07-19 04:12:47 +04:00
|
|
|
{
|
|
|
|
struct sme_sensor_names *snames, *snames2 = NULL;
|
|
|
|
|
2007-07-21 19:16:58 +04:00
|
|
|
KASSERT(edata != NULL);
|
2007-08-31 04:35:08 +04:00
|
|
|
KASSERT(mutex_owned(&sme_list_mtx));
|
2007-07-21 19:16:58 +04:00
|
|
|
|
2007-08-31 03:44:32 +04:00
|
|
|
SLIST_FOREACH(snames2, &sme->sme_names_list, sme_names) {
|
2007-07-22 22:17:02 +04:00
|
|
|
/*
|
|
|
|
* Match sensors with empty and duplicate description.
|
|
|
|
*/
|
|
|
|
if (strlen(edata->desc) == 0 ||
|
|
|
|
strcmp(snames2->desc, edata->desc) == 0)
|
2007-07-21 16:11:27 +04:00
|
|
|
if (snames2->assigned) {
|
2007-07-22 22:17:02 +04:00
|
|
|
edata->flags |= ENVSYS_FNOTVALID;
|
2007-07-21 16:11:27 +04:00
|
|
|
DPRINTF(("%s: duplicate name "
|
|
|
|
"(%s)\n", __func__, edata->desc));
|
|
|
|
return EEXIST;
|
|
|
|
}
|
2007-07-19 04:12:47 +04:00
|
|
|
}
|
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
snames = kmem_zalloc(sizeof(*snames), KM_NOSLEEP);
|
|
|
|
if (snames == NULL)
|
|
|
|
return ENOMEM;
|
|
|
|
|
2007-07-19 04:12:47 +04:00
|
|
|
snames->assigned = true;
|
|
|
|
(void)strlcpy(snames->desc, edata->desc, sizeof(snames->desc));
|
|
|
|
DPRINTF(("%s: registering sensor name=%s\n", __func__, edata->desc));
|
2007-08-31 03:44:32 +04:00
|
|
|
SLIST_INSERT_HEAD(&sme->sme_names_list, snames, sme_names);
|
|
|
|
sme->sme_uniqsensors++;
|
2007-07-19 04:12:47 +04:00
|
|
|
|
|
|
|
return 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
|
|
|
/*
|
|
|
|
* sme_make_dictionary:
|
|
|
|
*
|
2007-07-22 22:17:02 +04:00
|
|
|
* + Create sensor's dictionary in device's array.
|
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-07-22 22:17:02 +04:00
|
|
|
void
|
2007-08-30 22:01:26 +04:00
|
|
|
sme_add_sensor_dictionary(struct sysmon_envsys *sme, prop_array_t array,
|
|
|
|
prop_dictionary_t dict, envsys_data_t *edata)
|
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 struct sme_sensor_type *est = sme_sensor_type;
|
2007-08-31 03:44:32 +04:00
|
|
|
const struct sme_sensor_type *ess = sme_sensor_state;
|
|
|
|
const struct sme_sensor_type *esds = sme_sensor_drive_state;
|
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
|
|
|
sme_event_drv_t *sme_evdrv_t = NULL;
|
2007-07-22 22:17:02 +04:00
|
|
|
int i, j;
|
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-07-22 22:17:02 +04:00
|
|
|
i = j = 0;
|
2007-07-19 04:12:47 +04:00
|
|
|
|
2007-08-31 04:35:08 +04:00
|
|
|
KASSERT(mutex_owned(&sme_list_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
|
|
|
/* find the correct unit for this sensor. */
|
|
|
|
for (i = 0; est[i].type != -1; i++)
|
|
|
|
if (est[i].type == edata->units)
|
|
|
|
break;
|
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (strcmp(est[i].desc, "unknown") == 0) {
|
2007-07-23 12:45:51 +04:00
|
|
|
DPRINTF(("%s: invalid units type for sensor=%d\n",
|
|
|
|
__func__, edata->sensor));
|
2007-07-22 22:17:02 +04:00
|
|
|
goto invalidate_sensor;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
/*
|
|
|
|
* ...
|
|
|
|
* <key>type</key>
|
|
|
|
* <string>foo</string>
|
|
|
|
* <key>description</key>
|
|
|
|
* <string>blah blah</string>
|
|
|
|
* ...
|
|
|
|
*/
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "type", est[i].desc))
|
|
|
|
goto invalidate_sensor;
|
|
|
|
|
|
|
|
if (strlen(edata->desc) == 0) {
|
2007-07-23 12:45:51 +04:00
|
|
|
DPRINTF(("%s: invalid description for sensor=%d\n",
|
|
|
|
__func__, edata->sensor));
|
2007-07-22 22:17:02 +04:00
|
|
|
goto invalidate_sensor;
|
|
|
|
}
|
2007-07-20 14:40:07 +04:00
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "description", edata->desc))
|
|
|
|
goto invalidate_sensor;
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Add sensor's state description.
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>state</key>
|
|
|
|
* <string>valid</string>
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
for (j = 0; ess[j].type != -1; j++)
|
|
|
|
if (ess[j].type == edata->state)
|
|
|
|
break;
|
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (strcmp(ess[j].desc, "unknown") == 0) {
|
2007-07-23 12:45:51 +04:00
|
|
|
DPRINTF(("%s: invalid state for sensor=%d\n",
|
|
|
|
__func__, edata->sensor));
|
2007-07-22 22:17:02 +04:00
|
|
|
goto invalidate_sensor;
|
|
|
|
}
|
|
|
|
|
|
|
|
DPRINTF(("%s: sensor desc=%s type=%d state=%d\n",
|
|
|
|
__func__, edata->desc, edata->units, edata->state));
|
|
|
|
|
|
|
|
if (sme_sensor_upstring(dict, "state", ess[j].desc))
|
|
|
|
goto invalidate_sensor;
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* add the percentage boolean object:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>want-percentage</key>
|
|
|
|
* <true/>
|
|
|
|
* ...
|
|
|
|
*/
|
2007-07-22 22:17:02 +04:00
|
|
|
if (edata->flags & ENVSYS_FPERCENT)
|
|
|
|
if (sme_sensor_upbool(dict, "want-percentage", true))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the monitoring boolean object:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>monitoring-supported</key>
|
|
|
|
* <true/>
|
|
|
|
* ...
|
|
|
|
*
|
2007-07-16 21:48:52 +04:00
|
|
|
* always false on Drive and Indicator types, they
|
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
|
|
|
* cannot be monitored.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
if ((edata->flags & ENVSYS_FMONNOTSUPP) ||
|
|
|
|
(edata->units == ENVSYS_INDICATOR) ||
|
|
|
|
(edata->units == ENVSYS_DRIVE)) {
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upbool(dict, "monitoring-supported", false))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
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
|
|
|
} else {
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upbool(dict, "monitoring-supported", true))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the drive-state object for drive sensors:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>drive-state</key>
|
|
|
|
* <string>drive is online</string>
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
if (edata->units == ENVSYS_DRIVE) {
|
2007-07-22 22:17:02 +04:00
|
|
|
for (j = 0; esds[j].type != -1; j++)
|
|
|
|
if (esds[j].type == edata->value_cur)
|
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-07-20 14:40:07 +04:00
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "drive-state", esds[j].desc))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
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 sensor is enabled, add the following properties... */
|
|
|
|
if (edata->state == ENVSYS_SVALID) {
|
|
|
|
/*
|
|
|
|
* ...
|
|
|
|
* <key>rpms</key>
|
|
|
|
* <integer>2500</integer>
|
|
|
|
* <key>rfact</key>
|
|
|
|
* <integer>10000</integer>
|
|
|
|
* <key>cur-value</key>
|
|
|
|
* <integer>1250</integer>
|
|
|
|
* <key>min-value</key>
|
|
|
|
* <integer>800</integer>
|
|
|
|
* <key>max-value</integer>
|
|
|
|
* <integer>3000</integer>
|
|
|
|
* <key>avg-value</integer>
|
|
|
|
* <integer>1400</integer>
|
|
|
|
* </dict>
|
|
|
|
*/
|
2007-07-22 22:17:02 +04:00
|
|
|
if (edata->units == ENVSYS_SFANRPM)
|
|
|
|
if (sme_sensor_upuint32(dict, "rpms", edata->rpms))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
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-07-22 22:17:02 +04:00
|
|
|
if (edata->units == ENVSYS_SVOLTS_AC ||
|
|
|
|
edata->units == ENVSYS_SVOLTS_DC)
|
|
|
|
if (sme_sensor_upint32(dict, "rfact", edata->rfact))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
2007-07-20 14:40:07 +04:00
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upint32(dict, "cur-value", edata->value_cur))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
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-07-22 22:17:02 +04:00
|
|
|
if (edata->flags & ENVSYS_FVALID_MIN) {
|
|
|
|
if (sme_sensor_upint32(dict,
|
|
|
|
"min-value",
|
|
|
|
edata->value_min))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
2007-07-20 14:40:07 +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
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (edata->flags & ENVSYS_FVALID_MAX) {
|
|
|
|
if (sme_sensor_upint32(dict,
|
|
|
|
"max-value",
|
|
|
|
edata->value_max))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
2007-07-20 14:40:07 +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
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (edata->flags & ENVSYS_FVALID_AVG) {
|
|
|
|
if (sme_sensor_upint32(dict,
|
|
|
|
"avg-value",
|
|
|
|
edata->value_avg))
|
2007-08-30 22:01:26 +04:00
|
|
|
return;
|
2007-07-20 14:40:07 +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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* ...
|
|
|
|
* </array>
|
2007-08-30 22:01:26 +04:00
|
|
|
*
|
|
|
|
* Add the dictionary into the array.
|
|
|
|
*
|
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-07-22 22:17:02 +04:00
|
|
|
|
2007-08-31 03:44:32 +04:00
|
|
|
if (!prop_array_set(array, sme->sme_uniqsensors - 1, dict)) {
|
2007-07-22 22:17:02 +04:00
|
|
|
DPRINTF(("%s: prop_array_add\n", __func__));
|
|
|
|
goto invalidate_sensor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Add a new event if a monitoring flag was set.
|
|
|
|
*/
|
|
|
|
if (edata->monitor) {
|
2007-08-30 22:01:26 +04:00
|
|
|
sme_evdrv_t = kmem_zalloc(sizeof(*sme_evdrv_t), KM_NOSLEEP);
|
|
|
|
if (sme_evdrv_t == NULL) {
|
|
|
|
DPRINTF(("%s: edata->monitor failed\n", __func__));
|
|
|
|
return;
|
|
|
|
}
|
2007-07-22 22:17:02 +04:00
|
|
|
|
|
|
|
sme_evdrv_t->sdict = dict;
|
|
|
|
sme_evdrv_t->edata = edata;
|
|
|
|
sme_evdrv_t->sme = sme;
|
|
|
|
sme_evdrv_t->powertype = est[i].crittype;
|
|
|
|
|
|
|
|
sysmon_task_queue_init();
|
|
|
|
sysmon_task_queue_sched(0, sme_event_drvadd, sme_evdrv_t);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
invalidate_sensor:
|
|
|
|
edata->flags |= ENVSYS_FNOTVALID;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sme_update_dictionary:
|
|
|
|
*
|
|
|
|
* + Update per-sensor dictionaries with new values if there were
|
|
|
|
* changes, otherwise the object in dictionary is untouched.
|
|
|
|
* + Send a critical event if any sensor is in a critical condition.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sme_update_dictionary(struct sysmon_envsys *sme)
|
|
|
|
{
|
2007-07-29 18:02:29 +04:00
|
|
|
const struct sme_sensor_type *est = sme_sensor_type;
|
2007-08-31 03:44:32 +04:00
|
|
|
const struct sme_sensor_type *ess = sme_sensor_state;
|
|
|
|
const struct sme_sensor_type *esds = sme_sensor_drive_state;
|
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
|
|
|
envsys_data_t *edata = NULL;
|
2007-07-21 16:11:27 +04:00
|
|
|
prop_object_t array, dict;
|
2007-07-22 22:17:02 +04:00
|
|
|
int i, j, error, invalid;
|
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-08-31 04:35:08 +04:00
|
|
|
KASSERT(mutex_owned(&sme_list_mtx));
|
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
error = invalid = 0;
|
2007-07-21 16:11:27 +04:00
|
|
|
array = dict = NULL;
|
2007-07-20 14:40:07 +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
|
|
|
/* retrieve the array of dictionaries in device. */
|
|
|
|
array = prop_dictionary_get(sme_propd, sme->sme_name);
|
2007-07-17 21:56:04 +04:00
|
|
|
if (prop_object_type(array) != PROP_TYPE_ARRAY) {
|
|
|
|
DPRINTF(("%s: not an array (%s)\n", __func__, sme->sme_name));
|
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;
|
2007-07-17 21:56:04 +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
|
|
|
|
|
|
|
/*
|
|
|
|
* - iterate over all sensors.
|
|
|
|
* - fetch new data.
|
|
|
|
* - check if data in dictionary is different than new data.
|
|
|
|
* - update dictionary if there were changes.
|
|
|
|
*/
|
|
|
|
for (i = 0; i < sme->sme_nsensors; i++) {
|
|
|
|
edata = &sme->sme_sensor_data[i];
|
2007-07-22 22:17:02 +04:00
|
|
|
/* skip invalid sensors */
|
|
|
|
if (edata->flags & ENVSYS_FNOTVALID) {
|
|
|
|
invalid++;
|
2007-07-17 20:47:58 +04:00
|
|
|
continue;
|
2007-07-17 21:56:04 +04:00
|
|
|
}
|
2007-07-17 20:47:58 +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
|
|
|
/*
|
|
|
|
* refresh sensor data via sme_gtredata only if the
|
|
|
|
* flag is not set.
|
|
|
|
*/
|
|
|
|
if ((sme->sme_flags & SME_DISABLE_GTREDATA) == 0) {
|
|
|
|
error = (*sme->sme_gtredata)(sme, edata);
|
|
|
|
if (error) {
|
|
|
|
DPRINTF(("%s: gtredata[%d] failed\n",
|
|
|
|
__func__, i));
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* retrieve sensor's dictionary. */
|
2007-07-22 22:17:02 +04:00
|
|
|
dict = prop_array_get(array, i - invalid);
|
2007-07-17 21:56:04 +04:00
|
|
|
if (prop_object_type(dict) != PROP_TYPE_DICTIONARY) {
|
|
|
|
DPRINTF(("%s: not a dictionary (%d:%s)\n",
|
|
|
|
__func__, edata->sensor, sme->sme_name));
|
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;
|
2007-07-17 21:56:04 +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
|
|
|
|
|
|
|
for (j = 0; ess[j].type != -1; j++)
|
|
|
|
if (ess[j].type == edata->state)
|
|
|
|
break;
|
|
|
|
|
|
|
|
DPRINTFOBJ(("%s: state=%s type=%d flags=%d "
|
|
|
|
"units=%d sensor=%d\n", __func__, ess[j].desc,
|
|
|
|
ess[j].type, edata->flags, edata->units, edata->sensor));
|
|
|
|
|
|
|
|
/* update sensor state */
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upstring(dict, "state", ess[j].desc);
|
2007-07-20 14:40:07 +04:00
|
|
|
if (error)
|
|
|
|
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
|
|
|
|
2007-07-29 18:02:29 +04:00
|
|
|
for (j = 0; est[j].type != -1; j++)
|
|
|
|
if (est[j].type == edata->units)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* update sensor type */
|
|
|
|
error = sme_sensor_upstring(dict, "type", est[j].desc);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
/* update sensor current value */
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upint32(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"cur-value",
|
|
|
|
edata->value_cur);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Integer and Indicator types do not the following
|
|
|
|
* values, so skip them.
|
|
|
|
*/
|
|
|
|
if (edata->units == ENVSYS_INTEGER ||
|
|
|
|
edata->units == ENVSYS_INDICATOR)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/* update sensor flags */
|
2007-07-20 14:40:07 +04:00
|
|
|
if (edata->flags & ENVSYS_FPERCENT) {
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upbool(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"want-percentage",
|
|
|
|
true);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
2007-07-20 14:40:07 +04:00
|
|
|
if (edata->flags & ENVSYS_FVALID_MAX) {
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upint32(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"max-value",
|
|
|
|
edata->value_max);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edata->flags & ENVSYS_FVALID_MIN) {
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upint32(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"min-value",
|
|
|
|
edata->value_min);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
|
2007-07-20 14:40:07 +04:00
|
|
|
if (edata->flags & ENVSYS_FVALID_AVG) {
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upint32(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"avg-value",
|
|
|
|
edata->value_avg);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
|
|
|
|
/* update 'rpms' only in ENVSYS_SFANRPM. */
|
2007-07-20 14:40:07 +04:00
|
|
|
if (edata->units == ENVSYS_SFANRPM) {
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upuint32(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"rpms",
|
|
|
|
edata->rpms);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
|
|
|
|
/* update 'rfact' only in ENVSYS_SVOLTS_[AD]C. */
|
|
|
|
if (edata->units == ENVSYS_SVOLTS_AC ||
|
|
|
|
edata->units == ENVSYS_SVOLTS_DC) {
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upint32(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"rfact",
|
|
|
|
edata->rfact);
|
|
|
|
if (error)
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/* update 'drive-state' only in ENVSYS_DRIVE. */
|
|
|
|
if (edata->units == ENVSYS_DRIVE) {
|
|
|
|
for (j = 0; esds[j].type != -1; j++)
|
|
|
|
if (esds[j].type == edata->value_cur)
|
|
|
|
break;
|
|
|
|
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upstring(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"drive-state",
|
|
|
|
esds[j].desc);
|
2007-07-20 18:59:58 +04:00
|
|
|
if (error)
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return error;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sme_userset_dictionary:
|
|
|
|
*
|
|
|
|
* + Parses the userland dictionary and run the appropiate
|
|
|
|
* tasks that were requested.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sme_userset_dictionary(struct sysmon_envsys *sme, prop_dictionary_t udict,
|
|
|
|
prop_array_t array)
|
|
|
|
{
|
|
|
|
const struct sme_sensor_type *sst = sme_sensor_type;
|
2007-07-17 20:47:58 +04:00
|
|
|
envsys_data_t *edata, *nedata;
|
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
|
|
|
prop_dictionary_t dict;
|
|
|
|
prop_object_t obj, obj1, obj2;
|
|
|
|
int32_t critval;
|
2007-07-22 22:17:02 +04:00
|
|
|
int i, invalid, error;
|
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 *blah, *sname;
|
|
|
|
bool targetfound = false;
|
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
error = invalid = 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
|
|
|
blah = sname = NULL;
|
|
|
|
|
|
|
|
/* get sensor's name from userland dictionary. */
|
|
|
|
obj = prop_dictionary_get(udict, "sensor-name");
|
|
|
|
if (prop_object_type(obj) != PROP_TYPE_STRING) {
|
|
|
|
DPRINTF(("%s: sensor-name failed\n", __func__));
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* iterate over the sensors to find the right one */
|
|
|
|
for (i = 0; i < sme->sme_nsensors; i++) {
|
|
|
|
edata = &sme->sme_sensor_data[i];
|
2007-07-22 02:11:02 +04:00
|
|
|
/* skip sensors with duplicate description */
|
2007-07-22 22:17:02 +04:00
|
|
|
if (edata->flags & ENVSYS_FNOTVALID) {
|
|
|
|
invalid++;
|
2007-07-19 04:12:47 +04:00
|
|
|
continue;
|
2007-07-22 02:11:02 +04:00
|
|
|
}
|
2007-07-19 04:12:47 +04:00
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
dict = prop_array_get(array, i - invalid);
|
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
|
|
|
obj1 = prop_dictionary_get(dict, "description");
|
|
|
|
|
|
|
|
/* is it our sensor? */
|
|
|
|
if (!prop_string_equals(obj1, obj))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if a new description operation was
|
|
|
|
* requested by the user and set new description.
|
|
|
|
*/
|
|
|
|
if ((obj2 = prop_dictionary_get(udict, "new-description"))) {
|
|
|
|
targetfound = true;
|
|
|
|
blah = prop_string_cstring_nocopy(obj2);
|
2007-07-17 20:47:58 +04:00
|
|
|
|
|
|
|
for (i = 0; i < sme->sme_nsensors; i++) {
|
|
|
|
if (i == edata->sensor)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
nedata = &sme->sme_sensor_data[i];
|
|
|
|
if (strcmp(blah, nedata->desc) == 0) {
|
|
|
|
error = EEXIST;
|
2007-07-20 14:40:07 +04:00
|
|
|
break;
|
2007-07-17 20:47:58 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-20 14:47:25 +04:00
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upstring(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"description",
|
|
|
|
blah);
|
2007-07-21 04:05:54 +04:00
|
|
|
if (!error)
|
|
|
|
(void)strlcpy(edata->desc,
|
|
|
|
blah,
|
|
|
|
sizeof(edata->desc));
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did the user want to remove a critical capacity limit? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "remove-critical-cap");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
if ((edata->flags & ENVSYS_FMONNOTSUPP) ||
|
|
|
|
(edata->flags & ENVSYS_FPERCENT) == 0) {
|
|
|
|
error = ENOTSUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
sname = prop_string_cstring_nocopy(obj);
|
|
|
|
error = sme_event_unregister(sname,
|
|
|
|
PENVSYS_EVENT_BATT_USERCAP);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
prop_dictionary_remove(dict, "critical-capacity");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did the user want to remove a critical min limit? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "remove-cmin-limit");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
sname = prop_string_cstring_nocopy(obj);
|
|
|
|
error = sme_event_unregister(sname,
|
|
|
|
PENVSYS_EVENT_USER_CRITMIN);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
prop_dictionary_remove(dict, "critical-min-limit");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did the user want to remove a critical max limit? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "remove-cmax-limit");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
sname = prop_string_cstring_nocopy(obj);
|
|
|
|
error = sme_event_unregister(sname,
|
|
|
|
PENVSYS_EVENT_USER_CRITMAX);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
|
|
|
|
prop_dictionary_remove(dict, "critical-max-limit");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did the user want to change rfact? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "new-rfact");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
if (edata->flags & ENVSYS_FCHANGERFACT)
|
|
|
|
edata->rfact = prop_number_integer_value(obj2);
|
|
|
|
else
|
|
|
|
error = ENOTSUP;
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; sst[i].type != -1; i++)
|
|
|
|
if (sst[i].type == edata->units)
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* did the user want to set a critical capacity event? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "critical-capacity");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
if ((edata->flags & ENVSYS_FMONNOTSUPP) ||
|
|
|
|
(edata->flags & ENVSYS_FPERCENT) == 0) {
|
|
|
|
error = ENOTSUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
critval = prop_number_integer_value(obj2);
|
|
|
|
error = sme_event_add(dict,
|
|
|
|
edata,
|
|
|
|
sme->sme_name,
|
|
|
|
"critical-capacity",
|
|
|
|
critval,
|
|
|
|
PENVSYS_EVENT_BATT_USERCAP,
|
|
|
|
sst[i].crittype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did the user want to set a critical max event? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "critical-max-limit");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
if (edata->units == ENVSYS_INDICATOR ||
|
|
|
|
edata->flags & ENVSYS_FMONNOTSUPP) {
|
|
|
|
error = ENOTSUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
critval = prop_number_integer_value(obj2);
|
|
|
|
error = sme_event_add(dict,
|
|
|
|
edata,
|
|
|
|
sme->sme_name,
|
|
|
|
"critical-max-limit",
|
|
|
|
critval,
|
|
|
|
PENVSYS_EVENT_USER_CRITMAX,
|
|
|
|
sst[i].crittype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* did the user want to set a critical min event? */
|
|
|
|
obj2 = prop_dictionary_get(udict, "critical-min-limit");
|
|
|
|
if (obj2 != NULL) {
|
|
|
|
targetfound = true;
|
|
|
|
if (edata->units == ENVSYS_INDICATOR ||
|
|
|
|
edata->flags & ENVSYS_FMONNOTSUPP) {
|
|
|
|
error = ENOTSUP;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
critval = prop_number_integer_value(obj2);
|
|
|
|
error = sme_event_add(dict,
|
|
|
|
edata,
|
|
|
|
sme->sme_name,
|
|
|
|
"critical-min-limit",
|
|
|
|
critval,
|
|
|
|
PENVSYS_EVENT_USER_CRITMIN,
|
|
|
|
sst[i].crittype);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* invalid target? return the error */
|
|
|
|
if (!targetfound)
|
|
|
|
error = EINVAL;
|
|
|
|
|
|
|
|
return error;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|