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