2007-09-09 03:59:38 +04:00
|
|
|
/* $NetBSD: sysmon_envsys.c,v 1.66 2007/09/08 23:59:38 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-09-09 03:59:38 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.66 2007/09/08 23:59:38 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
|
|
|
|
2007-09-08 07:41:28 +04:00
|
|
|
/* #define ENVSYS_DEBUG */
|
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
|
|
|
|
2007-09-08 19:25:18 +04:00
|
|
|
/*
|
|
|
|
* Notes about locking:
|
|
|
|
*
|
|
|
|
* There's a global lock 'sme_mtx' to protect access to 'sysmon_envsys_list'
|
|
|
|
* (devices linked list), 'struct sysmon_envsys' (device), 'sme_events_list'
|
|
|
|
* (events linked list), 'sme_event_t' (event) and the global counter
|
|
|
|
* 'sysmon_envsys_next_sensor_index'.
|
|
|
|
*
|
|
|
|
* Another lock 'sme_init_mtx' is used to protect initialization and
|
|
|
|
* finalization of the events framework (the callout(9) and workqueue(9)
|
|
|
|
* that is used to check for conditions and sending events to powerd(8)).
|
|
|
|
*
|
|
|
|
* The global 'sme_cv' condition variable is used to wait for state changes
|
|
|
|
* on the 'sysmon_envsys_list' and 'sme_events_list' linked lists.
|
|
|
|
*
|
|
|
|
*/
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-09-08 07:17:38 +04:00
|
|
|
kmutex_t sme_mtx, sme_event_init_mtx;
|
2007-09-08 19:25:18 +04:00
|
|
|
kcondvar_t sme_cv;
|
2007-07-22 22:17:02 +04:00
|
|
|
|
2007-09-08 19:25:18 +04:00
|
|
|
static prop_dictionary_t sme_propd;
|
2007-09-08 04:21:43 +04:00
|
|
|
static uint32_t sysmon_envsys_next_sensor_index = 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
|
|
|
static struct sysmon_envsys *sysmon_envsys_find_40(u_int);
|
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-09-01 17:43:10 +04:00
|
|
|
static void sysmon_envsys_destroy_plist(prop_array_t);
|
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);
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_init(&sme_mtx, MUTEX_DRIVER, IPL_NONE);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
mutex_init(&sme_event_init_mtx, MUTEX_DRIVER, IPL_NONE);
|
2007-09-08 19:25:18 +04:00
|
|
|
cv_init(&sme_cv, "smework");
|
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:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Perform a sysmon 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;
|
|
|
|
u_int oidx;
|
|
|
|
|
|
|
|
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;
|
2007-09-08 04:21:43 +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
|
|
|
/*
|
|
|
|
* Update all sysmon envsys devices dictionaries with
|
|
|
|
* new data if it's different than we have currently
|
|
|
|
* in the dictionary.
|
|
|
|
*/
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_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-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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);
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_object_release(udict);
|
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
|
|
|
/*
|
|
|
|
* Compatibility functions with the old interface, only
|
|
|
|
* implemented ENVSYS_GTREDATA and ENVSYS_GTREINFO; enough
|
|
|
|
* to make old applications work.
|
|
|
|
*/
|
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-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_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-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_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-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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;
|
|
|
|
}
|
|
|
|
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:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Register a sysmon envsys device.
|
|
|
|
* + Create array of dictionaries for a device.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
sysmon_envsys_register(struct sysmon_envsys *sme)
|
|
|
|
{
|
2007-09-08 07:17:38 +04:00
|
|
|
struct sme_evdrv {
|
|
|
|
SLIST_ENTRY(sme_evdrv) evdrv_head;
|
|
|
|
sme_event_drv_t *evdrv;
|
|
|
|
};
|
|
|
|
SLIST_HEAD(, sme_evdrv) sme_evdrv_list;
|
|
|
|
struct sme_evdrv *sme_evdrv = 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
|
|
|
struct sysmon_envsys *lsme;
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_dictionary_t dict;
|
2007-08-30 22:01:26 +04:00
|
|
|
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-09-08 04:21:43 +04: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 for sensor descriptions.
|
|
|
|
*/
|
2007-08-31 03:44:32 +04:00
|
|
|
SLIST_INIT(&sme->sme_names_list);
|
2007-09-08 07:17:38 +04:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the singly linked list for driver events.
|
|
|
|
*/
|
|
|
|
SLIST_INIT(&sme_evdrv_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++) {
|
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;
|
|
|
|
|
2007-09-01 17:43:10 +04:00
|
|
|
dict = prop_dictionary_create();
|
|
|
|
if (dict == NULL) {
|
|
|
|
error = ENOMEM;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
2007-08-31 01:31:28 +04:00
|
|
|
/*
|
|
|
|
* Create all objects in sensor's dictionary.
|
|
|
|
*/
|
2007-09-08 07:17:38 +04:00
|
|
|
sme_evdrv = kmem_zalloc(sizeof(*sme_evdrv), KM_SLEEP);
|
|
|
|
sme_evdrv->evdrv = sme_add_sensor_dictionary(sme,
|
|
|
|
array, dict, edata);
|
|
|
|
if (sme_evdrv->evdrv)
|
|
|
|
SLIST_INSERT_HEAD(&sme_evdrv_list,
|
|
|
|
sme_evdrv, evdrv_head);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if requested sysmon_envsys device is valid
|
|
|
|
* and does not exist already in the list.
|
|
|
|
*/
|
|
|
|
mutex_enter(&sme_mtx);
|
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)) {
|
2007-09-01 17:43:10 +04:00
|
|
|
error = EINVAL;
|
2007-08-30 22:01:26 +04:00
|
|
|
DPRINTF(("%s: prop_dictionary_set for '%s'\n", __func__,
|
|
|
|
sme->sme_name));
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
/*
|
2007-08-31 01:31:28 +04:00
|
|
|
* Add the device into the list.
|
2007-08-30 22:01:26 +04:00
|
|
|
*/
|
|
|
|
LIST_INSERT_HEAD(&sysmon_envsys_list, sme, sme_list);
|
2007-09-08 04:21:43 +04:00
|
|
|
sme->sme_fsensor = sysmon_envsys_next_sensor_index;
|
|
|
|
sysmon_envsys_next_sensor_index += sme->sme_nsensors;
|
2007-09-08 07:17:38 +04:00
|
|
|
out:
|
|
|
|
sme->sme_uniqsensors = 0;
|
2007-09-09 03:59:38 +04:00
|
|
|
sme->sme_flags &= ~SME_FLAG_BUSY;
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_mtx);
|
2007-09-08 04:21:43 +04:00
|
|
|
|
|
|
|
if (error == 0) {
|
2007-09-08 07:17:38 +04:00
|
|
|
i = 0;
|
|
|
|
SLIST_FOREACH(sme_evdrv, &sme_evdrv_list, evdrv_head) {
|
|
|
|
if (i == 0)
|
|
|
|
sysmon_task_queue_init();
|
|
|
|
sysmon_task_queue_sched(0,
|
|
|
|
sme_event_drvadd, sme_evdrv->evdrv);
|
|
|
|
}
|
2007-09-08 04:21:43 +04:00
|
|
|
DPRINTF(("%s: driver '%s' registered (nsens=%d)\n",
|
|
|
|
__func__, sme->sme_name, sme->sme_nsensors));
|
|
|
|
}
|
2007-09-08 19:47:37 +04:00
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
out2:
|
2007-09-08 07:17:38 +04:00
|
|
|
while (!SLIST_EMPTY(&sme_evdrv_list)) {
|
|
|
|
sme_evdrv = SLIST_FIRST(&sme_evdrv_list);
|
|
|
|
SLIST_REMOVE_HEAD(&sme_evdrv_list, evdrv_head);
|
|
|
|
kmem_free(sme_evdrv, sizeof(*sme_evdrv));
|
|
|
|
}
|
2007-09-08 19:47:37 +04:00
|
|
|
if (error == 0)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
DPRINTF(("%s: failed to register '%s' (%d)\n", __func__,
|
|
|
|
sme->sme_name, error));
|
2007-09-08 07:37:51 +04:00
|
|
|
if (error != EEXIST) {
|
|
|
|
mutex_enter(&sme_mtx);
|
|
|
|
sme_event_unregister_all(sme->sme_name);
|
|
|
|
mutex_exit(&sme_mtx);
|
|
|
|
}
|
2007-09-01 17:43:10 +04:00
|
|
|
sysmon_envsys_destroy_plist(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
|
|
|
}
|
|
|
|
|
2007-09-01 17:43:10 +04:00
|
|
|
/*
|
|
|
|
* sysmon_envsys_destroy_plist:
|
|
|
|
*
|
|
|
|
* + Remove all objects from the array of dictionaries that is
|
|
|
|
* created in a sysmon envsys device.
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sysmon_envsys_destroy_plist(prop_array_t array)
|
|
|
|
{
|
|
|
|
prop_object_iterator_t iter, iter2;
|
2007-09-09 02:42:37 +04:00
|
|
|
prop_dictionary_t dict;
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_object_t obj;
|
|
|
|
|
|
|
|
KASSERT(array != NULL);
|
|
|
|
|
2007-09-09 02:42:37 +04:00
|
|
|
DPRINTF(("%s: objects in array=%d\n", __func__,
|
|
|
|
prop_array_count(array)));
|
|
|
|
|
2007-09-01 17:43:10 +04:00
|
|
|
iter = prop_array_iterator(array);
|
|
|
|
if (iter == NULL)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while ((dict = prop_object_iterator_next(iter)) != NULL) {
|
2007-09-09 02:42:37 +04:00
|
|
|
KASSERT(prop_object_type(dict) == PROP_TYPE_DICTIONARY);
|
2007-09-01 17:43:10 +04:00
|
|
|
iter2 = prop_dictionary_iterator(dict);
|
2007-09-09 02:42:37 +04:00
|
|
|
if (iter2 == NULL)
|
|
|
|
goto out;
|
2007-09-09 03:14:13 +04:00
|
|
|
DPRINTF(("%s: iterating over dictionary\n", __func__));
|
2007-09-09 02:42:37 +04:00
|
|
|
while ((obj = prop_object_iterator_next(iter2)) != NULL) {
|
2007-09-09 03:21:02 +04:00
|
|
|
DPRINTF(("%s: obj=%s\n", __func__,
|
|
|
|
prop_dictionary_keysym_cstring_nocopy(obj)));
|
2007-09-09 02:42:37 +04:00
|
|
|
prop_dictionary_remove(dict,
|
|
|
|
prop_dictionary_keysym_cstring_nocopy(obj));
|
|
|
|
prop_object_iterator_reset(iter2);
|
2007-09-01 17:43:10 +04:00
|
|
|
}
|
2007-09-09 02:42:37 +04:00
|
|
|
prop_object_iterator_release(iter2);
|
|
|
|
DPRINTF(("%s: objects in dictionary:%d\n",
|
|
|
|
__func__, prop_dictionary_count(dict)));
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_object_release(dict);
|
|
|
|
}
|
|
|
|
|
2007-09-09 02:42:37 +04:00
|
|
|
out:
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_object_iterator_release(iter);
|
2007-09-09 02:42:37 +04:00
|
|
|
prop_object_release(array);
|
2007-09-01 17:43:10 +04:00
|
|
|
}
|
|
|
|
|
2000-11-05 07:06:13 +03:00
|
|
|
/*
|
|
|
|
* sysmon_envsys_unregister:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Unregister a sysmon envsys device.
|
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-09-01 17:43:10 +04:00
|
|
|
prop_array_t array;
|
2007-07-21 19:16:58 +04:00
|
|
|
|
|
|
|
KASSERT(sme != NULL);
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_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;
|
2007-09-08 19:25:18 +04:00
|
|
|
cv_wait(&sme_cv, &sme_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
|
|
|
}
|
2007-09-08 04:21:43 +04:00
|
|
|
sysmon_envsys_next_sensor_index -= sme->sme_nsensors;
|
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-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* Unregister all events associated with this device.
|
|
|
|
*/
|
2007-09-01 02:44:39 +04:00
|
|
|
sme_event_unregister_all(sme->sme_name);
|
2007-09-08 07:17:38 +04:00
|
|
|
LIST_REMOVE(sme, sme_list);
|
|
|
|
mutex_exit(&sme_mtx);
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
2007-09-01 17:43:10 +04:00
|
|
|
* Remove the device (and all its objects) from the global dictionary.
|
2007-08-30 22:01:26 +04:00
|
|
|
*/
|
2007-09-01 17:43:10 +04:00
|
|
|
array = prop_dictionary_get(sme_propd, sme->sme_name);
|
2007-09-09 02:42:37 +04:00
|
|
|
if (array && prop_object_type(array) == PROP_TYPE_ARRAY) {
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_dictionary_remove(sme_propd, sme->sme_name);
|
2007-09-09 02:42:37 +04:00
|
|
|
sysmon_envsys_destroy_plist(array);
|
2007-09-01 17:43:10 +04:00
|
|
|
}
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_find:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Find a sysmon 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;
|
|
|
|
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_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;
|
2007-09-08 19:25:18 +04:00
|
|
|
cv_wait(&sme_cv, &sme_mtx);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
goto again;
|
|
|
|
}
|
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
|
|
|
break;
|
2003-08-11 18:24:41 +04:00
|
|
|
}
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_mtx);
|
2003-08-11 18:24:41 +04:00
|
|
|
return sme;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_release:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Release a sysmon envsys device.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_release(struct sysmon_envsys *sme)
|
|
|
|
{
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_mtx);
|
2003-08-11 19:07:14 +04:00
|
|
|
if (sme->sme_flags & SME_FLAG_WANTED)
|
2007-09-08 19:25:18 +04:00
|
|
|
cv_broadcast(&sme_cv);
|
2003-08-11 19:07:14 +04:00
|
|
|
sme->sme_flags &= ~(SME_FLAG_BUSY | SME_FLAG_WANTED);
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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
|
|
|
}
|
|
|
|
|
|
|
|
/* compatibility function */
|
|
|
|
struct sysmon_envsys *
|
|
|
|
sysmon_envsys_find_40(u_int idx)
|
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_enter(&sme_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
|
|
|
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;
|
|
|
|
}
|
2007-09-08 07:17:38 +04:00
|
|
|
mutex_exit(&sme_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 sme;
|
|
|
|
}
|
|
|
|
|
2007-07-19 04:12:47 +04:00
|
|
|
/*
|
|
|
|
* sme_register_sensorname:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Register a sensor description into the list maintained per device.
|
2007-07-19 04:12:47 +04:00
|
|
|
*/
|
|
|
|
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 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-09-08 04:21:43 +04:00
|
|
|
DPRINTF(("%s: wrong sensor name='%s'\n",
|
|
|
|
sme->sme_name, edata->desc));
|
2007-07-21 16:11:27 +04:00
|
|
|
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));
|
2007-09-08 04:21:43 +04:00
|
|
|
DPRINTF(("%s: registering sensor name='%s'\n",
|
|
|
|
sme->sme_name, 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
|
|
|
/*
|
2007-09-01 02:44:39 +04:00
|
|
|
* sme_add_sensor_dictionary:
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Add the objects into the dictionary.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
2007-09-08 07:17:38 +04:00
|
|
|
sme_event_drv_t *
|
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
|
|
|
{
|
2007-09-04 20:54:02 +04:00
|
|
|
const struct sme_description_table *sdt, *sdt_units;
|
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
|
|
|
|
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. */
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt_units = sme_get_description_table(SME_DESC_UNITS);
|
|
|
|
for (i = 0; sdt_units[i].type != -1; i++)
|
|
|
|
if (sdt_units[i].type == edata->units)
|
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-09-04 20:54:02 +04:00
|
|
|
if (strcmp(sdt_units[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-09-04 20:54:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "type", sdt_units[i].desc))
|
2007-07-22 22:17:02 +04:00
|
|
|
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>
|
|
|
|
* ...
|
|
|
|
*/
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt = sme_get_description_table(SME_DESC_STATES);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->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
|
|
|
break;
|
|
|
|
|
2007-09-04 20:54:02 +04:00
|
|
|
if (strcmp(sdt[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));
|
|
|
|
|
2007-09-04 20:54:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "state", sdt[j].desc))
|
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
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the monitoring boolean object:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>monitoring-supported</key>
|
|
|
|
* <true/>
|
|
|
|
* ...
|
|
|
|
*
|
2007-09-04 20:54:02 +04:00
|
|
|
* always false on Battery state, Drive and Indicator types.
|
2007-09-02 23:36:59 +04:00
|
|
|
* They cannot be monitored.
|
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 ((edata->flags & ENVSYS_FMONNOTSUPP) ||
|
|
|
|
(edata->units == ENVSYS_INDICATOR) ||
|
2007-09-02 23:36:59 +04:00
|
|
|
(edata->units == ENVSYS_DRIVE) ||
|
2007-09-04 20:54:02 +04:00
|
|
|
(edata->units == ENVSYS_BATTERY_STATE)) {
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upbool(dict, "monitoring-supported", false))
|
2007-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-02 23:36:59 +04:00
|
|
|
/*
|
2007-09-04 20:54:02 +04:00
|
|
|
* add the percentage boolean object:
|
2007-09-02 23:36:59 +04:00
|
|
|
*
|
|
|
|
* ...
|
2007-09-04 20:54:02 +04:00
|
|
|
* <key>want-percentage</key>
|
|
|
|
* <true/>
|
2007-09-02 23:36:59 +04:00
|
|
|
* ...
|
|
|
|
*/
|
2007-09-04 20:54:02 +04:00
|
|
|
if (edata->flags & ENVSYS_FPERCENT)
|
|
|
|
if (sme_sensor_upbool(dict, "want-percentage", true))
|
2007-09-08 07:17:38 +04:00
|
|
|
goto out;
|
2007-09-02 23:36:59 +04:00
|
|
|
|
|
|
|
/*
|
2007-09-04 20:54:02 +04:00
|
|
|
* Add the battery-state object for battery state sensors:
|
2007-09-02 23:36:59 +04:00
|
|
|
*
|
|
|
|
* ...
|
2007-09-04 20:54:02 +04:00
|
|
|
* <key>battery-state</key>
|
|
|
|
* <string>NORMAL</string>
|
2007-09-02 23:36:59 +04:00
|
|
|
* ...
|
|
|
|
*/
|
2007-09-04 20:54:02 +04:00
|
|
|
if (edata->units == ENVSYS_BATTERY_STATE) {
|
|
|
|
sdt = sme_get_description_table(SME_DESC_BATTERY_STATES);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->value_cur)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (sme_sensor_upstring(dict, "battery-state", sdt[j].desc))
|
2007-09-08 07:17:38 +04:00
|
|
|
goto out;
|
2007-09-04 20:54:02 +04:00
|
|
|
}
|
2007-09-02 23:36:59 +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
|
|
|
/*
|
|
|
|
* Add the drive-state object for drive sensors:
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>drive-state</key>
|
|
|
|
* <string>drive is online</string>
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
if (edata->units == ENVSYS_DRIVE) {
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt = sme_get_description_table(SME_DESC_DRIVE_STATES);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[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-09-04 20:54:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "drive-state", sdt[j].desc))
|
2007-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-02 23:36:59 +04:00
|
|
|
/*
|
|
|
|
* if sensor is enabled, add the following properties...
|
|
|
|
*/
|
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 (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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
goto out;
|
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-09-08 07:17:38 +04:00
|
|
|
sme_evdrv_t = kmem_zalloc(sizeof(*sme_evdrv_t), KM_SLEEP);
|
2007-07-22 22:17:02 +04:00
|
|
|
sme_evdrv_t->sdict = dict;
|
|
|
|
sme_evdrv_t->edata = edata;
|
|
|
|
sme_evdrv_t->sme = sme;
|
2007-09-04 20:54:02 +04:00
|
|
|
sme_evdrv_t->powertype = sdt_units[i].crittype;
|
2007-07-22 22:17:02 +04:00
|
|
|
}
|
|
|
|
|
2007-09-08 07:17:38 +04:00
|
|
|
out:
|
|
|
|
return sme_evdrv_t;
|
2007-07-22 22:17:02 +04:00
|
|
|
|
|
|
|
invalidate_sensor:
|
|
|
|
edata->flags |= ENVSYS_FNOTVALID;
|
2007-09-08 07:17:38 +04:00
|
|
|
return sme_evdrv_t;
|
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.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sme_update_dictionary(struct sysmon_envsys *sme)
|
|
|
|
{
|
2007-09-04 20:54:02 +04:00
|
|
|
const struct sme_description_table *sdt;
|
|
|
|
envsys_data_t *edata;
|
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-09-08 07:17:38 +04:00
|
|
|
KASSERT(mutex_owned(&sme_mtx));
|
2007-08-31 04:35:08 +04:00
|
|
|
|
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.
|
|
|
|
*/
|
2007-09-08 04:21:43 +04:00
|
|
|
DPRINTF(("%s: updating '%s' with nsensors=%d\n", __func__,
|
|
|
|
sme->sme_name, 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
|
|
|
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) {
|
2007-09-08 04:21:43 +04:00
|
|
|
DPRINTF(("%s: invalid sensor=%s idx=%d\n",
|
|
|
|
__func__, edata->desc, edata->sensor));
|
2007-07-22 22:17:02 +04:00
|
|
|
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
|
|
|
|
2007-09-04 20:54:02 +04:00
|
|
|
/* update sensor's state */
|
|
|
|
sdt = sme_get_description_table(SME_DESC_STATES);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->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
|
|
|
break;
|
|
|
|
|
|
|
|
DPRINTFOBJ(("%s: state=%s type=%d flags=%d "
|
2007-09-04 20:54:02 +04:00
|
|
|
"units=%d sensor=%d\n", __func__, sdt[j].desc,
|
|
|
|
sdt[j].type, edata->flags, edata->units, edata->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
|
|
|
|
|
|
|
/* update sensor state */
|
2007-09-04 20:54:02 +04:00
|
|
|
error = sme_sensor_upstring(dict, "state", sdt[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-09-04 20:54:02 +04:00
|
|
|
/* update sensor type */
|
|
|
|
sdt = sme_get_description_table(SME_DESC_UNITS);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->units)
|
2007-07-29 18:02:29 +04:00
|
|
|
break;
|
|
|
|
|
2007-09-04 20:54:02 +04:00
|
|
|
error = sme_sensor_upstring(dict, "type", sdt[j].desc);
|
2007-07-29 18:02:29 +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
|
|
|
/* 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) {
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt = sme_get_description_table(SME_DESC_DRIVE_STATES);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[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-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upstring(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"drive-state",
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt[j].desc);
|
|
|
|
if (error)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* update 'battery-state' only in ENVSYS_BATTERY_STATE. */
|
|
|
|
if (edata->units == ENVSYS_BATTERY_STATE) {
|
|
|
|
sdt =
|
|
|
|
sme_get_description_table(SME_DESC_BATTERY_STATES);
|
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->value_cur)
|
|
|
|
break;
|
|
|
|
|
|
|
|
error = sme_sensor_upstring(dict,
|
|
|
|
"battery-state",
|
|
|
|
sdt[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:
|
|
|
|
*
|
2007-09-01 02:44:39 +04:00
|
|
|
* + Parse the userland dictionary and run the appropiate
|
|
|
|
* task that was requested.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
|
|
|
int
|
|
|
|
sme_userset_dictionary(struct sysmon_envsys *sme, prop_dictionary_t udict,
|
|
|
|
prop_array_t array)
|
|
|
|
{
|
2007-09-04 20:54:02 +04:00
|
|
|
const struct sme_description_table *sdt;
|
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;
|
|
|
|
}
|
|
|
|
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt = sme_get_description_table(SME_DESC_UNITS);
|
|
|
|
for (i = 0; sdt[i].type != -1; i++)
|
|
|
|
if (sdt[i].type == edata->units)
|
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 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);
|
2007-08-31 14:13:27 +04:00
|
|
|
error = sme_event_register(dict,
|
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_name,
|
|
|
|
"critical-capacity",
|
|
|
|
critval,
|
|
|
|
PENVSYS_EVENT_BATT_USERCAP,
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt[i].crittype);
|
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 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);
|
2007-08-31 14:13:27 +04:00
|
|
|
error = sme_event_register(dict,
|
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_name,
|
|
|
|
"critical-max-limit",
|
|
|
|
critval,
|
|
|
|
PENVSYS_EVENT_USER_CRITMAX,
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt[i].crittype);
|
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 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);
|
2007-08-31 14:13:27 +04:00
|
|
|
error = sme_event_register(dict,
|
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_name,
|
|
|
|
"critical-min-limit",
|
|
|
|
critval,
|
|
|
|
PENVSYS_EVENT_USER_CRITMIN,
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt[i].crittype);
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* invalid target? return the error */
|
|
|
|
if (!targetfound)
|
|
|
|
error = EINVAL;
|
|
|
|
|
|
|
|
return error;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|