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 2005 Sun Microsystems, Inc. All rights reserved.
24*1708Sstevel * Use is subject to license terms.
25*1708Sstevel */
26*1708Sstevel
27*1708Sstevel #pragma ident "%Z%%M% %I% %E% SMI"
28*1708Sstevel
29*1708Sstevel #include <sys/time.h>
30*1708Sstevel #include <sys/kstat.h>
31*1708Sstevel #include <sys/mdb_modapi.h>
32*1708Sstevel
33*1708Sstevel #include <sys/sgenv.h>
34*1708Sstevel
35*1708Sstevel
36*1708Sstevel /*
37*1708Sstevel * This dcmd returns the values of the tunable variables in the Serengeti
38*1708Sstevel * environmental driver (SGENV).
39*1708Sstevel */
40*1708Sstevel /*ARGSUSED*/
41*1708Sstevel static int
sgenv_parameters(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)42*1708Sstevel sgenv_parameters(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
43*1708Sstevel {
44*1708Sstevel int mbox_wait_time;
45*1708Sstevel int debug_flag;
46*1708Sstevel
47*1708Sstevel int err;
48*1708Sstevel
49*1708Sstevel if ((flags & DCMD_ADDRSPEC) || argc != 0)
50*1708Sstevel return (DCMD_USAGE);
51*1708Sstevel
52*1708Sstevel mdb_printf("SGENV tunable parameters:\n");
53*1708Sstevel mdb_printf("=========================\n");
54*1708Sstevel
55*1708Sstevel err = mdb_readvar(&mbox_wait_time, "sgenv_max_mbox_wait_time");
56*1708Sstevel if (err != -1) {
57*1708Sstevel mdb_printf("sgenv_max_mbox_wait_time = %d seconds\n",
58*1708Sstevel mbox_wait_time);
59*1708Sstevel }
60*1708Sstevel
61*1708Sstevel err = mdb_readvar(&debug_flag, "sgenv_debug");
62*1708Sstevel if (err != -1) {
63*1708Sstevel mdb_printf("sgenv_debug = 0x%x\n", debug_flag);
64*1708Sstevel }
65*1708Sstevel
66*1708Sstevel return (DCMD_OK);
67*1708Sstevel }
68*1708Sstevel
69*1708Sstevel
70*1708Sstevel /*
71*1708Sstevel * This dcmd prints the values of some of the module specific
72*1708Sstevel * variables in the Serengeti environmental driver (SGENV).
73*1708Sstevel */
74*1708Sstevel /*ARGSUSED*/
75*1708Sstevel static int
sgenv_variables(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)76*1708Sstevel sgenv_variables(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
77*1708Sstevel {
78*1708Sstevel size_t env_cache_snapshot_size;
79*1708Sstevel int env_cache_updated;
80*1708Sstevel int env_writer_count;
81*1708Sstevel
82*1708Sstevel int board_cache_updated;
83*1708Sstevel int board_count_snapshot;
84*1708Sstevel int board_count;
85*1708Sstevel int board_writer_count;
86*1708Sstevel
87*1708Sstevel int mbox_error_count;
88*1708Sstevel
89*1708Sstevel int rv;
90*1708Sstevel
91*1708Sstevel if ((flags & DCMD_ADDRSPEC) || argc != 0)
92*1708Sstevel return (DCMD_USAGE);
93*1708Sstevel
94*1708Sstevel mdb_printf("\nSGENV module variables:\n");
95*1708Sstevel mdb_printf("=======================\n");
96*1708Sstevel
97*1708Sstevel mdb_printf("\nEnvironmental variables:\n");
98*1708Sstevel mdb_printf("------------------------\n");
99*1708Sstevel rv = mdb_readvar(&env_cache_updated, "env_cache_updated");
100*1708Sstevel if (rv == sizeof (env_cache_updated)) {
101*1708Sstevel mdb_printf("env_cache_updated\t\t= %s\n",
102*1708Sstevel (env_cache_updated ? "TRUE": "FALSE"));
103*1708Sstevel }
104*1708Sstevel
105*1708Sstevel rv = mdb_readvar(&env_writer_count, "env_writer_count");
106*1708Sstevel if (rv == sizeof (env_writer_count)) {
107*1708Sstevel mdb_printf("env_writer_count\t\t= %d\n", env_writer_count);
108*1708Sstevel }
109*1708Sstevel
110*1708Sstevel rv = mdb_readvar(&env_cache_snapshot_size, "env_cache_snapshot_size");
111*1708Sstevel if (rv == sizeof (env_cache_snapshot_size)) {
112*1708Sstevel mdb_printf("env_cache_snapshot_size\t\t= %d\n",
113*1708Sstevel env_cache_snapshot_size);
114*1708Sstevel }
115*1708Sstevel
116*1708Sstevel mdb_printf("\nBoard info variables:\n");
117*1708Sstevel mdb_printf("---------------------\n");
118*1708Sstevel rv = mdb_readvar(&board_cache_updated, "board_cache_updated");
119*1708Sstevel if (rv == sizeof (board_cache_updated)) {
120*1708Sstevel mdb_printf("board_cache_updated\t\t= %s\n",
121*1708Sstevel (board_cache_updated ? "TRUE": "FALSE"));
122*1708Sstevel }
123*1708Sstevel
124*1708Sstevel rv = mdb_readvar(&board_writer_count, "board_writer_count");
125*1708Sstevel if (rv == sizeof (board_writer_count)) {
126*1708Sstevel mdb_printf("board_writer_count\t\t= %d\n", board_writer_count);
127*1708Sstevel }
128*1708Sstevel
129*1708Sstevel rv = mdb_readvar(&board_count, "board_count");
130*1708Sstevel if (rv == sizeof (board_count)) {
131*1708Sstevel mdb_printf("board_count\t\t\t= %d\n", board_count);
132*1708Sstevel }
133*1708Sstevel
134*1708Sstevel rv = mdb_readvar(&board_count_snapshot, "board_count_snapshot");
135*1708Sstevel if (rv == sizeof (board_count_snapshot)) {
136*1708Sstevel mdb_printf("board_count_snapshot\t\t= %d\n",
137*1708Sstevel board_count_snapshot);
138*1708Sstevel }
139*1708Sstevel
140*1708Sstevel mdb_printf("\nError variables:\n");
141*1708Sstevel mdb_printf("----------------\n");
142*1708Sstevel rv = mdb_readvar(&mbox_error_count, "sgenv_mbox_error_count");
143*1708Sstevel if (rv == sizeof (mbox_error_count)) {
144*1708Sstevel mdb_printf("mbox_error_count\t\t= %d\n", mbox_error_count);
145*1708Sstevel }
146*1708Sstevel
147*1708Sstevel mdb_printf("\n");
148*1708Sstevel
149*1708Sstevel return (DCMD_OK);
150*1708Sstevel }
151*1708Sstevel
152*1708Sstevel /*ARGSUSED2*/
153*1708Sstevel int
sgenv_env_sensor(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)154*1708Sstevel sgenv_env_sensor(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
155*1708Sstevel {
156*1708Sstevel env_sensor_t value;
157*1708Sstevel
158*1708Sstevel int rv;
159*1708Sstevel
160*1708Sstevel if ((flags & DCMD_ADDRSPEC) == 0) {
161*1708Sstevel mdb_warn("sgenv_env_sensor: requires an address");
162*1708Sstevel return (DCMD_ERR);
163*1708Sstevel }
164*1708Sstevel
165*1708Sstevel rv = mdb_vread(&value, sizeof (env_sensor_t), addr);
166*1708Sstevel if (rv != sizeof (env_sensor_t)) {
167*1708Sstevel mdb_warn("sgenv_env_sensor: Failed read on "
168*1708Sstevel "address %ll#r", addr);
169*1708Sstevel return (DCMD_ERR);
170*1708Sstevel }
171*1708Sstevel mdb_printf("---------- struct_env_sensor @ %ll#r ----------\n", addr);
172*1708Sstevel
173*1708Sstevel mdb_printf("sd_id: %29ll#x\n", value.sd_id);
174*1708Sstevel mdb_printf("sd_value: %26lld\n", value.sd_value);
175*1708Sstevel mdb_printf("sd_lo: %29lld\n", value.sd_lo);
176*1708Sstevel mdb_printf("sd_hi: %29lld\n", value.sd_hi);
177*1708Sstevel mdb_printf("sd_lo_warn: %24lld\n", value.sd_lo_warn);
178*1708Sstevel mdb_printf("sd_hi_warn: %24lld\n", value.sd_hi_warn);
179*1708Sstevel mdb_printf("sd_status: %25ll#x\n", value.sd_status);
180*1708Sstevel
181*1708Sstevel return (DCMD_OK);
182*1708Sstevel }
183*1708Sstevel
184*1708Sstevel /*
185*1708Sstevel * MDB module linkage information:
186*1708Sstevel */
187*1708Sstevel
188*1708Sstevel static const mdb_dcmd_t dcmds[] = {{
189*1708Sstevel "sgenv_parameters",
190*1708Sstevel NULL,
191*1708Sstevel "print environmental driver tunable parameters",
192*1708Sstevel sgenv_parameters
193*1708Sstevel }, {
194*1708Sstevel "sgenv_variables",
195*1708Sstevel NULL,
196*1708Sstevel "print environmental driver variables",
197*1708Sstevel sgenv_variables
198*1708Sstevel }, {
199*1708Sstevel "sgenv_env_sensor",
200*1708Sstevel NULL,
201*1708Sstevel "print contents of environmental sesnor",
202*1708Sstevel sgenv_env_sensor },
203*1708Sstevel { NULL }
204*1708Sstevel };
205*1708Sstevel
206*1708Sstevel static const mdb_modinfo_t modinfo = {
207*1708Sstevel MDB_API_VERSION, dcmds, NULL
208*1708Sstevel };
209*1708Sstevel
210*1708Sstevel const mdb_modinfo_t *
_mdb_init(void)211*1708Sstevel _mdb_init(void)
212*1708Sstevel {
213*1708Sstevel return (&modinfo);
214*1708Sstevel }
215