1 .\" $NetBSD: envsys.4,v 1.44 2009/10/14 23:18:39 joerg Exp $
3 .\" Copyright (c) 2007 The NetBSD Foundation, Inc.
4 .\" All rights reserved.
6 .\" This code is derived from software contributed to The NetBSD Foundation
7 .\" by Juan Romero Pardines.
9 .\" Redistribution and use in source and binary forms, with or without
10 .\" modification, are permitted provided that the following conditions
12 .\" 1. Redistributions of source code must retain the above copyright
13 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in the
16 .\" documentation and/or other materials provided with the distribution.
18 .\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
19 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20 .\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
21 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
22 .\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 .\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 .\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 .\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 .\" POSSIBILITY OF SUCH DAMAGE.
35 .Nd Environmental Systems framework (version 2)
41 framework provides support to handle hardware monitor devices.
42 Hardware monitoring chips are able to report values from different types of
47 framework consists of two parts:
49 .Bl -enum -offset indent -compact
51 the userland part, to receive the current sensor data and
52 to set some properties on sensors:
55 The kernel part that is able to talk to the drivers providing sensor
64 for communication between kernel and user space.
70 .It Dv ENVSYS_GETDICTIONARY Pq prop_dictionary_t
74 is used to receive the global dictionary that is being used in
78 It will contain an array of dictionaries per device
79 and one dictionary per sensor plus another special dictionary that
80 contains the properties for a device.
81 Each sensor dictionary will have their own characteristics and values.
83 The following XML property list represents a virtual device
87 and all available properties set on it, plus another sensor for
90 dictionary (which contains specific properties for a device):
93 \&\*[Lt]key\&\*[Gt]device0\&\*[Lt]\&/key\&\*[Gt]
96 \&\*[Lt]key\&\*[Gt]allow-rfact\&\*[Lt]\&/key\&\*[Gt]
97 \&\*[Lt]true\&/\&\*[Gt]
98 \&\*[Lt]key\&\*[Gt]avg-value\&\*[Lt]\&/key\&\*[Gt]
99 \&\*[Lt]integer\&\*[Gt]36400\&\*[Lt]\&/integer\&\*[Gt]
100 \&\*[Lt]key\&\*[Gt]battery-capacity\&\*[Lt]\&/key\&\*[Gt]
101 \&\*[Lt]string\&\*[Gt]NORMAL\&\*[Lt]\&/string\&\*[Gt]
102 \&\*[Lt]key\&\*[Gt]critical-capacity\&\*[Lt]\&/key\&\*[Gt]
103 \&\*[Lt]integer\&\*[Gt]21417\&\*[Lt]\&/integer\&\*[Gt]
104 \&\*[Lt]key\&\*[Gt]critical-max\&\*[Lt]\&/key\&\*[Gt]
105 \&\*[Lt]integer\&\*[Gt]343150000\&\*[Lt]\&/integer\&\*[Gt]
106 \&\*[Lt]key\&\*[Gt]critical-min\&\*[Lt]\&/key\&\*[Gt]
107 \&\*[Lt]integer\&\*[Gt]288150000\&\*[Lt]\&/integer\&\*[Gt]
108 \&\*[Lt]key\&\*[Gt]cur-value\&\*[Lt]\&/key\&\*[Gt]
109 \&\*[Lt]integer\&\*[Gt]406000\&\*[Lt]\&/integer\&\*[Gt]
110 \&\*[Lt]key\&\*[Gt]description\&\*[Lt]\&/key\&\*[Gt]
111 \&\*[Lt]string\&\*[Gt]CPU Temp\&\*[Lt]\&/string\&\*[Gt]
112 \&\*[Lt]string\&\*[Gt]index\&\*[Lt]\&/string\&\*[Gt]
113 \&\*[Lt]string\&\*[Gt]sensor0\&\*[Lt]\&/string\&\*[Gt]
114 \&\*[Lt]key\&\*[Gt]max-value\&\*[Lt]\&/key\&\*[Gt]
115 \&\*[Lt]integer\&\*[Gt]3894000\&\*[Lt]\&/integer\&\*[Gt]
116 \&\*[Lt]key\&\*[Gt]min-value\&\*[Lt]\&/key\&\*[Gt]
117 \&\*[Lt]integer\&\*[Gt]2894000\&\*[Lt]\&/integer\&\*[Gt]
118 \&\*[Lt]key\&\*[Gt]monitoring-state-critical\&\*[Lt]\&/key\&\*[Gt]
119 \&\*[Lt]true\&/\&\*[Gt]
120 \&\*[Lt]key\&\*[Gt]monitoring-state-critover\&\*[Lt]\&/key\&\*[Gt]
121 \&\*[Lt]true\&/\&\*[Gt]
122 \&\*[Lt]key\&\*[Gt]monitoring-state-critunder\&\*[Lt]\&/key\&\*[Gt]
123 \&\*[Lt]true\&/\&\*[Gt]
124 \&\*[Lt]key\&\*[Gt]monitoring-state-state-changed\&\*[Lt]\&/key\&\*[Gt]
125 \&\*[Lt]true\&/\&\*[Gt]
126 \&\*[Lt]key\&\*[Gt]monitoring-state-warnover\&\*[Lt]\&/key\&\*[Gt]
127 \&\*[Lt]true\&/\&\*[Gt]
128 \&\*[Lt]key\&\*[Gt]monitoring-state-warnunder\&\*[Lt]\&/key\&\*[Gt]
129 \&\*[Lt]true\&/\&\*[Gt]
130 \&\*[Lt]key\&\*[Gt]monitoring-supported\&\*[Lt]\&/key\&\*[Gt]
131 \&\*[Lt]true\&/\&\*[Gt]
132 \&\*[Lt]key\&\*[Gt]state\&\*[Lt]\&/key\&\*[Gt]
133 \&\*[Lt]string\&\*[Gt]valid\&\*[Lt]\&/string\&\*[Gt]
134 \&\*[Lt]key\&\*[Gt]type\&\*[Lt]\&/key\&\*[Gt]
135 \&\*[Lt]string\&\*[Gt]Ampere hour\&\*[Lt]\&/string\&\*[Gt]
136 \&\*[Lt]key\&\*[Gt]want-percentage\&\*[Lt]\&/key\&\*[Gt]
137 \&\*[Lt]true\&/\&\*[Gt]
138 \&\*[Lt]key\&\*[Gt]warning-capacity\&\*[Lt]\&/key\&\*[Gt]
139 \&\*[Lt]integer\&\*[Gt]19234\&\*[Lt]\&/integer\&\*[Gt]
140 \&\*[Lt]key\&\*[Gt]warning-max\&\*[Lt]\&/key\&\*[Gt]
141 \&\*[Lt]integer\&\*[Gt]323150000\&\*[Lt]\&/integer\&\*[Gt]
142 \&\*[Lt]key\&\*[Gt]warning-min\&\*[Lt]\&/key\&\*[Gt]
143 \&\*[Lt]integer\&\*[Gt]298150000\&\*[Lt]\&/integer\&\*[Gt]
144 \&\*[Lt]\&/dict\&\*[Gt]
146 \&\*[Lt]key\&\*[Gt]device-properties\&\*[Lt]\&/key\&\*[Gt]
148 \&\*[Lt]key\&\*[Gt]refresh-timeout\&\*[Lt]\&/key\&\*[Gt]
149 \&\*[Lt]integer\&\*[Gt]0xa\&\*[Lt]\&/integer\&\*[Gt]
150 \&\*[Lt]\&/dict\&\*[Gt]
151 \&\*[Lt]\&/dict\&\*[Gt]
152 \&\*[Lt]\&/array\&\*[Gt]
155 Let's explain some more about those objects:
156 .Bl -tag -width "monitoring-state-critical-overxx"
160 means that the sensor is able to change the resistor factor,
161 only used in Voltage sensors.
163 Current average value in the sensor.
164 .It Fa battery-capacity
165 Current capacity state for a battery capacity sensor.
166 .It Fa critical-capacity
167 Critical capacity set previously by the
168 .Dv ENVSYS_SETDICTIONARY
170 Only available on sensors with the
174 Critical max limit set previously by the
175 .Dv ENVSYS_SETDICTIONARY
178 Critical min limit set previously by the
179 .Dv ENVSYS_SETDICTIONARY
182 Current value in the sensor.
184 Description of the sensor.
186 Index position of the sensor.
188 Current max value in the sensor.
190 Current min value in the sensor.
191 .It Fa monitoring-state-critical
192 If true, the driver has enabled the flag to monitor a critical state.
193 .It Fa monitoring-state-hw-range-limits
194 If true, the driver has enabled the flag to monitor warning or critical
196 .It Fa monitoring-state-state-changed
197 If true, the driver has enabled the flag to monitor for state changes in
198 a drive or Battery state sensor.
199 .It Fa monitoring-supported
200 If true, critical/warning capacity/max/min limits may be set by the
201 .Dv ENVSYS_SETDICTIONARY
204 Current state in the sensor.
206 Type of unit in the sensor.
207 .It Fa want-percentage
212 are valid and a percentage may be computed from them.
213 .It Fa warning-capacity
214 Warning capacity set previously by the
215 .Dv ENVSYS_SETDICTIONARY
217 Only available on sensors with the
221 Warning max limit set previously by the
222 .Dv ENVSYS_SETDICTIONARY
225 Warning min limit set previously by the
226 .Dv ENVSYS_SETDICTIONARY
229 .It Dv ENVSYS_REMOVEPROPS Pq prop_dictionary_t
233 is used to remove all properties that are currently set via the
234 .Dv ENVSYS_SETDICTIONARY
236 The values will be set to defaults, the ones that the driver uses.
238 Only one object is allowed on this dictionary:
239 .Bd -literal -offset ident
240 \*[Lt]key\*[Gt]envsys-remove-props\*[Lt]/key\*[Gt]
244 It is a boolean object and must be set to
247 .It Dv ENVSYS_SETDICTIONARY Pq prop_dictionary_t
250 is used to send a dictionary with new properties that should be
254 Only a set of predefined keywords are recognized by the kernel part.
255 The following is the property list representation
256 of a dictionary with all recognized and required keywords that
257 a sensor understands:
260 \&\*[Lt]key\&\*[Gt]description\&\*[Lt]\&/key\&\*[Gt]
261 \&\*[Lt]string\&\*[Gt]cpu temp\&\*[Lt]\&/string\&\*[Gt]
262 \&\*[Lt]key\&\*[Gt]rfact\&\*[Lt]\&/key\&\*[Gt]
263 \&\*[Lt]integer\&\*[Gt]56000\&\*[Lt]\&/integer\&\*[Gt]
264 \&\*[Lt]key\&\*[Gt]critical-capacity\&\*[Lt]\&/key\&\*[Gt]
265 \&\*[Lt]integer\&\*[Gt]10\&\*[Lt]\&/integer\&\*[Gt]
266 \&\*[Lt]key\&\*[Gt]critical-max\&\*[Lt]\&/key\&\*[Gt]
267 \&\*[Lt]integer\&\*[Gt]3400\&\*[Lt]\&/integer\&\*[Gt]
268 \&\*[Lt]key\&\*[Gt]critical-min\&\*[Lt]\&/key\&\*[Gt]
269 \&\*[Lt]integer\&\*[Gt]2800\&\*[Lt]\&/integer\&\*[Gt]
270 \&\*[Lt]key\&\*[Gt]warning-capacity\&\*[Lt]\&/key\&\*[Gt]
271 \&\*[Lt]integer\&\*[Gt]15\&\*[Lt]\&/integer\&\*[Gt]
272 \&\*[Lt]key\&\*[Gt]warning-max\&\*[Lt]\&/key\&\*[Gt]
273 \&\*[Lt]integer\&\*[Gt]3200\&\*[Lt]\&/integer\&\*[Gt]
274 \&\*[Lt]key\&\*[Gt]warning-min\&\*[Lt]\&/key\&\*[Gt]
275 \&\*[Lt]integer\&\*[Gt]2900\&\*[Lt]\&/integer\&\*[Gt]
276 \&\*[Lt]\&/dict\&\*[Gt]
279 Also if some properties in a device need to be changed, the
280 .Dq device-properties
281 dictionary must be used.
282 At this moment only the
284 property is understood.
285 This has the following structure:
288 \&\*[Lt]key\&\*[Gt]device-properties\&\*[Lt]\&/key\&\*[Gt]
290 \&\*[Lt]key\&\*[Gt]refresh-timeout\&\*[Lt]\&/key\&\*[Gt]
291 \&\*[Lt]integer\&\*[Gt]0xa\&\*[Lt]\&/integer\&\*[Gt]
292 \&\*[Lt]\&/dict\&\*[Gt]
293 \&\*[Lt]\&/dict\&\*[Gt]
296 A dictionary sent to the kernel with this
298 should have the following structure:
301 \&\*[Lt]key\&\*[Gt]device_name\&\*[Lt]\&/key\&\*[Gt]
302 \&\*[Lt]array\&\*[Gt]
304 \&\*[Lt]key\&\*[Gt]index\&\*[Lt]\&/key\&\*[Gt]
305 \&\*[Lt]string\&\*[Gt]sensor0\&\*[Lt]\&/string\&\*[Gt]
306 \&\*[Lt]key\&\*[Gt]description\&\*[Lt]\&/key\&\*[Gt]
307 \&\*[Lt]string\&\*[Gt]cpu temp\&\*[Lt]\&/string\&\*[Gt]
309 Another property for this sensor
311 \&\*[Lt]\&/dict\&\*[Gt]
313 Another dictionary for device-properties or sensor
315 \&\*[Lt]\&/array\&\*[Gt]
317 Another device as above
319 \&\*[Lt]\&/dict\&\*[Gt]
322 The named device will be an array and will contain dictionaries,
323 any dictionary needs to have the
325 object specifying the sensor that is required for the new properties.
327 If an unknown object was sent with the dictionary,
329 will be returned, or if the sensor does not support changing
330 rfact (voltage sensors) or critical/warning/capacity limits,
335 When setting a critical/warning max or min limit with the
336 .Dv ENVSYS_SETDICTIONARY
338 the user must be aware that
340 expects to have a proper unit, so the value must be converted.
343 for more information.
345 Also when setting a critical or warning capacity limit, the formula to send a
349 .Em value = (value / 100) * max value .
350 The max value is available in the sensor's dictionary.
352 The following example shows how to change the description
358 .Dv ENVSYS_SETDICTIONARY
364 prop_dictionary_t global_dict, sensor_dict;
369 global_dict = prop_dictionary_create();
370 sensor_dict = prop_dictionary_create();
371 array = prop_array_create();
373 if (!prop_dictionary_set(global_dict, "aiboost0", array))
374 err(EINVAL, "prop_dictionary_set global");
376 obj = prop_string_create_cstring_nocopy("sensor0");
378 !prop_dictionary_set(dict, "index", obj))
379 err(EINVAL, "sensor index");
381 prop_object_release(obj);
383 /* new description */
384 obj = prop_string_create_cstring_nocopy("CPU temp");
386 !prop_dictionary_set(dict, "description", obj))
387 err(EINVAL, "new description");
389 prop_object_release(obj);
391 if (!prop_array_add(array, sensor_dict))
392 err(EINVAL, "prop_array_add");
394 if ((fd = open(_DEV_SYSMON, O_RDWR)) == \-1)
395 err(EXIT_FAILURE, "open")
397 /* we are done, send the dictionary */
398 error = prop_dictionary_send_ioctl(global_dict,
400 ENVSYS_SETDICTIONARY);
401 prop_object_release(array);
402 prop_object_release(global_dict);
414 framework first appeared in
418 framework first appeared in
423 framework was implemented by
424 .An Juan Romero Pardines .
425 Additional input on the design was provided by many
427 developers around the world.
431 framework was implemented by Jason R. Thorpe, Tim Rightnour,