2010-03-27 16:34:16 +03:00
|
|
|
/* $NetBSD: sysmon_envsys.c,v 1.103 2010/03/27 13:34:16 pgoyette 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
|
|
|
|
|
|
|
/*-
|
2008-03-23 19:09:41 +03:00
|
|
|
* Copyright (c) 2007, 2008 Juan Romero Pardines.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
2007-10-07 08:11:15 +04:00
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
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>
|
2010-03-27 16:34:16 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: sysmon_envsys.c,v 1.103 2010/03/27 13:34:16 pgoyette 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
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
kmutex_t sme_global_mtx;
|
2007-07-22 22:17:02 +04:00
|
|
|
|
2007-09-08 19:25:18 +04:00
|
|
|
static prop_dictionary_t sme_propd;
|
2008-04-01 16:25:30 +04:00
|
|
|
static uint32_t sysmon_envsys_next_sensor_index;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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
|
|
|
|
2007-09-01 17:43:10 +04:00
|
|
|
static void sysmon_envsys_destroy_plist(prop_array_t);
|
2007-10-07 08:11:15 +04:00
|
|
|
static void sme_remove_userprops(void);
|
2007-11-16 11:00:11 +03:00
|
|
|
static int sme_add_property_dictionary(struct sysmon_envsys *, prop_array_t,
|
|
|
|
prop_dictionary_t);
|
2010-03-14 21:03:15 +03:00
|
|
|
static sme_event_drv_t * sme_add_sensor_dictionary(struct sysmon_envsys *,
|
|
|
|
prop_array_t, prop_dictionary_t, envsys_data_t *);
|
2008-03-23 19:09:41 +03:00
|
|
|
static void sme_initial_refresh(void *);
|
2010-02-01 00:36:38 +03:00
|
|
|
static uint32_t sme_get_max_value(struct sysmon_envsys *,
|
|
|
|
bool (*)(const envsys_data_t*), bool);
|
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:
|
|
|
|
*
|
2008-04-01 16:25:30 +04:00
|
|
|
* + Initialize global mutex, dictionary and the linked 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
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_init(void)
|
|
|
|
{
|
|
|
|
LIST_INIT(&sysmon_envsys_list);
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_init(&sme_global_mtx, MUTEX_DEFAULT, IPL_NONE);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
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
|
|
|
{
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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) {
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* To update the global dictionary with latest data from devices.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* Update dictionaries on all sysmon envsys devices
|
|
|
|
* registered.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_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) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_acquire(sme, false);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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));
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
|
|
|
mutex_exit(&sme_global_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;
|
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme_global_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;
|
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* To set properties on multiple devices.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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_SETDICTIONARY:
|
|
|
|
{
|
|
|
|
const struct plistref *plist = (const struct plistref *)data;
|
|
|
|
prop_dictionary_t udict;
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_object_iterator_t iter, iter2;
|
|
|
|
prop_object_t obj, obj2;
|
|
|
|
prop_array_t array_u, array_k;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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 *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
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
iter = prop_dictionary_iterator(udict);
|
|
|
|
if (!iter) {
|
|
|
|
prop_object_release(udict);
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
/*
|
2007-10-07 08:11:15 +04:00
|
|
|
* Iterate over the userland dictionary and process
|
|
|
|
* the list of devices.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
2007-10-07 08:11:15 +04:00
|
|
|
while ((obj = prop_object_iterator_next(iter))) {
|
|
|
|
array_u = prop_dictionary_get_keysym(udict, obj);
|
|
|
|
if (prop_object_type(array_u) != PROP_TYPE_ARRAY) {
|
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
prop_object_release(udict);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
devname = prop_dictionary_keysym_cstring_nocopy(obj);
|
|
|
|
DPRINTF(("%s: processing the '%s' array requests\n",
|
|
|
|
__func__, devname));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* find the correct sme device.
|
|
|
|
*/
|
|
|
|
sme = sysmon_envsys_find(devname);
|
|
|
|
if (!sme) {
|
|
|
|
DPRINTF(("%s: NULL sme\n", __func__));
|
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
prop_object_release(udict);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the correct array object with the string
|
|
|
|
* supplied by the userland dictionary.
|
|
|
|
*/
|
|
|
|
array_k = prop_dictionary_get(sme_propd, devname);
|
|
|
|
if (prop_object_type(array_k) != PROP_TYPE_ARRAY) {
|
|
|
|
DPRINTF(("%s: array device failed\n",
|
|
|
|
__func__));
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
prop_object_release(udict);
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
iter2 = prop_array_iterator(array_u);
|
|
|
|
if (!iter2) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
prop_object_release(udict);
|
|
|
|
return ENOMEM;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Iterate over the array of dictionaries to
|
2007-11-16 11:00:11 +03:00
|
|
|
* process the list of sensors and properties.
|
2007-10-07 08:11:15 +04:00
|
|
|
*/
|
|
|
|
while ((obj2 = prop_object_iterator_next(iter2))) {
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* do the real work now.
|
|
|
|
*/
|
2007-10-07 08:11:15 +04:00
|
|
|
error = sme_userset_dictionary(sme,
|
|
|
|
obj2,
|
|
|
|
array_k);
|
|
|
|
if (error) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_object_iterator_release(iter2);
|
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
prop_object_release(udict);
|
2007-11-16 11:00:11 +03:00
|
|
|
return error;
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_object_iterator_release(iter2);
|
2002-12-31 08:26:56 +03:00
|
|
|
}
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
prop_object_release(udict);
|
|
|
|
break;
|
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* To remove all properties from all devices registered.
|
|
|
|
*/
|
2007-10-07 08:11:15 +04:00
|
|
|
case ENVSYS_REMOVEPROPS:
|
|
|
|
{
|
|
|
|
const struct plistref *plist = (const struct plistref *)data;
|
|
|
|
prop_dictionary_t udict;
|
|
|
|
prop_object_t obj;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
if ((flag & FWRITE) == 0)
|
|
|
|
return EPERM;
|
|
|
|
|
|
|
|
error = prop_dictionary_copyin_ioctl(plist, cmd, &udict);
|
|
|
|
if (error) {
|
|
|
|
DPRINTF(("%s: copyin_ioctl error=%d\n",
|
|
|
|
__func__, error));
|
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
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
obj = prop_dictionary_get(udict, "envsys-remove-props");
|
|
|
|
if (!obj || !prop_bool_true(obj)) {
|
|
|
|
DPRINTF(("%s: invalid 'envsys-remove-props'\n",
|
|
|
|
__func__));
|
|
|
|
return EINVAL;
|
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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
prop_object_release(udict);
|
2007-10-07 08:11:15 +04:00
|
|
|
sme_remove_userprops();
|
|
|
|
|
2000-11-05 07:06:13 +03:00
|
|
|
break;
|
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Compatibility ioctls 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;
|
2007-11-16 11:00:11 +03:00
|
|
|
bool found = false;
|
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);
|
2008-04-01 16:25:30 +04:00
|
|
|
if (!sme)
|
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
|
|
|
|
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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
|
|
|
if (edata->sensor == tred->sensor) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-11-16 11:00:11 +03:00
|
|
|
error = ENODEV;
|
|
|
|
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
|
|
|
|
|
|
|
if (tred->sensor < sme->sme_nsensors) {
|
2008-06-03 19:00:57 +04:00
|
|
|
if ((sme->sme_flags & SME_DISABLE_REFRESH) == 0 &&
|
|
|
|
(sme->sme_flags & SME_POLL_ONLY) == 0) {
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
(*sme->sme_refresh)(sme, edata);
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme->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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* copy required values to the old interface.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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 = 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;
|
2007-11-04 02:05:21 +03:00
|
|
|
if (edata->units == ENVSYS_BATTERY_CHARGE)
|
|
|
|
tred->units = ENVSYS_INDICATOR;
|
|
|
|
else
|
2007-11-16 11:00:11 +03:00
|
|
|
tred->units = 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
|
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
if (edata->state == ENVSYS_SINVALID) {
|
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;
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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;
|
2007-11-16 11:00:11 +03:00
|
|
|
bool found = false;
|
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);
|
2008-04-01 16:25:30 +04:00
|
|
|
if (!sme)
|
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
|
|
|
|
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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
|
|
|
if (edata->sensor == binfo->sensor) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-11-16 11:00:11 +03:00
|
|
|
error = ENODEV;
|
|
|
|
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-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) {
|
2007-11-04 02:05:21 +03:00
|
|
|
if (edata->units == ENVSYS_BATTERY_CHARGE)
|
|
|
|
binfo->units = ENVSYS_INDICATOR;
|
|
|
|
else
|
2007-11-16 11:00:11 +03:00
|
|
|
binfo->units = edata->units;
|
2007-11-02 22:21:29 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* previously, the ACPI sensor names included the
|
|
|
|
* device name. Include that in compatibility code.
|
|
|
|
*/
|
|
|
|
if (strncmp(sme->sme_name, "acpi", 4) == 0)
|
|
|
|
(void)snprintf(binfo->desc, sizeof(binfo->desc),
|
|
|
|
"%s %s", sme->sme_name, edata->desc);
|
|
|
|
else
|
|
|
|
(void)strlcpy(binfo->desc, edata->desc,
|
|
|
|
sizeof(binfo->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
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* sysmon_envsys_create:
|
|
|
|
*
|
|
|
|
* + Allocates a new sysmon_envsys object and initializes the
|
|
|
|
* stuff for sensors and events.
|
|
|
|
*/
|
|
|
|
struct sysmon_envsys *
|
|
|
|
sysmon_envsys_create(void)
|
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
|
|
|
|
sme = kmem_zalloc(sizeof(*sme), KM_SLEEP);
|
|
|
|
TAILQ_INIT(&sme->sme_sensors_list);
|
|
|
|
LIST_INIT(&sme->sme_events_list);
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_init(&sme->sme_mtx, MUTEX_DEFAULT, IPL_NONE);
|
|
|
|
cv_init(&sme->sme_condvar, "sme_wait");
|
2007-11-16 11:00:11 +03:00
|
|
|
|
|
|
|
return sme;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_destroy:
|
|
|
|
*
|
2008-02-02 05:02:37 +03:00
|
|
|
* + Removes all sensors from the tail queue, destroys the callout
|
|
|
|
* and frees the sysmon_envsys object.
|
2007-11-16 11:00:11 +03:00
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_destroy(struct sysmon_envsys *sme)
|
|
|
|
{
|
|
|
|
envsys_data_t *edata;
|
|
|
|
|
|
|
|
KASSERT(sme != NULL);
|
|
|
|
|
|
|
|
while (!TAILQ_EMPTY(&sme->sme_sensors_list)) {
|
|
|
|
edata = TAILQ_FIRST(&sme->sme_sensors_list);
|
|
|
|
TAILQ_REMOVE(&sme->sme_sensors_list, edata, sensors_head);
|
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_destroy(&sme->sme_mtx);
|
|
|
|
cv_destroy(&sme->sme_condvar);
|
2007-11-16 11:00:11 +03:00
|
|
|
kmem_free(sme, sizeof(*sme));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_sensor_attach:
|
|
|
|
*
|
|
|
|
* + Attachs a sensor into a sysmon_envsys device checking that units
|
|
|
|
* is set to a valid type and description is unique and not empty.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sysmon_envsys_sensor_attach(struct sysmon_envsys *sme, envsys_data_t *edata)
|
|
|
|
{
|
|
|
|
const struct sme_description_table *sdt_units;
|
|
|
|
envsys_data_t *oedata;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
KASSERT(sme != NULL || edata != NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Find the correct units for this sensor.
|
|
|
|
*/
|
|
|
|
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)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (strcmp(sdt_units[i].desc, "unknown") == 0)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check that description is not empty or duplicate.
|
|
|
|
*/
|
|
|
|
if (strlen(edata->desc) == 0)
|
|
|
|
return EINVAL;
|
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
sysmon_envsys_acquire(sme, true);
|
2007-11-16 11:00:11 +03:00
|
|
|
TAILQ_FOREACH(oedata, &sme->sme_sensors_list, sensors_head) {
|
|
|
|
if (strcmp(oedata->desc, edata->desc) == 0) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, true);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
return EEXIST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* Ok, the sensor has been added into the device queue.
|
|
|
|
*/
|
|
|
|
TAILQ_INSERT_TAIL(&sme->sme_sensors_list, edata, sensors_head);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Give the sensor a index position.
|
|
|
|
*/
|
|
|
|
edata->sensor = sme->sme_nsensors;
|
|
|
|
sme->sme_nsensors++;
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, true);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
2009-07-08 21:54:27 +04:00
|
|
|
DPRINTF(("%s: attached #%d (%s), units=%d (%s)\n",
|
|
|
|
__func__, edata->sensor, edata->desc,
|
2009-06-08 04:55:35 +04:00
|
|
|
sdt_units[i].type, sdt_units[i].desc));
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_sensor_detach:
|
|
|
|
*
|
|
|
|
* + Detachs a sensor from a sysmon_envsys device and decrements the
|
|
|
|
* sensors count on success.
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
sysmon_envsys_sensor_detach(struct sysmon_envsys *sme, envsys_data_t *edata)
|
|
|
|
{
|
|
|
|
envsys_data_t *oedata;
|
|
|
|
bool found = false;
|
|
|
|
|
|
|
|
KASSERT(sme != NULL || edata != NULL);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check the sensor is already on the list.
|
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
sysmon_envsys_acquire(sme, true);
|
2007-11-16 11:00:11 +03:00
|
|
|
TAILQ_FOREACH(oedata, &sme->sme_sensors_list, sensors_head) {
|
|
|
|
if (oedata->sensor == edata->sensor) {
|
|
|
|
found = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!found) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, true);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remove it and decrement the sensors count.
|
|
|
|
*/
|
|
|
|
TAILQ_REMOVE(&sme->sme_sensors_list, edata, sensors_head);
|
|
|
|
sme->sme_nsensors--;
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, true);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
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;
|
2008-04-01 16:25:30 +04:00
|
|
|
struct sme_evdrv *evdv = 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;
|
2008-04-01 16:25:30 +04:00
|
|
|
prop_array_t array = NULL;
|
2007-11-16 11:00:11 +03:00
|
|
|
prop_dictionary_t dict, dict2;
|
2007-08-30 22:01:26 +04:00
|
|
|
envsys_data_t *edata = NULL;
|
2009-06-03 15:43:15 +04:00
|
|
|
sme_event_drv_t *this_evdrv;
|
2010-03-14 21:03:15 +03:00
|
|
|
int nevent;
|
2008-03-23 19:09:41 +03:00
|
|
|
int 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);
|
2000-11-05 07:06:13 +03:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
/*
|
|
|
|
* Check if requested sysmon_envsys device is valid
|
|
|
|
* and does not exist already in the list.
|
|
|
|
*/
|
|
|
|
mutex_enter(&sme_global_mtx);
|
|
|
|
LIST_FOREACH(lsme, &sysmon_envsys_list, sme_list) {
|
|
|
|
if (strcmp(lsme->sme_name, sme->sme_name) == 0) {
|
|
|
|
mutex_exit(&sme_global_mtx);
|
|
|
|
return EEXIST;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_exit(&sme_global_mtx);
|
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* sanity check: if SME_DISABLE_REFRESH is not set,
|
|
|
|
* the sme_refresh function callback must be non 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
|
|
|
*/
|
2007-11-16 11:00:11 +03:00
|
|
|
if ((sme->sme_flags & SME_DISABLE_REFRESH) == 0)
|
|
|
|
if (!sme->sme_refresh)
|
|
|
|
return EINVAL;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-16 11:00:11 +03:00
|
|
|
* If the list of sensors is empty, there's no point to continue...
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-16 11:00:11 +03:00
|
|
|
if (TAILQ_EMPTY(&sme->sme_sensors_list)) {
|
|
|
|
DPRINTF(("%s: sensors list empty for %s\n", __func__,
|
|
|
|
sme->sme_name));
|
|
|
|
return ENOTSUP;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
2008-04-01 16:25:30 +04:00
|
|
|
* Initialize the singly linked list for driver events.
|
2007-11-16 11:00:11 +03:00
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
SLIST_INIT(&sme_evdrv_list);
|
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
array = prop_array_create();
|
2007-10-07 08:11:15 +04:00
|
|
|
if (!array)
|
2007-08-30 22:01:26 +04:00
|
|
|
return ENOMEM;
|
|
|
|
|
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* Iterate over all sensors and create a dictionary per sensor.
|
|
|
|
* We must respect the order in which the sensors were added.
|
2007-08-30 22:01:26 +04:00
|
|
|
*/
|
2008-01-02 05:29:14 +03:00
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
2007-09-01 17:43:10 +04:00
|
|
|
dict = prop_dictionary_create();
|
2007-10-07 08:11:15 +04:00
|
|
|
if (!dict) {
|
2007-09-01 17:43:10 +04:00
|
|
|
error = ENOMEM;
|
|
|
|
goto out2;
|
|
|
|
}
|
|
|
|
|
2007-08-31 01:31:28 +04:00
|
|
|
/*
|
|
|
|
* Create all objects in sensor's dictionary.
|
|
|
|
*/
|
2009-06-03 15:43:15 +04:00
|
|
|
this_evdrv = sme_add_sensor_dictionary(sme, array,
|
|
|
|
dict, edata);
|
|
|
|
if (this_evdrv) {
|
|
|
|
evdv = kmem_zalloc(sizeof(*evdv), KM_SLEEP);
|
|
|
|
evdv->evdrv = this_evdrv;
|
2008-04-01 16:25:30 +04:00
|
|
|
SLIST_INSERT_HEAD(&sme_evdrv_list, evdv, evdrv_head);
|
2009-06-03 15:43:15 +04:00
|
|
|
}
|
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;
|
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Add the dictionary for the global properties of this device.
|
|
|
|
*/
|
|
|
|
dict2 = prop_dictionary_create();
|
|
|
|
if (!dict2) {
|
|
|
|
error = ENOMEM;
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
error = sme_add_property_dictionary(sme, array, dict2);
|
|
|
|
if (error) {
|
|
|
|
prop_object_release(dict2);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
|
|
|
* Add the array into the global dictionary for the driver.
|
|
|
|
*
|
|
|
|
* <dict>
|
|
|
|
* <key>foo0</key>
|
|
|
|
* <array>
|
|
|
|
* ...
|
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_mtx);
|
2007-08-30 22:01:26 +04:00
|
|
|
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;
|
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
|
2007-08-30 22:01:26 +04:00
|
|
|
/*
|
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;
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme_global_mtx);
|
2007-09-08 04:21:43 +04:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
out:
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
2010-03-24 15:15:54 +03:00
|
|
|
* No errors? Make an initial data refresh if was requested,
|
|
|
|
* then register the events that were set in the driver. Do
|
|
|
|
* the refresh first in case it is needed to establish the
|
|
|
|
* limits or max_value needed by some events.
|
2007-11-16 11:00:11 +03:00
|
|
|
*/
|
2007-09-08 04:21:43 +04:00
|
|
|
if (error == 0) {
|
2010-03-14 21:03:15 +03:00
|
|
|
nevent = 0;
|
2008-03-23 19:09:41 +03:00
|
|
|
sysmon_task_queue_init();
|
2010-03-24 15:15:54 +03:00
|
|
|
|
|
|
|
if (sme->sme_flags & SME_INIT_REFRESH) {
|
|
|
|
sysmon_task_queue_sched(0, sme_initial_refresh, sme);
|
|
|
|
DPRINTF(("%s: scheduled initial refresh for '%s'\n",
|
|
|
|
__func__, sme->sme_name));
|
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
SLIST_FOREACH(evdv, &sme_evdrv_list, evdrv_head) {
|
2007-09-08 07:17:38 +04:00
|
|
|
sysmon_task_queue_sched(0,
|
2008-04-01 16:25:30 +04:00
|
|
|
sme_event_drvadd, evdv->evdrv);
|
2010-03-14 21:03:15 +03:00
|
|
|
nevent++;
|
2007-09-08 07:17:38 +04:00
|
|
|
}
|
2010-03-14 21:03:15 +03:00
|
|
|
DPRINTF(("%s: driver '%s' registered (nsens=%d nevent=%d)\n",
|
|
|
|
__func__, sme->sme_name, sme->sme_nsensors, nevent));
|
2007-09-08 04:21:43 +04:00
|
|
|
}
|
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)) {
|
2008-04-01 16:25:30 +04:00
|
|
|
evdv = SLIST_FIRST(&sme_evdrv_list);
|
2007-09-08 07:17:38 +04:00
|
|
|
SLIST_REMOVE_HEAD(&sme_evdrv_list, evdrv_head);
|
2008-04-01 16:25:30 +04:00
|
|
|
kmem_free(evdv, sizeof(*evdv));
|
2007-09-08 07:17:38 +04:00
|
|
|
}
|
2007-10-07 08:11:15 +04:00
|
|
|
if (!error)
|
2007-09-08 19:47:37 +04:00
|
|
|
return 0;
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Ugh... something wasn't right; unregister all events and sensors
|
|
|
|
* previously assigned and destroy the array with all its objects.
|
|
|
|
*/
|
2007-09-08 19:47:37 +04:00
|
|
|
DPRINTF(("%s: failed to register '%s' (%d)\n", __func__,
|
|
|
|
sme->sme_name, error));
|
2008-04-01 16:25:30 +04:00
|
|
|
|
|
|
|
sme_event_unregister_all(sme);
|
|
|
|
while (!TAILQ_EMPTY(&sme->sme_sensors_list)) {
|
|
|
|
edata = TAILQ_FIRST(&sme->sme_sensors_list);
|
|
|
|
TAILQ_REMOVE(&sme->sme_sensors_list, edata, sensors_head);
|
2007-09-08 07:37:51 +04:00
|
|
|
}
|
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);
|
2008-04-01 16:25:30 +04:00
|
|
|
KASSERT(prop_object_type(array) == PROP_TYPE_ARRAY);
|
2007-09-01 17:43:10 +04:00
|
|
|
|
2007-09-09 16:28:08 +04:00
|
|
|
DPRINTFOBJ(("%s: objects in array=%d\n", __func__,
|
2007-09-09 02:42:37 +04:00
|
|
|
prop_array_count(array)));
|
|
|
|
|
2007-09-01 17:43:10 +04:00
|
|
|
iter = prop_array_iterator(array);
|
2007-10-07 08:11:15 +04:00
|
|
|
if (!iter)
|
2007-09-01 17:43:10 +04:00
|
|
|
return;
|
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
while ((dict = prop_object_iterator_next(iter))) {
|
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-10-07 08:11:15 +04:00
|
|
|
if (!iter2)
|
2007-09-09 02:42:37 +04:00
|
|
|
goto out;
|
2007-09-09 16:28:08 +04:00
|
|
|
DPRINTFOBJ(("%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 16:28:08 +04:00
|
|
|
DPRINTFOBJ(("%s: obj=%s\n", __func__,
|
2007-09-09 03:21:02 +04:00
|
|
|
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);
|
2007-09-09 16:28:08 +04:00
|
|
|
DPRINTFOBJ(("%s: objects in dictionary:%d\n",
|
2007-09-09 02:42:37 +04:00
|
|
|
__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-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-11-16 11:00:11 +03:00
|
|
|
/*
|
2008-04-02 15:19:22 +04:00
|
|
|
* Unregister all events associated with device.
|
2007-07-19 04:12:47 +04:00
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
sme_event_unregister_all(sme);
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
2008-04-01 16:25:30 +04:00
|
|
|
* Decrement global sensors counter (only used for compatibility
|
|
|
|
* with previous API) and remove the device from the list.
|
2007-11-16 11:00:11 +03:00
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
sysmon_envsys_next_sensor_index -= sme->sme_nsensors;
|
2007-09-08 07:17:38 +04:00
|
|
|
LIST_REMOVE(sme, sme_list);
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme_global_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) {
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_mtx);
|
2007-09-01 17:43:10 +04:00
|
|
|
prop_dictionary_remove(sme_propd, sme->sme_name);
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme_global_mtx);
|
2007-09-09 02:42:37 +04:00
|
|
|
sysmon_envsys_destroy_plist(array);
|
2007-09-01 17:43:10 +04:00
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* And finally destroy the sysmon_envsys object.
|
|
|
|
*/
|
|
|
|
sysmon_envsys_destroy(sme);
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sysmon_envsys_find:
|
|
|
|
*
|
2008-04-01 16:25:30 +04:00
|
|
|
* + Find a sysmon envsys device and mark it as busy
|
|
|
|
* once it's available.
|
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;
|
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_mtx);
|
2008-01-02 06:06:02 +03:00
|
|
|
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
|
2008-01-02 15:20:26 +03:00
|
|
|
if (strcmp(sme->sme_name, name) == 0) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_acquire(sme, false);
|
2008-01-02 15:20:26 +03:00
|
|
|
break;
|
|
|
|
}
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme_global_mtx);
|
|
|
|
|
2003-08-11 18:24:41 +04:00
|
|
|
return sme;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
2008-04-01 16:25:30 +04:00
|
|
|
* Compatibility function with the old API.
|
2007-11-16 11:00:11 +03:00
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
struct sysmon_envsys *
|
|
|
|
sysmon_envsys_find_40(u_int idx)
|
2007-11-16 11:00:11 +03:00
|
|
|
{
|
2008-04-01 16:25:30 +04:00
|
|
|
struct sysmon_envsys *sme;
|
2007-11-16 11:00:11 +03:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_mtx);
|
|
|
|
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
|
|
|
|
if (idx >= sme->sme_fsensor &&
|
|
|
|
idx < (sme->sme_fsensor + sme->sme_nsensors)) {
|
|
|
|
sysmon_envsys_acquire(sme, false);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mutex_exit(&sme_global_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
return sme;
|
2007-11-16 11:00:11 +03:00
|
|
|
}
|
|
|
|
|
2000-11-05 07:06:13 +03:00
|
|
|
/*
|
2008-04-01 16:25:30 +04:00
|
|
|
* sysmon_envsys_acquire:
|
2000-11-05 07:06:13 +03:00
|
|
|
*
|
2008-04-01 16:25:30 +04:00
|
|
|
* + Wait until a sysmon envsys device is available and mark
|
|
|
|
* it as busy.
|
2000-11-05 07:06:13 +03:00
|
|
|
*/
|
|
|
|
void
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_acquire(struct sysmon_envsys *sme, bool locked)
|
2000-11-05 07:06:13 +03:00
|
|
|
{
|
2008-04-01 16:25:30 +04:00
|
|
|
KASSERT(sme != NULL);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
if (locked) {
|
|
|
|
while (sme->sme_flags & SME_FLAG_BUSY)
|
|
|
|
cv_wait(&sme->sme_condvar, &sme->sme_mtx);
|
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
|
|
|
} else {
|
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
while (sme->sme_flags & SME_FLAG_BUSY)
|
|
|
|
cv_wait(&sme->sme_condvar, &sme->sme_mtx);
|
|
|
|
sme->sme_flags |= SME_FLAG_BUSY;
|
|
|
|
mutex_exit(&sme->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
|
|
|
}
|
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
/*
|
|
|
|
* sysmon_envsys_release:
|
|
|
|
*
|
|
|
|
* + Unmark a sysmon envsys device as busy, and notify
|
|
|
|
* waiters.
|
|
|
|
*/
|
|
|
|
void
|
|
|
|
sysmon_envsys_release(struct sysmon_envsys *sme, bool locked)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
{
|
2008-04-01 16:25:30 +04:00
|
|
|
KASSERT(sme != NULL);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
if (locked) {
|
|
|
|
sme->sme_flags &= ~SME_FLAG_BUSY;
|
|
|
|
cv_broadcast(&sme->sme_condvar);
|
|
|
|
} else {
|
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
sme->sme_flags &= ~SME_FLAG_BUSY;
|
|
|
|
cv_broadcast(&sme->sme_condvar);
|
|
|
|
mutex_exit(&sme->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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-23 19:09:41 +03:00
|
|
|
/*
|
|
|
|
* sme_initial_refresh:
|
|
|
|
*
|
|
|
|
* + Do an initial refresh of the sensors in a device just after
|
|
|
|
* interrupts are enabled in the autoconf(9) process.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sme_initial_refresh(void *arg)
|
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme = arg;
|
|
|
|
envsys_data_t *edata;
|
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
sysmon_envsys_acquire(sme, true);
|
2008-03-23 19:09:41 +03:00
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head)
|
2010-02-05 20:44:27 +03:00
|
|
|
if ((sme->sme_flags & SME_DISABLE_REFRESH) == 0)
|
|
|
|
(*sme->sme_refresh)(sme, edata);
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, true);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
2008-03-23 19:09:41 +03:00
|
|
|
}
|
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* sme_sensor_dictionary_get:
|
|
|
|
*
|
2007-11-16 11:00:11 +03:00
|
|
|
* + Returns a dictionary of a device specified by its index
|
|
|
|
* position.
|
2007-10-07 08:11:15 +04:00
|
|
|
*/
|
|
|
|
prop_dictionary_t
|
|
|
|
sme_sensor_dictionary_get(prop_array_t array, const char *index)
|
|
|
|
{
|
|
|
|
prop_object_iterator_t iter;
|
|
|
|
prop_dictionary_t dict;
|
|
|
|
prop_object_t obj;
|
|
|
|
|
|
|
|
KASSERT(array != NULL || index != NULL);
|
|
|
|
|
|
|
|
iter = prop_array_iterator(array);
|
|
|
|
if (!iter)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
while ((dict = prop_object_iterator_next(iter))) {
|
|
|
|
obj = prop_dictionary_get(dict, "index");
|
|
|
|
if (prop_string_equals_cstring(obj, index))
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
prop_object_iterator_release(iter);
|
|
|
|
return dict;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* sme_remove_userprops:
|
|
|
|
*
|
|
|
|
* + Remove all properties from all devices that were set by
|
2007-11-16 11:00:11 +03:00
|
|
|
* the ENVSYS_SETDICTIONARY ioctl.
|
2007-10-07 08:11:15 +04:00
|
|
|
*/
|
|
|
|
static void
|
|
|
|
sme_remove_userprops(void)
|
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
prop_array_t array;
|
|
|
|
prop_dictionary_t sdict;
|
|
|
|
envsys_data_t *edata = NULL;
|
|
|
|
char tmp[ENVSYS_DESCLEN];
|
2007-11-16 11:00:11 +03:00
|
|
|
int ptype;
|
2007-10-07 08:11:15 +04:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme_global_mtx);
|
2007-10-07 08:11:15 +04:00
|
|
|
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_acquire(sme, false);
|
2007-10-07 08:11:15 +04:00
|
|
|
array = prop_dictionary_get(sme_propd, sme->sme_name);
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
2007-10-07 08:11:15 +04:00
|
|
|
(void)snprintf(tmp, sizeof(tmp), "sensor%d",
|
|
|
|
edata->sensor);
|
|
|
|
sdict = sme_sensor_dictionary_get(array, tmp);
|
2007-11-16 11:00:11 +03:00
|
|
|
KASSERT(sdict != NULL);
|
2007-10-07 08:11:15 +04:00
|
|
|
|
2008-08-22 15:27:50 +04:00
|
|
|
ptype = 0;
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_BATTCAP) {
|
2007-10-07 08:11:15 +04:00
|
|
|
prop_dictionary_remove(sdict,
|
|
|
|
"critical-capacity");
|
2009-06-08 04:55:35 +04:00
|
|
|
ptype = PENVSYS_EVENT_CAPACITY;
|
2008-08-22 15:27:50 +04:00
|
|
|
}
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_BATTWARN) {
|
2008-08-22 15:27:50 +04:00
|
|
|
prop_dictionary_remove(sdict,
|
|
|
|
"warning-capacity");
|
2009-06-08 04:55:35 +04:00
|
|
|
ptype = PENVSYS_EVENT_CAPACITY;
|
2008-08-22 15:27:50 +04:00
|
|
|
}
|
2010-02-16 01:32:04 +03:00
|
|
|
|
|
|
|
if (edata->upropset & PROP_BATTHIGH) {
|
|
|
|
prop_dictionary_remove(sdict,
|
|
|
|
"high-capacity");
|
|
|
|
ptype = PENVSYS_EVENT_CAPACITY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (edata->upropset & PROP_BATTMAX) {
|
|
|
|
prop_dictionary_remove(sdict,
|
|
|
|
"maximum-capacity");
|
|
|
|
ptype = PENVSYS_EVENT_CAPACITY;
|
|
|
|
}
|
2008-08-22 15:27:50 +04:00
|
|
|
if (ptype != 0)
|
2007-11-16 11:00:11 +03:00
|
|
|
sme_event_unregister(sme, edata->desc, ptype);
|
2008-08-22 15:27:50 +04:00
|
|
|
|
|
|
|
ptype = 0;
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_WARNMAX) {
|
|
|
|
prop_dictionary_remove(sdict, "warning-max");
|
|
|
|
ptype = PENVSYS_EVENT_LIMITS;
|
2008-08-22 15:27:50 +04:00
|
|
|
}
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_WARNMIN) {
|
|
|
|
prop_dictionary_remove(sdict, "warning-min");
|
|
|
|
ptype = PENVSYS_EVENT_LIMITS;
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_CRITMAX) {
|
|
|
|
prop_dictionary_remove(sdict, "critical-max");
|
|
|
|
ptype = PENVSYS_EVENT_LIMITS;
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_CRITMIN) {
|
|
|
|
prop_dictionary_remove(sdict, "critical-min");
|
|
|
|
ptype = PENVSYS_EVENT_LIMITS;
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
2008-08-22 15:27:50 +04:00
|
|
|
if (ptype != 0)
|
|
|
|
sme_event_unregister(sme, edata->desc, ptype);
|
2007-10-07 08:11:15 +04:00
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_RFACT) {
|
2007-10-07 08:11:15 +04:00
|
|
|
(void)sme_sensor_upint32(sdict, "rfact", 0);
|
|
|
|
edata->rfact = 0;
|
|
|
|
}
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
if (edata->upropset & PROP_DESC)
|
2007-10-07 08:11:15 +04:00
|
|
|
(void)sme_sensor_upstring(sdict,
|
|
|
|
"description", edata->desc);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
|
|
|
if (edata->upropset)
|
|
|
|
edata->upropset = 0;
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Restore default timeout value.
|
|
|
|
*/
|
|
|
|
sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT;
|
2008-04-01 16:25:30 +04:00
|
|
|
sysmon_envsys_release(sme, false);
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme_global_mtx);
|
2007-10-07 08:11:15 +04:00
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
|
2007-07-19 04:12:47 +04:00
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* sme_add_property_dictionary:
|
|
|
|
*
|
|
|
|
* + Add global properties into a device.
|
2007-07-19 04:12:47 +04:00
|
|
|
*/
|
|
|
|
static int
|
2007-11-16 11:00:11 +03:00
|
|
|
sme_add_property_dictionary(struct sysmon_envsys *sme, prop_array_t array,
|
|
|
|
prop_dictionary_t dict)
|
2007-07-19 04:12:47 +04:00
|
|
|
{
|
2007-11-16 11:00:11 +03:00
|
|
|
prop_dictionary_t pdict;
|
2010-03-26 15:36:59 +03:00
|
|
|
const char *class;
|
2007-11-16 11:00:11 +03:00
|
|
|
int error = 0;
|
2007-07-19 04:12:47 +04:00
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
pdict = prop_dictionary_create();
|
|
|
|
if (!pdict)
|
|
|
|
return EINVAL;
|
2007-07-21 19:16:58 +04:00
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
2010-03-26 15:36:59 +03:00
|
|
|
* Add the 'refresh-timeout' and 'dev-class' objects into the
|
|
|
|
* 'device-properties' dictionary.
|
2007-11-16 11:00:11 +03:00
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <dict>
|
|
|
|
* <key>device-properties</key>
|
|
|
|
* <dict>
|
|
|
|
* <key>refresh-timeout</key>
|
|
|
|
* <integer>120</integer<
|
2010-03-26 15:36:59 +03:00
|
|
|
* <key>device-class</key>
|
|
|
|
* <string>class_name</string>
|
|
|
|
* </dict>
|
2007-11-16 11:00:11 +03:00
|
|
|
* </dict>
|
|
|
|
* ...
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
if (!sme->sme_events_timeout)
|
|
|
|
sme->sme_events_timeout = SME_EVENTS_DEFTIMEOUT;
|
|
|
|
|
|
|
|
if (!prop_dictionary_set_uint64(pdict, "refresh-timeout",
|
|
|
|
sme->sme_events_timeout)) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
2007-07-19 04:12:47 +04:00
|
|
|
}
|
2010-03-26 15:36:59 +03:00
|
|
|
if (sme->sme_class == SME_CLASS_BATTERY)
|
|
|
|
class = "battery";
|
|
|
|
else if (sme->sme_class == SME_CLASS_ACADAPTER)
|
|
|
|
class = "ac-adapter";
|
|
|
|
else
|
|
|
|
class = "other";
|
|
|
|
if (!prop_dictionary_set_cstring_nocopy(pdict, "device-class", class)) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-07-19 04:12:47 +04:00
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
if (!prop_dictionary_set(dict, "device-properties", pdict)) {
|
|
|
|
error = EINVAL;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-08-30 22:01:26 +04:00
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Add the device dictionary into the sysmon envsys array.
|
|
|
|
*/
|
|
|
|
if (!prop_array_add(array, dict))
|
|
|
|
error = EINVAL;
|
2007-07-19 04:12:47 +04:00
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
out:
|
|
|
|
prop_object_release(pdict);
|
|
|
|
return error;
|
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
|
|
|
/*
|
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-11-16 11:00:11 +03:00
|
|
|
* + Adds the sensor objects into the dictionary and returns a pointer
|
|
|
|
* to a sme_event_drv_t object if a monitoring flag was set
|
|
|
|
* (or NULL otherwise).
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
*/
|
2010-03-14 21:03:15 +03:00
|
|
|
static 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;
|
2007-10-07 08:11:15 +04:00
|
|
|
char indexstr[ENVSYS_DESCLEN];
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Find the correct units 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-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* Add the index sensor string.
|
|
|
|
*
|
|
|
|
* ...
|
2007-11-16 11:00:11 +03:00
|
|
|
* <key>index</eyr
|
2007-10-07 08:11:15 +04:00
|
|
|
* <string>sensor0</string>
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
(void)snprintf(indexstr, sizeof(indexstr), "sensor%d", edata->sensor);
|
|
|
|
if (sme_sensor_upstring(dict, "index", indexstr))
|
2007-11-16 11:00:11 +03:00
|
|
|
goto bad;
|
2007-10-07 08:11:15 +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
|
|
|
/*
|
|
|
|
* ...
|
|
|
|
* <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-11-16 11:00:11 +03:00
|
|
|
goto bad;
|
2007-07-20 14:40:07 +04:00
|
|
|
|
2007-07-22 22:17:02 +04:00
|
|
|
if (sme_sensor_upstring(dict, "description", edata->desc))
|
2007-11-16 11:00:11 +03:00
|
|
|
goto bad;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-07-22 22:17:02 +04:00
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
goto bad;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-04 02:05:21 +03:00
|
|
|
* always false on Battery {capacity,charge}, 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-11-04 02:05:21 +03:00
|
|
|
(edata->units == ENVSYS_BATTERY_CAPACITY) ||
|
|
|
|
(edata->units == ENVSYS_BATTERY_CHARGE)) {
|
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-10-07 08:11:15 +04:00
|
|
|
* Add the percentage boolean object, true if ENVSYS_FPERCENT
|
|
|
|
* is set or false otherwise.
|
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-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* Add the allow-rfact boolean object, true if
|
|
|
|
* ENVSYS_FCHANGERFACT if set or false otherwise.
|
|
|
|
*
|
|
|
|
* ...
|
|
|
|
* <key>allow-rfact</key>
|
|
|
|
* <true/>
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
if (edata->units == ENVSYS_SVOLTS_DC ||
|
|
|
|
edata->units == ENVSYS_SVOLTS_AC) {
|
|
|
|
if (edata->flags & ENVSYS_FCHANGERFACT) {
|
|
|
|
if (sme_sensor_upbool(dict, "allow-rfact", true))
|
|
|
|
goto out;
|
|
|
|
} else {
|
|
|
|
if (sme_sensor_upbool(dict, "allow-rfact", false))
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-02 23:36:59 +04:00
|
|
|
/*
|
2007-11-04 02:05:21 +03:00
|
|
|
* Add the object for battery capacity sensors:
|
2007-09-02 23:36:59 +04:00
|
|
|
*
|
|
|
|
* ...
|
2007-11-04 02:05:21 +03:00
|
|
|
* <key>battery-capacity</key>
|
2007-09-04 20:54:02 +04:00
|
|
|
* <string>NORMAL</string>
|
2007-09-02 23:36:59 +04:00
|
|
|
* ...
|
|
|
|
*/
|
2007-11-04 02:05:21 +03:00
|
|
|
if (edata->units == ENVSYS_BATTERY_CAPACITY) {
|
|
|
|
sdt = sme_get_description_table(SME_DESC_BATTERY_CAPACITY);
|
2007-09-04 20:54:02 +04:00
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->value_cur)
|
|
|
|
break;
|
|
|
|
|
2007-11-04 02:05:21 +03:00
|
|
|
if (sme_sensor_upstring(dict, "battery-capacity", 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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Add the following objects if sensor is enabled...
|
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
|
|
|
if (edata->state == ENVSYS_SVALID) {
|
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* Add the following objects:
|
|
|
|
*
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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>rpms</key>
|
|
|
|
* <integer>2500</integer>
|
|
|
|
* <key>rfact</key>
|
|
|
|
* <integer>10000</integer>
|
|
|
|
* <key>cur-value</key>
|
2007-11-16 11:00:11 +03:00
|
|
|
* <integer>1250</integer>
|
|
|
|
* <key>min-value</key>
|
|
|
|
* <integer>800</integer>
|
|
|
|
* <key>max-value</integer>
|
|
|
|
* <integer>3000</integer>
|
|
|
|
* <key>avg-value</integer>
|
|
|
|
* <integer>1400</integer>
|
|
|
|
* ...
|
|
|
|
*/
|
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 ||
|
2007-11-16 11:00:11 +03:00
|
|
|
edata->units == ENVSYS_SVOLTS_DC)
|
2007-07-22 22:17:02 +04:00
|
|
|
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-11-16 11:00:11 +03: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-11-16 11:00:11 +03: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",
|
2007-11-16 11:00:11 +03:00
|
|
|
edata->value_avg))
|
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
* </dict>
|
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-11-16 11:00:11 +03:00
|
|
|
if (!prop_array_add(array, dict)) {
|
2007-07-22 22:17:02 +04:00
|
|
|
DPRINTF(("%s: prop_array_add\n", __func__));
|
2007-11-16 11:00:11 +03:00
|
|
|
goto bad;
|
2007-07-22 22:17:02 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2010-03-14 21:03:15 +03:00
|
|
|
* Register new event(s) if any monitoring flag was set.
|
2007-07-22 22:17:02 +04:00
|
|
|
*/
|
2010-03-14 21:03:15 +03:00
|
|
|
if (edata->flags & ENVSYS_FMONANY) {
|
2007-09-08 07:17:38 +04:00
|
|
|
sme_evdrv_t = kmem_zalloc(sizeof(*sme_evdrv_t), KM_SLEEP);
|
2007-11-16 11:00:11 +03:00
|
|
|
sme_evdrv_t->sed_sdict = dict;
|
|
|
|
sme_evdrv_t->sed_edata = edata;
|
|
|
|
sme_evdrv_t->sed_sme = sme;
|
|
|
|
sme_evdrv_t->sed_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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
bad:
|
2007-09-24 23:46:38 +04:00
|
|
|
prop_object_release(dict);
|
2007-11-16 11:00:11 +03:00
|
|
|
return 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
|
|
|
}
|
|
|
|
|
2010-02-01 00:36:38 +03:00
|
|
|
/*
|
|
|
|
* Find the maximum of all currently reported values.
|
|
|
|
* The provided callback decides wether a sensor is part of the
|
|
|
|
* maximum calculation (by returning true) or ignored (callback
|
|
|
|
* returns false). Example usage: callback selects temperature
|
|
|
|
* sensors in a given thermal zone, the function calculates the
|
|
|
|
* maximum currently reported temperature in this zone.
|
|
|
|
* If the parameter "refresh" is true, new values will be aquired
|
|
|
|
* from the hardware, if not, the last reported value will be used.
|
|
|
|
*/
|
|
|
|
uint32_t
|
|
|
|
sysmon_envsys_get_max_value(bool (*predicate)(const envsys_data_t*),
|
|
|
|
bool refresh)
|
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
uint32_t maxv, v;
|
|
|
|
|
|
|
|
maxv = 0;
|
|
|
|
mutex_enter(&sme_global_mtx);
|
|
|
|
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
|
|
|
|
sysmon_envsys_acquire(sme, false);
|
|
|
|
v = sme_get_max_value(sme, predicate, refresh);
|
|
|
|
sysmon_envsys_release(sme, false);
|
|
|
|
if (v > maxv)
|
|
|
|
maxv = v;
|
|
|
|
}
|
|
|
|
mutex_exit(&sme_global_mtx);
|
|
|
|
return maxv;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint32_t
|
|
|
|
sme_get_max_value(struct sysmon_envsys *sme,
|
|
|
|
bool (*predicate)(const envsys_data_t*),
|
|
|
|
bool refresh)
|
|
|
|
{
|
|
|
|
envsys_data_t *edata;
|
|
|
|
uint32_t maxv, v;
|
|
|
|
|
|
|
|
/*
|
2010-02-01 01:53:56 +03:00
|
|
|
* Iterate over all sensors that match the predicate
|
2010-02-01 00:36:38 +03:00
|
|
|
*/
|
|
|
|
maxv = 0;
|
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
|
|
|
if (!(*predicate)(edata))
|
|
|
|
continue;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* refresh sensor data via sme_refresh only if the
|
|
|
|
* flag is not set.
|
|
|
|
*/
|
|
|
|
if (refresh && (sme->sme_flags & SME_DISABLE_REFRESH) == 0) {
|
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
(*sme->sme_refresh)(sme, edata);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
|
|
|
}
|
|
|
|
|
|
|
|
v = edata->value_cur;
|
|
|
|
if (v > maxv)
|
|
|
|
maxv = v;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return maxv;
|
|
|
|
}
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-16 11:00:11 +03:00
|
|
|
prop_object_t array, dict, obj, obj2;
|
|
|
|
int j, error = 0;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Retrieve the array of dictionaries in device.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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 = 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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Get the last dictionary on the array, this contains the
|
|
|
|
* 'device-properties' sub-dictionary.
|
|
|
|
*/
|
|
|
|
obj = prop_array_get(array, prop_array_count(array) - 1);
|
|
|
|
if (!obj || prop_object_type(obj) != PROP_TYPE_DICTIONARY) {
|
|
|
|
DPRINTF(("%s: not a device-properties dictionary\n", __func__));
|
|
|
|
return EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
obj2 = prop_dictionary_get(obj, "device-properties");
|
|
|
|
if (!obj2)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Update the 'refresh-timeout' property.
|
|
|
|
*/
|
|
|
|
if (!prop_dictionary_set_uint64(obj2, "refresh-timeout",
|
|
|
|
sme->sme_events_timeout))
|
|
|
|
return EINVAL;
|
|
|
|
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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));
|
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
/*
|
|
|
|
* Don't bother with locking when traversing the queue,
|
|
|
|
* the device is already marked as busy; if a sensor
|
|
|
|
* is going to be removed or added it will have to wait.
|
|
|
|
*/
|
2007-11-16 11:00:11 +03:00
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* refresh sensor data via sme_refresh only if the
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
* flag is not set.
|
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
if ((sme->sme_flags & SME_DISABLE_REFRESH) == 0) {
|
|
|
|
mutex_enter(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
(*sme->sme_refresh)(sme, edata);
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme->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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* retrieve sensor's dictionary.
|
|
|
|
*/
|
|
|
|
dict = prop_array_get(array, edata->sensor);
|
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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update sensor's state.
|
|
|
|
*/
|
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;
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
DPRINTFOBJ(("%s: sensor #%d type=%d (%s) flags=%d\n",
|
|
|
|
__func__, edata->sensor, sdt[j].type, sdt[j].desc,
|
|
|
|
edata->flags));
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update sensor's type.
|
|
|
|
*/
|
2007-09-04 20:54:02 +04:00
|
|
|
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;
|
|
|
|
|
2009-06-08 04:55:35 +04:00
|
|
|
DPRINTFOBJ(("%s: sensor #%d units=%d (%s)\n",
|
|
|
|
__func__, edata->sensor, sdt[j].type, sdt[j].desc));
|
|
|
|
|
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;
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update sensor's 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
|
|
|
|
|
|
|
/*
|
2007-11-04 02:05:21 +03:00
|
|
|
* Battery charge, Integer and Indicator types do not
|
|
|
|
* need the following objects, so skip them.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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->units == ENVSYS_INTEGER ||
|
2007-11-04 02:05:21 +03:00
|
|
|
edata->units == ENVSYS_INDICATOR ||
|
|
|
|
edata->units == ENVSYS_BATTERY_CHARGE)
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
continue;
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* 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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update sensor's {avg,max,min}-value.
|
|
|
|
*/
|
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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update 'rpms' only for ENVSYS_SFANRPM sensors.
|
|
|
|
*/
|
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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update 'rfact' only for ENVSYS_SVOLTS_[AD]C sensors.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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->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
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update 'drive-state' only for ENVSYS_DRIVE sensors.
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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->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;
|
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* update 'battery-capacity' only for ENVSYS_BATTERY_CAPACITY
|
|
|
|
* sensors.
|
|
|
|
*/
|
2007-11-04 02:05:21 +03:00
|
|
|
if (edata->units == ENVSYS_BATTERY_CAPACITY) {
|
2007-09-04 20:54:02 +04:00
|
|
|
sdt =
|
2007-11-16 11:00:11 +03:00
|
|
|
sme_get_description_table(SME_DESC_BATTERY_CAPACITY);
|
2007-09-04 20:54:02 +04:00
|
|
|
for (j = 0; sdt[j].type != -1; j++)
|
|
|
|
if (sdt[j].type == edata->value_cur)
|
|
|
|
break;
|
|
|
|
|
|
|
|
error = sme_sensor_upstring(dict,
|
2007-11-04 02:05:21 +03:00
|
|
|
"battery-capacity",
|
2007-09-04 20:54:02 +04:00
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
* + Parse the userland dictionary and run the appropiate tasks
|
|
|
|
* that were specified.
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-16 11:00:11 +03:00
|
|
|
envsys_data_t *edata;
|
|
|
|
prop_dictionary_t dict, tdict = NULL;
|
|
|
|
prop_object_t obj, obj1, obj2, tobj = NULL;
|
2010-02-15 02:06:01 +03:00
|
|
|
uint32_t props;
|
2007-11-16 11:00:11 +03:00
|
|
|
uint64_t refresh_timo = 0;
|
2009-06-13 20:08:25 +04:00
|
|
|
sysmon_envsys_lim_t lims;
|
2007-11-16 11:00:11 +03:00
|
|
|
int i, error = 0;
|
|
|
|
const char *blah;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
bool targetfound = false;
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* The user wanted to change the refresh timeout value for this
|
|
|
|
* device.
|
|
|
|
*
|
|
|
|
* Get the 'device-properties' object from the userland dictionary.
|
|
|
|
*/
|
|
|
|
obj = prop_dictionary_get(udict, "device-properties");
|
|
|
|
if (obj && prop_object_type(obj) == PROP_TYPE_DICTIONARY) {
|
|
|
|
/*
|
|
|
|
* Get the 'refresh-timeout' property for this device.
|
|
|
|
*/
|
|
|
|
obj1 = prop_dictionary_get(obj, "refresh-timeout");
|
|
|
|
if (obj1 && prop_object_type(obj1) == PROP_TYPE_NUMBER) {
|
|
|
|
targetfound = true;
|
|
|
|
refresh_timo =
|
|
|
|
prop_number_unsigned_integer_value(obj1);
|
|
|
|
if (refresh_timo < 1)
|
|
|
|
error = EINVAL;
|
2008-04-01 16:25:30 +04:00
|
|
|
else {
|
|
|
|
mutex_enter(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
sme->sme_events_timeout = refresh_timo;
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
}
|
2008-04-01 16:25:30 +04:00
|
|
|
}
|
|
|
|
return 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
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
} else if (!obj) {
|
2007-10-07 08:11:15 +04:00
|
|
|
/*
|
2007-11-16 11:00:11 +03:00
|
|
|
* Get sensor's index from userland dictionary.
|
2007-10-07 08:11:15 +04:00
|
|
|
*/
|
2007-11-16 11:00:11 +03:00
|
|
|
obj = prop_dictionary_get(udict, "index");
|
|
|
|
if (!obj)
|
2008-04-01 16:25:30 +04:00
|
|
|
return EINVAL;
|
2007-11-16 11:00:11 +03:00
|
|
|
if (prop_object_type(obj) != PROP_TYPE_STRING) {
|
|
|
|
DPRINTF(("%s: 'index' not a string\n", __func__));
|
|
|
|
return EINVAL;
|
2007-07-22 02:11:02 +04:00
|
|
|
}
|
2007-11-16 11:00:11 +03:00
|
|
|
} else
|
|
|
|
return EINVAL;
|
2007-07-19 04:12:47 +04:00
|
|
|
|
2008-04-01 16:25:30 +04:00
|
|
|
/*
|
|
|
|
* Don't bother with locking when traversing the queue,
|
|
|
|
* the device is already marked as busy; if a sensor
|
|
|
|
* is going to be removed or added it will have to wait.
|
2007-11-16 11:00:11 +03:00
|
|
|
*/
|
|
|
|
TAILQ_FOREACH(edata, &sme->sme_sensors_list, sensors_head) {
|
|
|
|
/*
|
|
|
|
* Get a dictionary and check if it's our sensor by checking
|
|
|
|
* at its index position.
|
|
|
|
*/
|
|
|
|
dict = prop_array_get(array, edata->sensor);
|
2007-10-07 08:11:15 +04:00
|
|
|
obj1 = prop_dictionary_get(dict, "index");
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
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-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* is it our 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
|
|
|
if (!prop_string_equals(obj1, obj))
|
|
|
|
continue;
|
|
|
|
|
2010-02-15 02:06:01 +03:00
|
|
|
props = 0;
|
2009-06-13 20:08:25 +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
|
|
|
/*
|
|
|
|
* Check if a new description operation was
|
|
|
|
* requested by the user and set new description.
|
|
|
|
*/
|
2007-11-16 11:00:11 +03:00
|
|
|
obj2 = prop_dictionary_get(udict, "description");
|
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_STRING) {
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
targetfound = true;
|
|
|
|
blah = prop_string_cstring_nocopy(obj2);
|
2007-11-16 11:00:11 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Check for duplicate description.
|
|
|
|
*/
|
2007-07-17 20:47:58 +04:00
|
|
|
for (i = 0; i < sme->sme_nsensors; i++) {
|
|
|
|
if (i == edata->sensor)
|
|
|
|
continue;
|
2007-11-16 11:00:11 +03:00
|
|
|
tdict = prop_array_get(array, i);
|
|
|
|
tobj =
|
|
|
|
prop_dictionary_get(tdict, "description");
|
2008-04-01 16:25:30 +04:00
|
|
|
if (prop_string_equals(obj2, tobj)) {
|
|
|
|
error = EEXIST;
|
|
|
|
goto out;
|
|
|
|
}
|
2007-07-17 20:47:58 +04:00
|
|
|
}
|
|
|
|
|
2007-11-16 11:00:11 +03:00
|
|
|
/*
|
|
|
|
* Update the object in dictionary.
|
|
|
|
*/
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme->sme_mtx);
|
2007-07-21 16:11:27 +04:00
|
|
|
error = sme_sensor_upstring(dict,
|
2007-07-20 14:40:07 +04:00
|
|
|
"description",
|
|
|
|
blah);
|
2008-04-01 16:25:30 +04:00
|
|
|
if (error) {
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
DPRINTF(("%s: sensor%d changed desc to: %s\n",
|
|
|
|
__func__, edata->sensor, blah));
|
2009-06-08 04:55:35 +04:00
|
|
|
edata->upropset |= PROP_DESC;
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme->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-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* did the user want to change the rfact?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "rfact");
|
2007-11-16 11:00:11 +03:00
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
targetfound = true;
|
2007-10-07 08:11:15 +04:00
|
|
|
if (edata->flags & ENVSYS_FCHANGERFACT) {
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_enter(&sme->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
|
|
|
edata->rfact = prop_number_integer_value(obj2);
|
2009-06-08 04:55:35 +04:00
|
|
|
edata->upropset |= PROP_RFACT;
|
2008-04-01 16:25:30 +04:00
|
|
|
mutex_exit(&sme->sme_mtx);
|
2007-11-16 11:00:11 +03:00
|
|
|
DPRINTF(("%s: sensor%d changed rfact to %d\n",
|
|
|
|
__func__, edata->sensor, edata->rfact));
|
2008-04-01 16:25:30 +04:00
|
|
|
} else {
|
|
|
|
error = ENOTSUP;
|
|
|
|
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-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;
|
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* did the user want to set a critical capacity event?
|
|
|
|
*/
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
obj2 = prop_dictionary_get(udict, "critical-capacity");
|
2007-11-16 11:00:11 +03:00
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
targetfound = true;
|
2009-06-13 20:08:25 +04:00
|
|
|
lims.sel_critmin = prop_number_integer_value(obj2);
|
2010-02-15 02:06:01 +03:00
|
|
|
props |= PROP_BATTCAP;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
|
|
|
|
2008-08-22 15:27:50 +04:00
|
|
|
/*
|
|
|
|
* did the user want to set a warning capacity event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "warning-capacity");
|
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
|
|
|
targetfound = true;
|
2009-06-13 20:08:25 +04:00
|
|
|
lims.sel_warnmin = prop_number_integer_value(obj2);
|
2010-02-15 02:06:01 +03:00
|
|
|
props |= PROP_BATTWARN;
|
2008-08-22 15:27:50 +04:00
|
|
|
}
|
|
|
|
|
2010-02-16 01:32:04 +03:00
|
|
|
/*
|
|
|
|
* did the user want to set a high capacity event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "high-capacity");
|
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
|
|
|
targetfound = true;
|
|
|
|
lims.sel_warnmin = prop_number_integer_value(obj2);
|
|
|
|
props |= PROP_BATTHIGH;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* did the user want to set a maximum capacity event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "maximum-capacity");
|
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
|
|
|
targetfound = true;
|
|
|
|
lims.sel_warnmin = prop_number_integer_value(obj2);
|
|
|
|
props |= PROP_BATTMAX;
|
|
|
|
}
|
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* did the user want to set a critical max event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "critical-max");
|
2007-11-16 11:00:11 +03:00
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
targetfound = true;
|
2009-06-13 20:08:25 +04:00
|
|
|
lims.sel_critmax = prop_number_integer_value(obj2);
|
2010-02-15 02:06:01 +03:00
|
|
|
props |= PROP_CRITMAX;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
|
|
|
|
2008-08-22 15:27:50 +04:00
|
|
|
/*
|
|
|
|
* did the user want to set a warning max event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "warning-max");
|
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
|
|
|
targetfound = true;
|
2009-06-13 20:08:25 +04:00
|
|
|
lims.sel_warnmax = prop_number_integer_value(obj2);
|
2010-02-15 02:06:01 +03:00
|
|
|
props |= PROP_WARNMAX;
|
2008-08-22 15:27:50 +04:00
|
|
|
}
|
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* did the user want to set a critical min event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "critical-min");
|
2007-11-16 11:00:11 +03:00
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
targetfound = true;
|
2009-06-13 20:08:25 +04:00
|
|
|
lims.sel_critmin = prop_number_integer_value(obj2);
|
2010-02-15 02:06:01 +03:00
|
|
|
props |= PROP_CRITMIN;
|
Imported envsys 2, a brief description of the new features:
(Part 1: API)
* Support for detachable sensors.
* Cleaned up the API for simplicity and efficiency.
* Ability to send capacity/critical/warning events to powerd(8).
* Adapted all the code to the new locking order.
* Compatibility with the old envsys API: the ENVSYS_GTREINFO
and ENVSYS_GTREDATA ioctl(2)s are supported.
* Added support for a 'dictionary based communication channel' between
sysmon_power(9) and powerd(8), that means there is no 32 bytes event
size restriction anymore.
* Binary compatibility with old envstat(8) and powerd(8) via COMPAT_40.
* All drivers with the n^2 gtredata bug were fixed, PR kern/36226.
Tested by:
blymn: smsc(4).
bouyer: ipmi(4), mfi(4).
kefren: ug(4).
njoly: viaenv(4), adt7463.c.
riz: owtemp(4).
xtraeme: acpiacad(4), acpibat(4), acpitz(4), aiboost(4), it(4), lm(4).
2007-07-01 11:36:39 +04:00
|
|
|
}
|
2007-10-07 08:11:15 +04:00
|
|
|
|
2008-08-22 15:27:50 +04:00
|
|
|
/*
|
|
|
|
* did the user want to set a warning min event?
|
|
|
|
*/
|
|
|
|
obj2 = prop_dictionary_get(udict, "warning-min");
|
|
|
|
if (obj2 && prop_object_type(obj2) == PROP_TYPE_NUMBER) {
|
|
|
|
targetfound = true;
|
2009-06-13 20:08:25 +04:00
|
|
|
lims.sel_warnmin = prop_number_integer_value(obj2);
|
2010-02-15 02:06:01 +03:00
|
|
|
props |= PROP_WARNMIN;
|
2009-06-08 04:55:35 +04:00
|
|
|
}
|
|
|
|
|
2010-02-15 02:06:01 +03:00
|
|
|
if (props) {
|
2010-01-30 05:46:52 +03:00
|
|
|
if (edata->flags & ENVSYS_FMONNOTSUPP) {
|
|
|
|
error = ENOTSUP;
|
|
|
|
goto out;
|
|
|
|
}
|
2009-06-13 20:08:25 +04:00
|
|
|
error = sme_event_register(dict, edata, sme, &lims,
|
2010-02-15 02:06:01 +03:00
|
|
|
props,
|
|
|
|
(edata->flags & ENVSYS_FPERCENT)?
|
2009-06-08 04:55:35 +04:00
|
|
|
PENVSYS_EVENT_CAPACITY:
|
|
|
|
PENVSYS_EVENT_LIMITS,
|
2010-02-15 02:06:01 +03:00
|
|
|
sdt[i].crittype);
|
2008-08-22 15:27:50 +04:00
|
|
|
if (error == EEXIST)
|
|
|
|
error = 0;
|
|
|
|
if (error)
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
2007-10-07 08:11:15 +04:00
|
|
|
/*
|
|
|
|
* All objects in dictionary were processed.
|
|
|
|
*/
|
|
|
|
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-11-16 11:00:11 +03:00
|
|
|
out:
|
|
|
|
/*
|
|
|
|
* invalid target? return the 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
|
|
|
if (!targetfound)
|
|
|
|
error = EINVAL;
|
|
|
|
|
|
|
|
return error;
|
2000-11-05 07:06:13 +03:00
|
|
|
}
|
2010-03-26 23:31:06 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* + sysmon_envsys_foreach_sensor
|
|
|
|
*
|
|
|
|
* Walk through the devices' sensor lists and execute the callback.
|
|
|
|
* If the callback returns false, the remainder of the current
|
|
|
|
* device's sensors are skipped.
|
|
|
|
*/
|
|
|
|
void
|
2010-03-27 16:34:16 +03:00
|
|
|
sysmon_envsys_foreach_sensor(bool(*func)(const struct sysmon_envsys *,
|
|
|
|
const envsys_data_t *, void*),
|
|
|
|
void *arg, bool refresh)
|
2010-03-26 23:31:06 +03:00
|
|
|
{
|
|
|
|
struct sysmon_envsys *sme;
|
|
|
|
envsys_data_t *sensor;
|
|
|
|
|
|
|
|
mutex_enter(&sme_global_mtx);
|
|
|
|
LIST_FOREACH(sme, &sysmon_envsys_list, sme_list) {
|
|
|
|
|
2010-03-27 16:23:18 +03:00
|
|
|
sysmon_envsys_acquire(sme, false);
|
2010-03-26 23:31:06 +03:00
|
|
|
TAILQ_FOREACH(sensor, &sme->sme_sensors_list, sensors_head) {
|
2010-03-27 16:23:18 +03:00
|
|
|
if (refresh &&
|
|
|
|
(sme->sme_flags & SME_DISABLE_REFRESH) == 0) {
|
|
|
|
mutex_enter(&sme->sme_mtx);
|
|
|
|
(*sme->sme_refresh)(sme, sensor);
|
|
|
|
mutex_exit(&sme->sme_mtx);
|
|
|
|
}
|
2010-03-27 00:06:25 +03:00
|
|
|
if (!(*func)(sme, sensor, arg))
|
2010-03-26 23:31:06 +03:00
|
|
|
break;
|
|
|
|
}
|
2010-03-27 16:23:18 +03:00
|
|
|
sysmon_envsys_release(sme, false);
|
2010-03-26 23:31:06 +03:00
|
|
|
}
|
|
|
|
mutex_exit(&sme_global_mtx);
|
|
|
|
}
|