1*0Sstevel@tonic-gate /*
2*0Sstevel@tonic-gate  * CDDL HEADER START
3*0Sstevel@tonic-gate  *
4*0Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*0Sstevel@tonic-gate  * Common Development and Distribution License, Version 1.0 only
6*0Sstevel@tonic-gate  * (the "License").  You may not use this file except in compliance
7*0Sstevel@tonic-gate  * with the License.
8*0Sstevel@tonic-gate  *
9*0Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10*0Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
11*0Sstevel@tonic-gate  * See the License for the specific language governing permissions
12*0Sstevel@tonic-gate  * and limitations under the License.
13*0Sstevel@tonic-gate  *
14*0Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
15*0Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16*0Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
17*0Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
18*0Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
19*0Sstevel@tonic-gate  *
20*0Sstevel@tonic-gate  * CDDL HEADER END
21*0Sstevel@tonic-gate  */
22*0Sstevel@tonic-gate /*
23*0Sstevel@tonic-gate  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24*0Sstevel@tonic-gate  * Use is subject to license terms.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
28*0Sstevel@tonic-gate 
29*0Sstevel@tonic-gate #include <sys/mdb_modapi.h>
30*0Sstevel@tonic-gate 
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate int	md_verbose = 0;		/* be verbose about the addresses */
33*0Sstevel@tonic-gate 
34*0Sstevel@tonic-gate extern int metaset(uintptr_t, uint_t, int, const mdb_arg_t *);
35*0Sstevel@tonic-gate extern int metastat(uintptr_t, uint_t, int, const mdb_arg_t *);
36*0Sstevel@tonic-gate extern int set_io(uintptr_t, uint_t, int, const mdb_arg_t *);
37*0Sstevel@tonic-gate extern int dumpnamespace(uintptr_t, uint_t, int, const mdb_arg_t *);
38*0Sstevel@tonic-gate extern int dumpsetaddr(uintptr_t, uint_t, int, const mdb_arg_t *);
39*0Sstevel@tonic-gate extern int dumphotspare(uintptr_t, uint_t, int, const mdb_arg_t *);
40*0Sstevel@tonic-gate extern void set_io_help();
41*0Sstevel@tonic-gate 
42*0Sstevel@tonic-gate /* from mdbgen */
43*0Sstevel@tonic-gate extern int mddb_db_walk_init(mdb_walk_state_t *);
44*0Sstevel@tonic-gate extern int mddb_db_walk_step(mdb_walk_state_t *);
45*0Sstevel@tonic-gate extern int mddb_de_ic_walk_init(mdb_walk_state_t *);
46*0Sstevel@tonic-gate extern int mddb_de_ic_walk_step(mdb_walk_state_t *);
47*0Sstevel@tonic-gate extern int hotsparepool_walk_init(mdb_walk_state_t *);
48*0Sstevel@tonic-gate extern int hotsparepool_walk_step(mdb_walk_state_t *);
49*0Sstevel@tonic-gate extern void hotsparepool_walk_fini(mdb_walk_state_t *);
50*0Sstevel@tonic-gate extern int didnamespace_walk_init(mdb_walk_state_t *);
51*0Sstevel@tonic-gate extern int didnamespace_walk_step(mdb_walk_state_t *);
52*0Sstevel@tonic-gate extern void didnamespace_walk_fini(mdb_walk_state_t *);
53*0Sstevel@tonic-gate extern int namespace_walk_init(mdb_walk_state_t *);
54*0Sstevel@tonic-gate extern int namespace_walk_step(mdb_walk_state_t *);
55*0Sstevel@tonic-gate extern void namespace_walk_fini(mdb_walk_state_t *);
56*0Sstevel@tonic-gate extern int sets_walk_init(mdb_walk_state_t *);
57*0Sstevel@tonic-gate extern int sets_walk_step(mdb_walk_state_t *);
58*0Sstevel@tonic-gate extern void sets_walk_fini(mdb_walk_state_t *);
59*0Sstevel@tonic-gate extern int units_walk_init(mdb_walk_state_t *);
60*0Sstevel@tonic-gate extern int units_walk_step(mdb_walk_state_t *);
61*0Sstevel@tonic-gate extern void units_walk_fini(mdb_walk_state_t *);
62*0Sstevel@tonic-gate extern int simple_de_ic(uintptr_t, uint_t, int, const mdb_arg_t *);
63*0Sstevel@tonic-gate int md_set_verbose(uintptr_t, uint_t, int, const mdb_arg_t *);
64*0Sstevel@tonic-gate 
65*0Sstevel@tonic-gate 
66*0Sstevel@tonic-gate const mdb_dcmd_t dcmds[] = {
67*0Sstevel@tonic-gate 	{ "md_verbose", NULL, "toggle verbose mode for SVM dcmds",
68*0Sstevel@tonic-gate 	    md_set_verbose },
69*0Sstevel@tonic-gate 	{ "metaset", NULL, "list SVM metasets", metaset },
70*0Sstevel@tonic-gate 	{ "metastat", "[-v]", "list SVM metadevices",
71*0Sstevel@tonic-gate 	    metastat },
72*0Sstevel@tonic-gate 	{ "set_io", NULL, "show the pending IO counts", set_io,
73*0Sstevel@tonic-gate 	    set_io_help },
74*0Sstevel@tonic-gate 	{ "dumpnamespace", "[-s setname]", "dump the SVM name space",
75*0Sstevel@tonic-gate 	    dumpnamespace },
76*0Sstevel@tonic-gate 	{ "dumphotspare", NULL, "dump the hot spare pools",
77*0Sstevel@tonic-gate 	    dumphotspare },
78*0Sstevel@tonic-gate 	{ "dumpsetaddr", "[-s setname]", "dump the SVM set addresses",
79*0Sstevel@tonic-gate 	    dumpsetaddr },
80*0Sstevel@tonic-gate 	{ "simple_de_ic", NULL, "simple mddb_de_ic_t",
81*0Sstevel@tonic-gate 	    simple_de_ic },
82*0Sstevel@tonic-gate 	{ NULL }
83*0Sstevel@tonic-gate };
84*0Sstevel@tonic-gate 
85*0Sstevel@tonic-gate static const mdb_walker_t walkers[] = {
86*0Sstevel@tonic-gate 	{ "mddb_db", "walk list of mddb_db_t structures",
87*0Sstevel@tonic-gate 	    mddb_db_walk_init, mddb_db_walk_step, NULL, NULL },
88*0Sstevel@tonic-gate 	{ "mddb_de_ic", "walk list of mddb_de_t structures",
89*0Sstevel@tonic-gate 	    mddb_de_ic_walk_init, mddb_de_ic_walk_step, NULL, NULL },
90*0Sstevel@tonic-gate 	{ "hotsparepool", "walk list of hotspare pools",
91*0Sstevel@tonic-gate 	    hotsparepool_walk_init, hotsparepool_walk_step,
92*0Sstevel@tonic-gate 	    hotsparepool_walk_fini, NULL },
93*0Sstevel@tonic-gate 	{ "didnamespace", "walk the did namespace",
94*0Sstevel@tonic-gate 	    didnamespace_walk_init, didnamespace_walk_step,
95*0Sstevel@tonic-gate 	    didnamespace_walk_fini, NULL },
96*0Sstevel@tonic-gate 	{ "namespace", "walk the namespace",
97*0Sstevel@tonic-gate 	    namespace_walk_init, namespace_walk_step, namespace_walk_fini,
98*0Sstevel@tonic-gate 	    NULL },
99*0Sstevel@tonic-gate 	{ "md_sets", "walk list of sets",
100*0Sstevel@tonic-gate 	    sets_walk_init, sets_walk_step, sets_walk_fini, NULL },
101*0Sstevel@tonic-gate 	{ "md_units", "walk list of unit structures",
102*0Sstevel@tonic-gate 	    units_walk_init, units_walk_step, units_walk_fini, NULL },
103*0Sstevel@tonic-gate 	{ NULL }
104*0Sstevel@tonic-gate };
105*0Sstevel@tonic-gate 
106*0Sstevel@tonic-gate static const mdb_modinfo_t modinfo = {
107*0Sstevel@tonic-gate 	MDB_API_VERSION, dcmds, walkers
108*0Sstevel@tonic-gate };
109*0Sstevel@tonic-gate 
110*0Sstevel@tonic-gate const mdb_modinfo_t *
111*0Sstevel@tonic-gate _mdb_init(void)
112*0Sstevel@tonic-gate {
113*0Sstevel@tonic-gate 	return (&modinfo);
114*0Sstevel@tonic-gate }
115*0Sstevel@tonic-gate 
116*0Sstevel@tonic-gate 
117*0Sstevel@tonic-gate /* ARGSUSED */
118*0Sstevel@tonic-gate int
119*0Sstevel@tonic-gate md_set_verbose(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
120*0Sstevel@tonic-gate {
121*0Sstevel@tonic-gate 	md_verbose = !md_verbose;
122*0Sstevel@tonic-gate 
123*0Sstevel@tonic-gate 	if ((flags & DCMD_ADDRSPEC) != 0 || argc != 0)
124*0Sstevel@tonic-gate 		return (DCMD_USAGE);
125*0Sstevel@tonic-gate 
126*0Sstevel@tonic-gate 	mdb_printf("Verbose mode is now %d\n", md_verbose);
127*0Sstevel@tonic-gate 	return (DCMD_OK);
128*0Sstevel@tonic-gate }
129