xref: /onnv-gate/usr/src/cmd/picl/plugins/sun4u/taco/envd/envd.h (revision 0:68f95e015346)
1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_ENVD_H
28*0Sstevel@tonic-gate #define	_ENVD_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/types.h>
33*0Sstevel@tonic-gate #include <libintl.h>
34*0Sstevel@tonic-gate 
35*0Sstevel@tonic-gate #ifdef	__cplusplus
36*0Sstevel@tonic-gate extern "C" {
37*0Sstevel@tonic-gate #endif
38*0Sstevel@tonic-gate 
39*0Sstevel@tonic-gate #define	SENSORPOLL_INTERVAL	4
40*0Sstevel@tonic-gate #define	INTERRUPTPOLL_INTERVAL	2
41*0Sstevel@tonic-gate #define	WARNING_INTERVAL	30
42*0Sstevel@tonic-gate #define	SHUTDOWN_INTERVAL	60
43*0Sstevel@tonic-gate #define	ENV_CONF_FILE		"envmodel.conf"
44*0Sstevel@tonic-gate #define	TUNABLE_CONF_FILE	"piclenvd.conf"
45*0Sstevel@tonic-gate #define	PM_DEVICE		"/dev/pm"
46*0Sstevel@tonic-gate #define	SHUTDOWN_CMD		"/usr/sbin/shutdown -y -g 60 -i 5"
47*0Sstevel@tonic-gate #define	PICL_PLUGINS_NODE	"plugins"
48*0Sstevel@tonic-gate #define	PICL_ENVIRONMENTAL_NODE	"environmental"
49*0Sstevel@tonic-gate 
50*0Sstevel@tonic-gate /*
51*0Sstevel@tonic-gate  * ADC Sample of ADM in Khz, currently 11.2 KHz
52*0Sstevel@tonic-gate  */
53*0Sstevel@tonic-gate #define	ADCSAMPLE		11250
54*0Sstevel@tonic-gate 
55*0Sstevel@tonic-gate /*
56*0Sstevel@tonic-gate  * Taco Platform Details
57*0Sstevel@tonic-gate  */
58*0Sstevel@tonic-gate #define	MAX_SENSORS	3
59*0Sstevel@tonic-gate #define	MAX_FANS	2
60*0Sstevel@tonic-gate #define	MAX_HWMS	1
61*0Sstevel@tonic-gate 
62*0Sstevel@tonic-gate /*
63*0Sstevel@tonic-gate  * ADM1031 Hardware Monitor IDs
64*0Sstevel@tonic-gate  * Used as index into arrays
65*0Sstevel@tonic-gate  */
66*0Sstevel@tonic-gate #define	CPU_HWM_ID	0
67*0Sstevel@tonic-gate 
68*0Sstevel@tonic-gate #define	CPU_HWM_DEVFS	\
69*0Sstevel@tonic-gate 	"/devices/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:control"
70*0Sstevel@tonic-gate 
71*0Sstevel@tonic-gate #define	HWM_FAN1	0
72*0Sstevel@tonic-gate #define	HWM_FAN2	1
73*0Sstevel@tonic-gate 
74*0Sstevel@tonic-gate /*
75*0Sstevel@tonic-gate  * Taco sensor IDs as used in FRUID segment
76*0Sstevel@tonic-gate  */
77*0Sstevel@tonic-gate #define	SYS_IN_SENSOR_ID	0
78*0Sstevel@tonic-gate #define	CPU_SENSOR_ID		1
79*0Sstevel@tonic-gate #define	INT_AMB_SENSOR_ID	2
80*0Sstevel@tonic-gate #define	MAX_SENSOR_ID		2
81*0Sstevel@tonic-gate 
82*0Sstevel@tonic-gate /*
83*0Sstevel@tonic-gate  * Taco fan IDs used in FRUID segment
84*0Sstevel@tonic-gate  */
85*0Sstevel@tonic-gate #define	SYSTEM_FAN_ID		0
86*0Sstevel@tonic-gate #define	CPU_FAN_ID		1
87*0Sstevel@tonic-gate #define	MAX_FAN_ID		1
88*0Sstevel@tonic-gate 
89*0Sstevel@tonic-gate /*
90*0Sstevel@tonic-gate  * devfs-path for various fans and their min/max speeds
91*0Sstevel@tonic-gate  */
92*0Sstevel@tonic-gate #define	ENV_CPU_FAN_DEVFS	\
93*0Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_2"
94*0Sstevel@tonic-gate #define	ENV_SYSTEM_FAN_DEVFS	\
95*0Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:fan_1"
96*0Sstevel@tonic-gate 
97*0Sstevel@tonic-gate #define	FAN_RANGE_DEFAULT	4
98*0Sstevel@tonic-gate #define	CPU_FAN_SPEED_MIN	14
99*0Sstevel@tonic-gate #define	CPU_FAN_SPEED_MAX	100
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate #define	SYSTEM_OUT_FAN_SPEED_MIN	14
102*0Sstevel@tonic-gate #define	SYSTEM_OUT_FAN_SPEED_MAX	100
103*0Sstevel@tonic-gate 
104*0Sstevel@tonic-gate #define	SYSTEM_INTAKE_FAN_SPEED_MIN	14
105*0Sstevel@tonic-gate #define	SYSTEM_INTAKE_FAN_SPEED_MAX	100
106*0Sstevel@tonic-gate 
107*0Sstevel@tonic-gate 
108*0Sstevel@tonic-gate 
109*0Sstevel@tonic-gate /*
110*0Sstevel@tonic-gate  * devfs-path for various temperature sensors and CPU platform path
111*0Sstevel@tonic-gate  */
112*0Sstevel@tonic-gate #define	SENSOR_CPU_DIE_DEVFS	\
113*0Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_2"
114*0Sstevel@tonic-gate #define	SENSOR_SYS_IN_DEVFS	\
115*0Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:remote_1"
116*0Sstevel@tonic-gate #define	SENSOR_INT_AMB_DEVFS	\
117*0Sstevel@tonic-gate 	"/pci@1e,600000/isa@7/i2c@0,320/hardware-monitor@0,5c:local"
118*0Sstevel@tonic-gate 
119*0Sstevel@tonic-gate /*
120*0Sstevel@tonic-gate  * Temperature type
121*0Sstevel@tonic-gate  */
122*0Sstevel@tonic-gate typedef int16_t tempr_t;
123*0Sstevel@tonic-gate 
124*0Sstevel@tonic-gate 
125*0Sstevel@tonic-gate /*
126*0Sstevel@tonic-gate  * Fan names
127*0Sstevel@tonic-gate  */
128*0Sstevel@tonic-gate #define	ENV_SYSTEM_INTAKE_FAN	"intake-fan"
129*0Sstevel@tonic-gate #define	ENV_SYSTEM_OUT_FAN	"outtake-fan"
130*0Sstevel@tonic-gate #define	ENV_CPU_FAN		"cpu-fan"
131*0Sstevel@tonic-gate #define	ENV_SYSTEM_IN_OUT_FANS	"intake-outtake-fans"
132*0Sstevel@tonic-gate 
133*0Sstevel@tonic-gate /*
134*0Sstevel@tonic-gate  * Sensor names
135*0Sstevel@tonic-gate  */
136*0Sstevel@tonic-gate #define	SENSOR_CPU_DIE		"cpu"
137*0Sstevel@tonic-gate #define	SENSOR_SYS_IN		"sys-in"
138*0Sstevel@tonic-gate #define	SENSOR_INT_AMB		"int-amb"
139*0Sstevel@tonic-gate 
140*0Sstevel@tonic-gate /* Bit Map of ADM 1031 Status 1/2 Registers */
141*0Sstevel@tonic-gate enum adm1031 {
142*0Sstevel@tonic-gate 	FANFAULT = 0x2,
143*0Sstevel@tonic-gate 	REMOTEHIGH = 0x4,
144*0Sstevel@tonic-gate 	REMOTELOW = 0x8,
145*0Sstevel@tonic-gate 	REMOTETHERN = 0x10,
146*0Sstevel@tonic-gate 	LHIGH = 0x40,
147*0Sstevel@tonic-gate 	LLOW  = 0x80
148*0Sstevel@tonic-gate } adm1031_t;
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate /* ADM Stat 1/2 Mask */
151*0Sstevel@tonic-gate enum adm1031Mask {
152*0Sstevel@tonic-gate 	STAT1MASK = 0xdc,
153*0Sstevel@tonic-gate 	STAT2MASK = 0x1c
154*0Sstevel@tonic-gate } adm1031Mask_t;
155*0Sstevel@tonic-gate 
156*0Sstevel@tonic-gate /*
157*0Sstevel@tonic-gate  * ES segment related structures
158*0Sstevel@tonic-gate  */
159*0Sstevel@tonic-gate typedef struct id_off {
160*0Sstevel@tonic-gate 	uint_t id;
161*0Sstevel@tonic-gate 	ushort_t offset;
162*0Sstevel@tonic-gate } id_off_t;
163*0Sstevel@tonic-gate 
164*0Sstevel@tonic-gate typedef struct fan_ctl_pair {
165*0Sstevel@tonic-gate 	uchar_t tMin;
166*0Sstevel@tonic-gate 	uchar_t tRange;
167*0Sstevel@tonic-gate } fan_ctl_pair_t;
168*0Sstevel@tonic-gate 
169*0Sstevel@tonic-gate typedef struct Correction_Pair {
170*0Sstevel@tonic-gate 	uchar_t measured;
171*0Sstevel@tonic-gate 	uchar_t corrected;
172*0Sstevel@tonic-gate } Correction_Pair_t;
173*0Sstevel@tonic-gate 
174*0Sstevel@tonic-gate #define	ES_SENSOR_POLICY_LEN	8
175*0Sstevel@tonic-gate #define	ES_CORRECTION_PAIRS	12
176*0Sstevel@tonic-gate 
177*0Sstevel@tonic-gate typedef struct sensor_ctrl_blk {
178*0Sstevel@tonic-gate 	uchar_t  high_power_off;
179*0Sstevel@tonic-gate 	uchar_t  high_shutdown;
180*0Sstevel@tonic-gate 	uchar_t  high_warning;
181*0Sstevel@tonic-gate 	uchar_t  low_warning;
182*0Sstevel@tonic-gate 	uchar_t  low_shutdown;
183*0Sstevel@tonic-gate 	uchar_t  low_power_off;
184*0Sstevel@tonic-gate 	uchar_t  sensorPolicy[ES_SENSOR_POLICY_LEN];
185*0Sstevel@tonic-gate 	ushort_t correctionEntries;
186*0Sstevel@tonic-gate 	Correction_Pair_t correctionPair[ES_CORRECTION_PAIRS];
187*0Sstevel@tonic-gate } sensor_ctrl_blk_t;
188*0Sstevel@tonic-gate 
189*0Sstevel@tonic-gate 
190*0Sstevel@tonic-gate #define	ES_FAN_CTL_PAIRS	4
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate typedef struct fan_ctrl_blk {
193*0Sstevel@tonic-gate 	uchar_t  tSpinUp;
194*0Sstevel@tonic-gate 	uchar_t  minFanSpeed;
195*0Sstevel@tonic-gate 	ushort_t setPoint;
196*0Sstevel@tonic-gate 	ushort_t loopGain;
197*0Sstevel@tonic-gate 	ushort_t loopBias;
198*0Sstevel@tonic-gate 	ushort_t hysteresis;
199*0Sstevel@tonic-gate 	ushort_t fanViabTestInt;
200*0Sstevel@tonic-gate 	ushort_t fanViabTestThresh;
201*0Sstevel@tonic-gate 	ushort_t grossFanThresh;
202*0Sstevel@tonic-gate 	uchar_t no_ctl_pairs;
203*0Sstevel@tonic-gate 	fan_ctl_pair_t fan_ctl_pairs[ES_FAN_CTL_PAIRS];
204*0Sstevel@tonic-gate } fan_ctrl_blk_t;
205*0Sstevel@tonic-gate 
206*0Sstevel@tonic-gate #define	TEMP_IN_WARNING_RANGE(val, sensorp) \
207*0Sstevel@tonic-gate 	((val) > (sensorp)->es_ptr->high_warning || \
208*0Sstevel@tonic-gate 		(val) < (char)((sensorp)->es_ptr->low_warning))
209*0Sstevel@tonic-gate 
210*0Sstevel@tonic-gate #define	TEMP_IN_SHUTDOWN_RANGE(val, sensorp) \
211*0Sstevel@tonic-gate 	((val) > (sensorp)->es_ptr->high_shutdown || \
212*0Sstevel@tonic-gate 		(val) < (char)((sensorp)->es_ptr->low_shutdown))
213*0Sstevel@tonic-gate 
214*0Sstevel@tonic-gate /*
215*0Sstevel@tonic-gate  * Macros to fetch 16 and 32 bit data from unaligned address
216*0Sstevel@tonic-gate  */
217*0Sstevel@tonic-gate #define	GET_UNALIGN16(addr)	\
218*0Sstevel@tonic-gate 	(((*(uint8_t *)addr) << 8) | *((uint8_t *)addr + 1))
219*0Sstevel@tonic-gate 
220*0Sstevel@tonic-gate #define	GET_UNALIGN32(addr)	\
221*0Sstevel@tonic-gate 	(((*(uint8_t *)addr) << 24) | (*((uint8_t *)addr + 1) << 16) | \
222*0Sstevel@tonic-gate 	((*((uint8_t *)addr + 2)) << 8) | (*((uint8_t *)addr + 3)))
223*0Sstevel@tonic-gate 
224*0Sstevel@tonic-gate /*
225*0Sstevel@tonic-gate  * SEEPROM section header layout and location
226*0Sstevel@tonic-gate  */
227*0Sstevel@tonic-gate typedef struct {
228*0Sstevel@tonic-gate 	uint8_t		header_tag;		/* section header tag */
229*0Sstevel@tonic-gate 	uint8_t		header_version[2];	/* header version (msb) */
230*0Sstevel@tonic-gate 	uint8_t		header_length;		/* header length */
231*0Sstevel@tonic-gate 	uint8_t		header_crc8;		/* crc8 */
232*0Sstevel@tonic-gate 	uint8_t		segment_count;		/* total number of segments */
233*0Sstevel@tonic-gate } section_layout_t;
234*0Sstevel@tonic-gate 
235*0Sstevel@tonic-gate #define	SECTION_HDR_OFFSET	0x1800
236*0Sstevel@tonic-gate #define	SECTION_HDR_TAG		0x08
237*0Sstevel@tonic-gate #define	SECTION_HDR_VER		0x0001
238*0Sstevel@tonic-gate #define	SECTION_HDR_LENGTH	0x06
239*0Sstevel@tonic-gate 
240*0Sstevel@tonic-gate /*
241*0Sstevel@tonic-gate  * SEEPROM segment header layout
242*0Sstevel@tonic-gate  */
243*0Sstevel@tonic-gate typedef struct {
244*0Sstevel@tonic-gate 	uint16_t	name;		/* segment name */
245*0Sstevel@tonic-gate 	uint16_t	descriptor[2];	/* descriptor (msb) */
246*0Sstevel@tonic-gate 	uint16_t	offset;		/* segment data offset */
247*0Sstevel@tonic-gate 	uint16_t	length;		/* segment length */
248*0Sstevel@tonic-gate } segment_layout_t;
249*0Sstevel@tonic-gate 
250*0Sstevel@tonic-gate #define	ENVSEG_NAME		0x4553	/* environmental segment name */
251*0Sstevel@tonic-gate #define	ENVSEG_VERSION		2	/* environmental segment version */
252*0Sstevel@tonic-gate 
253*0Sstevel@tonic-gate #define	SENSOR_WARN		1
254*0Sstevel@tonic-gate #define	SENSOR_OK		0
255*0Sstevel@tonic-gate 
256*0Sstevel@tonic-gate /*
257*0Sstevel@tonic-gate  * SEEPROM environmental segment header layout
258*0Sstevel@tonic-gate  */
259*0Sstevel@tonic-gate typedef struct {
260*0Sstevel@tonic-gate 	uint16_t	sensor_id[2];	/* unique sensor ID (on this FRU) */
261*0Sstevel@tonic-gate 	uint16_t	offset;		/* sensor data record offset */
262*0Sstevel@tonic-gate } envseg_sensor_t;
263*0Sstevel@tonic-gate 
264*0Sstevel@tonic-gate typedef struct {
265*0Sstevel@tonic-gate 	uint8_t		version;	/* envseg version */
266*0Sstevel@tonic-gate 	uint8_t		sensor_count;	/* total number of sensor records */
267*0Sstevel@tonic-gate 	envseg_sensor_t	sensors[1];	/* sensor table (variable length) */
268*0Sstevel@tonic-gate } envseg_layout_t;
269*0Sstevel@tonic-gate 
270*0Sstevel@tonic-gate /*
271*0Sstevel@tonic-gate  * FRU envseg list
272*0Sstevel@tonic-gate  */
273*0Sstevel@tonic-gate typedef struct fruenvseg {
274*0Sstevel@tonic-gate 	struct fruenvseg	*next;		/* next entry */
275*0Sstevel@tonic-gate 	char			*fru;		/* FRU SEEPROM path */
276*0Sstevel@tonic-gate 	void			*envsegbufp;	/* envseg data buffer */
277*0Sstevel@tonic-gate 	int			envseglen;	/* envseg length */
278*0Sstevel@tonic-gate } fruenvseg_t;
279*0Sstevel@tonic-gate 
280*0Sstevel@tonic-gate #define	I2C_DEVFS	"/devices/pci@1e,600000/isa@7/i2c@0,320"
281*0Sstevel@tonic-gate #define	MBFRU_DEV	"/motherboard-fru-prom@0,a8:motherboard-fru-prom"
282*0Sstevel@tonic-gate #define	FRU_SEEPROM_NAME	"motherboard-fru-prom"
283*0Sstevel@tonic-gate /*
284*0Sstevel@tonic-gate  * Table data structures
285*0Sstevel@tonic-gate  */
286*0Sstevel@tonic-gate typedef struct {
287*0Sstevel@tonic-gate 	int32_t	x;
288*0Sstevel@tonic-gate 	int32_t	y;
289*0Sstevel@tonic-gate } point_t;
290*0Sstevel@tonic-gate 
291*0Sstevel@tonic-gate typedef struct {
292*0Sstevel@tonic-gate 	int	nentries;
293*0Sstevel@tonic-gate 	point_t	*xymap;
294*0Sstevel@tonic-gate } table_t;
295*0Sstevel@tonic-gate 
296*0Sstevel@tonic-gate /*
297*0Sstevel@tonic-gate  * Temperature sensor related data structure
298*0Sstevel@tonic-gate  */
299*0Sstevel@tonic-gate typedef struct env_sensor {
300*0Sstevel@tonic-gate 	char		*name;			/* sensor name */
301*0Sstevel@tonic-gate 	char		*devfs_path;		/* sensor device devfs path */
302*0Sstevel@tonic-gate 	sensor_ctrl_blk_t *es_ptr;
303*0Sstevel@tonic-gate 	uchar_t		id;
304*0Sstevel@tonic-gate 	int		hwm_id;
305*0Sstevel@tonic-gate 	void		*fanp;
306*0Sstevel@tonic-gate 	int		fd;			/* device file descriptor */
307*0Sstevel@tonic-gate 	int		error;			/* error flag */
308*0Sstevel@tonic-gate 	boolean_t 	present;		/* sensor present */
309*0Sstevel@tonic-gate 	tempr_t		cur_temp;		/* current temperature */
310*0Sstevel@tonic-gate 	time_t		warning_tstamp;		/* last warning time (secs) */
311*0Sstevel@tonic-gate 	time_t		shutdown_tstamp;	/* shutdown temp time (secs) */
312*0Sstevel@tonic-gate 	boolean_t 	shutdown_initiated;	/* shutdown initated */
313*0Sstevel@tonic-gate 	table_t		*crtbl;			/* Correction table */
314*0Sstevel@tonic-gate 	tempr_t		tmin;
315*0Sstevel@tonic-gate } env_sensor_t;
316*0Sstevel@tonic-gate 
317*0Sstevel@tonic-gate extern	env_sensor_t *sensor_lookup(char *sensor_name);
318*0Sstevel@tonic-gate extern	int get_temperature(env_sensor_t *, tempr_t *);
319*0Sstevel@tonic-gate 
320*0Sstevel@tonic-gate /*
321*0Sstevel@tonic-gate  * Fan information data structure
322*0Sstevel@tonic-gate  */
323*0Sstevel@tonic-gate typedef int fanspeed_t;
324*0Sstevel@tonic-gate 
325*0Sstevel@tonic-gate typedef struct env_fan {
326*0Sstevel@tonic-gate 	char		*name;			/* fan name */
327*0Sstevel@tonic-gate 	char		*devfs_path;		/* fan device devfs path */
328*0Sstevel@tonic-gate 	fan_ctrl_blk_t	*es_ptr;
329*0Sstevel@tonic-gate 	uchar_t		id;
330*0Sstevel@tonic-gate 	fanspeed_t	speed_min;		/* minimum speed */
331*0Sstevel@tonic-gate 	fanspeed_t	speed_max;		/* maximum speed */
332*0Sstevel@tonic-gate 	int		forced_speed;		/* forced (fixed) speed */
333*0Sstevel@tonic-gate 	int		fd;			/* device file descriptor */
334*0Sstevel@tonic-gate 	boolean_t	present;		/* fan present */
335*0Sstevel@tonic-gate 	int		speedrange;		/* speed range N */
336*0Sstevel@tonic-gate 	int		fanstat;		/* Fan status */
337*0Sstevel@tonic-gate 	uint8_t		cspeed;			/* Current speed (tach) */
338*0Sstevel@tonic-gate 	uint8_t		lspeed;			/* Last speed (tach) */
339*0Sstevel@tonic-gate 	int		conccnt;		/* Concurrent tach count */
340*0Sstevel@tonic-gate } env_fan_t;
341*0Sstevel@tonic-gate 
342*0Sstevel@tonic-gate /*
343*0Sstevel@tonic-gate  * Tuneables
344*0Sstevel@tonic-gate  */
345*0Sstevel@tonic-gate typedef struct env_tuneable {
346*0Sstevel@tonic-gate 	char		*name;
347*0Sstevel@tonic-gate 	char		type;
348*0Sstevel@tonic-gate 	void		*value;
349*0Sstevel@tonic-gate 	int		(*rfunc)(ptree_rarg_t *, void *);
350*0Sstevel@tonic-gate 	int		(*wfunc)(ptree_warg_t *, const void *);
351*0Sstevel@tonic-gate 	int		nbytes;
352*0Sstevel@tonic-gate 	picl_prophdl_t proph;
353*0Sstevel@tonic-gate } env_tuneable_t;
354*0Sstevel@tonic-gate 
355*0Sstevel@tonic-gate extern	env_fan_t *fan_lookup(char *fan_name);
356*0Sstevel@tonic-gate extern	int get_fan_speed(env_fan_t *, fanspeed_t *);
357*0Sstevel@tonic-gate extern	int set_fan_speed(env_fan_t *, fanspeed_t);
358*0Sstevel@tonic-gate 
359*0Sstevel@tonic-gate extern int env_debug;
360*0Sstevel@tonic-gate extern void envd_log(int pri, const char *fmt, ...);
361*0Sstevel@tonic-gate 
362*0Sstevel@tonic-gate /*
363*0Sstevel@tonic-gate  * Various messages
364*0Sstevel@tonic-gate  */
365*0Sstevel@tonic-gate #define	ENVD_PLUGIN_INIT_FAILED		\
366*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: initialization failed!\n")
367*0Sstevel@tonic-gate 
368*0Sstevel@tonic-gate #define	ENVD_PICL_SETUP_FAILED		\
369*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: PICL setup failed!\n")
370*0Sstevel@tonic-gate 
371*0Sstevel@tonic-gate #define	PM_THREAD_CREATE_FAILED		\
372*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: pmthr thread creation failed!\n")
373*0Sstevel@tonic-gate 
374*0Sstevel@tonic-gate #define	PM_THREAD_EXITING		\
375*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: pmthr exiting! errno:%d %s\n")
376*0Sstevel@tonic-gate 
377*0Sstevel@tonic-gate #define	ENVTHR_THREAD_CREATE_FAILED		\
378*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: envthr thread creation failed!\n")
379*0Sstevel@tonic-gate 
380*0Sstevel@tonic-gate #define	ENV_SHUTDOWN_MSG		\
381*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \
382*0Sstevel@tonic-gate 	"limits (%d...%d). Shutting down the system.\n")
383*0Sstevel@tonic-gate 
384*0Sstevel@tonic-gate #define	ENV_WARNING_MSG			\
385*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: '%s' sensor temperature %d outside safe " \
386*0Sstevel@tonic-gate 	"operating limits (%d...%d).\n")
387*0Sstevel@tonic-gate 
388*0Sstevel@tonic-gate #define	ENV_FAN_OPEN_FAIL		\
389*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open '%s' fan path:%s errno:%d %s\n")
390*0Sstevel@tonic-gate 
391*0Sstevel@tonic-gate #define	ENV_SENSOR_OPEN_FAIL		\
392*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open '%s' sensor path:%s errno:%d %s\n")
393*0Sstevel@tonic-gate 
394*0Sstevel@tonic-gate #define	ENV_SENSOR_ACCESS_FAIL		\
395*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't access '%s' sensor errno:%d %s\n")
396*0Sstevel@tonic-gate 
397*0Sstevel@tonic-gate #define	ENV_SENSOR_ACCESS_OK		\
398*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: '%s' sensor is accessible now.\n")
399*0Sstevel@tonic-gate 
400*0Sstevel@tonic-gate #define	ENV_FRU_OPEN_FAIL		\
401*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open FRU SEEPROM path:%s errno:%d %s\n")
402*0Sstevel@tonic-gate 
403*0Sstevel@tonic-gate #define	ENV_FRU_BAD_ENVSEG		\
404*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: version mismatch or environmental segment " \
405*0Sstevel@tonic-gate 	"header too short in FRU SEEPROM %s\n")
406*0Sstevel@tonic-gate 
407*0Sstevel@tonic-gate #define	ENV_FRU_BAD_SENSOR_ENTRY	\
408*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: discarding bad sensor entry (sensor_id " \
409*0Sstevel@tonic-gate 	"%x sensor '%s') in FRU SEEPROM %s\n")
410*0Sstevel@tonic-gate 
411*0Sstevel@tonic-gate #define	ENV_FRU_SENSOR_MAP_NOMEM	\
412*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: out of memory, discarding sensor map for " \
413*0Sstevel@tonic-gate 	"sensor_id %x (sensor '%s') in FRU SEEPROM %s\n")
414*0Sstevel@tonic-gate 
415*0Sstevel@tonic-gate #define	ENV_ADM_OPEN_FAIL		\
416*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: can't open hwm path:%s errno:%d %s\n")
417*0Sstevel@tonic-gate 
418*0Sstevel@tonic-gate #define	ENV_ADM_MANUAL_MODE \
419*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: Cannot change the ADM Chip to Manual mode")
420*0Sstevel@tonic-gate 
421*0Sstevel@tonic-gate #define	ENV_ADM_AUTO_MODE \
422*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: Cannot change the ADM Chip to Auto mode")
423*0Sstevel@tonic-gate 
424*0Sstevel@tonic-gate #define	ENV_FAN_FAULT \
425*0Sstevel@tonic-gate 	gettext("SUNW_piclenvd: ADM %s, Fan %s Fault")
426*0Sstevel@tonic-gate #ifdef	__cplusplus
427*0Sstevel@tonic-gate }
428*0Sstevel@tonic-gate #endif
429*0Sstevel@tonic-gate 
430*0Sstevel@tonic-gate #endif	/* _ENVD_H */
431