1 /* $NetBSD: envsys.h,v 1.5 2000/06/24 19:50:28 thorpej Exp $ */ 2 3 /*- 4 * Copyright (c) 1999 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Tim Rightnour and Bill Squier. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. All advertising materials mentioning features or use of this software 19 * must display the following acknowledgement: 20 * This product includes software developed by the NetBSD 21 * Foundation, Inc. and its contributors. 22 * 4. Neither the name of The NetBSD Foundation nor the names of its 23 * contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 36 * POSSIBILITY OF SUCH DAMAGE. 37 */ 38 39 #ifndef _SYS_ENVSYS_H_ 40 #define _SYS_ENVSYS_H_ 41 42 #include <sys/ioccom.h> 43 44 /* Returns API Version * 1000 */ 45 46 #define ENVSYS_VERSION _IOR('E', 0, int32_t) 47 48 /* returns the range for a particular sensor */ 49 50 struct envsys_range { 51 u_int low; 52 u_int high; 53 u_int units; /* see GTREDATA */ 54 }; 55 typedef struct envsys_range envsys_range_t; 56 57 #define ENVSYS_GRANGE _IOWR('E', 1, envsys_range_t) 58 59 /* get sensor data */ 60 61 struct envsys_tre_data { 62 u_int sensor; 63 union { /* all data is given */ 64 u_int32_t data_us; /* in microKelvins, */ 65 int32_t data_s; /* rpms, volts, amps, */ 66 } cur, min, max, avg; /* ohms, watts, etc */ 67 /* see units below */ 68 69 u_int32_t warnflags; /* warning flags */ 70 u_int32_t validflags; /* sensor valid flags */ 71 u_int units; /* type of sensor */ 72 }; 73 typedef struct envsys_tre_data envsys_temp_data_t; 74 typedef struct envsys_tre_data envsys_rpm_data_t; 75 typedef struct envsys_tre_data envsys_electrical_data_t; 76 typedef struct envsys_tre_data envsys_tre_data_t; 77 78 /* flags for warnflags */ 79 #define ENVSYS_WARN_OK 0x00000000 /* All is well */ 80 #define ENVSYS_WARN_UNDER 0x00000001 /* an under condition */ 81 #define ENVSYS_WARN_CRITUNDER 0x00000002 /* a critical under condition */ 82 #define ENVSYS_WARN_OVER 0x00000004 /* an over condition */ 83 #define ENVSYS_WARN_CRITOVER 0x00000008 /* a critical over condition */ 84 85 /* type of sensor for units */ 86 enum envsys_units { 87 ENVSYS_STEMP = 0, 88 ENVSYS_SFANRPM, 89 ENVSYS_SVOLTS_AC, 90 ENVSYS_SVOLTS_DC, 91 ENVSYS_SOHMS, 92 ENVSYS_SWATTS, 93 ENVSYS_SAMPS, 94 ENVSYS_NSENSORS, 95 }; 96 97 /* flags for validflags */ 98 #define ENVSYS_FVALID 0x00000001 /* sensor is valid */ 99 #define ENVSYS_FCURVALID 0x00000002 /* cur for this sens is valid */ 100 #define ENVSYS_FMINVALID 0x00000004 /* min for this sens is valid */ 101 #define ENVSYS_FMAXVALID 0x00000008 /* max for this sens is valid */ 102 #define ENVSYS_FAVGVALID 0x00000010 /* avg for this sens is valid */ 103 104 #define ENVSYS_GTREDATA _IOWR('E', 2, envsys_temp_data_t) 105 106 /* set and check sensor info */ 107 108 struct envsys_basic_info { 109 u_int sensor; /* sensor number */ 110 u_int units; /* type of sensor */ 111 char desc[33]; /* sensor description */ 112 u_int rfact; /* for volts, (int)(factor x 10^4) */ 113 u_int rpms; /* for fans, set nominal RPMs */ 114 u_int32_t validflags; /* sensor valid flags */ 115 }; 116 typedef struct envsys_basic_info envsys_temp_info_t; 117 typedef struct envsys_basic_info envsys_rpm_info_t; 118 typedef struct envsys_basic_info envsys_electrical_info_t; 119 typedef struct envsys_basic_info envsys_basic_info_t; 120 121 #define ENVSYS_STREINFO _IOWR('E', 3, envsys_temp_info_t) 122 #define ENVSYS_GTREINFO _IOWR('E', 4, envsys_temp_info_t) 123 124 #endif /* _SYS_ENVSYS_H_ */ 125