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 (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 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. 12 * 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] 18 * 19 * CDDL HEADER END 20 */ 21 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 #pragma ident "%Z%%M% %I% %E% SMI" 28 29 #include <sys/time.h> 30 #include <sys/kstat.h> 31 #include <sys/mdb_modapi.h> 32 33 #include <sys/sgenv.h> 34 35 36 /* 37 * This dcmd returns the values of the tunable variables in the Serengeti 38 * environmental driver (SGENV). 39 */ 40 /*ARGSUSED*/ 41 static int 42 sgenv_parameters(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 43 { 44 int mbox_wait_time; 45 int debug_flag; 46 47 int err; 48 49 if ((flags & DCMD_ADDRSPEC) || argc != 0) 50 return (DCMD_USAGE); 51 52 mdb_printf("SGENV tunable parameters:\n"); 53 mdb_printf("=========================\n"); 54 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); 59 } 60 61 err = mdb_readvar(&debug_flag, "sgenv_debug"); 62 if (err != -1) { 63 mdb_printf("sgenv_debug = 0x%x\n", debug_flag); 64 } 65 66 return (DCMD_OK); 67 } 68 69 70 /* 71 * This dcmd prints the values of some of the module specific 72 * variables in the Serengeti environmental driver (SGENV). 73 */ 74 /*ARGSUSED*/ 75 static int 76 sgenv_variables(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 77 { 78 size_t env_cache_snapshot_size; 79 int env_cache_updated; 80 int env_writer_count; 81 82 int board_cache_updated; 83 int board_count_snapshot; 84 int board_count; 85 int board_writer_count; 86 87 int mbox_error_count; 88 89 int rv; 90 91 if ((flags & DCMD_ADDRSPEC) || argc != 0) 92 return (DCMD_USAGE); 93 94 mdb_printf("\nSGENV module variables:\n"); 95 mdb_printf("=======================\n"); 96 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")); 103 } 104 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); 108 } 109 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); 114 } 115 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")); 122 } 123 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); 127 } 128 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); 132 } 133 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); 138 } 139 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); 145 } 146 147 mdb_printf("\n"); 148 149 return (DCMD_OK); 150 } 151 152 /*ARGSUSED2*/ 153 int 154 sgenv_env_sensor(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) 155 { 156 env_sensor_t value; 157 158 int rv; 159 160 if ((flags & DCMD_ADDRSPEC) == 0) { 161 mdb_warn("sgenv_env_sensor: requires an address"); 162 return (DCMD_ERR); 163 } 164 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); 170 } 171 mdb_printf("---------- struct_env_sensor @ %ll#r ----------\n", addr); 172 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); 180 181 return (DCMD_OK); 182 } 183 184 /* 185 * MDB module linkage information: 186 */ 187 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 } 204 }; 205 206 static const mdb_modinfo_t modinfo = { 207 MDB_API_VERSION, dcmds, NULL 208 }; 209 210 const mdb_modinfo_t * 211 _mdb_init(void) 212 { 213 return (&modinfo); 214 } 215