17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate * CDDL HEADER START
37c478bd9Sstevel@tonic-gate *
47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*bf85a12bSJohn Wren Kennedy * Common Development and Distribution License (the "License").
6*bf85a12bSJohn Wren Kennedy * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate *
87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate * and limitations under the License.
127c478bd9Sstevel@tonic-gate *
137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate *
197c478bd9Sstevel@tonic-gate * CDDL HEADER END
207c478bd9Sstevel@tonic-gate */
217c478bd9Sstevel@tonic-gate /*
22*bf85a12bSJohn Wren Kennedy * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
237c478bd9Sstevel@tonic-gate * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate */
257c478bd9Sstevel@tonic-gate
267c478bd9Sstevel@tonic-gate #include <sys/mdb_modapi.h>
277c478bd9Sstevel@tonic-gate
287c478bd9Sstevel@tonic-gate
297c478bd9Sstevel@tonic-gate int md_verbose = 0; /* be verbose about the addresses */
307c478bd9Sstevel@tonic-gate
317c478bd9Sstevel@tonic-gate extern int metaset(uintptr_t, uint_t, int, const mdb_arg_t *);
327c478bd9Sstevel@tonic-gate extern int metastat(uintptr_t, uint_t, int, const mdb_arg_t *);
337c478bd9Sstevel@tonic-gate extern int set_io(uintptr_t, uint_t, int, const mdb_arg_t *);
347c478bd9Sstevel@tonic-gate extern int dumpnamespace(uintptr_t, uint_t, int, const mdb_arg_t *);
357c478bd9Sstevel@tonic-gate extern int dumpsetaddr(uintptr_t, uint_t, int, const mdb_arg_t *);
367c478bd9Sstevel@tonic-gate extern int dumphotspare(uintptr_t, uint_t, int, const mdb_arg_t *);
37*bf85a12bSJohn Wren Kennedy extern int printmmbm(uintptr_t, uint_t, int, const mdb_arg_t *);
387c478bd9Sstevel@tonic-gate extern void set_io_help();
397c478bd9Sstevel@tonic-gate
407c478bd9Sstevel@tonic-gate /* from mdbgen */
417c478bd9Sstevel@tonic-gate extern int mddb_db_walk_init(mdb_walk_state_t *);
427c478bd9Sstevel@tonic-gate extern int mddb_db_walk_step(mdb_walk_state_t *);
437c478bd9Sstevel@tonic-gate extern int mddb_de_ic_walk_init(mdb_walk_state_t *);
447c478bd9Sstevel@tonic-gate extern int mddb_de_ic_walk_step(mdb_walk_state_t *);
457c478bd9Sstevel@tonic-gate extern int hotsparepool_walk_init(mdb_walk_state_t *);
467c478bd9Sstevel@tonic-gate extern int hotsparepool_walk_step(mdb_walk_state_t *);
477c478bd9Sstevel@tonic-gate extern void hotsparepool_walk_fini(mdb_walk_state_t *);
487c478bd9Sstevel@tonic-gate extern int didnamespace_walk_init(mdb_walk_state_t *);
497c478bd9Sstevel@tonic-gate extern int didnamespace_walk_step(mdb_walk_state_t *);
507c478bd9Sstevel@tonic-gate extern void didnamespace_walk_fini(mdb_walk_state_t *);
517c478bd9Sstevel@tonic-gate extern int namespace_walk_init(mdb_walk_state_t *);
527c478bd9Sstevel@tonic-gate extern int namespace_walk_step(mdb_walk_state_t *);
537c478bd9Sstevel@tonic-gate extern void namespace_walk_fini(mdb_walk_state_t *);
547c478bd9Sstevel@tonic-gate extern int sets_walk_init(mdb_walk_state_t *);
557c478bd9Sstevel@tonic-gate extern int sets_walk_step(mdb_walk_state_t *);
567c478bd9Sstevel@tonic-gate extern void sets_walk_fini(mdb_walk_state_t *);
577c478bd9Sstevel@tonic-gate extern int units_walk_init(mdb_walk_state_t *);
587c478bd9Sstevel@tonic-gate extern int units_walk_step(mdb_walk_state_t *);
597c478bd9Sstevel@tonic-gate extern void units_walk_fini(mdb_walk_state_t *);
607c478bd9Sstevel@tonic-gate extern int simple_de_ic(uintptr_t, uint_t, int, const mdb_arg_t *);
617c478bd9Sstevel@tonic-gate int md_set_verbose(uintptr_t, uint_t, int, const mdb_arg_t *);
627c478bd9Sstevel@tonic-gate
637c478bd9Sstevel@tonic-gate
647c478bd9Sstevel@tonic-gate const mdb_dcmd_t dcmds[] = {
657c478bd9Sstevel@tonic-gate { "md_verbose", NULL, "toggle verbose mode for SVM dcmds",
667c478bd9Sstevel@tonic-gate md_set_verbose },
677c478bd9Sstevel@tonic-gate { "metaset", NULL, "list SVM metasets", metaset },
687c478bd9Sstevel@tonic-gate { "metastat", "[-v]", "list SVM metadevices",
697c478bd9Sstevel@tonic-gate metastat },
707c478bd9Sstevel@tonic-gate { "set_io", NULL, "show the pending IO counts", set_io,
717c478bd9Sstevel@tonic-gate set_io_help },
727c478bd9Sstevel@tonic-gate { "dumpnamespace", "[-s setname]", "dump the SVM name space",
737c478bd9Sstevel@tonic-gate dumpnamespace },
747c478bd9Sstevel@tonic-gate { "dumphotspare", NULL, "dump the hot spare pools",
757c478bd9Sstevel@tonic-gate dumphotspare },
767c478bd9Sstevel@tonic-gate { "dumpsetaddr", "[-s setname]", "dump the SVM set addresses",
777c478bd9Sstevel@tonic-gate dumpsetaddr },
787c478bd9Sstevel@tonic-gate { "simple_de_ic", NULL, "simple mddb_de_ic_t",
797c478bd9Sstevel@tonic-gate simple_de_ic },
80*bf85a12bSJohn Wren Kennedy { "printmmbm", NULL, "print bitmaps for given mm_unit_t",
81*bf85a12bSJohn Wren Kennedy printmmbm },
827c478bd9Sstevel@tonic-gate { NULL }
837c478bd9Sstevel@tonic-gate };
847c478bd9Sstevel@tonic-gate
857c478bd9Sstevel@tonic-gate static const mdb_walker_t walkers[] = {
867c478bd9Sstevel@tonic-gate { "mddb_db", "walk list of mddb_db_t structures",
877c478bd9Sstevel@tonic-gate mddb_db_walk_init, mddb_db_walk_step, NULL, NULL },
887c478bd9Sstevel@tonic-gate { "mddb_de_ic", "walk list of mddb_de_t structures",
897c478bd9Sstevel@tonic-gate mddb_de_ic_walk_init, mddb_de_ic_walk_step, NULL, NULL },
907c478bd9Sstevel@tonic-gate { "hotsparepool", "walk list of hotspare pools",
917c478bd9Sstevel@tonic-gate hotsparepool_walk_init, hotsparepool_walk_step,
927c478bd9Sstevel@tonic-gate hotsparepool_walk_fini, NULL },
937c478bd9Sstevel@tonic-gate { "didnamespace", "walk the did namespace",
947c478bd9Sstevel@tonic-gate didnamespace_walk_init, didnamespace_walk_step,
957c478bd9Sstevel@tonic-gate didnamespace_walk_fini, NULL },
967c478bd9Sstevel@tonic-gate { "namespace", "walk the namespace",
977c478bd9Sstevel@tonic-gate namespace_walk_init, namespace_walk_step, namespace_walk_fini,
987c478bd9Sstevel@tonic-gate NULL },
997c478bd9Sstevel@tonic-gate { "md_sets", "walk list of sets",
1007c478bd9Sstevel@tonic-gate sets_walk_init, sets_walk_step, sets_walk_fini, NULL },
1017c478bd9Sstevel@tonic-gate { "md_units", "walk list of unit structures",
1027c478bd9Sstevel@tonic-gate units_walk_init, units_walk_step, units_walk_fini, NULL },
1037c478bd9Sstevel@tonic-gate { NULL }
1047c478bd9Sstevel@tonic-gate };
1057c478bd9Sstevel@tonic-gate
1067c478bd9Sstevel@tonic-gate static const mdb_modinfo_t modinfo = {
1077c478bd9Sstevel@tonic-gate MDB_API_VERSION, dcmds, walkers
1087c478bd9Sstevel@tonic-gate };
1097c478bd9Sstevel@tonic-gate
1107c478bd9Sstevel@tonic-gate const mdb_modinfo_t *
_mdb_init(void)1117c478bd9Sstevel@tonic-gate _mdb_init(void)
1127c478bd9Sstevel@tonic-gate {
1137c478bd9Sstevel@tonic-gate return (&modinfo);
1147c478bd9Sstevel@tonic-gate }
1157c478bd9Sstevel@tonic-gate
1167c478bd9Sstevel@tonic-gate
1177c478bd9Sstevel@tonic-gate /* ARGSUSED */
1187c478bd9Sstevel@tonic-gate int
md_set_verbose(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1197c478bd9Sstevel@tonic-gate md_set_verbose(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1207c478bd9Sstevel@tonic-gate {
1217c478bd9Sstevel@tonic-gate md_verbose = !md_verbose;
1227c478bd9Sstevel@tonic-gate
1237c478bd9Sstevel@tonic-gate if ((flags & DCMD_ADDRSPEC) != 0 || argc != 0)
1247c478bd9Sstevel@tonic-gate return (DCMD_USAGE);
1257c478bd9Sstevel@tonic-gate
1267c478bd9Sstevel@tonic-gate mdb_printf("Verbose mode is now %d\n", md_verbose);
1277c478bd9Sstevel@tonic-gate return (DCMD_OK);
1287c478bd9Sstevel@tonic-gate }
129