xref: /titanic_52/usr/src/lib/libprtdiag/common/kstat.c (revision 03831d35f7499c87d51205817c93e9a8d42c4bae)
1*03831d35Sstevel /*
2*03831d35Sstevel  * CDDL HEADER START
3*03831d35Sstevel  *
4*03831d35Sstevel  * The contents of this file are subject to the terms of the
5*03831d35Sstevel  * Common Development and Distribution License, Version 1.0 only
6*03831d35Sstevel  * (the "License").  You may not use this file except in compliance
7*03831d35Sstevel  * with the License.
8*03831d35Sstevel  *
9*03831d35Sstevel  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*03831d35Sstevel  * or http://www.opensolaris.org/os/licensing.
11*03831d35Sstevel  * See the License for the specific language governing permissions
12*03831d35Sstevel  * and limitations under the License.
13*03831d35Sstevel  *
14*03831d35Sstevel  * When distributing Covered Code, include this CDDL HEADER in each
15*03831d35Sstevel  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*03831d35Sstevel  * If applicable, add the following below this CDDL HEADER, with the
17*03831d35Sstevel  * fields enclosed by brackets "[]" replaced with your own identifying
18*03831d35Sstevel  * information: Portions Copyright [yyyy] [name of copyright owner]
19*03831d35Sstevel  *
20*03831d35Sstevel  * CDDL HEADER END
21*03831d35Sstevel  */
22*03831d35Sstevel /*
23*03831d35Sstevel  * Copyright (c) 1999 by Sun Microsystems, Inc.
24*03831d35Sstevel  * All rights reserved.
25*03831d35Sstevel  */
26*03831d35Sstevel 
27*03831d35Sstevel #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*03831d35Sstevel 
29*03831d35Sstevel #include <stdio.h>
30*03831d35Sstevel #include <stdlib.h>
31*03831d35Sstevel #include <unistd.h>
32*03831d35Sstevel #include <ctype.h>
33*03831d35Sstevel #include <string.h>
34*03831d35Sstevel #include <kvm.h>
35*03831d35Sstevel #include <varargs.h>
36*03831d35Sstevel #include <errno.h>
37*03831d35Sstevel #include <time.h>
38*03831d35Sstevel #include <dirent.h>
39*03831d35Sstevel #include <fcntl.h>
40*03831d35Sstevel #include <sys/param.h>
41*03831d35Sstevel #include <sys/stat.h>
42*03831d35Sstevel #include <sys/types.h>
43*03831d35Sstevel #include <sys/utsname.h>
44*03831d35Sstevel #include <sys/openpromio.h>
45*03831d35Sstevel #include <kstat.h>
46*03831d35Sstevel #include <libintl.h>
47*03831d35Sstevel #include <syslog.h>
48*03831d35Sstevel #include <sys/dkio.h>
49*03831d35Sstevel #include "pdevinfo.h"
50*03831d35Sstevel #include "display.h"
51*03831d35Sstevel #include "pdevinfo_sun4u.h"
52*03831d35Sstevel #include "display_sun4u.h"
53*03831d35Sstevel #include "libprtdiag.h"
54*03831d35Sstevel 
55*03831d35Sstevel /*
56*03831d35Sstevel  * This module does the reading and interpreting of sun4u system
57*03831d35Sstevel  * kstats. These kstats are created by the following drivers:
58*03831d35Sstevel  * fhc, environ, sysctrl. Each board in the tree should have
59*03831d35Sstevel  * kstats created for it.  There are also system wide kstats that
60*03831d35Sstevel  * are created.
61*03831d35Sstevel  */
62*03831d35Sstevel void
63*03831d35Sstevel read_platform_kstats(Sys_tree *tree, struct system_kstat_data *sys_kstat,
64*03831d35Sstevel 	struct bd_kstat_data *bdp, struct envctrl_kstat_data *ep)
65*03831d35Sstevel {
66*03831d35Sstevel 	Board_node	*bnode;
67*03831d35Sstevel 	kstat_ctl_t	*kc;
68*03831d35Sstevel 	kstat_t		*ksp;
69*03831d35Sstevel 	kstat_named_t	*knp;
70*03831d35Sstevel 	int		i;
71*03831d35Sstevel 	struct hp_info	*hp;
72*03831d35Sstevel 
73*03831d35Sstevel #ifdef lint
74*03831d35Sstevel 	ep = ep;
75*03831d35Sstevel #endif
76*03831d35Sstevel 	if ((kc = kstat_open()) == NULL) {
77*03831d35Sstevel 		return;
78*03831d35Sstevel 	}
79*03831d35Sstevel 
80*03831d35Sstevel 	/* For each board in the system, read the kstats for it. */
81*03831d35Sstevel 	for (bnode = tree->bd_list; bnode != NULL; bnode = bnode->next) {
82*03831d35Sstevel 		int board;
83*03831d35Sstevel 
84*03831d35Sstevel 		/*
85*03831d35Sstevel 		 * Kstat instances numbers are set by fhc, ac, simmstat,
86*03831d35Sstevel 		 * and environ drivers based on their board# property.
87*03831d35Sstevel 		 */
88*03831d35Sstevel 		board = bnode->board_num;
89*03831d35Sstevel 		bdp = &sys_kstat->bd_ksp_list[board];
90*03831d35Sstevel 
91*03831d35Sstevel 		/* Try to find an FHC instance for this board number */
92*03831d35Sstevel 		ksp = kstat_lookup(kc, UNIX, board, FHC_KSTAT_NAME);
93*03831d35Sstevel 
94*03831d35Sstevel 		/* Atempt to read the FHC kstat */
95*03831d35Sstevel 		if ((ksp != NULL) && (kstat_read(kc, ksp, NULL) == -1)) {
96*03831d35Sstevel 			ksp = NULL;
97*03831d35Sstevel 		}
98*03831d35Sstevel 
99*03831d35Sstevel 		/* Now read out the data if the kstat read OK */
100*03831d35Sstevel 		if (ksp != NULL) {
101*03831d35Sstevel 			/*
102*03831d35Sstevel 			 * We set the kstats_ok flag to good here. If we
103*03831d35Sstevel 			 * fail one of the data reads, we set it to bad.
104*03831d35Sstevel 			 */
105*03831d35Sstevel 			bdp->fhc_kstats_ok = 1;
106*03831d35Sstevel 
107*03831d35Sstevel 			/*
108*03831d35Sstevel 			 * For each data value, If the Kstat named struct
109*03831d35Sstevel 			 * is found, then get the data out.
110*03831d35Sstevel 			 */
111*03831d35Sstevel 			knp = kstat_data_lookup(ksp, CSR_KSTAT_NAMED);
112*03831d35Sstevel 			if (knp != NULL) {
113*03831d35Sstevel 				bdp->fhc_csr = knp->value.ul;
114*03831d35Sstevel 			} else {
115*03831d35Sstevel 				bdp->fhc_kstats_ok = 0;
116*03831d35Sstevel 			}
117*03831d35Sstevel 			knp = kstat_data_lookup(ksp, BSR_KSTAT_NAMED);
118*03831d35Sstevel 			if (knp != NULL) {
119*03831d35Sstevel 				bdp->fhc_bsr = knp->value.ul;
120*03831d35Sstevel 			} else {
121*03831d35Sstevel 				bdp->fhc_kstats_ok = 0;
122*03831d35Sstevel 			}
123*03831d35Sstevel 		}
124*03831d35Sstevel 
125*03831d35Sstevel 		/* Try to find an AC instance for this board number */
126*03831d35Sstevel 		ksp = kstat_lookup(kc, UNIX, board, AC_KSTAT_NAME);
127*03831d35Sstevel 
128*03831d35Sstevel 		/* Attempt to read the AC kstat. */
129*03831d35Sstevel 		if ((ksp != NULL) && (kstat_read(kc, ksp, NULL) == -1)) {
130*03831d35Sstevel 			ksp = NULL;
131*03831d35Sstevel 		}
132*03831d35Sstevel 
133*03831d35Sstevel 		/* If the AC kstat exists, try to read the data from it. */
134*03831d35Sstevel 		if (ksp != NULL) {
135*03831d35Sstevel 			/*
136*03831d35Sstevel 			 * We set the kstats_ok flag to good here. If we
137*03831d35Sstevel 			 * fail one of the data reads, we set it to bad.
138*03831d35Sstevel 			 */
139*03831d35Sstevel 			bdp->ac_kstats_ok = 1;
140*03831d35Sstevel 			bdp->ac_memstat_ok = 1;
141*03831d35Sstevel 
142*03831d35Sstevel 			/*
143*03831d35Sstevel 			 * For each data value, If the Kstat named struct
144*03831d35Sstevel 			 * is found, then get the data out.
145*03831d35Sstevel 			 */
146*03831d35Sstevel 
147*03831d35Sstevel 			knp = kstat_data_lookup(ksp, MEMCTL_KSTAT_NAMED);
148*03831d35Sstevel 			if (knp != NULL) {
149*03831d35Sstevel 				bdp->ac_memctl = knp->value.ull;
150*03831d35Sstevel 			} else {
151*03831d35Sstevel 				bdp->ac_kstats_ok = 0;
152*03831d35Sstevel 			}
153*03831d35Sstevel 
154*03831d35Sstevel 			knp = kstat_data_lookup(ksp, MEMDECODE0_KSTAT_NAMED);
155*03831d35Sstevel 			if (knp != NULL) {
156*03831d35Sstevel 				bdp->ac_memdecode[0] = knp->value.ull;
157*03831d35Sstevel 			} else {
158*03831d35Sstevel 				bdp->ac_kstats_ok = 0;
159*03831d35Sstevel 			}
160*03831d35Sstevel 
161*03831d35Sstevel 			knp = kstat_data_lookup(ksp, MEMDECODE1_KSTAT_NAMED);
162*03831d35Sstevel 			if (knp != NULL) {
163*03831d35Sstevel 				bdp->ac_memdecode[1] = knp->value.ull;
164*03831d35Sstevel 			} else {
165*03831d35Sstevel 				bdp->ac_kstats_ok = 0;
166*03831d35Sstevel 			}
167*03831d35Sstevel 
168*03831d35Sstevel 			knp = kstat_data_lookup(ksp, BANK_0_KSTAT_NAMED);
169*03831d35Sstevel 			if (knp != NULL) {
170*03831d35Sstevel 				bdp->mem_stat[0].status = knp->value.c[0];
171*03831d35Sstevel 				bdp->mem_stat[0].condition = knp->value.c[1];
172*03831d35Sstevel 			} else {
173*03831d35Sstevel 				bdp->ac_memstat_ok = 0;
174*03831d35Sstevel 			}
175*03831d35Sstevel 
176*03831d35Sstevel 			knp = kstat_data_lookup(ksp, BANK_1_KSTAT_NAMED);
177*03831d35Sstevel 			if (knp != NULL) {
178*03831d35Sstevel 				bdp->mem_stat[1].status = knp->value.c[0];
179*03831d35Sstevel 				bdp->mem_stat[1].condition = knp->value.c[1];
180*03831d35Sstevel 			} else {
181*03831d35Sstevel 				bdp->ac_memstat_ok = 0;
182*03831d35Sstevel 			}
183*03831d35Sstevel 
184*03831d35Sstevel 		}
185*03831d35Sstevel 
186*03831d35Sstevel 		/* Try to find an simmstat instance for this board number */
187*03831d35Sstevel 		ksp = kstat_lookup(kc, UNIX, board, SIMMSTAT_KSTAT_NAME);
188*03831d35Sstevel 
189*03831d35Sstevel 		if (ksp != NULL) {
190*03831d35Sstevel 			if (kstat_read(kc, ksp, NULL) == -1) {
191*03831d35Sstevel 				bdp->simmstat_kstats_ok = 0;
192*03831d35Sstevel 			} else {
193*03831d35Sstevel 				bdp->simmstat_kstats_ok = 1;
194*03831d35Sstevel 				(void) memcpy(&bdp->simm_status, ksp->ks_data,
195*03831d35Sstevel 					sizeof (bdp->simm_status));
196*03831d35Sstevel 			}
197*03831d35Sstevel 		}
198*03831d35Sstevel 
199*03831d35Sstevel 		/* Try to find an overtemp kstat instance for this board */
200*03831d35Sstevel 		ksp = kstat_lookup(kc, UNIX, board, OVERTEMP_KSTAT_NAME);
201*03831d35Sstevel 
202*03831d35Sstevel 		if (ksp != NULL) {
203*03831d35Sstevel 			if (kstat_read(kc, ksp, NULL) == -1) {
204*03831d35Sstevel 				bdp->temp_kstat_ok = 0;
205*03831d35Sstevel 			} else {
206*03831d35Sstevel 				bdp->temp_kstat_ok = 1;
207*03831d35Sstevel 				(void) memcpy(&bdp->tempstat, ksp->ks_data,
208*03831d35Sstevel 					sizeof (bdp->tempstat));
209*03831d35Sstevel 				/* XXX - this is for 2.5.1 testing.  remove */
210*03831d35Sstevel 				if (sizeof (bdp->tempstat) > ksp->ks_data_size)
211*03831d35Sstevel 					bdp->tempstat.trend = TREND_UNKNOWN;
212*03831d35Sstevel 			}
213*03831d35Sstevel 		}
214*03831d35Sstevel 	}
215*03831d35Sstevel 
216*03831d35Sstevel 	/* Read the kstats for the system control board */
217*03831d35Sstevel 	ksp = kstat_lookup(kc, UNIX, 0, SYSCTRL_KSTAT_NAME);
218*03831d35Sstevel 
219*03831d35Sstevel 	if ((ksp != NULL) && (kstat_read(kc, ksp, NULL) == -1)) {
220*03831d35Sstevel 		sys_kstat->sys_kstats_ok = 0;
221*03831d35Sstevel 		ksp = NULL;
222*03831d35Sstevel 	}
223*03831d35Sstevel 
224*03831d35Sstevel 	if (ksp != NULL) {
225*03831d35Sstevel 		sys_kstat->sys_kstats_ok = 1;
226*03831d35Sstevel 
227*03831d35Sstevel 		knp = kstat_data_lookup(ksp, CSR_KSTAT_NAMED);
228*03831d35Sstevel 		if (knp != NULL) {
229*03831d35Sstevel 			sys_kstat->sysctrl = knp->value.c[0];
230*03831d35Sstevel 		} else {
231*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
232*03831d35Sstevel 		}
233*03831d35Sstevel 
234*03831d35Sstevel 		knp = kstat_data_lookup(ksp, STAT1_KSTAT_NAMED);
235*03831d35Sstevel 		if (knp != NULL) {
236*03831d35Sstevel 			sys_kstat->sysstat1 = knp->value.c[0];
237*03831d35Sstevel 		} else {
238*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
239*03831d35Sstevel 		}
240*03831d35Sstevel 
241*03831d35Sstevel 		knp = kstat_data_lookup(ksp, STAT2_KSTAT_NAMED);
242*03831d35Sstevel 		if (knp != NULL) {
243*03831d35Sstevel 			sys_kstat->sysstat2 = knp->value.c[0];
244*03831d35Sstevel 		} else {
245*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
246*03831d35Sstevel 		}
247*03831d35Sstevel 
248*03831d35Sstevel 		knp = kstat_data_lookup(ksp, CLK_FREQ2_KSTAT_NAMED);
249*03831d35Sstevel 		if (knp != NULL) {
250*03831d35Sstevel 			sys_kstat->clk_freq2 = knp->value.c[0];
251*03831d35Sstevel 		} else {
252*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
253*03831d35Sstevel 		}
254*03831d35Sstevel 
255*03831d35Sstevel 		knp = kstat_data_lookup(ksp, FAN_KSTAT_NAMED);
256*03831d35Sstevel 		if (knp != NULL) {
257*03831d35Sstevel 			sys_kstat->fan_status = knp->value.c[0];
258*03831d35Sstevel 		} else {
259*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
260*03831d35Sstevel 		}
261*03831d35Sstevel 
262*03831d35Sstevel 		knp = kstat_data_lookup(ksp, KEY_KSTAT_NAMED);
263*03831d35Sstevel 		if (knp != NULL) {
264*03831d35Sstevel 			sys_kstat->keysw_status = knp->value.c[0];
265*03831d35Sstevel 		} else {
266*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
267*03831d35Sstevel 		}
268*03831d35Sstevel 
269*03831d35Sstevel 		knp = kstat_data_lookup(ksp, POWER_KSTAT_NAMED);
270*03831d35Sstevel 		if (knp != NULL) {
271*03831d35Sstevel 			sys_kstat->power_state =
272*03831d35Sstevel 				(enum power_state)knp->value.l;
273*03831d35Sstevel 		} else {
274*03831d35Sstevel 			sys_kstat->sys_kstats_ok = 0;
275*03831d35Sstevel 		}
276*03831d35Sstevel 
277*03831d35Sstevel 		knp = kstat_data_lookup(ksp, CLK_VER_KSTAT_NAME);
278*03831d35Sstevel 		if (knp != NULL) {
279*03831d35Sstevel 			sys_kstat->clk_ver = knp->value.c[0];
280*03831d35Sstevel 		} else {
281*03831d35Sstevel 			/*
282*03831d35Sstevel 			 * the clock version register only appears
283*03831d35Sstevel 			 * on new clock boards
284*03831d35Sstevel 			 */
285*03831d35Sstevel 			sys_kstat->clk_ver = 0;
286*03831d35Sstevel 		}
287*03831d35Sstevel 
288*03831d35Sstevel 	}
289*03831d35Sstevel 
290*03831d35Sstevel 	/* Read the kstats for the power supply stats */
291*03831d35Sstevel 	ksp = kstat_lookup(kc, UNIX, 0, PSSHAD_KSTAT_NAME);
292*03831d35Sstevel 
293*03831d35Sstevel 	if ((ksp != NULL) && (kstat_read(kc, ksp, NULL) != -1)) {
294*03831d35Sstevel 		sys_kstat->psstat_kstat_ok = 1;
295*03831d35Sstevel 		(void) memcpy(&sys_kstat->ps_shadow[0], ksp->ks_data,
296*03831d35Sstevel 			sizeof (sys_kstat->ps_shadow));
297*03831d35Sstevel 	} else {
298*03831d35Sstevel 		sys_kstat->psstat_kstat_ok = 0;
299*03831d35Sstevel 	}
300*03831d35Sstevel 
301*03831d35Sstevel 	/* read the overtemp kstat for the system control board */
302*03831d35Sstevel 	/* Try to find an overtemp kstat instance for this board */
303*03831d35Sstevel 	ksp = kstat_lookup(kc, UNIX, CLOCK_BOARD_INDEX, OVERTEMP_KSTAT_NAME);
304*03831d35Sstevel 
305*03831d35Sstevel 	if (ksp != NULL) {
306*03831d35Sstevel 		if (kstat_read(kc, ksp, NULL) == -1) {
307*03831d35Sstevel 			sys_kstat->temp_kstat_ok = 0;
308*03831d35Sstevel 		} else {
309*03831d35Sstevel 			sys_kstat->temp_kstat_ok = 1;
310*03831d35Sstevel 			(void) memcpy(&sys_kstat->tempstat, ksp->ks_data,
311*03831d35Sstevel 				sizeof (sys_kstat->tempstat));
312*03831d35Sstevel 			/* XXX - this is for 2.5.1 testing.  remove */
313*03831d35Sstevel 			if (sizeof (sys_kstat->tempstat) > ksp->ks_data_size)
314*03831d35Sstevel 				sys_kstat->tempstat.trend = TREND_UNKNOWN;
315*03831d35Sstevel 		}
316*03831d35Sstevel 	}
317*03831d35Sstevel 
318*03831d35Sstevel 	/* Read the reset-info kstat from one of the boards. */
319*03831d35Sstevel 	ksp = kstat_lookup(kc, UNIX, 0, RESETINFO_KSTAT_NAME);
320*03831d35Sstevel 
321*03831d35Sstevel 	if (ksp == NULL) {
322*03831d35Sstevel 		sys_kstat->reset_kstats_ok = 0;
323*03831d35Sstevel 	} else if (kstat_read(kc, ksp, NULL) == -1) {
324*03831d35Sstevel 		sys_kstat->reset_kstats_ok = 0;
325*03831d35Sstevel 	} else {
326*03831d35Sstevel 		sys_kstat->reset_kstats_ok = 1;
327*03831d35Sstevel 		(void) memcpy(&sys_kstat->reset_info, ksp->ks_data,
328*03831d35Sstevel 			sizeof (sys_kstat->reset_info));
329*03831d35Sstevel 	}
330*03831d35Sstevel 
331*03831d35Sstevel 	/* read kstats for hotplugged boards */
332*03831d35Sstevel 	for (i = 0, hp = &sys_kstat->hp_info[0]; i < MAX_BOARDS; i++, hp++) {
333*03831d35Sstevel 		ksp = kstat_lookup(kc, UNIX, i, BDLIST_KSTAT_NAME);
334*03831d35Sstevel 
335*03831d35Sstevel 		if (ksp == NULL) {
336*03831d35Sstevel 			continue;
337*03831d35Sstevel 		}
338*03831d35Sstevel 
339*03831d35Sstevel 		if (kstat_read(kc, ksp, NULL) == -1) {
340*03831d35Sstevel 			hp->kstat_ok = 0;
341*03831d35Sstevel 		} else {
342*03831d35Sstevel 			hp->kstat_ok = 1;
343*03831d35Sstevel 			(void) memcpy(&hp->bd_info, ksp->ks_data,
344*03831d35Sstevel 				sizeof (hp->bd_info));
345*03831d35Sstevel 		}
346*03831d35Sstevel 	}
347*03831d35Sstevel 
348*03831d35Sstevel 	/* read in the kstat for the fault list. */
349*03831d35Sstevel 	ksp = kstat_lookup(kc, UNIX, 0, FT_LIST_KSTAT_NAME);
350*03831d35Sstevel 
351*03831d35Sstevel 	if (ksp == NULL) {
352*03831d35Sstevel 		sys_kstat->ft_kstat_ok = 0;
353*03831d35Sstevel 	} else {
354*03831d35Sstevel 		if (kstat_read(kc, ksp, NULL) == -1) {
355*03831d35Sstevel 			perror("kstat read");
356*03831d35Sstevel 			sys_kstat->ft_kstat_ok = 0;
357*03831d35Sstevel 			return;
358*03831d35Sstevel 		}
359*03831d35Sstevel 
360*03831d35Sstevel 		sys_kstat->nfaults = ksp->ks_data_size /
361*03831d35Sstevel 			sizeof (struct ft_list);
362*03831d35Sstevel 
363*03831d35Sstevel 		sys_kstat->ft_array =
364*03831d35Sstevel 			(struct ft_list *)malloc(ksp->ks_data_size);
365*03831d35Sstevel 
366*03831d35Sstevel 		if (sys_kstat->ft_array == NULL) {
367*03831d35Sstevel 			perror("Malloc");
368*03831d35Sstevel 			exit(2);
369*03831d35Sstevel 		}
370*03831d35Sstevel 		sys_kstat->ft_kstat_ok = 1;
371*03831d35Sstevel 		(void) memcpy(sys_kstat->ft_array, ksp->ks_data,
372*03831d35Sstevel 			ksp->ks_data_size);
373*03831d35Sstevel 	}
374*03831d35Sstevel }
375*03831d35Sstevel 
376*03831d35Sstevel /*
377*03831d35Sstevel  * This function does the reading and interpreting of sun4u system
378*03831d35Sstevel  * kstats. These kstats are created by the following drivers:
379*03831d35Sstevel  * fhc, environ, sysctrl. Each board in the tree should have
380*03831d35Sstevel  * kstats created for it.  There are also system wide kstats that
381*03831d35Sstevel  * are created.
382*03831d35Sstevel  */
383*03831d35Sstevel void
384*03831d35Sstevel read_sun4u_kstats(Sys_tree *tree, struct system_kstat_data *sys_kstat)
385*03831d35Sstevel {
386*03831d35Sstevel #if 0
387*03831d35Sstevel 	Board_node 	*bnode;
388*03831d35Sstevel 	kstat_t		*ksp;
389*03831d35Sstevel 	kstat_named_t	*knp;
390*03831d35Sstevel 	struct hp_info *hp;
391*03831d35Sstevel 	struct envctrltwo_kstat_data *ecp;
392*03831d35Sstevel #endif
393*03831d35Sstevel 	kstat_ctl_t 	*kc;
394*03831d35Sstevel 	int		i;
395*03831d35Sstevel 	struct bd_kstat_data *bdp;
396*03831d35Sstevel 	struct envctrl_kstat_data *ep;
397*03831d35Sstevel 
398*03831d35Sstevel 	if ((kc = kstat_open()) == NULL) {
399*03831d35Sstevel 		return;
400*03831d35Sstevel 	}
401*03831d35Sstevel #ifdef lint
402*03831d35Sstevel 	kc = kc;
403*03831d35Sstevel #endif
404*03831d35Sstevel 
405*03831d35Sstevel 	/* Initialize the kstats structure */
406*03831d35Sstevel 	sys_kstat->sys_kstats_ok = 0;
407*03831d35Sstevel 	sys_kstat->temp_kstat_ok = 0;
408*03831d35Sstevel 	sys_kstat->reset_kstats_ok = 0;
409*03831d35Sstevel 	sys_kstat->ft_kstat_ok = 0;
410*03831d35Sstevel 	sys_kstat->envctrl_kstat_ok = 0;
411*03831d35Sstevel 	for (i = 0; i < MAX_BOARDS; i++) {
412*03831d35Sstevel 		bdp = &sys_kstat->bd_ksp_list[i];
413*03831d35Sstevel 		bdp->ac_kstats_ok = 0;
414*03831d35Sstevel 		bdp->fhc_kstats_ok = 0;
415*03831d35Sstevel 		bdp->simmstat_kstats_ok = 0;
416*03831d35Sstevel 		bdp->temp_kstat_ok = 0;
417*03831d35Sstevel 
418*03831d35Sstevel 		sys_kstat->hp_info[i].kstat_ok = 0;
419*03831d35Sstevel 	}
420*03831d35Sstevel 	for (i = 0; i < MAX_DEVS; i++) {
421*03831d35Sstevel 		ep = &sys_kstat->env_data;
422*03831d35Sstevel 		ep->ps_kstats[i].instance = I2C_NODEV;
423*03831d35Sstevel 		ep->fan_kstats[i].instance = I2C_NODEV;
424*03831d35Sstevel 		ep->encl_kstats[i].instance = I2C_NODEV;
425*03831d35Sstevel 	}
426*03831d35Sstevel 
427*03831d35Sstevel 	read_platform_kstats(tree, sys_kstat, bdp, ep);
428*03831d35Sstevel }
429