8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mdb / sun4u / modules / lw8 / sgenv / sgenv.c
blobcac7ef78b89c194e13cbec560193f4761956ae10
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
19 * CDDL HEADER END
23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <sys/time.h>
30 #include <sys/kstat.h>
31 #include <sys/mdb_modapi.h>
33 #include <sys/sgenv.h>
37 * This dcmd returns the values of the tunable variables in the Serengeti
38 * environmental driver (SGENV).
40 /*ARGSUSED*/
41 static int
42 sgenv_parameters(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
44 int mbox_wait_time;
45 int debug_flag;
47 int err;
49 if ((flags & DCMD_ADDRSPEC) || argc != 0)
50 return (DCMD_USAGE);
52 mdb_printf("SGENV tunable parameters:\n");
53 mdb_printf("=========================\n");
55 err = mdb_readvar(&mbox_wait_time, "sgenv_max_mbox_wait_time");
56 if (err != -1) {
57 mdb_printf("sgenv_max_mbox_wait_time = %d seconds\n",
58 mbox_wait_time);
61 err = mdb_readvar(&debug_flag, "sgenv_debug");
62 if (err != -1) {
63 mdb_printf("sgenv_debug = 0x%x\n", debug_flag);
66 return (DCMD_OK);
71 * This dcmd prints the values of some of the module specific
72 * variables in the Serengeti environmental driver (SGENV).
74 /*ARGSUSED*/
75 static int
76 sgenv_variables(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
78 size_t env_cache_snapshot_size;
79 int env_cache_updated;
80 int env_writer_count;
82 int board_cache_updated;
83 int board_count_snapshot;
84 int board_count;
85 int board_writer_count;
87 int mbox_error_count;
89 int rv;
91 if ((flags & DCMD_ADDRSPEC) || argc != 0)
92 return (DCMD_USAGE);
94 mdb_printf("\nSGENV module variables:\n");
95 mdb_printf("=======================\n");
97 mdb_printf("\nEnvironmental variables:\n");
98 mdb_printf("------------------------\n");
99 rv = mdb_readvar(&env_cache_updated, "env_cache_updated");
100 if (rv == sizeof (env_cache_updated)) {
101 mdb_printf("env_cache_updated\t\t= %s\n",
102 (env_cache_updated ? "TRUE": "FALSE"));
105 rv = mdb_readvar(&env_writer_count, "env_writer_count");
106 if (rv == sizeof (env_writer_count)) {
107 mdb_printf("env_writer_count\t\t= %d\n", env_writer_count);
110 rv = mdb_readvar(&env_cache_snapshot_size, "env_cache_snapshot_size");
111 if (rv == sizeof (env_cache_snapshot_size)) {
112 mdb_printf("env_cache_snapshot_size\t\t= %d\n",
113 env_cache_snapshot_size);
116 mdb_printf("\nBoard info variables:\n");
117 mdb_printf("---------------------\n");
118 rv = mdb_readvar(&board_cache_updated, "board_cache_updated");
119 if (rv == sizeof (board_cache_updated)) {
120 mdb_printf("board_cache_updated\t\t= %s\n",
121 (board_cache_updated ? "TRUE": "FALSE"));
124 rv = mdb_readvar(&board_writer_count, "board_writer_count");
125 if (rv == sizeof (board_writer_count)) {
126 mdb_printf("board_writer_count\t\t= %d\n", board_writer_count);
129 rv = mdb_readvar(&board_count, "board_count");
130 if (rv == sizeof (board_count)) {
131 mdb_printf("board_count\t\t\t= %d\n", board_count);
134 rv = mdb_readvar(&board_count_snapshot, "board_count_snapshot");
135 if (rv == sizeof (board_count_snapshot)) {
136 mdb_printf("board_count_snapshot\t\t= %d\n",
137 board_count_snapshot);
140 mdb_printf("\nError variables:\n");
141 mdb_printf("----------------\n");
142 rv = mdb_readvar(&mbox_error_count, "sgenv_mbox_error_count");
143 if (rv == sizeof (mbox_error_count)) {
144 mdb_printf("mbox_error_count\t\t= %d\n", mbox_error_count);
147 mdb_printf("\n");
149 return (DCMD_OK);
152 /*ARGSUSED2*/
154 sgenv_env_sensor(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
156 env_sensor_t value;
158 int rv;
160 if ((flags & DCMD_ADDRSPEC) == 0) {
161 mdb_warn("sgenv_env_sensor: requires an address");
162 return (DCMD_ERR);
165 rv = mdb_vread(&value, sizeof (env_sensor_t), addr);
166 if (rv != sizeof (env_sensor_t)) {
167 mdb_warn("sgenv_env_sensor: Failed read on "
168 "address %ll#r", addr);
169 return (DCMD_ERR);
171 mdb_printf("---------- struct_env_sensor @ %ll#r ----------\n", addr);
173 mdb_printf("sd_id: %29ll#x\n", value.sd_id);
174 mdb_printf("sd_value: %26lld\n", value.sd_value);
175 mdb_printf("sd_lo: %29lld\n", value.sd_lo);
176 mdb_printf("sd_hi: %29lld\n", value.sd_hi);
177 mdb_printf("sd_lo_warn: %24lld\n", value.sd_lo_warn);
178 mdb_printf("sd_hi_warn: %24lld\n", value.sd_hi_warn);
179 mdb_printf("sd_status: %25ll#x\n", value.sd_status);
181 return (DCMD_OK);
185 * MDB module linkage information:
188 static const mdb_dcmd_t dcmds[] = {{
189 "sgenv_parameters",
190 NULL,
191 "print environmental driver tunable parameters",
192 sgenv_parameters
193 }, {
194 "sgenv_variables",
195 NULL,
196 "print environmental driver variables",
197 sgenv_variables
198 }, {
199 "sgenv_env_sensor",
200 NULL,
201 "print contents of environmental sesnor",
202 sgenv_env_sensor },
203 { NULL }
206 static const mdb_modinfo_t modinfo = {
207 MDB_API_VERSION, dcmds, NULL
210 const mdb_modinfo_t *
211 _mdb_init(void)
213 return (&modinfo);