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, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22 /*
23 * Copyright (c) 1999 by Sun Microsystems, Inc.
24 * All rights reserved.
25 * Copyright (c) 2020 Peter Tribble.
26 */
27
28 #include <stdio.h>
29 #include <stdlib.h>
30 #include <unistd.h>
31 #include <ctype.h>
32 #include <string.h>
33 #include <kvm.h>
34 #include <varargs.h>
35 #include <errno.h>
36 #include <time.h>
37 #include <dirent.h>
38 #include <fcntl.h>
39 #include <sys/param.h>
40 #include <sys/stat.h>
41 #include <sys/types.h>
42 #include <sys/utsname.h>
43 #include <sys/openpromio.h>
44 #include <kstat.h>
45 #include <libintl.h>
46 #include <syslog.h>
47 #include <sys/dkio.h>
48 #include "pdevinfo.h"
49 #include "display.h"
50 #include "pdevinfo_sun4u.h"
51 #include "display_sun4u.h"
52 #include "libprtdiag.h"
53
54 /*
55 * This module does the reading and interpreting of sun4u system
56 * kstats. It is overlaid by a platform-specific implementation as
57 * appropriate.
58 */
59 void
read_platform_kstats(Sys_tree * tree,struct system_kstat_data * sys_kstat,struct envctrl_kstat_data * ep)60 read_platform_kstats(Sys_tree *tree, struct system_kstat_data *sys_kstat,
61 struct envctrl_kstat_data *ep)
62 {
63 }
64
65 /*
66 * This function does the reading and interpreting of sun4u system
67 * kstats.
68 */
69 void
read_sun4u_kstats(Sys_tree * tree,struct system_kstat_data * sys_kstat)70 read_sun4u_kstats(Sys_tree *tree, struct system_kstat_data *sys_kstat)
71 {
72 kstat_ctl_t *kc;
73 int i;
74 struct envctrl_kstat_data *ep;
75
76 if ((kc = kstat_open()) == NULL) {
77 return;
78 }
79
80 /* Initialize the kstats structure */
81 sys_kstat->sys_kstats_ok = 0;
82 sys_kstat->envctrl_kstat_ok = 0;
83 for (i = 0; i < MAX_DEVS; i++) {
84 ep = &sys_kstat->env_data;
85 ep->ps_kstats[i].instance = I2C_NODEV;
86 ep->fan_kstats[i].instance = I2C_NODEV;
87 ep->encl_kstats[i].instance = I2C_NODEV;
88 }
89
90 read_platform_kstats(tree, sys_kstat, ep);
91 }
92