2003-06-26 14:26:53 +04:00
|
|
|
.\" $NetBSD: envsys.4,v 1.12 2003/06/26 10:26:53 wiz Exp $
|
2000-02-27 03:59:49 +03:00
|
|
|
.\"
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2000 The NetBSD Foundation, Inc.
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
|
|
|
.Dd February 26, 2000
|
|
|
|
.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
|
|
|
|
available on modern motherboards. Initially it supports three
|
|
|
|
distinct sensor types; fan speed, temperature, and voltage.
|
|
|
|
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
|
|
|
|
physical phenomena. Thus, some userland mechanism of
|
|
|
|
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
|
|
|
|
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 is not desirable.
|
|
|
|
.It
|
|
|
|
Some ICs provide useful statistical information.
|
|
|
|
Collecting reliable statistical information in userland
|
|
|
|
from a polled device is problematic. We would like to use
|
|
|
|
the on-chip information when it is available.
|
|
|
|
.It
|
|
|
|
A useful balance between complexity of use and amount
|
|
|
|
of available information is desired. While it may be
|
|
|
|
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
|
|
|
|
impossible for devices to produce them all. Thus, a
|
|
|
|
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
|
|
|
|
sequentially, beginning with 0. Moreover, all sensors of the same
|
|
|
|
type must occupy a sub-interval of [0..n-1]. This arrangement
|
|
|
|
allows easy iteration over the entire collection of sensors or over
|
|
|
|
sensors of a particular type.
|
|
|
|
.Pp
|
|
|
|
The following
|
|
|
|
.Xr ioctl 2 's
|
|
|
|
must be supported by any device claiming to
|
|
|
|
be compliant with version 1.0 of
|
|
|
|
.Nm
|
|
|
|
.Pp
|
|
|
|
.Bl -tag -width indent
|
|
|
|
.It Dv ENVSYS_VERSION (int)
|
|
|
|
Returns API version * 1000. A userland application could use
|
|
|
|
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
|
|
|
|
typedef struct envsys_range {
|
|
|
|
u_int low;
|
|
|
|
u_int high;
|
|
|
|
|
|
|
|
u_int units; /* see GTREDATA */
|
2000-02-27 07:11:14 +03:00
|
|
|
} 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.
|
|
|
|
.It Dv ENVSYS_GTREDATA (envsys_tre_data)
|
|
|
|
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 */
|
|
|
|
u_int32_t data_us; /* in microKelvins, */
|
|
|
|
int32_t data_s; /* rpms, volts, amps, */
|
|
|
|
} cur, min, max, avg; /* ohms, watts, etc */
|
|
|
|
/* see units below */
|
|
|
|
|
|
|
|
u_int32_t warnflags; /* warning flags */
|
|
|
|
u_int32_t validflags; /* sensor valid flags */
|
|
|
|
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
|
|
|
|
requested. The structure is returned with available data
|
|
|
|
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
|
|
|
|
Set if these fields are filled with valid data
|
|
|
|
.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
|
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 */
|
|
|
|
u_int rpms; /* for fans */
|
|
|
|
u_int rfact; /* for volts, (factor x 10^4) */
|
|
|
|
u_int32_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
|
|
|
|
field and store the contents for subsequent requests. The
|
|
|
|
driver is expected to supply a default
|
|
|
|
.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
|
|
|
|
.Va flags
|
|
|
|
value, indicating to the user that he has successfully programmed or
|
|
|
|
retrieved data from an existing sensor.
|
|
|
|
.El
|
|
|
|
.Sh SEE ALSO
|
2000-07-04 12:57:44 +04:00
|
|
|
.Xr lm 4 ,
|
|
|
|
.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.
|