FreeBSD/Linux Kernel Cross Reference
sys/sys/envsys.h
1 /* $NetBSD: envsys.h,v 1.7.16.1 2007/10/15 05:09:54 riz 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_SWATTHOUR,
95 ENVSYS_SAMPHOUR,
96 ENVSYS_INDICATOR, /* boolean indicator */
97 ENVSYS_INTEGER, /* generic integer return */
98 ENVSYS_DRIVE, /* disk status */
99 ENVSYS_NSENSORS
100 };
101
102 /* drive status */
103 #define ENVSYS_DRIVE_EMPTY 1
104 #define ENVSYS_DRIVE_READY 2
105 #define ENVSYS_DRIVE_POWERUP 3
106 #define ENVSYS_DRIVE_ONLINE 4
107 #define ENVSYS_DRIVE_IDLE 5
108 #define ENVSYS_DRIVE_ACTIVE 6
109 #define ENVSYS_DRIVE_REBUILD 7
110 #define ENVSYS_DRIVE_POWERDOWN 8
111 #define ENVSYS_DRIVE_FAIL 9
112 #define ENVSYS_DRIVE_PFAIL 10
113
114 #ifdef ENVSYSUNITNAMES
115 static const char *envsysunitnames[] = {
116 "degC", "RPM", "VAC", "V", "Ohms", "W",
117 "A", "Wh", "Ah", "bool", "integer", "drive", "Unk"
118 };
119 static const char * const envsysdrivestatus[] = {
120 "unknown", "empty", "ready", "powering up", "online", "idle", "active",
121 "rebuilding", "powering down", "failed", "degraded"
122 };
123 #endif
124
125
126 /* flags for validflags */
127 #define ENVSYS_FVALID 0x00000001 /* sensor is valid */
128 #define ENVSYS_FCURVALID 0x00000002 /* cur for this sens is valid */
129 #define ENVSYS_FMINVALID 0x00000004 /* min for this sens is valid */
130 #define ENVSYS_FMAXVALID 0x00000008 /* max for this sens is valid */
131 #define ENVSYS_FAVGVALID 0x00000010 /* avg for this sens is valid */
132 #define ENVSYS_FFRACVALID 0x00000020 /* display fraction of max */
133
134 #define ENVSYS_GTREDATA _IOWR('E', 2, envsys_temp_data_t)
135
136 /* set and check sensor info */
137
138 struct envsys_basic_info {
139 u_int sensor; /* sensor number */
140 u_int units; /* type of sensor */
141 char desc[33]; /* sensor description */
142 u_int rfact; /* for volts, (int)(factor x 10^4) */
143 u_int rpms; /* for fans, set nominal RPMs */
144 u_int32_t validflags; /* sensor valid flags */
145 };
146 typedef struct envsys_basic_info envsys_temp_info_t;
147 typedef struct envsys_basic_info envsys_rpm_info_t;
148 typedef struct envsys_basic_info envsys_electrical_info_t;
149 typedef struct envsys_basic_info envsys_basic_info_t;
150
151 #define ENVSYS_STREINFO _IOWR('E', 3, envsys_temp_info_t)
152 #define ENVSYS_GTREINFO _IOWR('E', 4, envsys_temp_info_t)
153
154 #endif /* _SYS_ENVSYS_H_ */
Cache object: 307d7b78cd2161a40972cf6e9c8e8791
|