2006-05-13 13:04:48 +04:00
|
|
|
.\" $NetBSD: envsys.4,v 1.19 2006/05/13 09:04:48 xtraeme Exp $
|
2000-02-27 03:59:49 +03:00
|
|
|
.\"
|
|
|
|
.\"
|
2006-03-15 14:23:30 +03:00
|
|
|
.\" Copyright (c) 2000, 2004, 2006 The NetBSD Foundation, Inc.
|
2000-02-27 03:59:49 +03:00
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" This code is derived from software contributed to The NetBSD Foundation
|
|
|
|
.\" by Tim Rightnour and Bill Squier
|
|
|
|
.\"
|
|
|
|
.\" 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 the NetBSD
|
|
|
|
.\" Foundation, Inc. and its contributors.
|
|
|
|
.\" 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
.\" contributors may be used to endorse or promote products derived
|
|
|
|
.\" from this software without specific prior written permission.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
.\"
|
2006-05-13 13:04:48 +04:00
|
|
|
.Dd May 13, 2006
|
2000-02-27 03:59:49 +03:00
|
|
|
.Dt ENVSYS 4
|
|
|
|
.Os
|
|
|
|
.Sh NAME
|
|
|
|
.Nm envsys
|
|
|
|
.Nd Environmental Systems API
|
|
|
|
.Sh SYNOPSIS
|
2003-04-16 17:34:34 +04:00
|
|
|
.In sys/envsys.h
|
2000-02-27 03:59:49 +03:00
|
|
|
.Sh DESCRIPTION
|
2003-06-26 14:26:53 +04:00
|
|
|
.Bd -unfilled -offset center
|
2000-02-27 03:59:49 +03:00
|
|
|
.Em This API is experimental and may be deprecated at
|
|
|
|
.Em any time
|
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
There are a number of considerations:
|
|
|
|
.Bl -enum
|
|
|
|
.It
|
|
|
|
This API is designed to support various environmental sensor ICs
|
2004-05-12 02:42:47 +04:00
|
|
|
available on modern motherboards.
|
|
|
|
Initially it supports three
|
|
|
|
distinct sensor types: fan speed, temperature, and voltage.
|
2000-02-27 03:59:49 +03:00
|
|
|
Additional sensor types can be added with new ioctl's without
|
|
|
|
disrupting the current API.
|
|
|
|
.It
|
|
|
|
Many sensor ICs have no fixed assignment of registers to
|
2004-05-12 02:42:47 +04:00
|
|
|
physical phenomena.
|
|
|
|
Thus, some userland mechanism of
|
2000-02-27 03:59:49 +03:00
|
|
|
assigning meanings to the registers is required to allow
|
|
|
|
userland utilities to produce reasonable output.
|
|
|
|
.It
|
|
|
|
The number of registers for each class of sensor varies
|
2004-05-12 02:42:47 +04:00
|
|
|
among devices.
|
|
|
|
Therefore a way to enumerate all data of
|
|
|
|
a particular sensor type is required.
|
|
|
|
Fixed limits on the
|
|
|
|
number of sensors per type are not desirable.
|
2000-02-27 03:59:49 +03:00
|
|
|
.It
|
|
|
|
Some ICs provide useful statistical information.
|
|
|
|
Collecting reliable statistical information in userland
|
2004-05-12 02:42:47 +04:00
|
|
|
from a polled device is problematic.
|
|
|
|
We would like to use
|
2000-02-27 03:59:49 +03:00
|
|
|
the on-chip information when it is available.
|
|
|
|
.It
|
|
|
|
A useful balance between complexity of use and amount
|
2004-05-12 02:42:47 +04:00
|
|
|
of available information is desired.
|
|
|
|
While it may be
|
2000-02-27 03:59:49 +03:00
|
|
|
possible to allow for an unlimited number of statistical
|
|
|
|
measures to be returned by a device, we have chosen only
|
|
|
|
four common ones: current, minimum, maximum, and average.
|
|
|
|
Even with this limited set, it may be impractical or
|
2004-05-12 02:42:47 +04:00
|
|
|
impossible for devices to produce them all.
|
|
|
|
Thus, a
|
2000-02-27 03:59:49 +03:00
|
|
|
mechanism to determine which statistics are valid is required.
|
|
|
|
.It
|
|
|
|
The API is designed in a way that can be used to monitor
|
|
|
|
both system-internal, and system-external environmental
|
|
|
|
sensors.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
For the purposes of this API, all devices must number the sensors
|
2004-05-12 02:42:47 +04:00
|
|
|
sequentially, beginning with 0.
|
|
|
|
Moreover, all sensors of the same
|
|
|
|
type must occupy a sub-interval of [0..n-1].
|
|
|
|
This arrangement
|
2000-02-27 03:59:49 +03:00
|
|
|
allows easy iteration over the entire collection of sensors or over
|
|
|
|
sensors of a particular type.
|
|
|
|
.Pp
|
|
|
|
The following
|
2003-06-27 22:21:35 +04:00
|
|
|
.Xr ioctl 2 Ns 's
|
2000-02-27 03:59:49 +03:00
|
|
|
must be supported by any device claiming to
|
|
|
|
be compliant with version 1.0 of
|
2004-05-12 02:42:47 +04:00
|
|
|
.Nm :
|
2000-02-27 03:59:49 +03:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv ENVSYS_VERSION (int)
|
2004-05-12 02:42:47 +04:00
|
|
|
Returns API version * 1000.
|
|
|
|
A userland application could use
|
2000-02-27 03:59:49 +03:00
|
|
|
this command to determine further supported ioctl's of the
|
|
|
|
device.
|
|
|
|
.It Dv ENVSYS_GRANGE (envsys_range_t)
|
|
|
|
The caller fills in the
|
|
|
|
.Va units
|
2000-02-27 07:11:14 +03:00
|
|
|
member of:
|
2000-02-27 03:59:49 +03:00
|
|
|
.Bd -literal
|
2004-05-12 02:42:47 +04:00
|
|
|
struct envsys_range {
|
2000-02-27 03:59:49 +03:00
|
|
|
u_int low;
|
|
|
|
u_int high;
|
|
|
|
u_int units; /* see GTREDATA */
|
2004-05-12 02:42:47 +04:00
|
|
|
};
|
|
|
|
typedef struct envsys_range envsys_range_t;
|
2000-02-27 03:59:49 +03:00
|
|
|
.Ed
|
|
|
|
.Pp
|
|
|
|
The driver fills in the
|
|
|
|
.Va low
|
|
|
|
and
|
|
|
|
.Va high
|
|
|
|
values such that
|
|
|
|
sensor numbers from
|
|
|
|
.Va low
|
|
|
|
to
|
|
|
|
.Va high ,
|
|
|
|
inclusive, contain sensors of type
|
|
|
|
.Va units .
|
|
|
|
.Pp
|
|
|
|
NOTE:
|
|
|
|
.Va high
|
2002-02-13 11:17:26 +03:00
|
|
|
\*[Lt]
|
2000-02-27 03:59:49 +03:00
|
|
|
.Va low
|
|
|
|
implies no sensors of the unit type specified exist.
|
2006-03-15 14:23:30 +03:00
|
|
|
.It Dv ENVSYS_GTREDATA (envsys_tre_data_t)
|
2000-02-27 03:59:49 +03:00
|
|
|
This command makes use of:
|
|
|
|
.Bd -literal
|
2000-02-27 07:11:14 +03:00
|
|
|
typedef struct envsys_tre_data {
|
2000-02-27 03:59:49 +03:00
|
|
|
u_int sensor;
|
|
|
|
union { /* all data is given */
|
2005-12-26 22:40:14 +03:00
|
|
|
uint32_t data_us; /* in microKelvins, */
|
2000-02-27 03:59:49 +03:00
|
|
|
int32_t data_s; /* rpms, volts, amps, */
|
|
|
|
} cur, min, max, avg; /* ohms, watts, etc */
|
|
|
|
/* see units below */
|
|
|
|
|
2005-12-26 22:40:14 +03:00
|
|
|
uint32_t warnflags; /* warning flags */
|
|
|
|
uint32_t validflags; /* sensor valid flags */
|
2000-02-27 03:59:49 +03:00
|
|
|
u_int units; /* type of sensor */
|
2000-02-27 07:11:14 +03:00
|
|
|
} envsys_tre_data_t;
|
2000-02-27 03:59:49 +03:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2000-02-27 07:11:14 +03:00
|
|
|
At request time, the caller of this command fills only the
|
|
|
|
.Va sensor
|
2000-02-27 03:59:49 +03:00
|
|
|
member with the sensor number for which data is being
|
2004-05-12 02:42:47 +04:00
|
|
|
requested.
|
|
|
|
The structure is returned with available data
|
2000-02-27 03:59:49 +03:00
|
|
|
filled in by the driver.
|
|
|
|
.Pp
|
2000-02-27 07:11:14 +03:00
|
|
|
Zero or more of the following bits may be set in
|
|
|
|
.Va validflags :
|
2000-02-27 03:59:49 +03:00
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -compact -offset indent
|
|
|
|
.It Dv ENVSYS_FVALID
|
|
|
|
Not set implies an illegal sensor number was requested.
|
|
|
|
.Pp
|
|
|
|
.It Dv ENVSYS_FCURVALID
|
|
|
|
.It Dv ENVSYS_FMINVALID
|
|
|
|
.It Dv ENVSYS_FMAXVALID
|
|
|
|
.It Dv ENVSYS_FAVGVALID
|
2004-05-12 02:42:47 +04:00
|
|
|
.It Dv ENVSYS_FFRACVALID
|
|
|
|
Set if these fields are filled with valid data.
|
2000-02-27 03:59:49 +03:00
|
|
|
.Pp
|
2000-02-27 07:11:14 +03:00
|
|
|
Although
|
|
|
|
.Dv !ENVSYS_FVALID
|
|
|
|
might be implied from the absence of
|
2000-02-27 03:59:49 +03:00
|
|
|
all other *VALID flags, it is conceivable that some ICs have
|
|
|
|
a period during which valid sensors contain invalid data.
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
Valid
|
|
|
|
.Va warnflags
|
|
|
|
are:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -compact -offset indent
|
|
|
|
.It Dv ENVSYS_WARN_OK
|
|
|
|
.It Dv ENVSYS_WARN_UNDER
|
|
|
|
.It Dv ENVSYS_WARN_CRITUNDER
|
|
|
|
.It Dv ENVSYS_WARN_OVER
|
|
|
|
.It Dv ENVSYS_WARN_CRITOVER
|
|
|
|
.El
|
|
|
|
.Pp
|
|
|
|
The driver may return
|
|
|
|
.Dv ENVSYS_WARN_OK
|
|
|
|
at all times if the hardware or driver does not support warning flags.
|
|
|
|
.Pp
|
|
|
|
Valid
|
|
|
|
.Va units
|
|
|
|
are:
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent -compact -offset indent
|
|
|
|
.It Dv ENVSYS_STEMP
|
|
|
|
.It Dv ENVSYS_SFANRPM
|
|
|
|
.It Dv ENVSYS_SVOLTS_AC
|
|
|
|
.It Dv ENVSYS_SVOLTS_DC
|
|
|
|
.It Dv ENVSYS_SOHMS
|
|
|
|
.It Dv ENVSYS_SWATTS
|
2002-01-21 20:46:42 +03:00
|
|
|
.It Dv ENVSYS_SAMPS
|
2004-05-12 02:42:47 +04:00
|
|
|
.It Dv ENVSYS_SWATTHOUR
|
|
|
|
.It Dv ENVSYS_SAMPHOUR
|
|
|
|
.It Dv ENVSYS_INDICATOR
|
|
|
|
.It Dv ENVSYS_INTEGER
|
|
|
|
.It Dv ENVSYS_NSENSORS
|
2000-02-27 03:59:49 +03:00
|
|
|
.El
|
2000-02-27 07:11:14 +03:00
|
|
|
.It Dv ENVSYS_STREINFO (envsys_basic_info_t)
|
|
|
|
.It Dv ENVSYS_GTREINFO (envsys_basic_info_t)
|
2000-02-27 03:59:49 +03:00
|
|
|
These commands make use of:
|
|
|
|
.Bd -literal
|
2000-02-27 07:11:14 +03:00
|
|
|
typedef struct envsys_basic_info {
|
2000-03-09 07:17:20 +03:00
|
|
|
u_int sensor; /* sensor number */
|
|
|
|
u_int units; /* type of sensor */
|
|
|
|
char desc[33]; /* sensor description */
|
2004-05-12 02:55:00 +04:00
|
|
|
u_int rfact; /* for volts, (int)(factor x 10^4) */
|
2004-05-12 02:42:47 +04:00
|
|
|
u_int rpms; /* for fans */
|
2005-12-26 22:40:14 +03:00
|
|
|
uint32_t validflags; /* sensor valid flags */
|
2000-02-27 07:11:14 +03:00
|
|
|
} envsys_basic_info_t;
|
2000-02-27 03:59:49 +03:00
|
|
|
.Ed
|
|
|
|
.Pp
|
2001-08-21 21:56:41 +04:00
|
|
|
.Dv ENVSYS_STREINFO
|
|
|
|
is for setting this information in the driver,
|
2000-02-27 03:59:49 +03:00
|
|
|
while
|
2001-08-21 21:56:41 +04:00
|
|
|
.Dv ENVSYS_GTREINFO
|
|
|
|
is for retrieving this information.
|
2000-02-27 03:59:49 +03:00
|
|
|
.Pp
|
|
|
|
To retrieve information, simply fill in the
|
|
|
|
.Va sensor
|
|
|
|
member.
|
|
|
|
.Pp
|
|
|
|
All environmental sensor types read the supplied
|
|
|
|
.Va desc
|
2004-05-12 02:42:47 +04:00
|
|
|
field and store the contents for subsequent requests.
|
|
|
|
The driver is expected to supply a default
|
2000-02-27 03:59:49 +03:00
|
|
|
.Dv NULL
|
|
|
|
terminated string for
|
|
|
|
.Va desc .
|
|
|
|
.Pp
|
|
|
|
RPM sensor types additionally read the nominal RPM value from
|
|
|
|
.Va rpms .
|
2000-03-09 07:17:20 +03:00
|
|
|
Voltage sensors read
|
|
|
|
.Va rfact .
|
|
|
|
Drivers are expected to multiply DC voltage values by this factor before
|
|
|
|
returning them to the user.
|
2000-02-27 03:59:49 +03:00
|
|
|
.Pp
|
|
|
|
The driver will fill in the
|
2004-05-12 02:42:47 +04:00
|
|
|
.Va validflags
|
2000-02-27 03:59:49 +03:00
|
|
|
value, indicating to the user that he has successfully programmed or
|
|
|
|
retrieved data from an existing sensor.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
2004-04-25 07:13:00 +04:00
|
|
|
.Xr acpiacad 4 ,
|
|
|
|
.Xr acpibat 4 ,
|
|
|
|
.Xr acpitz 4 ,
|
2000-07-04 12:57:44 +04:00
|
|
|
.Xr lm 4 ,
|
2006-05-13 13:04:48 +04:00
|
|
|
.Xr it 4 ,
|
2000-07-04 12:57:44 +04:00
|
|
|
.Xr viaenv 4 ,
|
|
|
|
.Xr envstat 8
|
2000-02-27 03:59:49 +03:00
|
|
|
.Sh BUGS
|
|
|
|
This entire API should be replaced by a
|
|
|
|
.Xr sysctl 8
|
2000-02-27 07:11:14 +03:00
|
|
|
interface or a kernel events mechanism, should one be developed.
|