10Sstevel@tonic-gate /*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*8452SJohn.Wren.Kennedy@Sun.COM * Common Development and Distribution License (the "License").
6*8452SJohn.Wren.Kennedy@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate /*
22*8452SJohn.Wren.Kennedy@Sun.COM * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
260Sstevel@tonic-gate #include <sys/mdb_modapi.h>
270Sstevel@tonic-gate
280Sstevel@tonic-gate
290Sstevel@tonic-gate int md_verbose = 0; /* be verbose about the addresses */
300Sstevel@tonic-gate
310Sstevel@tonic-gate extern int metaset(uintptr_t, uint_t, int, const mdb_arg_t *);
320Sstevel@tonic-gate extern int metastat(uintptr_t, uint_t, int, const mdb_arg_t *);
330Sstevel@tonic-gate extern int set_io(uintptr_t, uint_t, int, const mdb_arg_t *);
340Sstevel@tonic-gate extern int dumpnamespace(uintptr_t, uint_t, int, const mdb_arg_t *);
350Sstevel@tonic-gate extern int dumpsetaddr(uintptr_t, uint_t, int, const mdb_arg_t *);
360Sstevel@tonic-gate extern int dumphotspare(uintptr_t, uint_t, int, const mdb_arg_t *);
37*8452SJohn.Wren.Kennedy@Sun.COM extern int printmmbm(uintptr_t, uint_t, int, const mdb_arg_t *);
380Sstevel@tonic-gate extern void set_io_help();
390Sstevel@tonic-gate
400Sstevel@tonic-gate /* from mdbgen */
410Sstevel@tonic-gate extern int mddb_db_walk_init(mdb_walk_state_t *);
420Sstevel@tonic-gate extern int mddb_db_walk_step(mdb_walk_state_t *);
430Sstevel@tonic-gate extern int mddb_de_ic_walk_init(mdb_walk_state_t *);
440Sstevel@tonic-gate extern int mddb_de_ic_walk_step(mdb_walk_state_t *);
450Sstevel@tonic-gate extern int hotsparepool_walk_init(mdb_walk_state_t *);
460Sstevel@tonic-gate extern int hotsparepool_walk_step(mdb_walk_state_t *);
470Sstevel@tonic-gate extern void hotsparepool_walk_fini(mdb_walk_state_t *);
480Sstevel@tonic-gate extern int didnamespace_walk_init(mdb_walk_state_t *);
490Sstevel@tonic-gate extern int didnamespace_walk_step(mdb_walk_state_t *);
500Sstevel@tonic-gate extern void didnamespace_walk_fini(mdb_walk_state_t *);
510Sstevel@tonic-gate extern int namespace_walk_init(mdb_walk_state_t *);
520Sstevel@tonic-gate extern int namespace_walk_step(mdb_walk_state_t *);
530Sstevel@tonic-gate extern void namespace_walk_fini(mdb_walk_state_t *);
540Sstevel@tonic-gate extern int sets_walk_init(mdb_walk_state_t *);
550Sstevel@tonic-gate extern int sets_walk_step(mdb_walk_state_t *);
560Sstevel@tonic-gate extern void sets_walk_fini(mdb_walk_state_t *);
570Sstevel@tonic-gate extern int units_walk_init(mdb_walk_state_t *);
580Sstevel@tonic-gate extern int units_walk_step(mdb_walk_state_t *);
590Sstevel@tonic-gate extern void units_walk_fini(mdb_walk_state_t *);
600Sstevel@tonic-gate extern int simple_de_ic(uintptr_t, uint_t, int, const mdb_arg_t *);
610Sstevel@tonic-gate int md_set_verbose(uintptr_t, uint_t, int, const mdb_arg_t *);
620Sstevel@tonic-gate
630Sstevel@tonic-gate
640Sstevel@tonic-gate const mdb_dcmd_t dcmds[] = {
650Sstevel@tonic-gate { "md_verbose", NULL, "toggle verbose mode for SVM dcmds",
660Sstevel@tonic-gate md_set_verbose },
670Sstevel@tonic-gate { "metaset", NULL, "list SVM metasets", metaset },
680Sstevel@tonic-gate { "metastat", "[-v]", "list SVM metadevices",
690Sstevel@tonic-gate metastat },
700Sstevel@tonic-gate { "set_io", NULL, "show the pending IO counts", set_io,
710Sstevel@tonic-gate set_io_help },
720Sstevel@tonic-gate { "dumpnamespace", "[-s setname]", "dump the SVM name space",
730Sstevel@tonic-gate dumpnamespace },
740Sstevel@tonic-gate { "dumphotspare", NULL, "dump the hot spare pools",
750Sstevel@tonic-gate dumphotspare },
760Sstevel@tonic-gate { "dumpsetaddr", "[-s setname]", "dump the SVM set addresses",
770Sstevel@tonic-gate dumpsetaddr },
780Sstevel@tonic-gate { "simple_de_ic", NULL, "simple mddb_de_ic_t",
790Sstevel@tonic-gate simple_de_ic },
80*8452SJohn.Wren.Kennedy@Sun.COM { "printmmbm", NULL, "print bitmaps for given mm_unit_t",
81*8452SJohn.Wren.Kennedy@Sun.COM printmmbm },
820Sstevel@tonic-gate { NULL }
830Sstevel@tonic-gate };
840Sstevel@tonic-gate
850Sstevel@tonic-gate static const mdb_walker_t walkers[] = {
860Sstevel@tonic-gate { "mddb_db", "walk list of mddb_db_t structures",
870Sstevel@tonic-gate mddb_db_walk_init, mddb_db_walk_step, NULL, NULL },
880Sstevel@tonic-gate { "mddb_de_ic", "walk list of mddb_de_t structures",
890Sstevel@tonic-gate mddb_de_ic_walk_init, mddb_de_ic_walk_step, NULL, NULL },
900Sstevel@tonic-gate { "hotsparepool", "walk list of hotspare pools",
910Sstevel@tonic-gate hotsparepool_walk_init, hotsparepool_walk_step,
920Sstevel@tonic-gate hotsparepool_walk_fini, NULL },
930Sstevel@tonic-gate { "didnamespace", "walk the did namespace",
940Sstevel@tonic-gate didnamespace_walk_init, didnamespace_walk_step,
950Sstevel@tonic-gate didnamespace_walk_fini, NULL },
960Sstevel@tonic-gate { "namespace", "walk the namespace",
970Sstevel@tonic-gate namespace_walk_init, namespace_walk_step, namespace_walk_fini,
980Sstevel@tonic-gate NULL },
990Sstevel@tonic-gate { "md_sets", "walk list of sets",
1000Sstevel@tonic-gate sets_walk_init, sets_walk_step, sets_walk_fini, NULL },
1010Sstevel@tonic-gate { "md_units", "walk list of unit structures",
1020Sstevel@tonic-gate units_walk_init, units_walk_step, units_walk_fini, NULL },
1030Sstevel@tonic-gate { NULL }
1040Sstevel@tonic-gate };
1050Sstevel@tonic-gate
1060Sstevel@tonic-gate static const mdb_modinfo_t modinfo = {
1070Sstevel@tonic-gate MDB_API_VERSION, dcmds, walkers
1080Sstevel@tonic-gate };
1090Sstevel@tonic-gate
1100Sstevel@tonic-gate const mdb_modinfo_t *
_mdb_init(void)1110Sstevel@tonic-gate _mdb_init(void)
1120Sstevel@tonic-gate {
1130Sstevel@tonic-gate return (&modinfo);
1140Sstevel@tonic-gate }
1150Sstevel@tonic-gate
1160Sstevel@tonic-gate
1170Sstevel@tonic-gate /* ARGSUSED */
1180Sstevel@tonic-gate int
md_set_verbose(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1190Sstevel@tonic-gate md_set_verbose(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1200Sstevel@tonic-gate {
1210Sstevel@tonic-gate md_verbose = !md_verbose;
1220Sstevel@tonic-gate
1230Sstevel@tonic-gate if ((flags & DCMD_ADDRSPEC) != 0 || argc != 0)
1240Sstevel@tonic-gate return (DCMD_USAGE);
1250Sstevel@tonic-gate
1260Sstevel@tonic-gate mdb_printf("Verbose mode is now %d\n", md_verbose);
1270Sstevel@tonic-gate return (DCMD_OK);
1280Sstevel@tonic-gate }
129