xref: /titanic_41/usr/src/uts/sun4u/sys/envmon.h (revision 28cdc3d776761766afeb198769d1b70ed7e0f2e1)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2005 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 #define	ENVMONIOCCHASSISSERIALNUM	\
88 		_IOR('a', ENVMON_BASE + 15, envmon_chassis_t)
89 
90 /* field length for text identifiers */
91 #define	ENVMON_MAXNAMELEN	32
92 
93 typedef struct {
94 	char			name[ENVMON_MAXNAMELEN];
95 } envmon_handle_t;
96 
97 /*
98  * Some structures include threshold fields.
99  * Where a particular threshold is not defined for a given sensor,
100  * the reserved value ENVMON_VAL_UNAVAILABLE is returned.
101  */
102 typedef struct {
103 	int16_t			warning;
104 	int16_t			shutdown;
105 	int16_t			poweroff;
106 } envmon_thresholds_t;
107 
108 /*
109  * id identifies the fru to be accessed.
110  * next_id returns the id for the next component of the type implied by
111  * the ioctl command. If there are no more frus in this sequence,
112  * next_id is set to an empty string.
113  * If id is set to an empty string on entry, next_id returns the first id.
114  * In this case, sensor_status will be returned as ENVMON_NOT_PRESENT.
115  */
116 typedef struct {
117 	envmon_handle_t		id;
118 	uint16_t		sensor_status;
119 	int16_t			value;		/* sensor reading */
120 	envmon_thresholds_t	lowthresholds;
121 	envmon_thresholds_t	highthresholds;
122 	envmon_handle_t		next_id;
123 } envmon_sensor_t;
124 
125 typedef struct {
126 	envmon_handle_t	id;
127 	uint16_t		sensor_status;
128 	uint16_t		condition;	/* 0 = within limits */
129 	envmon_handle_t	next_id;
130 } envmon_indicator_t;
131 
132 typedef struct {
133 	envmon_handle_t	id;
134 	uint16_t		sensor_status;
135 	uint16_t		speed;
136 	char			units[ENVMON_MAXNAMELEN];
137 	envmon_thresholds_t	lowthresholds;
138 	envmon_handle_t		next_id;
139 } envmon_fan_t;
140 
141 /*
142  * Values for led_state
143  */
144 #define	ENVMON_LED_OFF		0
145 #define	ENVMON_LED_ON		1
146 #define	ENVMON_LED_BLINKING	2
147 #define	ENVMON_LED_FLASHING	3
148 
149 /*
150  * Values for the hue of the leds
151  */
152 #define	ENVMON_LED_CLR_NONE	((int8_t)(-1))
153 #define	ENVMON_LED_CLR_ANY	0
154 #define	ENVMON_LED_CLR_WHITE	1
155 #define	ENVMON_LED_CLR_BLUE	2
156 #define	ENVMON_LED_CLR_GREEN	3
157 #define	ENVMON_LED_CLR_AMBER	4
158 #define	ENVMON_LED_CLR_RED	5
159 
160 typedef struct {
161 	envmon_handle_t		id;
162 	uint16_t		sensor_status;
163 	int8_t			led_state;
164 	int8_t			led_color;
165 	envmon_handle_t		next_id;
166 } envmon_led_info_t;
167 
168 typedef struct {
169 	envmon_handle_t		id;
170 	int8_t			led_state;
171 } envmon_led_ctl_t;
172 
173 /*
174  * Values for alarm_state
175  */
176 #define	ENVMON_ALARM_OFF	0
177 #define	ENVMON_ALARM_ON		1
178 
179 typedef struct {
180 	envmon_handle_t		id;
181 	uint16_t		sensor_status;
182 	int8_t			alarm_state;
183 	envmon_handle_t		next_id;
184 } envmon_alarm_info_t;
185 
186 typedef struct {
187 	envmon_handle_t		id;
188 	int8_t			alarm_state;
189 } envmon_alarm_ctl_t;
190 
191 /*
192  * Values for fru_status
193  */
194 #define	ENVMON_FRU_NOT_PRESENT	0
195 #define	ENVMON_FRU_PRESENT	1
196 #define	ENVMON_FRU_FAULT	2
197 #define	ENVMON_FRU_DOWNLOAD	3	/* flash update or download active */
198 
199 typedef struct {
200 	envmon_handle_t		id;
201 	uint8_t			sensor_status;
202 	uint8_t			fru_status;
203 	envmon_handle_t		next_id;
204 } envmon_hpu_t;
205 
206 /*
207  * env_sysinto_t is used to return limits on various item types
208  */
209 typedef struct {
210 	uint16_t	maxVoltSens;	/* max number of voltage sensors */
211 	uint16_t	maxVoltInd;	/* max number of voltage indicators */
212 	uint16_t	maxAmpSens;	/* max number of current sensors */
213 	uint16_t	maxAmpInd;	/* max number of circuit breakers */
214 	uint16_t	maxTempSens;	/* max number of temperature sensors */
215 	uint16_t	maxTempInd;	/* max number of temp'r indicators */
216 	uint16_t	maxFanSens;	/* max number of fan speed sensors */
217 	uint16_t	maxFanInd;	/* max number of fan indicators */
218 	uint16_t	maxLED;		/* max number of LEDs */
219 	uint16_t	maxHPU;		/* max number of Hot Pluggable Units */
220 } envmon_sysinfo_t;
221 
222 /*
223  * envmon_keysw_t is used to return the current value of the
224  * keyswitch (if fitted)
225  */
226 typedef enum envmon_keysw_pos {
227 	ENVMON_KEYSW_POS_UNKNOWN	= 0,
228 	ENVMON_KEYSW_POS_NORMAL,
229 	ENVMON_KEYSW_POS_DIAG,
230 	ENVMON_KEYSW_POS_LOCKED,
231 	ENVMON_KEYSW_POS_OFF
232 } envmon_keysw_pos_t;
233 
234 /*
235  * envmon_chassis_t is used to retuen the chassis serial number
236  */
237 typedef struct {
238 	char		serial_number[ENVMON_MAXNAMELEN];
239 } envmon_chassis_t;
240 
241 #ifdef	__cplusplus
242 }
243 #endif
244 
245 #endif	/* _SYS_ENVMON_H */
246