xref: /titanic_41/usr/src/uts/sun4u/sys/envmon.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_ENVMON_H
28 #define	_SYS_ENVMON_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/ioccom.h>
37 
38 /*
39  * environmental monitoring ioctls
40  *
41  * there are two types of environmental monitor:
42  * sensors	- these provide a value for the environmental property
43  * indicators	- these provide a status of "within range" or "out of range"
44  *
45  * for any given environmental property, a particular platform is likely
46  * to support either a sensor or an indicator
47  *
48  * a reserved value is used to signify that a particular sensor value is
49  * not available
50  */
51 
52 /* reserved values to signify "value unavailable" */
53 #define	ENVMON_VAL_UNAVAILABLE	((int16_t)(-32768))
54 
55 /*
56  * The ability of a sensor or indicator to deliver a value is encapsulated
57  * in the sensor_status field.
58  * The following sensor_status bit fields are defined
59  */
60 #define	ENVMON_SENSOR_OK	0	/* this one's a value */
61 #define	ENVMON_NOT_PRESENT	1
62 #define	ENVMON_INACCESSIBLE	2	/* e.g. i2c bus problem */
63 
64 /*
65  * Some drivers may implement the older lomv interface in addition to
66  * the ioctls defined here. To avoid a clash with values from older
67  * interfaces, ioctls defined here start high in the available range.
68  */
69 #define	ENVMON_BASE		200
70 
71 #define	ENVMONIOCSYSINFO	_IOR('a',  ENVMON_BASE + 0, envmon_sysinfo_t)
72 #define	ENVMONIOCVOLTSENSOR	_IOWR('a', ENVMON_BASE + 1, envmon_sensor_t)
73 #define	ENVMONIOCAMPSENSOR	_IOWR('a', ENVMON_BASE + 2, envmon_sensor_t)
74 #define	ENVMONIOCTEMPSENSOR	_IOWR('a', ENVMON_BASE + 3, envmon_sensor_t)
75 #define	ENVMONIOCFAN		_IOWR('a', ENVMON_BASE + 4, envmon_fan_t)
76 #define	ENVMONIOCVOLTIND	_IOWR('a', ENVMON_BASE + 5, envmon_indicator_t)
77 #define	ENVMONIOCAMPIND		_IOWR('a', ENVMON_BASE + 6, envmon_indicator_t)
78 #define	ENVMONIOCTEMPIND	_IOWR('a', ENVMON_BASE + 7, envmon_indicator_t)
79 #define	ENVMONIOCFANIND		_IOWR('a', ENVMON_BASE + 8, envmon_indicator_t)
80 #define	ENVMONIOCGETLED		_IOWR('a', ENVMON_BASE + 9, envmon_led_info_t)
81 #define	ENVMONIOCSETLED		_IOW('a',  ENVMON_BASE + 10, envmon_led_ctl_t)
82 #define	ENVMONIOCHPU		_IOWR('a', ENVMON_BASE + 11, envmon_hpu_t)
83 #define	ENVMONIOCGETKEYSW	_IOR('a',  ENVMON_BASE + 12, envmon_keysw_pos_t)
84 #define	ENVMONIOCGETALARM	\
85 		_IOWR('a', ENVMON_BASE + 13, envmon_alarm_info_t)
86 #define	ENVMONIOCSETALARM	_IOWR('a', ENVMON_BASE + 14, envmon_alarm_ctl_t)
87 
88 /* field length for text identifiers */
89 #define	ENVMON_MAXNAMELEN	32
90 
91 typedef struct {
92 	char			name[ENVMON_MAXNAMELEN];
93 } envmon_handle_t;
94 
95 /*
96  * Some structures include threshold fields.
97  * Where a particular threshold is not defined for a given sensor,
98  * the reserved value ENVMON_VAL_UNAVAILABLE is returned.
99  */
100 typedef struct {
101 	int16_t			warning;
102 	int16_t			shutdown;
103 	int16_t			poweroff;
104 } envmon_thresholds_t;
105 
106 /*
107  * id identifies the fru to be accessed.
108  * next_id returns the id for the next component of the type implied by
109  * the ioctl command. If there are no more frus in this sequence,
110  * next_id is set to an empty string.
111  * If id is set to an empty string on entry, next_id returns the first id.
112  * In this case, sensor_status will be returned as ENVMON_NOT_PRESENT.
113  */
114 typedef struct {
115 	envmon_handle_t		id;
116 	uint16_t		sensor_status;
117 	int16_t			value;		/* sensor reading */
118 	envmon_thresholds_t	lowthresholds;
119 	envmon_thresholds_t	highthresholds;
120 	envmon_handle_t		next_id;
121 } envmon_sensor_t;
122 
123 typedef struct {
124 	envmon_handle_t	id;
125 	uint16_t		sensor_status;
126 	uint16_t		condition;	/* 0 = within limits */
127 	envmon_handle_t	next_id;
128 } envmon_indicator_t;
129 
130 typedef struct {
131 	envmon_handle_t	id;
132 	uint16_t		sensor_status;
133 	uint16_t		speed;
134 	char			units[ENVMON_MAXNAMELEN];
135 	envmon_thresholds_t	lowthresholds;
136 	envmon_handle_t		next_id;
137 } envmon_fan_t;
138 
139 /*
140  * Values for led_state
141  */
142 #define	ENVMON_LED_OFF		0
143 #define	ENVMON_LED_ON		1
144 #define	ENVMON_LED_BLINKING	2
145 #define	ENVMON_LED_FLASHING	3
146 
147 /*
148  * Values for the hue of the leds
149  */
150 #define	ENVMON_LED_CLR_NONE	((int8_t)(-1))
151 #define	ENVMON_LED_CLR_ANY	0
152 #define	ENVMON_LED_CLR_WHITE	1
153 #define	ENVMON_LED_CLR_BLUE	2
154 #define	ENVMON_LED_CLR_GREEN	3
155 #define	ENVMON_LED_CLR_AMBER	4
156 #define	ENVMON_LED_CLR_RED	5
157 
158 typedef struct {
159 	envmon_handle_t		id;
160 	uint16_t		sensor_status;
161 	int8_t			led_state;
162 	int8_t			led_color;
163 	envmon_handle_t		next_id;
164 } envmon_led_info_t;
165 
166 typedef struct {
167 	envmon_handle_t		id;
168 	int8_t			led_state;
169 } envmon_led_ctl_t;
170 
171 /*
172  * Values for alarm_state
173  */
174 #define	ENVMON_ALARM_OFF	0
175 #define	ENVMON_ALARM_ON		1
176 
177 typedef struct {
178 	envmon_handle_t		id;
179 	uint16_t		sensor_status;
180 	int8_t			alarm_state;
181 	envmon_handle_t		next_id;
182 } envmon_alarm_info_t;
183 
184 typedef struct {
185 	envmon_handle_t		id;
186 	int8_t			alarm_state;
187 } envmon_alarm_ctl_t;
188 
189 /*
190  * Values for fru_status
191  */
192 #define	ENVMON_FRU_NOT_PRESENT	0
193 #define	ENVMON_FRU_PRESENT	1
194 #define	ENVMON_FRU_FAULT	2
195 #define	ENVMON_FRU_DOWNLOAD	3	/* flash update or download active */
196 
197 typedef struct {
198 	envmon_handle_t		id;
199 	uint8_t			sensor_status;
200 	uint8_t			fru_status;
201 	envmon_handle_t		next_id;
202 } envmon_hpu_t;
203 
204 /*
205  * env_sysinto_t is used to return limits on various item types
206  */
207 typedef struct {
208 	uint16_t	maxVoltSens;	/* max number of voltage sensors */
209 	uint16_t	maxVoltInd;	/* max number of voltage indicators */
210 	uint16_t	maxAmpSens;	/* max number of current sensors */
211 	uint16_t	maxAmpInd;	/* max number of circuit breakers */
212 	uint16_t	maxTempSens;	/* max number of temperature sensors */
213 	uint16_t	maxTempInd;	/* max number of temp'r indicators */
214 	uint16_t	maxFanSens;	/* max number of fan speed sensors */
215 	uint16_t	maxFanInd;	/* max number of fan indicators */
216 	uint16_t	maxLED;		/* max number of LEDs */
217 	uint16_t	maxHPU;		/* max number of Hot Pluggable Units */
218 } envmon_sysinfo_t;
219 
220 /*
221  * envmon_keysw_t is used to return the current value of the
222  * keyswitch (if fitted)
223  */
224 typedef enum envmon_keysw_pos {
225 	ENVMON_KEYSW_POS_UNKNOWN	= 0,
226 	ENVMON_KEYSW_POS_NORMAL,
227 	ENVMON_KEYSW_POS_DIAG,
228 	ENVMON_KEYSW_POS_LOCKED,
229 	ENVMON_KEYSW_POS_OFF
230 } envmon_keysw_pos_t;
231 
232 #ifdef	__cplusplus
233 }
234 #endif
235 
236 #endif	/* _SYS_ENVMON_H */
237