xref: /titanic_44/usr/src/uts/sun4u/lw8/sys/sgenv.h (revision 921e7e07108d1e3f09fecb1805fa2c79bb584fed)
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 2000 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef _SYS_SGENV_H
28 #define	_SYS_SGENV_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * sgenv.h - Serengeti Environmental Driver
38  *
39  * This header file contains the environmental definitions for
40  * the Serengeti platform.
41  *
42  * It contains all the information necessary to obtain the required
43  * data from the kstats which export the environmental data. The
44  * following information is exported.
45  *
46  *	o Board status information
47  *	o Keyswitch position
48  *	o Environmental Readings
49  */
50 
51 #include <sys/time.h>		/* hrtime_t */
52 #include <sys/sgenv_tag.h>	/* TagID information */
53 #include <sys/sgfrutypes.h>	/* HPU type information */
54 #include <sys/serengeti.h>
55 
56 #define	SGENV_DRV_NAME		"sgenv"
57 
58 /*
59  * Board Status Information
60  * ========================
61  */
62 
63 /* name of kstat returning board status info */
64 #define	SG_BOARD_STATUS_KSTAT_NAME	"sg_board_status"
65 
66 /* Masks to determine which LEDs are on */
67 #define	SG_HOTPLUG_LED_MASK	0x1
68 #define	SG_FAULT_LED_MASK	0x2
69 #define	SG_POWER_LED_MASK	0x4
70 
71 /*
72  * Calculate the number of boards, who's info readings that were
73  * returned by this kstat
74  */
75 #define	SGENV_NUM_BOARD_READINGS(ksp)	((ksp)->ks_data_size /	\
76 						(sizeof (sg_board_info_t)))
77 
78 typedef union sg_led {
79 	struct {
80 		int	_pad	:29,	/* MSB */
81 			power	:1,
82 			fault	:1,
83 			hotplug	:1;	/* LSB */
84 	} status;
85 
86 	int led_status;
87 
88 } sg_led_t;
89 
90 typedef struct sg_board_info {
91 	int	node_id;
92 	int	board_num;
93 
94 	int	condition;	/* see <sbd_cond_t> in <sbdp_ioctl.h> */
95 	int	assigned;
96 	int	claimed;
97 	int	present;	/* 1 if board is present in Domain */
98 
99 	sg_led_t	led;
100 
101 } sg_board_info_t;
102 
103 
104 /*
105  * Keyswitch Information
106  * =====================
107  */
108 
109 /* name of kstat returning keyswitch info */
110 #define	SG_KEYSWITCH_KSTAT_NAME		"sg_keyswitch"
111 
112 /*
113  * Kstat structure used to pass Keyswitch data to userland.
114  *
115  * The position is stored in the 32-bit integer value of the
116  * kstat_named_t union <keyswitch_position>.
117  *
118  * (i.e.  to get the position - read keyswitch_position.value.ui32)
119  */
120 typedef struct {
121 	kstat_named_t	keyswitch_position;	/* position */
122 
123 } sg_keyswitch_kstat_t;
124 
125 
126 /*
127  * Environmental Information
128  * =========================
129  *
130  * the environmental kstat exports an array of env_sensor_t structs
131  */
132 
133 #define	SG_ENV_INFO_KSTAT_NAME		"sg_env_info"
134 
135 
136 /*
137  * sd_infostamp access macros and return values
138  *
139  * N.b.	None of the values need shifting.  This means the
140  *	UTC time in nanoseconds since The Epoch has, at best,
141  *	a resolution of c.256 nanoseconds (since the lo-order
142  *	c.8-bits are overlaid with other information).
143  */
144 
145 #define	SG_INFO_TIMESTATUS(info)	((int)((info) & _SG_INFO_TIMSTSMSK))
146 #define	SG_INFO_VALUESTATUS(info)	((int)((info) & _SG_INFO_VALSTSMSK))
147 #define	SG_INFO_NANOSECONDS(info) ((hrtime_t)((info) & _SG_INFO_TIMVALMSK))
148 
149 #define	_SG_INFO_TIMSTSMSK		((sensor_status_t)0x0F)
150 #define	SG_INFO_TIME_OK			0x00  /* always 0 */
151 #define	SG_INFO_TIME_NOT_KNOWN		0x01
152 #define	SG_INFO_TIME_NOT_AVAILABLE	0x02
153 
154 #define	_SG_INFO_VALSTSMSK		((sensor_status_t)0xF0)
155 #define	SG_INFO_VALUE_OK		0x00  /* always 0 */
156 #define	SG_INFO_VALUE_NOT_POSSIBLE	0x10
157 #define	SG_INFO_VALUE_NOT_AVAILABLE	0x20
158 
159 #define	_SG_INFO_TIMVALMSK  \
160 		(((hrtime_t)~0) & ~(_SG_INFO_TIMSTSMSK | _SG_INFO_VALSTSMSK))
161 
162 
163 /* Calculate the number of sensor readings that were returned by this kstat */
164 #define	SGENV_NUM_ENV_READINGS(ksp)	((ksp)->ks_data_size /	\
165 						(sizeof (env_sensor_t)))
166 
167 /* used to calculate the status of a sensor reading from <sd_status> */
168 #define	SG_STATUS_SHIFT				16
169 #define	SG_STATUS_MASK				0xFFFF
170 #define	SG_PREV_STATUS_MASK			0xFFFF0000
171 
172 #define	SG_GET_SENSOR_STATUS(status)		((status) & SG_STATUS_MASK)
173 #define	SG_GET_PREV_SENSOR_STATUS(status)	((status) >> SG_STATUS_SHIFT)
174 
175 #define	SG_SET_SENSOR_STATUS(status, value) \
176 		status &= ~SG_STATUS_MASK; \
177 		status |= ((value) & SG_STATUS_MASK)
178 
179 #define	SG_SET_PREV_SENSOR_STATUS(status, value) \
180 		status &= ~SG_PREV_STATUS_MASK; \
181 		status |= (((value) & SG_STATUS_MASK) << SG_STATUS_SHIFT)
182 
183 
184 typedef int32_t		sensor_data_t;
185 typedef hrtime_t	sensor_status_t;
186 
187 /*
188  * The possible states a sensor reading can be in.
189  */
190 typedef enum env_sensor_status {
191 	SG_SENSOR_STATUS_OK		= 0x01,
192 	SG_SENSOR_STATUS_LO_WARN	= 0x02,
193 	SG_SENSOR_STATUS_HI_WARN	= 0x04,
194 	SG_SENSOR_STATUS_LO_DANGER	= 0x08,
195 	SG_SENSOR_STATUS_HI_DANGER	= 0x10,
196 	SG_SENSOR_STATUS_FAN_OFF	= 0x100,
197 	SG_SENSOR_STATUS_FAN_LOW	= 0x200,
198 	SG_SENSOR_STATUS_FAN_HIGH	= 0x400,
199 	SG_SENSOR_STATUS_FAN_FAIL	= 0x800,
200 	SG_SENSOR_STATUS_UNKNOWN	= 0x1000
201 
202 } env_sensor_status_t;
203 
204 
205 /*
206  * The raw env. info. kstat is made up of an array of these structures.
207  */
208 typedef struct env_sensor {
209 	sensor_id_t		sd_id;		/* defined in sensor_tag.h */
210 	sensor_data_t		sd_value;
211 	sensor_data_t		sd_lo;
212 	sensor_data_t		sd_hi;
213 	sensor_data_t		sd_lo_warn;
214 	sensor_data_t		sd_hi_warn;
215 	sensor_status_t		sd_infostamp;
216 	env_sensor_status_t	sd_status;
217 
218 } env_sensor_t;
219 
220 
221 /*
222  * Events Information
223  * ==================
224  */
225 #define	SGENV_FAN_SPEED_UNKNOWN		(-1)
226 #define	SGENV_FAN_SPEED_OFF		0
227 #define	SGENV_FAN_SPEED_LOW		1
228 #define	SGENV_FAN_SPEED_HIGH		2
229 
230 #define	SGENV_FAN_SPEED_UNKNOWN_STR	"Unknown"
231 #define	SGENV_FAN_SPEED_OFF_STR		"Off"
232 #define	SGENV_FAN_SPEED_LOW_STR		"Low"
233 #define	SGENV_FAN_SPEED_HIGH_STR	"High"
234 
235 #define	SGENV_EVENT_MSG_OK		"returned to the normal operating range"
236 #define	SGENV_EVENT_MSG_LO_WARN		"dropped below low warning threshold"
237 #define	SGENV_EVENT_MSG_HI_WARN		"exceeded high warning threshold"
238 #define	SGENV_EVENT_MSG_LO_DANGER	"dropped below low warning limit"
239 #define	SGENV_EVENT_MSG_HI_DANGER	"exceeded high warning limit"
240 #define	SGENV_EVENT_MSG_UNKNOWN		"changed to an unknown status"
241 
242 
243 #ifdef	__cplusplus
244 }
245 #endif
246 
247 #endif	/* _SYS_SGENV_H */
248