xref: /onnv-gate/usr/src/cmd/mdb/common/modules/nsctl/nsctl.c (revision 7836:4e95154b5b7a)
1*7836SJohn.Forte@Sun.COM /*
2*7836SJohn.Forte@Sun.COM  * CDDL HEADER START
3*7836SJohn.Forte@Sun.COM  *
4*7836SJohn.Forte@Sun.COM  * The contents of this file are subject to the terms of the
5*7836SJohn.Forte@Sun.COM  * Common Development and Distribution License (the "License").
6*7836SJohn.Forte@Sun.COM  * You may not use this file except in compliance with the License.
7*7836SJohn.Forte@Sun.COM  *
8*7836SJohn.Forte@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7836SJohn.Forte@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7836SJohn.Forte@Sun.COM  * See the License for the specific language governing permissions
11*7836SJohn.Forte@Sun.COM  * and limitations under the License.
12*7836SJohn.Forte@Sun.COM  *
13*7836SJohn.Forte@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7836SJohn.Forte@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7836SJohn.Forte@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7836SJohn.Forte@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7836SJohn.Forte@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7836SJohn.Forte@Sun.COM  *
19*7836SJohn.Forte@Sun.COM  * CDDL HEADER END
20*7836SJohn.Forte@Sun.COM  */
21*7836SJohn.Forte@Sun.COM /*
22*7836SJohn.Forte@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23*7836SJohn.Forte@Sun.COM  * Use is subject to license terms.
24*7836SJohn.Forte@Sun.COM  */
25*7836SJohn.Forte@Sun.COM 
26*7836SJohn.Forte@Sun.COM #include <sys/types.h>
27*7836SJohn.Forte@Sun.COM #include <sys/ksynch.h>
28*7836SJohn.Forte@Sun.COM #include <sys/kmem.h>
29*7836SJohn.Forte@Sun.COM #include <sys/errno.h>
30*7836SJohn.Forte@Sun.COM #include <sys/ddi.h>
31*7836SJohn.Forte@Sun.COM 
32*7836SJohn.Forte@Sun.COM #include <sys/mdb_modapi.h>
33*7836SJohn.Forte@Sun.COM 
34*7836SJohn.Forte@Sun.COM #define	__NSC_GEN__
35*7836SJohn.Forte@Sun.COM #include <sys/nsc_thread.h>
36*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_dev.h>
37*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_gen.h>
38*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_mem.h>
39*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsctl.h>
40*7836SJohn.Forte@Sun.COM #include <sys/nsctl/nsc_disk.h>
41*7836SJohn.Forte@Sun.COM 
42*7836SJohn.Forte@Sun.COM 
43*7836SJohn.Forte@Sun.COM /*
44*7836SJohn.Forte@Sun.COM  * Data struct for the complex walks.
45*7836SJohn.Forte@Sun.COM  */
46*7836SJohn.Forte@Sun.COM 
47*7836SJohn.Forte@Sun.COM struct complex_args {
48*7836SJohn.Forte@Sun.COM 	int		argc;
49*7836SJohn.Forte@Sun.COM 	mdb_arg_t	*argv;
50*7836SJohn.Forte@Sun.COM };
51*7836SJohn.Forte@Sun.COM 
52*7836SJohn.Forte@Sun.COM 
53*7836SJohn.Forte@Sun.COM /*
54*7836SJohn.Forte@Sun.COM  * Bit definitions
55*7836SJohn.Forte@Sun.COM  */
56*7836SJohn.Forte@Sun.COM 
57*7836SJohn.Forte@Sun.COM #define	NSC_RW_BITS	\
58*7836SJohn.Forte@Sun.COM 	{ "NSC_READ", NSC_READ, NSC_READ },	\
59*7836SJohn.Forte@Sun.COM 	{ "NSC_WRITE", NSC_WRITE, NSC_WRITE }
60*7836SJohn.Forte@Sun.COM 
61*7836SJohn.Forte@Sun.COM 
62*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nsc_bhflag_bits[] = {
63*7836SJohn.Forte@Sun.COM 	NSC_RW_BITS,
64*7836SJohn.Forte@Sun.COM 	{ "NSC_PINNABLE", NSC_PINNABLE, NSC_PINNABLE },
65*7836SJohn.Forte@Sun.COM 	{ "NSC_NOBLOCK", NSC_NOBLOCK, NSC_NOBLOCK },
66*7836SJohn.Forte@Sun.COM 	{ "NSC_HALLOCATED", NSC_HALLOCATED, NSC_HALLOCATED },
67*7836SJohn.Forte@Sun.COM 	{ "NSC_HACTIVE", NSC_HACTIVE, NSC_HACTIVE },
68*7836SJohn.Forte@Sun.COM 	{ "NSC_BCOPY", NSC_BCOPY, NSC_BCOPY },
69*7836SJohn.Forte@Sun.COM 	{ "NSC_PAGEIO", NSC_PAGEIO, NSC_PAGEIO },
70*7836SJohn.Forte@Sun.COM 	{ "NSC_ABUF", NSC_ABUF, NSC_ABUF },
71*7836SJohn.Forte@Sun.COM 	{ "NSC_MIXED", NSC_MIXED, NSC_MIXED },
72*7836SJohn.Forte@Sun.COM 	{ "NSC_WRTHRU", NSC_WRTHRU, NSC_WRTHRU },
73*7836SJohn.Forte@Sun.COM 	{ "NSC_FORCED_WRTHRU", NSC_FORCED_WRTHRU, NSC_FORCED_WRTHRU },
74*7836SJohn.Forte@Sun.COM 	{ "NSC_NOCACHE", NSC_NOCACHE, NSC_NOCACHE },
75*7836SJohn.Forte@Sun.COM 	{ "NSC_QUEUE", NSC_QUEUE, NSC_QUEUE },
76*7836SJohn.Forte@Sun.COM 	{ "NSC_RDAHEAD", NSC_RDAHEAD, NSC_RDAHEAD },
77*7836SJohn.Forte@Sun.COM 	{ "NSC_NO_FORCED_WRTHRU", NSC_NO_FORCED_WRTHRU, NSC_NO_FORCED_WRTHRU },
78*7836SJohn.Forte@Sun.COM 	{ "NSC_METADATA", NSC_METADATA, NSC_METADATA },
79*7836SJohn.Forte@Sun.COM 	{ "NSC_SEQ_IO", NSC_SEQ_IO, NSC_SEQ_IO },
80*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
81*7836SJohn.Forte@Sun.COM };
82*7836SJohn.Forte@Sun.COM 
83*7836SJohn.Forte@Sun.COM 
84*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nsc_fdflag_bits[] = {
85*7836SJohn.Forte@Sun.COM 	NSC_RW_BITS,
86*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
87*7836SJohn.Forte@Sun.COM };
88*7836SJohn.Forte@Sun.COM 
89*7836SJohn.Forte@Sun.COM 
90*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nsc_fdmode_bits[] = {
91*7836SJohn.Forte@Sun.COM 	{ "NSC_MULTI", NSC_MULTI, NSC_MULTI },
92*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
93*7836SJohn.Forte@Sun.COM };
94*7836SJohn.Forte@Sun.COM 
95*7836SJohn.Forte@Sun.COM 
96*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nsc_type_bits[] = {
97*7836SJohn.Forte@Sun.COM 	/* types */
98*7836SJohn.Forte@Sun.COM 	{ "NSC_NULL", NSC_NULL, NSC_NULL },
99*7836SJohn.Forte@Sun.COM 	{ "NSC_DEVICE", NSC_DEVICE, NSC_DEVICE },
100*7836SJohn.Forte@Sun.COM 	{ "NSC_FILE", NSC_FILE, NSC_FILE },
101*7836SJohn.Forte@Sun.COM 	{ "NSC_CACHE", NSC_CACHE, NSC_CACHE },
102*7836SJohn.Forte@Sun.COM 	{ "NSC_VCHR", NSC_VCHR, NSC_VCHR },
103*7836SJohn.Forte@Sun.COM 	{ "NSC_NCALL", NSC_NCALL, NSC_NCALL },
104*7836SJohn.Forte@Sun.COM 
105*7836SJohn.Forte@Sun.COM 	/* type flags */
106*7836SJohn.Forte@Sun.COM 	{ "NSC_ANON", NSC_ANON, NSC_ANON },
107*7836SJohn.Forte@Sun.COM 
108*7836SJohn.Forte@Sun.COM 	/* ids */
109*7836SJohn.Forte@Sun.COM 	{ "NSC_RAW_ID", NSC_RAW_ID, NSC_RAW_ID },
110*7836SJohn.Forte@Sun.COM 	{ "NSC_FILE_ID", NSC_FILE_ID, NSC_FILE_ID },
111*7836SJohn.Forte@Sun.COM 	{ "NSC_FREEZE_ID", NSC_FREEZE_ID, NSC_FREEZE_ID },
112*7836SJohn.Forte@Sun.COM 	{ "NSC_VCHR_ID", NSC_VCHR_ID, NSC_VCHR_ID },
113*7836SJohn.Forte@Sun.COM 	{ "NSC_NCALL_ID", NSC_NCALL_ID, NSC_NCALL_ID },
114*7836SJohn.Forte@Sun.COM 	{ "NSC_SDBC_ID", NSC_SDBC_ID, NSC_SDBC_ID },
115*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCLR_ID", NSC_RDCLR_ID, NSC_RDCLR_ID },
116*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCL_ID", NSC_RDCL_ID, NSC_RDCL_ID },
117*7836SJohn.Forte@Sun.COM 	{ "NSC_IIR_ID", NSC_IIR_ID, NSC_IIR_ID },
118*7836SJohn.Forte@Sun.COM 	{ "NSC_II_ID", NSC_II_ID, NSC_II_ID },
119*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCHR_ID", NSC_RDCHR_ID, NSC_RDCHR_ID },
120*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCH_ID", NSC_RDCH_ID, NSC_RDCH_ID },
121*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
122*7836SJohn.Forte@Sun.COM };
123*7836SJohn.Forte@Sun.COM 
124*7836SJohn.Forte@Sun.COM 
125*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nsc_availpend_bits[] = {
126*7836SJohn.Forte@Sun.COM 	NSC_RW_BITS,
127*7836SJohn.Forte@Sun.COM 	{ "_NSC_OPEN", _NSC_OPEN, _NSC_OPEN },
128*7836SJohn.Forte@Sun.COM 	{ "_NSC_CLOSE", _NSC_CLOSE, _NSC_CLOSE },
129*7836SJohn.Forte@Sun.COM 	{ "_NSC_PINNED", _NSC_PINNED, _NSC_PINNED },
130*7836SJohn.Forte@Sun.COM 	{ "_NSC_ATTACH", _NSC_ATTACH, _NSC_ATTACH },
131*7836SJohn.Forte@Sun.COM 	{ "_NSC_DETACH", _NSC_DETACH, _NSC_DETACH },
132*7836SJohn.Forte@Sun.COM 	{ "_NSC_OWNER", _NSC_OWNER, _NSC_OWNER },
133*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
134*7836SJohn.Forte@Sun.COM };
135*7836SJohn.Forte@Sun.COM 
136*7836SJohn.Forte@Sun.COM 
137*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nsc_ioflag_bits[] = {
138*7836SJohn.Forte@Sun.COM 	{ "NSC_REFCNT", NSC_REFCNT, NSC_REFCNT },
139*7836SJohn.Forte@Sun.COM 	{ "NSC_FILTER", NSC_FILTER, NSC_FILTER },
140*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
141*7836SJohn.Forte@Sun.COM };
142*7836SJohn.Forte@Sun.COM 
143*7836SJohn.Forte@Sun.COM 
144*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nstset_flag_bits[] = {
145*7836SJohn.Forte@Sun.COM 	{ "NST_SF_KILL", NST_SF_KILL, NST_SF_KILL },
146*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
147*7836SJohn.Forte@Sun.COM };
148*7836SJohn.Forte@Sun.COM 
149*7836SJohn.Forte@Sun.COM 
150*7836SJohn.Forte@Sun.COM static const mdb_bitmask_t nst_flag_bits[] = {
151*7836SJohn.Forte@Sun.COM 	{ "NST_TF_INUSE", NST_TF_INUSE, NST_TF_INUSE },
152*7836SJohn.Forte@Sun.COM 	{ "NST_TF_ACTIVE", NST_TF_ACTIVE, NST_TF_ACTIVE },
153*7836SJohn.Forte@Sun.COM 	{ "NST_TF_PENDING", NST_TF_PENDING, NST_TF_PENDING },
154*7836SJohn.Forte@Sun.COM 	{ "NST_TF_DESTROY", NST_TF_DESTROY, NST_TF_DESTROY },
155*7836SJohn.Forte@Sun.COM 	{ "NST_TF_KILL", NST_TF_KILL, NST_TF_KILL },
156*7836SJohn.Forte@Sun.COM 	{ NULL, 0, 0 }
157*7836SJohn.Forte@Sun.COM };
158*7836SJohn.Forte@Sun.COM 
159*7836SJohn.Forte@Sun.COM 
160*7836SJohn.Forte@Sun.COM /*
161*7836SJohn.Forte@Sun.COM  * Global data.
162*7836SJohn.Forte@Sun.COM  */
163*7836SJohn.Forte@Sun.COM 
164*7836SJohn.Forte@Sun.COM static nsc_mem_t type_mem[20];
165*7836SJohn.Forte@Sun.COM static int complex_walk;
166*7836SJohn.Forte@Sun.COM static int complex_hdr;
167*7836SJohn.Forte@Sun.COM 
168*7836SJohn.Forte@Sun.COM 
169*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
170*7836SJohn.Forte@Sun.COM 
171*7836SJohn.Forte@Sun.COM /*
172*7836SJohn.Forte@Sun.COM  * Walker for an nsc_io chain.
173*7836SJohn.Forte@Sun.COM  * A global walk is assumed to start at _nsc_io_top.
174*7836SJohn.Forte@Sun.COM  */
175*7836SJohn.Forte@Sun.COM 
176*7836SJohn.Forte@Sun.COM static int
nsc_io_winit(mdb_walk_state_t * wsp)177*7836SJohn.Forte@Sun.COM nsc_io_winit(mdb_walk_state_t *wsp)
178*7836SJohn.Forte@Sun.COM {
179*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL &&
180*7836SJohn.Forte@Sun.COM 	    mdb_readvar(&wsp->walk_addr, "_nsc_io_top") == -1) {
181*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read '_nsc_io_top'");
182*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
183*7836SJohn.Forte@Sun.COM 	}
184*7836SJohn.Forte@Sun.COM 
185*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
186*7836SJohn.Forte@Sun.COM }
187*7836SJohn.Forte@Sun.COM 
188*7836SJohn.Forte@Sun.COM 
189*7836SJohn.Forte@Sun.COM static int
nsc_io_wstep(mdb_walk_state_t * wsp)190*7836SJohn.Forte@Sun.COM nsc_io_wstep(mdb_walk_state_t *wsp)
191*7836SJohn.Forte@Sun.COM {
192*7836SJohn.Forte@Sun.COM 	uintptr_t next;
193*7836SJohn.Forte@Sun.COM 	int status;
194*7836SJohn.Forte@Sun.COM 
195*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL)
196*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
197*7836SJohn.Forte@Sun.COM 
198*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
199*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
200*7836SJohn.Forte@Sun.COM 
201*7836SJohn.Forte@Sun.COM 	next = wsp->walk_addr + OFFSETOF(nsc_io_t, next);
202*7836SJohn.Forte@Sun.COM 
203*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (uintptr_t), next) == -1) {
204*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_io_t.next at %p", next);
205*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
206*7836SJohn.Forte@Sun.COM 	}
207*7836SJohn.Forte@Sun.COM 
208*7836SJohn.Forte@Sun.COM 	return (status);
209*7836SJohn.Forte@Sun.COM }
210*7836SJohn.Forte@Sun.COM 
211*7836SJohn.Forte@Sun.COM 
212*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
213*7836SJohn.Forte@Sun.COM 
214*7836SJohn.Forte@Sun.COM /*
215*7836SJohn.Forte@Sun.COM  * Walker for an nsc_dev chain.
216*7836SJohn.Forte@Sun.COM  * A global walk is assumed to start at _nsc_dev_top.
217*7836SJohn.Forte@Sun.COM  */
218*7836SJohn.Forte@Sun.COM 
219*7836SJohn.Forte@Sun.COM static int
nsc_dev_winit(mdb_walk_state_t * wsp)220*7836SJohn.Forte@Sun.COM nsc_dev_winit(mdb_walk_state_t *wsp)
221*7836SJohn.Forte@Sun.COM {
222*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL &&
223*7836SJohn.Forte@Sun.COM 	    mdb_readvar(&wsp->walk_addr, "_nsc_dev_top") == -1) {
224*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read '_nsc_dev_top'");
225*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
226*7836SJohn.Forte@Sun.COM 	}
227*7836SJohn.Forte@Sun.COM 
228*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
229*7836SJohn.Forte@Sun.COM }
230*7836SJohn.Forte@Sun.COM 
231*7836SJohn.Forte@Sun.COM 
232*7836SJohn.Forte@Sun.COM static int
nsc_dev_wstep(mdb_walk_state_t * wsp)233*7836SJohn.Forte@Sun.COM nsc_dev_wstep(mdb_walk_state_t *wsp)
234*7836SJohn.Forte@Sun.COM {
235*7836SJohn.Forte@Sun.COM 	uintptr_t next;
236*7836SJohn.Forte@Sun.COM 	int status;
237*7836SJohn.Forte@Sun.COM 
238*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL)
239*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
240*7836SJohn.Forte@Sun.COM 
241*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
242*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
243*7836SJohn.Forte@Sun.COM 
244*7836SJohn.Forte@Sun.COM 	next = wsp->walk_addr + OFFSETOF(nsc_dev_t, nsc_next);
245*7836SJohn.Forte@Sun.COM 
246*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (uintptr_t), next) == -1) {
247*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_dev_t.nsc_next at %p", next);
248*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
249*7836SJohn.Forte@Sun.COM 	}
250*7836SJohn.Forte@Sun.COM 
251*7836SJohn.Forte@Sun.COM 	return (status);
252*7836SJohn.Forte@Sun.COM }
253*7836SJohn.Forte@Sun.COM 
254*7836SJohn.Forte@Sun.COM 
255*7836SJohn.Forte@Sun.COM /* ARGSUSED */
256*7836SJohn.Forte@Sun.COM 
257*7836SJohn.Forte@Sun.COM static void
nsc_dev_wfini(mdb_walk_state_t * wsp)258*7836SJohn.Forte@Sun.COM nsc_dev_wfini(mdb_walk_state_t *wsp)
259*7836SJohn.Forte@Sun.COM {
260*7836SJohn.Forte@Sun.COM 	complex_walk = 0;
261*7836SJohn.Forte@Sun.COM }
262*7836SJohn.Forte@Sun.COM 
263*7836SJohn.Forte@Sun.COM 
264*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
265*7836SJohn.Forte@Sun.COM 
266*7836SJohn.Forte@Sun.COM /*
267*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_devval_t structures.
268*7836SJohn.Forte@Sun.COM  * Global walks start from _nsc_devval_top;
269*7836SJohn.Forte@Sun.COM  */
270*7836SJohn.Forte@Sun.COM 
271*7836SJohn.Forte@Sun.COM static int
nsc_devval_winit(mdb_walk_state_t * wsp)272*7836SJohn.Forte@Sun.COM nsc_devval_winit(mdb_walk_state_t *wsp)
273*7836SJohn.Forte@Sun.COM {
274*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL &&
275*7836SJohn.Forte@Sun.COM 	    mdb_readvar(&wsp->walk_addr, "_nsc_devval_top") == -1) {
276*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read '_nsc_devval_top'");
277*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
278*7836SJohn.Forte@Sun.COM 	}
279*7836SJohn.Forte@Sun.COM 
280*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
281*7836SJohn.Forte@Sun.COM }
282*7836SJohn.Forte@Sun.COM 
283*7836SJohn.Forte@Sun.COM 
284*7836SJohn.Forte@Sun.COM static int
nsc_devval_wstep(mdb_walk_state_t * wsp)285*7836SJohn.Forte@Sun.COM nsc_devval_wstep(mdb_walk_state_t *wsp)
286*7836SJohn.Forte@Sun.COM {
287*7836SJohn.Forte@Sun.COM 	uintptr_t devval = wsp->walk_addr;
288*7836SJohn.Forte@Sun.COM 	int status;
289*7836SJohn.Forte@Sun.COM 
290*7836SJohn.Forte@Sun.COM 	if (!devval)
291*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
292*7836SJohn.Forte@Sun.COM 
293*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
294*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
295*7836SJohn.Forte@Sun.COM 
296*7836SJohn.Forte@Sun.COM 	/* move on to next devval */
297*7836SJohn.Forte@Sun.COM 
298*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
299*7836SJohn.Forte@Sun.COM 	    devval + OFFSETOF(nsc_devval_t, dv_next)) == -1) {
300*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_devval_t.dv_next");
301*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
302*7836SJohn.Forte@Sun.COM 	}
303*7836SJohn.Forte@Sun.COM 
304*7836SJohn.Forte@Sun.COM 	return (status);
305*7836SJohn.Forte@Sun.COM }
306*7836SJohn.Forte@Sun.COM 
307*7836SJohn.Forte@Sun.COM 
308*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
309*7836SJohn.Forte@Sun.COM 
310*7836SJohn.Forte@Sun.COM /*
311*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_fd_t structures.
312*7836SJohn.Forte@Sun.COM  * No global walks.
313*7836SJohn.Forte@Sun.COM  */
314*7836SJohn.Forte@Sun.COM 
315*7836SJohn.Forte@Sun.COM static int
nsc_fd_winit(mdb_walk_state_t * wsp)316*7836SJohn.Forte@Sun.COM nsc_fd_winit(mdb_walk_state_t *wsp)
317*7836SJohn.Forte@Sun.COM {
318*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
319*7836SJohn.Forte@Sun.COM 		mdb_warn("nsc_fd doesn't support global walks");
320*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
321*7836SJohn.Forte@Sun.COM 	}
322*7836SJohn.Forte@Sun.COM 
323*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
324*7836SJohn.Forte@Sun.COM }
325*7836SJohn.Forte@Sun.COM 
326*7836SJohn.Forte@Sun.COM 
327*7836SJohn.Forte@Sun.COM static int
nsc_fd_wstep(mdb_walk_state_t * wsp)328*7836SJohn.Forte@Sun.COM nsc_fd_wstep(mdb_walk_state_t *wsp)
329*7836SJohn.Forte@Sun.COM {
330*7836SJohn.Forte@Sun.COM 	uintptr_t fd = wsp->walk_addr;
331*7836SJohn.Forte@Sun.COM 	int status;
332*7836SJohn.Forte@Sun.COM 
333*7836SJohn.Forte@Sun.COM 	if (!fd)
334*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
335*7836SJohn.Forte@Sun.COM 
336*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
337*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
338*7836SJohn.Forte@Sun.COM 
339*7836SJohn.Forte@Sun.COM 	/* move on to next fd */
340*7836SJohn.Forte@Sun.COM 
341*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
342*7836SJohn.Forte@Sun.COM 	    fd + OFFSETOF(nsc_fd_t, sf_next)) == -1) {
343*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_fd_t.sf_next");
344*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
345*7836SJohn.Forte@Sun.COM 	}
346*7836SJohn.Forte@Sun.COM 
347*7836SJohn.Forte@Sun.COM 	return (status);
348*7836SJohn.Forte@Sun.COM }
349*7836SJohn.Forte@Sun.COM 
350*7836SJohn.Forte@Sun.COM 
351*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
352*7836SJohn.Forte@Sun.COM 
353*7836SJohn.Forte@Sun.COM /*
354*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_iodev_t structures.
355*7836SJohn.Forte@Sun.COM  * No global walks.
356*7836SJohn.Forte@Sun.COM  */
357*7836SJohn.Forte@Sun.COM 
358*7836SJohn.Forte@Sun.COM static int
nsc_iodev_winit(mdb_walk_state_t * wsp)359*7836SJohn.Forte@Sun.COM nsc_iodev_winit(mdb_walk_state_t *wsp)
360*7836SJohn.Forte@Sun.COM {
361*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
362*7836SJohn.Forte@Sun.COM 		mdb_warn("nsc_iodev doesn't support global walks");
363*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
364*7836SJohn.Forte@Sun.COM 	}
365*7836SJohn.Forte@Sun.COM 
366*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
367*7836SJohn.Forte@Sun.COM }
368*7836SJohn.Forte@Sun.COM 
369*7836SJohn.Forte@Sun.COM 
370*7836SJohn.Forte@Sun.COM static int
nsc_iodev_wstep(mdb_walk_state_t * wsp)371*7836SJohn.Forte@Sun.COM nsc_iodev_wstep(mdb_walk_state_t *wsp)
372*7836SJohn.Forte@Sun.COM {
373*7836SJohn.Forte@Sun.COM 	uintptr_t iodev = wsp->walk_addr;
374*7836SJohn.Forte@Sun.COM 	int status;
375*7836SJohn.Forte@Sun.COM 
376*7836SJohn.Forte@Sun.COM 	if (!iodev)
377*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
378*7836SJohn.Forte@Sun.COM 
379*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
380*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
381*7836SJohn.Forte@Sun.COM 
382*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
383*7836SJohn.Forte@Sun.COM 	    iodev + OFFSETOF(nsc_iodev_t, si_next)) == -1) {
384*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_iodev_t.si_next");
385*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
386*7836SJohn.Forte@Sun.COM 	}
387*7836SJohn.Forte@Sun.COM 
388*7836SJohn.Forte@Sun.COM 	return (status);
389*7836SJohn.Forte@Sun.COM }
390*7836SJohn.Forte@Sun.COM 
391*7836SJohn.Forte@Sun.COM 
392*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
393*7836SJohn.Forte@Sun.COM 
394*7836SJohn.Forte@Sun.COM /*
395*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_service_t structures.
396*7836SJohn.Forte@Sun.COM  * Global walks start at _nsc_services.
397*7836SJohn.Forte@Sun.COM  */
398*7836SJohn.Forte@Sun.COM 
399*7836SJohn.Forte@Sun.COM static int
nsc_service_winit(mdb_walk_state_t * wsp)400*7836SJohn.Forte@Sun.COM nsc_service_winit(mdb_walk_state_t *wsp)
401*7836SJohn.Forte@Sun.COM {
402*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL &&
403*7836SJohn.Forte@Sun.COM 	    mdb_readvar(&wsp->walk_addr, "_nsc_services") == -1) {
404*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read '_nsc_services'");
405*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
406*7836SJohn.Forte@Sun.COM 	}
407*7836SJohn.Forte@Sun.COM 
408*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
409*7836SJohn.Forte@Sun.COM }
410*7836SJohn.Forte@Sun.COM 
411*7836SJohn.Forte@Sun.COM 
412*7836SJohn.Forte@Sun.COM static int
nsc_service_wstep(mdb_walk_state_t * wsp)413*7836SJohn.Forte@Sun.COM nsc_service_wstep(mdb_walk_state_t *wsp)
414*7836SJohn.Forte@Sun.COM {
415*7836SJohn.Forte@Sun.COM 	uintptr_t service = wsp->walk_addr;
416*7836SJohn.Forte@Sun.COM 	int status;
417*7836SJohn.Forte@Sun.COM 
418*7836SJohn.Forte@Sun.COM 	if (!service)
419*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
420*7836SJohn.Forte@Sun.COM 
421*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
422*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
423*7836SJohn.Forte@Sun.COM 
424*7836SJohn.Forte@Sun.COM 	/* move on to next service */
425*7836SJohn.Forte@Sun.COM 
426*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
427*7836SJohn.Forte@Sun.COM 	    service + OFFSETOF(nsc_service_t, s_next)) == -1) {
428*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_service_t.s_next");
429*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
430*7836SJohn.Forte@Sun.COM 	}
431*7836SJohn.Forte@Sun.COM 
432*7836SJohn.Forte@Sun.COM 	return (status);
433*7836SJohn.Forte@Sun.COM }
434*7836SJohn.Forte@Sun.COM 
435*7836SJohn.Forte@Sun.COM 
436*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
437*7836SJohn.Forte@Sun.COM 
438*7836SJohn.Forte@Sun.COM /*
439*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_svc_t structures.
440*7836SJohn.Forte@Sun.COM  * No global walks.
441*7836SJohn.Forte@Sun.COM  */
442*7836SJohn.Forte@Sun.COM 
443*7836SJohn.Forte@Sun.COM static int
nsc_svc_winit(mdb_walk_state_t * wsp)444*7836SJohn.Forte@Sun.COM nsc_svc_winit(mdb_walk_state_t *wsp)
445*7836SJohn.Forte@Sun.COM {
446*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
447*7836SJohn.Forte@Sun.COM 		mdb_warn("nsc_svc does not support global walks");
448*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
449*7836SJohn.Forte@Sun.COM 	}
450*7836SJohn.Forte@Sun.COM 
451*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
452*7836SJohn.Forte@Sun.COM }
453*7836SJohn.Forte@Sun.COM 
454*7836SJohn.Forte@Sun.COM 
455*7836SJohn.Forte@Sun.COM static int
nsc_svc_wstep(mdb_walk_state_t * wsp)456*7836SJohn.Forte@Sun.COM nsc_svc_wstep(mdb_walk_state_t *wsp)
457*7836SJohn.Forte@Sun.COM {
458*7836SJohn.Forte@Sun.COM 	uintptr_t svc = wsp->walk_addr;
459*7836SJohn.Forte@Sun.COM 	int status;
460*7836SJohn.Forte@Sun.COM 
461*7836SJohn.Forte@Sun.COM 	if (!svc)
462*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
463*7836SJohn.Forte@Sun.COM 
464*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
465*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
466*7836SJohn.Forte@Sun.COM 
467*7836SJohn.Forte@Sun.COM 	/* move on to next svc */
468*7836SJohn.Forte@Sun.COM 
469*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
470*7836SJohn.Forte@Sun.COM 	    svc + OFFSETOF(nsc_svc_t, svc_next)) == -1) {
471*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_svc_t.svc_next");
472*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
473*7836SJohn.Forte@Sun.COM 	}
474*7836SJohn.Forte@Sun.COM 
475*7836SJohn.Forte@Sun.COM 	return (status);
476*7836SJohn.Forte@Sun.COM }
477*7836SJohn.Forte@Sun.COM 
478*7836SJohn.Forte@Sun.COM 
479*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
480*7836SJohn.Forte@Sun.COM 
481*7836SJohn.Forte@Sun.COM /*
482*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_val_t structures.
483*7836SJohn.Forte@Sun.COM  * No global walks.
484*7836SJohn.Forte@Sun.COM  */
485*7836SJohn.Forte@Sun.COM 
486*7836SJohn.Forte@Sun.COM static int
nsc_val_winit(mdb_walk_state_t * wsp)487*7836SJohn.Forte@Sun.COM nsc_val_winit(mdb_walk_state_t *wsp)
488*7836SJohn.Forte@Sun.COM {
489*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
490*7836SJohn.Forte@Sun.COM 		mdb_warn("nsc_val doesn't support global walks");
491*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
492*7836SJohn.Forte@Sun.COM 	}
493*7836SJohn.Forte@Sun.COM 
494*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
495*7836SJohn.Forte@Sun.COM }
496*7836SJohn.Forte@Sun.COM 
497*7836SJohn.Forte@Sun.COM 
498*7836SJohn.Forte@Sun.COM static int
nsc_val_wstep(mdb_walk_state_t * wsp)499*7836SJohn.Forte@Sun.COM nsc_val_wstep(mdb_walk_state_t *wsp)
500*7836SJohn.Forte@Sun.COM {
501*7836SJohn.Forte@Sun.COM 	uintptr_t val = wsp->walk_addr;
502*7836SJohn.Forte@Sun.COM 	int status;
503*7836SJohn.Forte@Sun.COM 
504*7836SJohn.Forte@Sun.COM 	if (!val)
505*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
506*7836SJohn.Forte@Sun.COM 
507*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
508*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
509*7836SJohn.Forte@Sun.COM 
510*7836SJohn.Forte@Sun.COM 	/* move on to next val */
511*7836SJohn.Forte@Sun.COM 
512*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
513*7836SJohn.Forte@Sun.COM 	    val + OFFSETOF(nsc_val_t, sv_next)) == -1) {
514*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_val_t.sv_next");
515*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
516*7836SJohn.Forte@Sun.COM 	}
517*7836SJohn.Forte@Sun.COM 
518*7836SJohn.Forte@Sun.COM 	return (status);
519*7836SJohn.Forte@Sun.COM }
520*7836SJohn.Forte@Sun.COM 
521*7836SJohn.Forte@Sun.COM 
522*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
523*7836SJohn.Forte@Sun.COM 
524*7836SJohn.Forte@Sun.COM /*
525*7836SJohn.Forte@Sun.COM  * Walker for a chain of nstset_t structures.
526*7836SJohn.Forte@Sun.COM  * Global walks start at _nst_sets.
527*7836SJohn.Forte@Sun.COM  */
528*7836SJohn.Forte@Sun.COM 
529*7836SJohn.Forte@Sun.COM static int
nstset_winit(mdb_walk_state_t * wsp)530*7836SJohn.Forte@Sun.COM nstset_winit(mdb_walk_state_t *wsp)
531*7836SJohn.Forte@Sun.COM {
532*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL &&
533*7836SJohn.Forte@Sun.COM 	    mdb_readvar(&wsp->walk_addr, "nst_sets") == -1) {
534*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read 'nst_sets'");
535*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
536*7836SJohn.Forte@Sun.COM 	}
537*7836SJohn.Forte@Sun.COM 
538*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
539*7836SJohn.Forte@Sun.COM }
540*7836SJohn.Forte@Sun.COM 
541*7836SJohn.Forte@Sun.COM 
542*7836SJohn.Forte@Sun.COM static int
nstset_wstep(mdb_walk_state_t * wsp)543*7836SJohn.Forte@Sun.COM nstset_wstep(mdb_walk_state_t *wsp)
544*7836SJohn.Forte@Sun.COM {
545*7836SJohn.Forte@Sun.COM 	uintptr_t set = wsp->walk_addr;
546*7836SJohn.Forte@Sun.COM 	int status;
547*7836SJohn.Forte@Sun.COM 
548*7836SJohn.Forte@Sun.COM 	if (!set)
549*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
550*7836SJohn.Forte@Sun.COM 
551*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
552*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
553*7836SJohn.Forte@Sun.COM 
554*7836SJohn.Forte@Sun.COM 	/* move on to next set */
555*7836SJohn.Forte@Sun.COM 
556*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
557*7836SJohn.Forte@Sun.COM 	    set + OFFSETOF(nstset_t, set_next)) == -1) {
558*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nstset_t.set_next");
559*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
560*7836SJohn.Forte@Sun.COM 	}
561*7836SJohn.Forte@Sun.COM 
562*7836SJohn.Forte@Sun.COM 	return (status);
563*7836SJohn.Forte@Sun.COM }
564*7836SJohn.Forte@Sun.COM 
565*7836SJohn.Forte@Sun.COM 
566*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
567*7836SJohn.Forte@Sun.COM 
568*7836SJohn.Forte@Sun.COM /*
569*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsthread_t structures.
570*7836SJohn.Forte@Sun.COM  * No global walks.
571*7836SJohn.Forte@Sun.COM  */
572*7836SJohn.Forte@Sun.COM 
573*7836SJohn.Forte@Sun.COM static int
nsthread_winit(mdb_walk_state_t * wsp)574*7836SJohn.Forte@Sun.COM nsthread_winit(mdb_walk_state_t *wsp)
575*7836SJohn.Forte@Sun.COM {
576*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
577*7836SJohn.Forte@Sun.COM 		mdb_warn("nsthread does not support global walks");
578*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
579*7836SJohn.Forte@Sun.COM 	}
580*7836SJohn.Forte@Sun.COM 
581*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
582*7836SJohn.Forte@Sun.COM }
583*7836SJohn.Forte@Sun.COM 
584*7836SJohn.Forte@Sun.COM 
585*7836SJohn.Forte@Sun.COM static int
nsthread_wstep(mdb_walk_state_t * wsp)586*7836SJohn.Forte@Sun.COM nsthread_wstep(mdb_walk_state_t *wsp)
587*7836SJohn.Forte@Sun.COM {
588*7836SJohn.Forte@Sun.COM 	uintptr_t thread = wsp->walk_addr;
589*7836SJohn.Forte@Sun.COM 	int status;
590*7836SJohn.Forte@Sun.COM 
591*7836SJohn.Forte@Sun.COM 	if (!thread)
592*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
593*7836SJohn.Forte@Sun.COM 
594*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
595*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
596*7836SJohn.Forte@Sun.COM 
597*7836SJohn.Forte@Sun.COM 	/* move on to next iodev */
598*7836SJohn.Forte@Sun.COM 
599*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
600*7836SJohn.Forte@Sun.COM 	    thread + OFFSETOF(nsthread_t, tp_chain)) == -1) {
601*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsthread_t.tp_chain");
602*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
603*7836SJohn.Forte@Sun.COM 	}
604*7836SJohn.Forte@Sun.COM 
605*7836SJohn.Forte@Sun.COM 	return (status);
606*7836SJohn.Forte@Sun.COM }
607*7836SJohn.Forte@Sun.COM 
608*7836SJohn.Forte@Sun.COM 
609*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
610*7836SJohn.Forte@Sun.COM 
611*7836SJohn.Forte@Sun.COM /*
612*7836SJohn.Forte@Sun.COM  * Walker for nsthread_t free/reuse chain.
613*7836SJohn.Forte@Sun.COM  * No global walks.
614*7836SJohn.Forte@Sun.COM  */
615*7836SJohn.Forte@Sun.COM 
616*7836SJohn.Forte@Sun.COM static int
nst_free_winit(mdb_walk_state_t * wsp)617*7836SJohn.Forte@Sun.COM nst_free_winit(mdb_walk_state_t *wsp)
618*7836SJohn.Forte@Sun.COM {
619*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL) {
620*7836SJohn.Forte@Sun.COM 		mdb_warn("nst_free does not support global walks");
621*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
622*7836SJohn.Forte@Sun.COM 	}
623*7836SJohn.Forte@Sun.COM 
624*7836SJohn.Forte@Sun.COM 	/* store starting address */
625*7836SJohn.Forte@Sun.COM 
626*7836SJohn.Forte@Sun.COM 	wsp->walk_data = (void *)wsp->walk_addr;
627*7836SJohn.Forte@Sun.COM 
628*7836SJohn.Forte@Sun.COM 	/* move on to next thread */
629*7836SJohn.Forte@Sun.COM 
630*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
631*7836SJohn.Forte@Sun.COM 	    wsp->walk_addr + OFFSETOF(nsthread_t, tp_link.q_forw)) == -1) {
632*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsthread_t.tp_link.q_forw");
633*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
634*7836SJohn.Forte@Sun.COM 	}
635*7836SJohn.Forte@Sun.COM 
636*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
637*7836SJohn.Forte@Sun.COM }
638*7836SJohn.Forte@Sun.COM 
639*7836SJohn.Forte@Sun.COM 
640*7836SJohn.Forte@Sun.COM static int
nst_free_wstep(mdb_walk_state_t * wsp)641*7836SJohn.Forte@Sun.COM nst_free_wstep(mdb_walk_state_t *wsp)
642*7836SJohn.Forte@Sun.COM {
643*7836SJohn.Forte@Sun.COM 	uintptr_t thread = wsp->walk_addr;
644*7836SJohn.Forte@Sun.COM 	int status;
645*7836SJohn.Forte@Sun.COM 
646*7836SJohn.Forte@Sun.COM 	if (!thread)
647*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
648*7836SJohn.Forte@Sun.COM 
649*7836SJohn.Forte@Sun.COM 	if (thread == (uintptr_t)wsp->walk_data)
650*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
651*7836SJohn.Forte@Sun.COM 
652*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
653*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
654*7836SJohn.Forte@Sun.COM 
655*7836SJohn.Forte@Sun.COM 	/* move on to next thread */
656*7836SJohn.Forte@Sun.COM 
657*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
658*7836SJohn.Forte@Sun.COM 	    thread + OFFSETOF(nsthread_t, tp_link.q_forw)) == -1) {
659*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsthread_t.tp_link.q_forw");
660*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
661*7836SJohn.Forte@Sun.COM 	}
662*7836SJohn.Forte@Sun.COM 
663*7836SJohn.Forte@Sun.COM 	return (status);
664*7836SJohn.Forte@Sun.COM }
665*7836SJohn.Forte@Sun.COM 
666*7836SJohn.Forte@Sun.COM 
667*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
668*7836SJohn.Forte@Sun.COM 
669*7836SJohn.Forte@Sun.COM /*
670*7836SJohn.Forte@Sun.COM  * Walker for a chain of nsc_mem_t structures.
671*7836SJohn.Forte@Sun.COM  * Global walks start at _nsc_mem_top.
672*7836SJohn.Forte@Sun.COM  */
673*7836SJohn.Forte@Sun.COM 
674*7836SJohn.Forte@Sun.COM static int
nsc_mem_winit(mdb_walk_state_t * wsp)675*7836SJohn.Forte@Sun.COM nsc_mem_winit(mdb_walk_state_t *wsp)
676*7836SJohn.Forte@Sun.COM {
677*7836SJohn.Forte@Sun.COM 	if (wsp->walk_addr == NULL &&
678*7836SJohn.Forte@Sun.COM 	    mdb_readvar(&wsp->walk_addr, "_nsc_mem_top") == -1) {
679*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read '_nsc_mem_top'");
680*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
681*7836SJohn.Forte@Sun.COM 	}
682*7836SJohn.Forte@Sun.COM 
683*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
684*7836SJohn.Forte@Sun.COM }
685*7836SJohn.Forte@Sun.COM 
686*7836SJohn.Forte@Sun.COM 
687*7836SJohn.Forte@Sun.COM static int
nsc_mem_wstep(mdb_walk_state_t * wsp)688*7836SJohn.Forte@Sun.COM nsc_mem_wstep(mdb_walk_state_t *wsp)
689*7836SJohn.Forte@Sun.COM {
690*7836SJohn.Forte@Sun.COM 	uintptr_t mem = wsp->walk_addr;
691*7836SJohn.Forte@Sun.COM 	int status;
692*7836SJohn.Forte@Sun.COM 
693*7836SJohn.Forte@Sun.COM 	if (!mem)
694*7836SJohn.Forte@Sun.COM 		return (WALK_DONE);
695*7836SJohn.Forte@Sun.COM 
696*7836SJohn.Forte@Sun.COM 	status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
697*7836SJohn.Forte@Sun.COM 	    wsp->walk_cbdata);
698*7836SJohn.Forte@Sun.COM 
699*7836SJohn.Forte@Sun.COM 	/* move on to next mem */
700*7836SJohn.Forte@Sun.COM 
701*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&wsp->walk_addr, sizeof (wsp->walk_addr),
702*7836SJohn.Forte@Sun.COM 	    mem + OFFSETOF(nsc_mem_t, next)) == -1) {
703*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_mem_t.next");
704*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
705*7836SJohn.Forte@Sun.COM 	}
706*7836SJohn.Forte@Sun.COM 
707*7836SJohn.Forte@Sun.COM 	return (status);
708*7836SJohn.Forte@Sun.COM }
709*7836SJohn.Forte@Sun.COM 
710*7836SJohn.Forte@Sun.COM 
711*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
712*7836SJohn.Forte@Sun.COM 
713*7836SJohn.Forte@Sun.COM struct {
714*7836SJohn.Forte@Sun.COM 	char	*name;
715*7836SJohn.Forte@Sun.COM 	int	id;
716*7836SJohn.Forte@Sun.COM } io_ids[] = {
717*7836SJohn.Forte@Sun.COM 	{ "NSC_RAW_ID", NSC_RAW_ID },
718*7836SJohn.Forte@Sun.COM 	{ "NSC_FILE_ID", NSC_FILE_ID },
719*7836SJohn.Forte@Sun.COM 	{ "NSC_FREEZE_ID", NSC_FREEZE_ID },
720*7836SJohn.Forte@Sun.COM 	{ "NSC_SDBC_ID", NSC_SDBC_ID },
721*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCLR_ID", NSC_RDCLR_ID },
722*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCL_ID", NSC_RDCL_ID },
723*7836SJohn.Forte@Sun.COM 	{ "NSC_IIR_ID", NSC_IIR_ID },
724*7836SJohn.Forte@Sun.COM 	{ "NSC_II_ID", NSC_II_ID },
725*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCHR_ID", NSC_RDCHR_ID },
726*7836SJohn.Forte@Sun.COM 	{ "NSC_RDCH_ID", NSC_RDCH_ID },
727*7836SJohn.Forte@Sun.COM 	{ NULL, 0 }
728*7836SJohn.Forte@Sun.COM };
729*7836SJohn.Forte@Sun.COM 
730*7836SJohn.Forte@Sun.COM 
731*7836SJohn.Forte@Sun.COM static char *
nsc_io_id(const int id)732*7836SJohn.Forte@Sun.COM nsc_io_id(const int id)
733*7836SJohn.Forte@Sun.COM {
734*7836SJohn.Forte@Sun.COM 	int i;
735*7836SJohn.Forte@Sun.COM 
736*7836SJohn.Forte@Sun.COM 	for (i = 0; io_ids[i].name != NULL; i++) {
737*7836SJohn.Forte@Sun.COM 		if (io_ids[i].id == id) {
738*7836SJohn.Forte@Sun.COM 			return (io_ids[i].name);
739*7836SJohn.Forte@Sun.COM 		}
740*7836SJohn.Forte@Sun.COM 	}
741*7836SJohn.Forte@Sun.COM 
742*7836SJohn.Forte@Sun.COM 	return ("unknown");
743*7836SJohn.Forte@Sun.COM }
744*7836SJohn.Forte@Sun.COM 
745*7836SJohn.Forte@Sun.COM 
746*7836SJohn.Forte@Sun.COM /*
747*7836SJohn.Forte@Sun.COM  * Display a single nsc_io_t structure.
748*7836SJohn.Forte@Sun.COM  * If called with no address, performs a global walk of all nsc_ios.
749*7836SJohn.Forte@Sun.COM  */
750*7836SJohn.Forte@Sun.COM static int
nsc_io(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)751*7836SJohn.Forte@Sun.COM nsc_io(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
752*7836SJohn.Forte@Sun.COM {
753*7836SJohn.Forte@Sun.COM 	char io_name[128];
754*7836SJohn.Forte@Sun.COM 	nsc_io_t *io;
755*7836SJohn.Forte@Sun.COM 	int v_opt;
756*7836SJohn.Forte@Sun.COM 
757*7836SJohn.Forte@Sun.COM 	v_opt = 0;
758*7836SJohn.Forte@Sun.COM 
759*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
760*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
761*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
762*7836SJohn.Forte@Sun.COM 
763*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
764*7836SJohn.Forte@Sun.COM 		if (mdb_walk_dcmd("nsctl`nsc_io",
765*7836SJohn.Forte@Sun.COM 		    "nsctl`nsc_io", argc, argv) == -1) {
766*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to walk 'nsc_io'");
767*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
768*7836SJohn.Forte@Sun.COM 		}
769*7836SJohn.Forte@Sun.COM 
770*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
771*7836SJohn.Forte@Sun.COM 	}
772*7836SJohn.Forte@Sun.COM 
773*7836SJohn.Forte@Sun.COM 	io = mdb_zalloc(sizeof (*io), UM_SLEEP | UM_GC);
774*7836SJohn.Forte@Sun.COM 	memset(io_name, 0, sizeof (io_name));
775*7836SJohn.Forte@Sun.COM 
776*7836SJohn.Forte@Sun.COM 	if (mdb_vread(io, sizeof (*io), addr) != sizeof (*io)) {
777*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_io at %p", addr);
778*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
779*7836SJohn.Forte@Sun.COM 	}
780*7836SJohn.Forte@Sun.COM 
781*7836SJohn.Forte@Sun.COM 	if (io->name) {
782*7836SJohn.Forte@Sun.COM 		if (mdb_readstr(io_name, sizeof (io_name),
783*7836SJohn.Forte@Sun.COM 		    (uintptr_t)io->name) == -1) {
784*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to read nsc_io_t.name");
785*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
786*7836SJohn.Forte@Sun.COM 		}
787*7836SJohn.Forte@Sun.COM 	}
788*7836SJohn.Forte@Sun.COM 
789*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
790*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8Tid       fl  ref abuf name\n", "io");
791*7836SJohn.Forte@Sun.COM 	}
792*7836SJohn.Forte@Sun.COM 
793*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%08x %2x %4d %4d %s\n",
794*7836SJohn.Forte@Sun.COM 	    addr, io->id, io->flag, io->refcnt, io->abufcnt, io_name);
795*7836SJohn.Forte@Sun.COM 
796*7836SJohn.Forte@Sun.COM 	if (!v_opt)
797*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
798*7836SJohn.Forte@Sun.COM 
799*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
800*7836SJohn.Forte@Sun.COM 
801*7836SJohn.Forte@Sun.COM 	mdb_printf("id: %08x <%s>\n", io->id, nsc_io_id(io->id));
802*7836SJohn.Forte@Sun.COM 
803*7836SJohn.Forte@Sun.COM 	mdb_printf("provide: %08x <%b>\n", io->provide,
804*7836SJohn.Forte@Sun.COM 	    io->provide, nsc_type_bits);
805*7836SJohn.Forte@Sun.COM 
806*7836SJohn.Forte@Sun.COM 	mdb_printf("flag: %08x <%b>\n", io->flag, io->flag, nsc_ioflag_bits);
807*7836SJohn.Forte@Sun.COM 
808*7836SJohn.Forte@Sun.COM 	mdb_printf("pend: %d\n", io->pend);
809*7836SJohn.Forte@Sun.COM 
810*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
811*7836SJohn.Forte@Sun.COM 
812*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
813*7836SJohn.Forte@Sun.COM }
814*7836SJohn.Forte@Sun.COM 
815*7836SJohn.Forte@Sun.COM 
816*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
817*7836SJohn.Forte@Sun.COM 
818*7836SJohn.Forte@Sun.COM /*
819*7836SJohn.Forte@Sun.COM  * Display a single nsc_dev_t structure.
820*7836SJohn.Forte@Sun.COM  * If called with no address, performs a global walk of all nsc_devs.
821*7836SJohn.Forte@Sun.COM  */
822*7836SJohn.Forte@Sun.COM static int
nsc_dev(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)823*7836SJohn.Forte@Sun.COM nsc_dev(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
824*7836SJohn.Forte@Sun.COM {
825*7836SJohn.Forte@Sun.COM 	char path[NSC_MAXPATH+1];
826*7836SJohn.Forte@Sun.COM 	nsc_devval_t *dv;
827*7836SJohn.Forte@Sun.COM 	nsc_dev_t *dev;
828*7836SJohn.Forte@Sun.COM 	uintptr_t dev_pend;
829*7836SJohn.Forte@Sun.COM 	int a_opt, v_opt;
830*7836SJohn.Forte@Sun.COM 
831*7836SJohn.Forte@Sun.COM 	a_opt = v_opt = 0;
832*7836SJohn.Forte@Sun.COM 
833*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
834*7836SJohn.Forte@Sun.COM 	    'a', MDB_OPT_SETBITS, TRUE, &a_opt,
835*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
836*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
837*7836SJohn.Forte@Sun.COM 
838*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
839*7836SJohn.Forte@Sun.COM 		mdb_printf("Active device structures:\n");
840*7836SJohn.Forte@Sun.COM 
841*7836SJohn.Forte@Sun.COM 		if (mdb_walk_dcmd("nsctl`nsc_dev",
842*7836SJohn.Forte@Sun.COM 		    "nsctl`nsc_dev", argc, argv) == -1) {
843*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to walk 'nsc_dev'");
844*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
845*7836SJohn.Forte@Sun.COM 		}
846*7836SJohn.Forte@Sun.COM 
847*7836SJohn.Forte@Sun.COM 		if (a_opt) {
848*7836SJohn.Forte@Sun.COM 			if (mdb_readvar(&dev_pend, "_nsc_dev_pend") == -1) {
849*7836SJohn.Forte@Sun.COM 				mdb_warn("failed to read _nsc_dev_pend");
850*7836SJohn.Forte@Sun.COM 				return (DCMD_ERR);
851*7836SJohn.Forte@Sun.COM 			}
852*7836SJohn.Forte@Sun.COM 
853*7836SJohn.Forte@Sun.COM 			mdb_printf("\nPending device structures:");
854*7836SJohn.Forte@Sun.COM 
855*7836SJohn.Forte@Sun.COM 			if (dev_pend) {
856*7836SJohn.Forte@Sun.COM 				mdb_printf("\n");
857*7836SJohn.Forte@Sun.COM 
858*7836SJohn.Forte@Sun.COM 				if (mdb_pwalk_dcmd("nsctl`nsc_dev",
859*7836SJohn.Forte@Sun.COM 				    "nsctl`nsc_dev", argc, argv,
860*7836SJohn.Forte@Sun.COM 				    dev_pend) == -1) {
861*7836SJohn.Forte@Sun.COM 					mdb_warn("failed to walk "
862*7836SJohn.Forte@Sun.COM 					    "pending dev structs");
863*7836SJohn.Forte@Sun.COM 					return (DCMD_ERR);
864*7836SJohn.Forte@Sun.COM 				}
865*7836SJohn.Forte@Sun.COM 			} else {
866*7836SJohn.Forte@Sun.COM 				mdb_printf(" none\n");
867*7836SJohn.Forte@Sun.COM 			}
868*7836SJohn.Forte@Sun.COM 		}
869*7836SJohn.Forte@Sun.COM 
870*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
871*7836SJohn.Forte@Sun.COM 	}
872*7836SJohn.Forte@Sun.COM 
873*7836SJohn.Forte@Sun.COM 	memset(path, 0, sizeof (path));
874*7836SJohn.Forte@Sun.COM 	dev = mdb_zalloc(sizeof (*dev), UM_SLEEP | UM_GC);
875*7836SJohn.Forte@Sun.COM 
876*7836SJohn.Forte@Sun.COM 	if (mdb_vread(dev, sizeof (*dev), addr) != sizeof (*dev)) {
877*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_dev at %p", addr);
878*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
879*7836SJohn.Forte@Sun.COM 	}
880*7836SJohn.Forte@Sun.COM 
881*7836SJohn.Forte@Sun.COM 	if (mdb_readstr(path, sizeof (path), (uintptr_t)dev->nsc_path) == -1) {
882*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_path at %p", dev->nsc_path);
883*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
884*7836SJohn.Forte@Sun.COM 	}
885*7836SJohn.Forte@Sun.COM 
886*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
887*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8Tref pend rpnd wait path\n", "dev");
888*7836SJohn.Forte@Sun.COM 	}
889*7836SJohn.Forte@Sun.COM 
890*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%3d %4d %4d %4d %s\n",
891*7836SJohn.Forte@Sun.COM 	    addr, dev->nsc_refcnt, dev->nsc_pend, dev->nsc_rpend,
892*7836SJohn.Forte@Sun.COM 	    dev->nsc_wait, path);
893*7836SJohn.Forte@Sun.COM 
894*7836SJohn.Forte@Sun.COM 	if (!v_opt)
895*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
896*7836SJohn.Forte@Sun.COM 
897*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
898*7836SJohn.Forte@Sun.COM 
899*7836SJohn.Forte@Sun.COM 	mdb_printf("next: %0?p  %8Tclose: %0?p\n",
900*7836SJohn.Forte@Sun.COM 	    dev->nsc_next, dev->nsc_close);
901*7836SJohn.Forte@Sun.COM 
902*7836SJohn.Forte@Sun.COM 	mdb_printf("list: %0?p  %8Tlock: %0?p\n",
903*7836SJohn.Forte@Sun.COM 	    dev->nsc_list, addr + OFFSETOF(nsc_dev_t, nsc_lock));
904*7836SJohn.Forte@Sun.COM 
905*7836SJohn.Forte@Sun.COM 	mdb_printf("cv: %0?p  %8Tpath: %0?p  %8Tphash: %016llx\n",
906*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nsc_dev_t, nsc_cv),
907*7836SJohn.Forte@Sun.COM 	    dev->nsc_path, dev->nsc_phash);
908*7836SJohn.Forte@Sun.COM 
909*7836SJohn.Forte@Sun.COM 	mdb_printf("drop: %d  %8Treopen: %d\n",
910*7836SJohn.Forte@Sun.COM 	    dev->nsc_drop, dev->nsc_reopen);
911*7836SJohn.Forte@Sun.COM 
912*7836SJohn.Forte@Sun.COM 	if (dev->nsc_values) {
913*7836SJohn.Forte@Sun.COM 		dv = mdb_zalloc(sizeof (*dv), UM_SLEEP | UM_GC);
914*7836SJohn.Forte@Sun.COM 		if (mdb_vread(dv, sizeof (*dv), (uintptr_t)dev->nsc_values) !=
915*7836SJohn.Forte@Sun.COM 		    sizeof (*dv)) {
916*7836SJohn.Forte@Sun.COM 			mdb_warn("unable to read nsc_dev_t.nsc_values");
917*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(4);
918*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
919*7836SJohn.Forte@Sun.COM 		}
920*7836SJohn.Forte@Sun.COM 
921*7836SJohn.Forte@Sun.COM 		if (dv->dv_values) {
922*7836SJohn.Forte@Sun.COM 			mdb_printf("device/values: (nsc_devval: %0?p)\n",
923*7836SJohn.Forte@Sun.COM 			    dev->nsc_values);
924*7836SJohn.Forte@Sun.COM 
925*7836SJohn.Forte@Sun.COM 			mdb_inc_indent(4);
926*7836SJohn.Forte@Sun.COM 
927*7836SJohn.Forte@Sun.COM 			if (mdb_pwalk_dcmd("nsctl`nsc_val", "nsctl`nsc_val",
928*7836SJohn.Forte@Sun.COM 			    0, NULL, (uintptr_t)dv->dv_values) == -1) {
929*7836SJohn.Forte@Sun.COM 				mdb_dec_indent(8);
930*7836SJohn.Forte@Sun.COM 				return (DCMD_ERR);
931*7836SJohn.Forte@Sun.COM 			}
932*7836SJohn.Forte@Sun.COM 
933*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(4);
934*7836SJohn.Forte@Sun.COM 		}
935*7836SJohn.Forte@Sun.COM 	}
936*7836SJohn.Forte@Sun.COM 
937*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
938*7836SJohn.Forte@Sun.COM 
939*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
940*7836SJohn.Forte@Sun.COM }
941*7836SJohn.Forte@Sun.COM 
942*7836SJohn.Forte@Sun.COM 
943*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
944*7836SJohn.Forte@Sun.COM 
945*7836SJohn.Forte@Sun.COM /*
946*7836SJohn.Forte@Sun.COM  * Display a single nsc_devval_t structure.
947*7836SJohn.Forte@Sun.COM  * If called with no address, performs a global walk of all nsc_devs.
948*7836SJohn.Forte@Sun.COM  */
949*7836SJohn.Forte@Sun.COM static int
nsc_devval(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)950*7836SJohn.Forte@Sun.COM nsc_devval(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
951*7836SJohn.Forte@Sun.COM {
952*7836SJohn.Forte@Sun.COM 	nsc_devval_t *dv;
953*7836SJohn.Forte@Sun.COM 	int a_opt;
954*7836SJohn.Forte@Sun.COM 
955*7836SJohn.Forte@Sun.COM 	a_opt = 0;
956*7836SJohn.Forte@Sun.COM 
957*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
958*7836SJohn.Forte@Sun.COM 	    'a', MDB_OPT_SETBITS, TRUE, &a_opt) != argc)
959*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
960*7836SJohn.Forte@Sun.COM 
961*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
962*7836SJohn.Forte@Sun.COM 		if (mdb_walk_dcmd("nsctl`nsc_devval",
963*7836SJohn.Forte@Sun.COM 		    "nsctl`nsc_devval", argc, argv) == -1) {
964*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to walk 'nsc_devval'");
965*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
966*7836SJohn.Forte@Sun.COM 		}
967*7836SJohn.Forte@Sun.COM 
968*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
969*7836SJohn.Forte@Sun.COM 	}
970*7836SJohn.Forte@Sun.COM 
971*7836SJohn.Forte@Sun.COM 	dv = mdb_zalloc(sizeof (*dv), UM_SLEEP | UM_GC);
972*7836SJohn.Forte@Sun.COM 
973*7836SJohn.Forte@Sun.COM 	if (mdb_vread(dv, sizeof (*dv), addr) != sizeof (*dv)) {
974*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_devval at %p", addr);
975*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
976*7836SJohn.Forte@Sun.COM 	}
977*7836SJohn.Forte@Sun.COM 
978*7836SJohn.Forte@Sun.COM 	if (!a_opt && !dv->dv_values) {
979*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
980*7836SJohn.Forte@Sun.COM 	}
981*7836SJohn.Forte@Sun.COM 
982*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
983*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8T%?-s  %8Tpath\n", "devval", "phash");
984*7836SJohn.Forte@Sun.COM 	}
985*7836SJohn.Forte@Sun.COM 
986*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%016llx  %8T%s\n", addr,
987*7836SJohn.Forte@Sun.COM 	    dv->dv_phash, dv->dv_path);
988*7836SJohn.Forte@Sun.COM 
989*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
990*7836SJohn.Forte@Sun.COM 
991*7836SJohn.Forte@Sun.COM 	if (dv->dv_values) {
992*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsc_val", "nsctl`nsc_val",
993*7836SJohn.Forte@Sun.COM 		    0, NULL, (uintptr_t)dv->dv_values) == -1) {
994*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
995*7836SJohn.Forte@Sun.COM 		}
996*7836SJohn.Forte@Sun.COM 	} else {
997*7836SJohn.Forte@Sun.COM 		mdb_printf("No values\n");
998*7836SJohn.Forte@Sun.COM 	}
999*7836SJohn.Forte@Sun.COM 
1000*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
1001*7836SJohn.Forte@Sun.COM 
1002*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1003*7836SJohn.Forte@Sun.COM }
1004*7836SJohn.Forte@Sun.COM 
1005*7836SJohn.Forte@Sun.COM 
1006*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1007*7836SJohn.Forte@Sun.COM 
1008*7836SJohn.Forte@Sun.COM /*
1009*7836SJohn.Forte@Sun.COM  * Part 2 callback for the all devices and fds walk.  Called per iodev.
1010*7836SJohn.Forte@Sun.COM  */
1011*7836SJohn.Forte@Sun.COM /* ARGSUSED */
1012*7836SJohn.Forte@Sun.COM static int
nsc_fd_iodev(uintptr_t addr,const void * data,void * cbdata)1013*7836SJohn.Forte@Sun.COM nsc_fd_iodev(uintptr_t addr, const void *data, void *cbdata)
1014*7836SJohn.Forte@Sun.COM {
1015*7836SJohn.Forte@Sun.COM 	struct complex_args *fdall = cbdata;
1016*7836SJohn.Forte@Sun.COM 	struct nsc_fd_t *fd;
1017*7836SJohn.Forte@Sun.COM 
1018*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&fd, sizeof (fd),
1019*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nsc_iodev_t, si_open)) == -1) {
1020*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read nsc_iodev_t.si_open");
1021*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
1022*7836SJohn.Forte@Sun.COM 	}
1023*7836SJohn.Forte@Sun.COM 
1024*7836SJohn.Forte@Sun.COM 	if (fd != NULL) {
1025*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsc_fd", "nsctl`nsc_fd",
1026*7836SJohn.Forte@Sun.COM 		    fdall->argc, fdall->argv, (uintptr_t)fd) == -1)
1027*7836SJohn.Forte@Sun.COM 			return (WALK_ERR);
1028*7836SJohn.Forte@Sun.COM 	}
1029*7836SJohn.Forte@Sun.COM 
1030*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
1031*7836SJohn.Forte@Sun.COM }
1032*7836SJohn.Forte@Sun.COM 
1033*7836SJohn.Forte@Sun.COM 
1034*7836SJohn.Forte@Sun.COM /*
1035*7836SJohn.Forte@Sun.COM  * Part 1 callback for the all devices and fds walk.  Called per device.
1036*7836SJohn.Forte@Sun.COM  */
1037*7836SJohn.Forte@Sun.COM /* ARGSUSED */
1038*7836SJohn.Forte@Sun.COM static int
nsc_fd_dev(uintptr_t addr,const void * data,void * cbdata)1039*7836SJohn.Forte@Sun.COM nsc_fd_dev(uintptr_t addr, const void *data, void *cbdata)
1040*7836SJohn.Forte@Sun.COM {
1041*7836SJohn.Forte@Sun.COM 	struct complex_args *fdall = cbdata;
1042*7836SJohn.Forte@Sun.COM 	nsc_iodev_t *iodev;
1043*7836SJohn.Forte@Sun.COM 	nsc_fd_t *fd;
1044*7836SJohn.Forte@Sun.COM 
1045*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&iodev, sizeof (iodev),
1046*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nsc_dev_t, nsc_list)) == -1) {
1047*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read nsc_dev_t.nsc_list at %p", addr);
1048*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
1049*7836SJohn.Forte@Sun.COM 	}
1050*7836SJohn.Forte@Sun.COM 
1051*7836SJohn.Forte@Sun.COM 	/* walk iodev chains */
1052*7836SJohn.Forte@Sun.COM 
1053*7836SJohn.Forte@Sun.COM 	if (iodev != NULL) {
1054*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk("nsctl`nsc_iodev",
1055*7836SJohn.Forte@Sun.COM 		    nsc_fd_iodev, fdall, (uintptr_t)iodev) == -1)
1056*7836SJohn.Forte@Sun.COM 			return (WALK_ERR);
1057*7836SJohn.Forte@Sun.COM 	}
1058*7836SJohn.Forte@Sun.COM 
1059*7836SJohn.Forte@Sun.COM 	/* walk nsc_close (closing fds) chains */
1060*7836SJohn.Forte@Sun.COM 
1061*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&fd, sizeof (fd),
1062*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nsc_dev_t, nsc_close)) == -1) {
1063*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read nsc_dev_t.nsc_close at %p", addr);
1064*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
1065*7836SJohn.Forte@Sun.COM 	}
1066*7836SJohn.Forte@Sun.COM 
1067*7836SJohn.Forte@Sun.COM 	if (fd != NULL) {
1068*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsc_fd", "nsctl`nsc_fd",
1069*7836SJohn.Forte@Sun.COM 		    fdall->argc, fdall->argv, (uintptr_t)fd) == -1)
1070*7836SJohn.Forte@Sun.COM 			return (WALK_ERR);
1071*7836SJohn.Forte@Sun.COM 	}
1072*7836SJohn.Forte@Sun.COM 
1073*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
1074*7836SJohn.Forte@Sun.COM }
1075*7836SJohn.Forte@Sun.COM 
1076*7836SJohn.Forte@Sun.COM 
1077*7836SJohn.Forte@Sun.COM /*
1078*7836SJohn.Forte@Sun.COM  * Walk all devices and fds in the system.
1079*7836SJohn.Forte@Sun.COM  */
1080*7836SJohn.Forte@Sun.COM static int
nsc_fd_all(int argc,const mdb_arg_t * argv)1081*7836SJohn.Forte@Sun.COM nsc_fd_all(int argc, const mdb_arg_t *argv)
1082*7836SJohn.Forte@Sun.COM {
1083*7836SJohn.Forte@Sun.COM 	struct complex_args fdall;
1084*7836SJohn.Forte@Sun.COM 
1085*7836SJohn.Forte@Sun.COM 	fdall.argc = argc;
1086*7836SJohn.Forte@Sun.COM 	fdall.argv = (mdb_arg_t *)argv;
1087*7836SJohn.Forte@Sun.COM 
1088*7836SJohn.Forte@Sun.COM 	complex_walk = 1;
1089*7836SJohn.Forte@Sun.COM 	complex_hdr = 0;
1090*7836SJohn.Forte@Sun.COM 
1091*7836SJohn.Forte@Sun.COM 	if (mdb_walk("nsctl`nsc_dev", nsc_fd_dev, &fdall) == -1) {
1092*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1093*7836SJohn.Forte@Sun.COM 	}
1094*7836SJohn.Forte@Sun.COM 
1095*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1096*7836SJohn.Forte@Sun.COM }
1097*7836SJohn.Forte@Sun.COM 
1098*7836SJohn.Forte@Sun.COM 
1099*7836SJohn.Forte@Sun.COM 
1100*7836SJohn.Forte@Sun.COM /*
1101*7836SJohn.Forte@Sun.COM  * Display an nsd_fd_t structure, or walk all devices and fds in the system.
1102*7836SJohn.Forte@Sun.COM  */
1103*7836SJohn.Forte@Sun.COM static int
nsc_fd(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1104*7836SJohn.Forte@Sun.COM nsc_fd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1105*7836SJohn.Forte@Sun.COM {
1106*7836SJohn.Forte@Sun.COM 	char io_name[128], *io_namep;
1107*7836SJohn.Forte@Sun.COM 	char path[NSC_MAXPATH+1];
1108*7836SJohn.Forte@Sun.COM 	uintptr_t pathp;
1109*7836SJohn.Forte@Sun.COM 	nsc_fd_t *fd;
1110*7836SJohn.Forte@Sun.COM 	nsc_io_t *io;
1111*7836SJohn.Forte@Sun.COM 	int v_opt;
1112*7836SJohn.Forte@Sun.COM 	int hdr;
1113*7836SJohn.Forte@Sun.COM 
1114*7836SJohn.Forte@Sun.COM 	v_opt = 0;
1115*7836SJohn.Forte@Sun.COM 
1116*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
1117*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
1118*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1119*7836SJohn.Forte@Sun.COM 
1120*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1121*7836SJohn.Forte@Sun.COM 		return (nsc_fd_all(argc, argv));
1122*7836SJohn.Forte@Sun.COM 	}
1123*7836SJohn.Forte@Sun.COM 
1124*7836SJohn.Forte@Sun.COM 	memset(path, 0, sizeof (path));
1125*7836SJohn.Forte@Sun.COM 	fd = mdb_zalloc(sizeof (*fd), UM_SLEEP | UM_GC);
1126*7836SJohn.Forte@Sun.COM 	memset(io_name, 0, sizeof (io_name));
1127*7836SJohn.Forte@Sun.COM 
1128*7836SJohn.Forte@Sun.COM 	if (mdb_vread(fd, sizeof (*fd), addr) != sizeof (*fd)) {
1129*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_fd at %p", addr);
1130*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1131*7836SJohn.Forte@Sun.COM 	}
1132*7836SJohn.Forte@Sun.COM 
1133*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&pathp, sizeof (pathp),
1134*7836SJohn.Forte@Sun.COM 	    (uintptr_t)fd->sf_dev + OFFSETOF(nsc_dev_t, nsc_path)) !=
1135*7836SJohn.Forte@Sun.COM 	    sizeof (pathp)) {
1136*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_dev.nsc_path");
1137*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1138*7836SJohn.Forte@Sun.COM 	}
1139*7836SJohn.Forte@Sun.COM 
1140*7836SJohn.Forte@Sun.COM 	if (mdb_readstr(path, sizeof (path), pathp) == -1) {
1141*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_path");
1142*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1143*7836SJohn.Forte@Sun.COM 	}
1144*7836SJohn.Forte@Sun.COM 
1145*7836SJohn.Forte@Sun.COM 	if (fd->sf_iodev) {
1146*7836SJohn.Forte@Sun.COM 		if (mdb_vread(&io, sizeof (io),
1147*7836SJohn.Forte@Sun.COM 		    (uintptr_t)fd->sf_iodev + OFFSETOF(nsc_iodev_t, si_io)) !=
1148*7836SJohn.Forte@Sun.COM 		    sizeof (io)) {
1149*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to read nsc_iodev.si_io");
1150*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1151*7836SJohn.Forte@Sun.COM 		}
1152*7836SJohn.Forte@Sun.COM 
1153*7836SJohn.Forte@Sun.COM 		if (mdb_vread(&io_namep, sizeof (io_namep),
1154*7836SJohn.Forte@Sun.COM 		    (uintptr_t)io + OFFSETOF(nsc_io_t, name)) !=
1155*7836SJohn.Forte@Sun.COM 		    sizeof (io_namep)) {
1156*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to read nsc_io_t.name");
1157*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1158*7836SJohn.Forte@Sun.COM 		}
1159*7836SJohn.Forte@Sun.COM 
1160*7836SJohn.Forte@Sun.COM 		if (mdb_readstr(io_name, sizeof (io_name),
1161*7836SJohn.Forte@Sun.COM 		    (uintptr_t)io_namep) == -1) {
1162*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to read nsc_io_t.name string");
1163*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1164*7836SJohn.Forte@Sun.COM 		}
1165*7836SJohn.Forte@Sun.COM 	}
1166*7836SJohn.Forte@Sun.COM 
1167*7836SJohn.Forte@Sun.COM 	hdr = 0;
1168*7836SJohn.Forte@Sun.COM 	if (complex_walk) {
1169*7836SJohn.Forte@Sun.COM 		if (!complex_hdr) {
1170*7836SJohn.Forte@Sun.COM 			complex_hdr = 1;
1171*7836SJohn.Forte@Sun.COM 			hdr = 1;
1172*7836SJohn.Forte@Sun.COM 		}
1173*7836SJohn.Forte@Sun.COM 	} else if (DCMD_HDRSPEC(flags)) {
1174*7836SJohn.Forte@Sun.COM 		hdr = 1;
1175*7836SJohn.Forte@Sun.COM 	}
1176*7836SJohn.Forte@Sun.COM 
1177*7836SJohn.Forte@Sun.COM 	if (hdr) {
1178*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8T%-?s  %8T%-8s  %-?s\n",
1179*7836SJohn.Forte@Sun.COM 		    "fd", "dev", "io", "cd");
1180*7836SJohn.Forte@Sun.COM 		mdb_printf("    %-?s  %8Trv pend av path\n", "arg");
1181*7836SJohn.Forte@Sun.COM 	}
1182*7836SJohn.Forte@Sun.COM 
1183*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%0?p  %8T%-8s  %p\n",
1184*7836SJohn.Forte@Sun.COM 	    addr, fd->sf_dev, io_name, fd->sf_cd);
1185*7836SJohn.Forte@Sun.COM 	mdb_printf("    %0?p  %8T%2d %4x %2x %s\n",
1186*7836SJohn.Forte@Sun.COM 	    fd->sf_arg, fd->sf_reserve, fd->sf_pend,
1187*7836SJohn.Forte@Sun.COM 	    fd->sf_avail, path);
1188*7836SJohn.Forte@Sun.COM 
1189*7836SJohn.Forte@Sun.COM 	if (!v_opt)
1190*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1191*7836SJohn.Forte@Sun.COM 
1192*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
1193*7836SJohn.Forte@Sun.COM 
1194*7836SJohn.Forte@Sun.COM 	mdb_printf("open type: %08x <%b>\n", fd->sf_type,
1195*7836SJohn.Forte@Sun.COM 	    fd->sf_type, nsc_type_bits);
1196*7836SJohn.Forte@Sun.COM 
1197*7836SJohn.Forte@Sun.COM 	mdb_printf("avail: %08x <%b>\n", fd->sf_avail,
1198*7836SJohn.Forte@Sun.COM 	    fd->sf_avail, nsc_availpend_bits);
1199*7836SJohn.Forte@Sun.COM 
1200*7836SJohn.Forte@Sun.COM 	mdb_printf("flag: %08x <%b>\n", fd->sf_flag,
1201*7836SJohn.Forte@Sun.COM 	    fd->sf_flag, nsc_fdflag_bits);
1202*7836SJohn.Forte@Sun.COM 
1203*7836SJohn.Forte@Sun.COM 	mdb_printf("rsrv mode: %08x <%b>\n", fd->sf_mode,
1204*7836SJohn.Forte@Sun.COM 	    fd->sf_mode, nsc_fdmode_bits);
1205*7836SJohn.Forte@Sun.COM 
1206*7836SJohn.Forte@Sun.COM 	mdb_printf("open lbolt: %?x  %8Treopen: %d\n", fd->sf_lbolt,
1207*7836SJohn.Forte@Sun.COM 	    fd->sf_reopen);
1208*7836SJohn.Forte@Sun.COM 
1209*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
1210*7836SJohn.Forte@Sun.COM 
1211*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1212*7836SJohn.Forte@Sun.COM }
1213*7836SJohn.Forte@Sun.COM 
1214*7836SJohn.Forte@Sun.COM 
1215*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1216*7836SJohn.Forte@Sun.COM 
1217*7836SJohn.Forte@Sun.COM /*
1218*7836SJohn.Forte@Sun.COM  * Callback for the all devices and iodevs walk.  Called per device.
1219*7836SJohn.Forte@Sun.COM  */
1220*7836SJohn.Forte@Sun.COM /* ARGSUSED */
1221*7836SJohn.Forte@Sun.COM static int
nsc_iodev_dev(uintptr_t addr,const void * data,void * cbdata)1222*7836SJohn.Forte@Sun.COM nsc_iodev_dev(uintptr_t addr, const void *data, void *cbdata)
1223*7836SJohn.Forte@Sun.COM {
1224*7836SJohn.Forte@Sun.COM 	struct complex_args *iodevall = cbdata;
1225*7836SJohn.Forte@Sun.COM 	uintptr_t iodev;
1226*7836SJohn.Forte@Sun.COM 
1227*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&iodev, sizeof (iodev),
1228*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nsc_dev_t, nsc_list)) == -1) {
1229*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read nsc_dev_t.nsc_list at %p", addr);
1230*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
1231*7836SJohn.Forte@Sun.COM 	}
1232*7836SJohn.Forte@Sun.COM 
1233*7836SJohn.Forte@Sun.COM 	/* walk iodev chains */
1234*7836SJohn.Forte@Sun.COM 
1235*7836SJohn.Forte@Sun.COM 	if (iodev != NULL) {
1236*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsc_iodev", "nsctl`nsc_iodev",
1237*7836SJohn.Forte@Sun.COM 		    iodevall->argc, iodevall->argv, iodev) == -1)
1238*7836SJohn.Forte@Sun.COM 			return (WALK_ERR);
1239*7836SJohn.Forte@Sun.COM 	}
1240*7836SJohn.Forte@Sun.COM 
1241*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
1242*7836SJohn.Forte@Sun.COM }
1243*7836SJohn.Forte@Sun.COM 
1244*7836SJohn.Forte@Sun.COM 
1245*7836SJohn.Forte@Sun.COM /*
1246*7836SJohn.Forte@Sun.COM  * Walk all devices and iodevs in the system.
1247*7836SJohn.Forte@Sun.COM  */
1248*7836SJohn.Forte@Sun.COM static int
nsc_iodev_all(int argc,const mdb_arg_t * argv)1249*7836SJohn.Forte@Sun.COM nsc_iodev_all(int argc, const mdb_arg_t *argv)
1250*7836SJohn.Forte@Sun.COM {
1251*7836SJohn.Forte@Sun.COM 	struct complex_args iodevall;
1252*7836SJohn.Forte@Sun.COM 
1253*7836SJohn.Forte@Sun.COM 	iodevall.argc = argc;
1254*7836SJohn.Forte@Sun.COM 	iodevall.argv = (mdb_arg_t *)argv;
1255*7836SJohn.Forte@Sun.COM 
1256*7836SJohn.Forte@Sun.COM 	complex_walk = 1;
1257*7836SJohn.Forte@Sun.COM 	complex_hdr = 0;
1258*7836SJohn.Forte@Sun.COM 
1259*7836SJohn.Forte@Sun.COM 	if (mdb_walk("nsctl`nsc_dev", nsc_iodev_dev, &iodevall) == -1) {
1260*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1261*7836SJohn.Forte@Sun.COM 	}
1262*7836SJohn.Forte@Sun.COM 
1263*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1264*7836SJohn.Forte@Sun.COM }
1265*7836SJohn.Forte@Sun.COM 
1266*7836SJohn.Forte@Sun.COM 
1267*7836SJohn.Forte@Sun.COM /*
1268*7836SJohn.Forte@Sun.COM  * Display an nsc_iodev_t structure, or walk all devices and
1269*7836SJohn.Forte@Sun.COM  * iodevs in the system.
1270*7836SJohn.Forte@Sun.COM  */
1271*7836SJohn.Forte@Sun.COM static int
nsc_iodev(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1272*7836SJohn.Forte@Sun.COM nsc_iodev(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1273*7836SJohn.Forte@Sun.COM {
1274*7836SJohn.Forte@Sun.COM 	char io_name[128], *io_namep;
1275*7836SJohn.Forte@Sun.COM 	char path[NSC_MAXPATH+1];
1276*7836SJohn.Forte@Sun.COM 	nsc_iodev_t *iodev;
1277*7836SJohn.Forte@Sun.COM 	uintptr_t pathp;
1278*7836SJohn.Forte@Sun.COM 	int v_opt;
1279*7836SJohn.Forte@Sun.COM 	int hdr;
1280*7836SJohn.Forte@Sun.COM 
1281*7836SJohn.Forte@Sun.COM 	v_opt = 0;
1282*7836SJohn.Forte@Sun.COM 
1283*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
1284*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
1285*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1286*7836SJohn.Forte@Sun.COM 
1287*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1288*7836SJohn.Forte@Sun.COM 		return (nsc_iodev_all(argc, argv));
1289*7836SJohn.Forte@Sun.COM 	}
1290*7836SJohn.Forte@Sun.COM 
1291*7836SJohn.Forte@Sun.COM 	memset(path, 0, sizeof (path));
1292*7836SJohn.Forte@Sun.COM 	iodev = mdb_zalloc(sizeof (*iodev), UM_SLEEP | UM_GC);
1293*7836SJohn.Forte@Sun.COM 	memset(io_name, 0, sizeof (io_name));
1294*7836SJohn.Forte@Sun.COM 
1295*7836SJohn.Forte@Sun.COM 	if (mdb_vread(iodev, sizeof (*iodev), addr) != sizeof (*iodev)) {
1296*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_iodev at %p", addr);
1297*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1298*7836SJohn.Forte@Sun.COM 	}
1299*7836SJohn.Forte@Sun.COM 
1300*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&pathp, sizeof (pathp),
1301*7836SJohn.Forte@Sun.COM 	    (uintptr_t)iodev->si_dev + OFFSETOF(nsc_dev_t, nsc_path)) !=
1302*7836SJohn.Forte@Sun.COM 	    sizeof (pathp)) {
1303*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_dev.nsc_path");
1304*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1305*7836SJohn.Forte@Sun.COM 	}
1306*7836SJohn.Forte@Sun.COM 
1307*7836SJohn.Forte@Sun.COM 	if (mdb_readstr(path, sizeof (path), pathp) == -1) {
1308*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_path");
1309*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1310*7836SJohn.Forte@Sun.COM 	}
1311*7836SJohn.Forte@Sun.COM 
1312*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&io_namep, sizeof (io_namep),
1313*7836SJohn.Forte@Sun.COM 	    (uintptr_t)iodev->si_io + OFFSETOF(nsc_io_t, name)) !=
1314*7836SJohn.Forte@Sun.COM 	    sizeof (io_namep)) {
1315*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_io_t.name");
1316*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1317*7836SJohn.Forte@Sun.COM 	}
1318*7836SJohn.Forte@Sun.COM 
1319*7836SJohn.Forte@Sun.COM 	if (mdb_readstr(io_name, sizeof (io_name),
1320*7836SJohn.Forte@Sun.COM 	    (uintptr_t)io_namep) == -1) {
1321*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_io_t.name string");
1322*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1323*7836SJohn.Forte@Sun.COM 	}
1324*7836SJohn.Forte@Sun.COM 
1325*7836SJohn.Forte@Sun.COM 	hdr = 0;
1326*7836SJohn.Forte@Sun.COM 	if (complex_walk) {
1327*7836SJohn.Forte@Sun.COM 		if (!complex_hdr) {
1328*7836SJohn.Forte@Sun.COM 			complex_hdr = 1;
1329*7836SJohn.Forte@Sun.COM 			hdr = 1;
1330*7836SJohn.Forte@Sun.COM 		}
1331*7836SJohn.Forte@Sun.COM 	} else if (DCMD_HDRSPEC(flags)) {
1332*7836SJohn.Forte@Sun.COM 		hdr = 1;
1333*7836SJohn.Forte@Sun.COM 	}
1334*7836SJohn.Forte@Sun.COM 
1335*7836SJohn.Forte@Sun.COM 	if (hdr) {
1336*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8T%-?s  ref %-8s path\n",
1337*7836SJohn.Forte@Sun.COM 		    "iodev", "dev", "io");
1338*7836SJohn.Forte@Sun.COM 	}
1339*7836SJohn.Forte@Sun.COM 
1340*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%0?p  %3d %-8s %s\n",
1341*7836SJohn.Forte@Sun.COM 	    addr, iodev->si_dev, iodev->si_refcnt, io_name, path);
1342*7836SJohn.Forte@Sun.COM 
1343*7836SJohn.Forte@Sun.COM 	if (!v_opt)
1344*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1345*7836SJohn.Forte@Sun.COM 
1346*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
1347*7836SJohn.Forte@Sun.COM 
1348*7836SJohn.Forte@Sun.COM 	mdb_printf("open fds: %?p  %8Tactive ios: %?p\n",
1349*7836SJohn.Forte@Sun.COM 	    iodev->si_open, iodev->si_active);
1350*7836SJohn.Forte@Sun.COM 
1351*7836SJohn.Forte@Sun.COM 	mdb_printf("busy: %d  %8Trsrv pend: %d\n",
1352*7836SJohn.Forte@Sun.COM 	    iodev->si_busy, iodev->si_rpend);
1353*7836SJohn.Forte@Sun.COM 
1354*7836SJohn.Forte@Sun.COM 	mdb_printf("pend: %08x <%b>\n", iodev->si_pend,
1355*7836SJohn.Forte@Sun.COM 	    iodev->si_pend, nsc_availpend_bits);
1356*7836SJohn.Forte@Sun.COM 
1357*7836SJohn.Forte@Sun.COM 	mdb_printf("avail: %08x <%b>\n", iodev->si_avail,
1358*7836SJohn.Forte@Sun.COM 	    iodev->si_avail, nsc_availpend_bits);
1359*7836SJohn.Forte@Sun.COM 
1360*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
1361*7836SJohn.Forte@Sun.COM 
1362*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1363*7836SJohn.Forte@Sun.COM }
1364*7836SJohn.Forte@Sun.COM 
1365*7836SJohn.Forte@Sun.COM 
1366*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1367*7836SJohn.Forte@Sun.COM 
1368*7836SJohn.Forte@Sun.COM /*
1369*7836SJohn.Forte@Sun.COM  * Display an nsc_service_t structure, or walk all services.
1370*7836SJohn.Forte@Sun.COM  */
1371*7836SJohn.Forte@Sun.COM static int
nsc_service(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1372*7836SJohn.Forte@Sun.COM nsc_service(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1373*7836SJohn.Forte@Sun.COM {
1374*7836SJohn.Forte@Sun.COM 	nsc_service_t *service;
1375*7836SJohn.Forte@Sun.COM 	char s_name[32];
1376*7836SJohn.Forte@Sun.COM 	int v_opt;
1377*7836SJohn.Forte@Sun.COM 
1378*7836SJohn.Forte@Sun.COM 	v_opt = 0;
1379*7836SJohn.Forte@Sun.COM 
1380*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
1381*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
1382*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1383*7836SJohn.Forte@Sun.COM 
1384*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1385*7836SJohn.Forte@Sun.COM 		if (mdb_walk_dcmd("nsctl`nsc_service",
1386*7836SJohn.Forte@Sun.COM 		    "nsctl`nsc_service", argc, argv) == -1) {
1387*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to walk 'nsc_service'");
1388*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1389*7836SJohn.Forte@Sun.COM 		}
1390*7836SJohn.Forte@Sun.COM 
1391*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1392*7836SJohn.Forte@Sun.COM 	}
1393*7836SJohn.Forte@Sun.COM 
1394*7836SJohn.Forte@Sun.COM 	service = mdb_zalloc(sizeof (*service), UM_SLEEP | UM_GC);
1395*7836SJohn.Forte@Sun.COM 
1396*7836SJohn.Forte@Sun.COM 	if (mdb_vread(service, sizeof (*service), addr) != sizeof (*service)) {
1397*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_service at %p", addr);
1398*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1399*7836SJohn.Forte@Sun.COM 	}
1400*7836SJohn.Forte@Sun.COM 
1401*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
1402*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8Tname\n", "service");
1403*7836SJohn.Forte@Sun.COM 	}
1404*7836SJohn.Forte@Sun.COM 
1405*7836SJohn.Forte@Sun.COM 	memset(s_name, 0, sizeof (s_name));
1406*7836SJohn.Forte@Sun.COM 	if (service->s_name) {
1407*7836SJohn.Forte@Sun.COM 		if (mdb_readstr(s_name, sizeof (s_name),
1408*7836SJohn.Forte@Sun.COM 		    (uintptr_t)service->s_name) == -1) {
1409*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to read nsc_io_t.name");
1410*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1411*7836SJohn.Forte@Sun.COM 		}
1412*7836SJohn.Forte@Sun.COM 	}
1413*7836SJohn.Forte@Sun.COM 
1414*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%s\n", addr, s_name);
1415*7836SJohn.Forte@Sun.COM 
1416*7836SJohn.Forte@Sun.COM 	if (!v_opt)
1417*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1418*7836SJohn.Forte@Sun.COM 
1419*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
1420*7836SJohn.Forte@Sun.COM 
1421*7836SJohn.Forte@Sun.COM 	mdb_printf("servers:\n");
1422*7836SJohn.Forte@Sun.COM 	if (service->s_servers == NULL) {
1423*7836SJohn.Forte@Sun.COM 		mdb_printf("<none>\n");
1424*7836SJohn.Forte@Sun.COM 	} else {
1425*7836SJohn.Forte@Sun.COM 		mdb_inc_indent(4);
1426*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsc_svc", "nsctl`nsc_svc",
1427*7836SJohn.Forte@Sun.COM 		    argc, argv, (uintptr_t)service->s_servers) == -1) {
1428*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(8);
1429*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1430*7836SJohn.Forte@Sun.COM 		}
1431*7836SJohn.Forte@Sun.COM 		mdb_dec_indent(4);
1432*7836SJohn.Forte@Sun.COM 	}
1433*7836SJohn.Forte@Sun.COM 
1434*7836SJohn.Forte@Sun.COM 	mdb_printf("clients:\n");
1435*7836SJohn.Forte@Sun.COM 	if (service->s_clients == NULL) {
1436*7836SJohn.Forte@Sun.COM 		mdb_printf("<none>\n");
1437*7836SJohn.Forte@Sun.COM 	} else {
1438*7836SJohn.Forte@Sun.COM 		mdb_inc_indent(4);
1439*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsc_svc", "nsctl`nsc_svc",
1440*7836SJohn.Forte@Sun.COM 		    argc, argv, (uintptr_t)service->s_clients) == -1) {
1441*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(8);
1442*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1443*7836SJohn.Forte@Sun.COM 		}
1444*7836SJohn.Forte@Sun.COM 		mdb_dec_indent(4);
1445*7836SJohn.Forte@Sun.COM 	}
1446*7836SJohn.Forte@Sun.COM 
1447*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
1448*7836SJohn.Forte@Sun.COM 
1449*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1450*7836SJohn.Forte@Sun.COM }
1451*7836SJohn.Forte@Sun.COM 
1452*7836SJohn.Forte@Sun.COM 
1453*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1454*7836SJohn.Forte@Sun.COM 
1455*7836SJohn.Forte@Sun.COM /*
1456*7836SJohn.Forte@Sun.COM  * Display an nsc_svc_t structure.
1457*7836SJohn.Forte@Sun.COM  */
1458*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1459*7836SJohn.Forte@Sun.COM static int
nsc_svc(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1460*7836SJohn.Forte@Sun.COM nsc_svc(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1461*7836SJohn.Forte@Sun.COM {
1462*7836SJohn.Forte@Sun.COM 	nsc_svc_t *svc;
1463*7836SJohn.Forte@Sun.COM 
1464*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC))
1465*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1466*7836SJohn.Forte@Sun.COM 
1467*7836SJohn.Forte@Sun.COM 	svc = mdb_zalloc(sizeof (*svc), UM_SLEEP | UM_GC);
1468*7836SJohn.Forte@Sun.COM 
1469*7836SJohn.Forte@Sun.COM 	if (mdb_vread(svc, sizeof (*svc), addr) != sizeof (*svc)) {
1470*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_svc at %p", addr);
1471*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1472*7836SJohn.Forte@Sun.COM 	}
1473*7836SJohn.Forte@Sun.COM 
1474*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
1475*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8T%-?s  %8Tfunc\n", "svc", "service");
1476*7836SJohn.Forte@Sun.COM 	}
1477*7836SJohn.Forte@Sun.COM 
1478*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%0?p  %8T%a\n", addr, svc->svc_svc, svc->svc_fn);
1479*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1480*7836SJohn.Forte@Sun.COM }
1481*7836SJohn.Forte@Sun.COM 
1482*7836SJohn.Forte@Sun.COM 
1483*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1484*7836SJohn.Forte@Sun.COM 
1485*7836SJohn.Forte@Sun.COM /*
1486*7836SJohn.Forte@Sun.COM  * Display a single nsc_val_t structure.
1487*7836SJohn.Forte@Sun.COM  * If called with no address, performs a global walk of all nsc_devs.
1488*7836SJohn.Forte@Sun.COM  */
1489*7836SJohn.Forte@Sun.COM /* ARGSUSED3 */
1490*7836SJohn.Forte@Sun.COM static int
nsc_val(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1491*7836SJohn.Forte@Sun.COM nsc_val(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1492*7836SJohn.Forte@Sun.COM {
1493*7836SJohn.Forte@Sun.COM 	nsc_val_t *vp;
1494*7836SJohn.Forte@Sun.COM 
1495*7836SJohn.Forte@Sun.COM 	if (argc != 0)
1496*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1497*7836SJohn.Forte@Sun.COM 
1498*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1499*7836SJohn.Forte@Sun.COM 		mdb_warn("nsc_val requires an address");
1500*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1501*7836SJohn.Forte@Sun.COM 	}
1502*7836SJohn.Forte@Sun.COM 
1503*7836SJohn.Forte@Sun.COM 	vp = mdb_zalloc(sizeof (*vp), UM_SLEEP | UM_GC);
1504*7836SJohn.Forte@Sun.COM 
1505*7836SJohn.Forte@Sun.COM 	if (mdb_vread(vp, sizeof (*vp), addr) != sizeof (*vp)) {
1506*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_val at %p", addr);
1507*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1508*7836SJohn.Forte@Sun.COM 	}
1509*7836SJohn.Forte@Sun.COM 
1510*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
1511*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8T%8-s  %8Tname\n", "val", "value");
1512*7836SJohn.Forte@Sun.COM 	}
1513*7836SJohn.Forte@Sun.COM 
1514*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%08x  %8T%s\n", addr, vp->sv_value, vp->sv_name);
1515*7836SJohn.Forte@Sun.COM 
1516*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1517*7836SJohn.Forte@Sun.COM }
1518*7836SJohn.Forte@Sun.COM 
1519*7836SJohn.Forte@Sun.COM 
1520*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1521*7836SJohn.Forte@Sun.COM 
1522*7836SJohn.Forte@Sun.COM /*
1523*7836SJohn.Forte@Sun.COM  * Display an nstset_t structure, or walk all sets.
1524*7836SJohn.Forte@Sun.COM  */
1525*7836SJohn.Forte@Sun.COM 
1526*7836SJohn.Forte@Sun.COM static int
nstset(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1527*7836SJohn.Forte@Sun.COM nstset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1528*7836SJohn.Forte@Sun.COM {
1529*7836SJohn.Forte@Sun.COM 	nstset_t *set;
1530*7836SJohn.Forte@Sun.COM 	int f_opt, r_opt, t_opt, v_opt;
1531*7836SJohn.Forte@Sun.COM 
1532*7836SJohn.Forte@Sun.COM 	f_opt = r_opt = t_opt = v_opt = 0;
1533*7836SJohn.Forte@Sun.COM 
1534*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
1535*7836SJohn.Forte@Sun.COM 	    'f', MDB_OPT_SETBITS, TRUE, &f_opt,		/* free list */
1536*7836SJohn.Forte@Sun.COM 	    'r', MDB_OPT_SETBITS, TRUE, &r_opt,		/* reuse list */
1537*7836SJohn.Forte@Sun.COM 	    't', MDB_OPT_SETBITS, TRUE, &t_opt,		/* all threads */
1538*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
1539*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1540*7836SJohn.Forte@Sun.COM 
1541*7836SJohn.Forte@Sun.COM 	/* displaying threads implies verbose */
1542*7836SJohn.Forte@Sun.COM 	if (f_opt || r_opt || t_opt)
1543*7836SJohn.Forte@Sun.COM 		v_opt = 1;
1544*7836SJohn.Forte@Sun.COM 
1545*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1546*7836SJohn.Forte@Sun.COM 		if (mdb_walk_dcmd("nsctl`nstset",
1547*7836SJohn.Forte@Sun.COM 		    "nsctl`nstset", argc, argv) == -1) {
1548*7836SJohn.Forte@Sun.COM 			mdb_warn("failed to walk 'nstset'");
1549*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1550*7836SJohn.Forte@Sun.COM 		}
1551*7836SJohn.Forte@Sun.COM 
1552*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1553*7836SJohn.Forte@Sun.COM 	}
1554*7836SJohn.Forte@Sun.COM 
1555*7836SJohn.Forte@Sun.COM 	set = mdb_zalloc(sizeof (*set), UM_SLEEP | UM_GC);
1556*7836SJohn.Forte@Sun.COM 
1557*7836SJohn.Forte@Sun.COM 	if (mdb_vread(set, sizeof (*set), addr) != sizeof (*set)) {
1558*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nstset at %p", addr);
1559*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1560*7836SJohn.Forte@Sun.COM 	}
1561*7836SJohn.Forte@Sun.COM 
1562*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
1563*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8T  live   nthr flag name\n", "set");
1564*7836SJohn.Forte@Sun.COM 	}
1565*7836SJohn.Forte@Sun.COM 
1566*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%6d %6d %4x %s\n", addr,
1567*7836SJohn.Forte@Sun.COM 	    set->set_nlive, set->set_nthread, set->set_flag, set->set_name);
1568*7836SJohn.Forte@Sun.COM 
1569*7836SJohn.Forte@Sun.COM 	if (!v_opt)
1570*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1571*7836SJohn.Forte@Sun.COM 
1572*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
1573*7836SJohn.Forte@Sun.COM 
1574*7836SJohn.Forte@Sun.COM 	mdb_printf("chain: %0?p  %8Tpending: %4d  res_cnt: %4d\n",
1575*7836SJohn.Forte@Sun.COM 	    set->set_chain, set->set_pending, set->set_res_cnt);
1576*7836SJohn.Forte@Sun.COM 
1577*7836SJohn.Forte@Sun.COM 	if (set->set_reuse.q_forw == set->set_reuse.q_back &&
1578*7836SJohn.Forte@Sun.COM 	    (uintptr_t)set->set_reuse.q_forw ==
1579*7836SJohn.Forte@Sun.COM 	    (addr + OFFSETOF(nstset_t, set_reuse))) {
1580*7836SJohn.Forte@Sun.COM 		mdb_printf("reuse.forw: %-?s  %8Treuse.back: %s\n",
1581*7836SJohn.Forte@Sun.COM 		    "empty", "empty");
1582*7836SJohn.Forte@Sun.COM 	} else {
1583*7836SJohn.Forte@Sun.COM 		mdb_printf("reuse.forw: %0?p  %8Treuse.back: %0?p\n",
1584*7836SJohn.Forte@Sun.COM 		    set->set_reuse.q_forw, set->set_reuse.q_back);
1585*7836SJohn.Forte@Sun.COM 
1586*7836SJohn.Forte@Sun.COM 		/* display all threads in reuse list */
1587*7836SJohn.Forte@Sun.COM 		if (r_opt &&
1588*7836SJohn.Forte@Sun.COM 		    mdb_pwalk_dcmd("nsctl`nst_free", "nsctl`nsthread",
1589*7836SJohn.Forte@Sun.COM 		    0, (const mdb_arg_t *)NULL,
1590*7836SJohn.Forte@Sun.COM 		    (addr + OFFSETOF(nstset_t, set_reuse))) == -1) {
1591*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(4);
1592*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1593*7836SJohn.Forte@Sun.COM 		}
1594*7836SJohn.Forte@Sun.COM 	}
1595*7836SJohn.Forte@Sun.COM 
1596*7836SJohn.Forte@Sun.COM 	if (set->set_free.q_forw == set->set_free.q_back &&
1597*7836SJohn.Forte@Sun.COM 	    (uintptr_t)set->set_free.q_forw ==
1598*7836SJohn.Forte@Sun.COM 	    (addr + OFFSETOF(nstset_t, set_free))) {
1599*7836SJohn.Forte@Sun.COM 		mdb_printf("free.forw:  %-?s  %8Tfree.back:  %s\n",
1600*7836SJohn.Forte@Sun.COM 		    "empty", "empty");
1601*7836SJohn.Forte@Sun.COM 	} else {
1602*7836SJohn.Forte@Sun.COM 		mdb_printf("free.forw:  %0?p  %8Tfree.back:  %0?p\n",
1603*7836SJohn.Forte@Sun.COM 		    set->set_free.q_forw, set->set_free.q_back);
1604*7836SJohn.Forte@Sun.COM 
1605*7836SJohn.Forte@Sun.COM 		/* display all threads in free list */
1606*7836SJohn.Forte@Sun.COM 		if (f_opt &&
1607*7836SJohn.Forte@Sun.COM 		    mdb_pwalk_dcmd("nsctl`nst_free", "nsctl`nsthread",
1608*7836SJohn.Forte@Sun.COM 		    0, (const mdb_arg_t *)NULL,
1609*7836SJohn.Forte@Sun.COM 		    (addr + OFFSETOF(nstset_t, set_free))) == -1) {
1610*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(4);
1611*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1612*7836SJohn.Forte@Sun.COM 		}
1613*7836SJohn.Forte@Sun.COM 	}
1614*7836SJohn.Forte@Sun.COM 
1615*7836SJohn.Forte@Sun.COM 	mdb_printf("flag: %08x <%b>\n",
1616*7836SJohn.Forte@Sun.COM 	    set->set_flag, set->set_flag, nstset_flag_bits);
1617*7836SJohn.Forte@Sun.COM 
1618*7836SJohn.Forte@Sun.COM 	/* display all threads in set */
1619*7836SJohn.Forte@Sun.COM 	if (t_opt) {
1620*7836SJohn.Forte@Sun.COM 		mdb_printf("all threads in set:\n");
1621*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsthread", "nsctl`nsthread",
1622*7836SJohn.Forte@Sun.COM 		    0, (const mdb_arg_t *)NULL,
1623*7836SJohn.Forte@Sun.COM 		    (uintptr_t)set->set_chain) == -1) {
1624*7836SJohn.Forte@Sun.COM 			mdb_dec_indent(4);
1625*7836SJohn.Forte@Sun.COM 			return (DCMD_ERR);
1626*7836SJohn.Forte@Sun.COM 		}
1627*7836SJohn.Forte@Sun.COM 	}
1628*7836SJohn.Forte@Sun.COM 
1629*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
1630*7836SJohn.Forte@Sun.COM 
1631*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1632*7836SJohn.Forte@Sun.COM }
1633*7836SJohn.Forte@Sun.COM 
1634*7836SJohn.Forte@Sun.COM 
1635*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1636*7836SJohn.Forte@Sun.COM 
1637*7836SJohn.Forte@Sun.COM /*
1638*7836SJohn.Forte@Sun.COM  * Callback for the all nstsets and threads walk.  Called per set.
1639*7836SJohn.Forte@Sun.COM  */
1640*7836SJohn.Forte@Sun.COM /* ARGSUSED */
1641*7836SJohn.Forte@Sun.COM static int
nst_thr_set(uintptr_t addr,const void * data,void * cbdata)1642*7836SJohn.Forte@Sun.COM nst_thr_set(uintptr_t addr, const void *data, void *cbdata)
1643*7836SJohn.Forte@Sun.COM {
1644*7836SJohn.Forte@Sun.COM 	struct complex_args *thrall = cbdata;
1645*7836SJohn.Forte@Sun.COM 	char set_name[48];
1646*7836SJohn.Forte@Sun.COM 	uintptr_t tp;
1647*7836SJohn.Forte@Sun.COM 
1648*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&tp, sizeof (tp),
1649*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nstset_t, set_chain)) == -1) {
1650*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read nstset_t.set_chain at %p", addr);
1651*7836SJohn.Forte@Sun.COM 		return (WALK_ERR);
1652*7836SJohn.Forte@Sun.COM 	}
1653*7836SJohn.Forte@Sun.COM 
1654*7836SJohn.Forte@Sun.COM 	memset(set_name, 0, sizeof (set_name));
1655*7836SJohn.Forte@Sun.COM 
1656*7836SJohn.Forte@Sun.COM 	if (mdb_readstr(set_name, sizeof (set_name),
1657*7836SJohn.Forte@Sun.COM 	    addr + OFFSETOF(nstset_t, set_name)) == -1) {
1658*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read nstset_t.set_name at %p", addr);
1659*7836SJohn.Forte@Sun.COM 	}
1660*7836SJohn.Forte@Sun.COM 
1661*7836SJohn.Forte@Sun.COM 	mdb_printf("nstset: %0?p (%s)\n", addr, set_name);
1662*7836SJohn.Forte@Sun.COM 
1663*7836SJohn.Forte@Sun.COM 	/* walk thread chains */
1664*7836SJohn.Forte@Sun.COM 
1665*7836SJohn.Forte@Sun.COM 	if (tp != NULL) {
1666*7836SJohn.Forte@Sun.COM 		if (mdb_pwalk_dcmd("nsctl`nsthread", "nsctl`nsthread",
1667*7836SJohn.Forte@Sun.COM 		    thrall->argc, thrall->argv, tp) == -1)
1668*7836SJohn.Forte@Sun.COM 			return (WALK_ERR);
1669*7836SJohn.Forte@Sun.COM 	} else
1670*7836SJohn.Forte@Sun.COM 		mdb_printf("    no threads\n");
1671*7836SJohn.Forte@Sun.COM 
1672*7836SJohn.Forte@Sun.COM 	mdb_printf("\n");
1673*7836SJohn.Forte@Sun.COM 
1674*7836SJohn.Forte@Sun.COM 	return (WALK_NEXT);
1675*7836SJohn.Forte@Sun.COM }
1676*7836SJohn.Forte@Sun.COM 
1677*7836SJohn.Forte@Sun.COM 
1678*7836SJohn.Forte@Sun.COM /*
1679*7836SJohn.Forte@Sun.COM  * Walk all nstsets and threads in the system.
1680*7836SJohn.Forte@Sun.COM  */
1681*7836SJohn.Forte@Sun.COM static int
nst_thr_all(int argc,const mdb_arg_t * argv)1682*7836SJohn.Forte@Sun.COM nst_thr_all(int argc, const mdb_arg_t *argv)
1683*7836SJohn.Forte@Sun.COM {
1684*7836SJohn.Forte@Sun.COM 	struct complex_args thrall;
1685*7836SJohn.Forte@Sun.COM 
1686*7836SJohn.Forte@Sun.COM 	thrall.argc = argc;
1687*7836SJohn.Forte@Sun.COM 	thrall.argv = (mdb_arg_t *)argv;
1688*7836SJohn.Forte@Sun.COM 
1689*7836SJohn.Forte@Sun.COM 	if (mdb_walk("nsctl`nstset", nst_thr_set, &thrall) == -1)
1690*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1691*7836SJohn.Forte@Sun.COM 
1692*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1693*7836SJohn.Forte@Sun.COM }
1694*7836SJohn.Forte@Sun.COM 
1695*7836SJohn.Forte@Sun.COM 
1696*7836SJohn.Forte@Sun.COM /*
1697*7836SJohn.Forte@Sun.COM  * Display an nsthread_t structure, or walk all threads.
1698*7836SJohn.Forte@Sun.COM  */
1699*7836SJohn.Forte@Sun.COM 
1700*7836SJohn.Forte@Sun.COM static int
nsthread(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1701*7836SJohn.Forte@Sun.COM nsthread(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1702*7836SJohn.Forte@Sun.COM {
1703*7836SJohn.Forte@Sun.COM 	uintptr_t thrpend;
1704*7836SJohn.Forte@Sun.COM 	nsthread_t *tp;
1705*7836SJohn.Forte@Sun.COM 	int a_opt, v_opt;
1706*7836SJohn.Forte@Sun.COM 	int rc;
1707*7836SJohn.Forte@Sun.COM 
1708*7836SJohn.Forte@Sun.COM 	a_opt = v_opt = 0;
1709*7836SJohn.Forte@Sun.COM 
1710*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
1711*7836SJohn.Forte@Sun.COM 	    'a', MDB_OPT_SETBITS, TRUE, &a_opt,
1712*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
1713*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1714*7836SJohn.Forte@Sun.COM 
1715*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1716*7836SJohn.Forte@Sun.COM 		if ((rc = nst_thr_all(argc, argv)) != DCMD_OK)
1717*7836SJohn.Forte@Sun.COM 			return (rc);
1718*7836SJohn.Forte@Sun.COM 
1719*7836SJohn.Forte@Sun.COM 		if (a_opt) {
1720*7836SJohn.Forte@Sun.COM 			if (mdb_readvar(&thrpend, "nst_pending") == -1) {
1721*7836SJohn.Forte@Sun.COM 				mdb_warn("unable to read 'nst_pending'");
1722*7836SJohn.Forte@Sun.COM 				return (DCMD_ERR);
1723*7836SJohn.Forte@Sun.COM 			}
1724*7836SJohn.Forte@Sun.COM 
1725*7836SJohn.Forte@Sun.COM 			if (thrpend) {
1726*7836SJohn.Forte@Sun.COM 				mdb_printf("\nPending threads:\n");
1727*7836SJohn.Forte@Sun.COM 
1728*7836SJohn.Forte@Sun.COM 				if (mdb_pwalk_dcmd("nsctl`nsthread",
1729*7836SJohn.Forte@Sun.COM 				    "nsctl`nsthread", argc, argv,
1730*7836SJohn.Forte@Sun.COM 				    thrpend) == -1) {
1731*7836SJohn.Forte@Sun.COM 					mdb_warn("failed to walk 'nsthread'");
1732*7836SJohn.Forte@Sun.COM 					return (DCMD_ERR);
1733*7836SJohn.Forte@Sun.COM 				}
1734*7836SJohn.Forte@Sun.COM 			}
1735*7836SJohn.Forte@Sun.COM 		}
1736*7836SJohn.Forte@Sun.COM 
1737*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1738*7836SJohn.Forte@Sun.COM 	}
1739*7836SJohn.Forte@Sun.COM 
1740*7836SJohn.Forte@Sun.COM 	tp = mdb_zalloc(sizeof (*tp), UM_SLEEP | UM_GC);
1741*7836SJohn.Forte@Sun.COM 
1742*7836SJohn.Forte@Sun.COM 	if (mdb_vread(tp, sizeof (*tp), addr) != sizeof (*tp)) {
1743*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsthread at %p", addr);
1744*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1745*7836SJohn.Forte@Sun.COM 	}
1746*7836SJohn.Forte@Sun.COM 
1747*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
1748*7836SJohn.Forte@Sun.COM 		mdb_printf("%-?s  %8Tflag %-?s  %8Tfunc\n", "thread", "arg");
1749*7836SJohn.Forte@Sun.COM 	}
1750*7836SJohn.Forte@Sun.COM 
1751*7836SJohn.Forte@Sun.COM 	mdb_printf("%0?p  %8T%4x %0?p  %8T%a\n",
1752*7836SJohn.Forte@Sun.COM 	    addr, tp->tp_flag, tp->tp_arg, tp->tp_func);
1753*7836SJohn.Forte@Sun.COM 
1754*7836SJohn.Forte@Sun.COM 	if (!v_opt)
1755*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1756*7836SJohn.Forte@Sun.COM 
1757*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
1758*7836SJohn.Forte@Sun.COM 
1759*7836SJohn.Forte@Sun.COM 	mdb_printf("set: %0?p  %8Tchain: %0?p\n",
1760*7836SJohn.Forte@Sun.COM 	    tp->tp_set, tp->tp_chain);
1761*7836SJohn.Forte@Sun.COM 
1762*7836SJohn.Forte@Sun.COM 	mdb_printf("link.forw: %0?p  %8Tlink.back: %0?p\n",
1763*7836SJohn.Forte@Sun.COM 	    tp->tp_link.q_forw, tp->tp_link.q_back);
1764*7836SJohn.Forte@Sun.COM 
1765*7836SJohn.Forte@Sun.COM 	mdb_printf("flag: %08x <%b>\n",
1766*7836SJohn.Forte@Sun.COM 	    tp->tp_flag, tp->tp_flag, nst_flag_bits);
1767*7836SJohn.Forte@Sun.COM 
1768*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
1769*7836SJohn.Forte@Sun.COM 
1770*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1771*7836SJohn.Forte@Sun.COM }
1772*7836SJohn.Forte@Sun.COM 
1773*7836SJohn.Forte@Sun.COM 
1774*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
1775*7836SJohn.Forte@Sun.COM 
1776*7836SJohn.Forte@Sun.COM static void
nsc_rmap(char * name)1777*7836SJohn.Forte@Sun.COM nsc_rmap(char *name)
1778*7836SJohn.Forte@Sun.COM {
1779*7836SJohn.Forte@Sun.COM 	nsc_rmmap_t slot;
1780*7836SJohn.Forte@Sun.COM 	uintptr_t addr;
1781*7836SJohn.Forte@Sun.COM 	int nslot;
1782*7836SJohn.Forte@Sun.COM 	char *cp;
1783*7836SJohn.Forte@Sun.COM 
1784*7836SJohn.Forte@Sun.COM 	if (mdb_readvar(&addr, name) == -1) {
1785*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read rmap '%s'", name);
1786*7836SJohn.Forte@Sun.COM 		return;
1787*7836SJohn.Forte@Sun.COM 	}
1788*7836SJohn.Forte@Sun.COM 
1789*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&slot, sizeof (slot), addr) != sizeof (slot)) {
1790*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read rmap '%s' slot 0", name);
1791*7836SJohn.Forte@Sun.COM 		return;
1792*7836SJohn.Forte@Sun.COM 	}
1793*7836SJohn.Forte@Sun.COM 
1794*7836SJohn.Forte@Sun.COM 	mdb_printf("\nmap name		offset      size    nslot\n");
1795*7836SJohn.Forte@Sun.COM 	mdb_printf("%16s     %9d %9d    %5d\n",
1796*7836SJohn.Forte@Sun.COM 	    slot.name, slot.offset, slot.size, slot.inuse);
1797*7836SJohn.Forte@Sun.COM 
1798*7836SJohn.Forte@Sun.COM 	nslot = slot.inuse;
1799*7836SJohn.Forte@Sun.COM 	mdb_printf("\nslot name	       offset      size    inuse\n");
1800*7836SJohn.Forte@Sun.COM 
1801*7836SJohn.Forte@Sun.COM 	while (--nslot) {
1802*7836SJohn.Forte@Sun.COM 		addr += sizeof (slot);
1803*7836SJohn.Forte@Sun.COM 
1804*7836SJohn.Forte@Sun.COM 		if (mdb_vread(&slot, sizeof (slot), addr) != sizeof (slot)) {
1805*7836SJohn.Forte@Sun.COM 			mdb_warn("unable to read rmap '%s' slot @ %p",
1806*7836SJohn.Forte@Sun.COM 			    name, addr);
1807*7836SJohn.Forte@Sun.COM 			return;
1808*7836SJohn.Forte@Sun.COM 		}
1809*7836SJohn.Forte@Sun.COM 
1810*7836SJohn.Forte@Sun.COM 		if (!slot.inuse || !slot.size)
1811*7836SJohn.Forte@Sun.COM 			continue;
1812*7836SJohn.Forte@Sun.COM 
1813*7836SJohn.Forte@Sun.COM 		for (cp = slot.name; *cp; cp++)
1814*7836SJohn.Forte@Sun.COM 			if (*cp == ':')
1815*7836SJohn.Forte@Sun.COM 				*cp = ' ';
1816*7836SJohn.Forte@Sun.COM 
1817*7836SJohn.Forte@Sun.COM 		mdb_printf("%16s     %9d %9d %08x\n",
1818*7836SJohn.Forte@Sun.COM 		    slot.name, slot.offset, slot.size, slot.inuse);
1819*7836SJohn.Forte@Sun.COM 	}
1820*7836SJohn.Forte@Sun.COM }
1821*7836SJohn.Forte@Sun.COM 
1822*7836SJohn.Forte@Sun.COM 
1823*7836SJohn.Forte@Sun.COM static void
nsc_rmhdr(void)1824*7836SJohn.Forte@Sun.COM nsc_rmhdr(void)
1825*7836SJohn.Forte@Sun.COM {
1826*7836SJohn.Forte@Sun.COM 	nsc_rmhdr_t *rmhdr = mdb_zalloc(sizeof (*rmhdr), UM_SLEEP | UM_GC);
1827*7836SJohn.Forte@Sun.COM 	uintptr_t addr;
1828*7836SJohn.Forte@Sun.COM 
1829*7836SJohn.Forte@Sun.COM 	if (mdb_readvar(&addr, "_nsc_rmhdr_ptr") == -1) {
1830*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read _nsc_rmhdr_ptr");
1831*7836SJohn.Forte@Sun.COM 		return;
1832*7836SJohn.Forte@Sun.COM 	}
1833*7836SJohn.Forte@Sun.COM 
1834*7836SJohn.Forte@Sun.COM 	if (!addr) {
1835*7836SJohn.Forte@Sun.COM 		mdb_printf("\n\nGlobal header not initialised\n");
1836*7836SJohn.Forte@Sun.COM 		return;
1837*7836SJohn.Forte@Sun.COM 	}
1838*7836SJohn.Forte@Sun.COM 
1839*7836SJohn.Forte@Sun.COM 	if (mdb_vread(rmhdr, sizeof (*rmhdr), addr) != sizeof (*rmhdr)) {
1840*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to read global header at %p", addr);
1841*7836SJohn.Forte@Sun.COM 		return;
1842*7836SJohn.Forte@Sun.COM 	}
1843*7836SJohn.Forte@Sun.COM 
1844*7836SJohn.Forte@Sun.COM 	mdb_printf("\n\nglobal header    (magic %08x, version %d, size %d)\n",
1845*7836SJohn.Forte@Sun.COM 	    rmhdr->magic, rmhdr->ver, rmhdr->size);
1846*7836SJohn.Forte@Sun.COM 
1847*7836SJohn.Forte@Sun.COM 	nsc_rmap("_nsc_global_map");
1848*7836SJohn.Forte@Sun.COM }
1849*7836SJohn.Forte@Sun.COM 
1850*7836SJohn.Forte@Sun.COM 
1851*7836SJohn.Forte@Sun.COM static nsc_mem_t *
memptr(int type,int flag)1852*7836SJohn.Forte@Sun.COM memptr(int type, int flag)
1853*7836SJohn.Forte@Sun.COM {
1854*7836SJohn.Forte@Sun.COM 	int i;
1855*7836SJohn.Forte@Sun.COM 
1856*7836SJohn.Forte@Sun.COM 	type &= NSC_MEM_GLOBAL;
1857*7836SJohn.Forte@Sun.COM 
1858*7836SJohn.Forte@Sun.COM 	if (type)
1859*7836SJohn.Forte@Sun.COM 		flag = 0;
1860*7836SJohn.Forte@Sun.COM 
1861*7836SJohn.Forte@Sun.COM 	if (!type && !flag)
1862*7836SJohn.Forte@Sun.COM 		return (&type_mem[0]);
1863*7836SJohn.Forte@Sun.COM 
1864*7836SJohn.Forte@Sun.COM 	for (i = 1; i < (sizeof (type_mem) / sizeof (nsc_mem_t)); i++) {
1865*7836SJohn.Forte@Sun.COM 		if (!type_mem[i].flag && !type_mem[i].type) {
1866*7836SJohn.Forte@Sun.COM 			type_mem[i].flag = flag;
1867*7836SJohn.Forte@Sun.COM 			type_mem[i].type = type;
1868*7836SJohn.Forte@Sun.COM 			return (&type_mem[i]);
1869*7836SJohn.Forte@Sun.COM 		}
1870*7836SJohn.Forte@Sun.COM 
1871*7836SJohn.Forte@Sun.COM 		if (type_mem[i].flag == flag && type_mem[i].type == type)
1872*7836SJohn.Forte@Sun.COM 			return (&type_mem[i]);
1873*7836SJohn.Forte@Sun.COM 	}
1874*7836SJohn.Forte@Sun.COM 
1875*7836SJohn.Forte@Sun.COM 	return (&type_mem[i]);
1876*7836SJohn.Forte@Sun.COM }
1877*7836SJohn.Forte@Sun.COM 
1878*7836SJohn.Forte@Sun.COM 
1879*7836SJohn.Forte@Sun.COM #define	typename(t)	\
1880*7836SJohn.Forte@Sun.COM 		(((t) & NSC_MEM_GLOBAL) ? "gbl" : " - ")
1881*7836SJohn.Forte@Sun.COM 
1882*7836SJohn.Forte@Sun.COM #define	memname(t)	\
1883*7836SJohn.Forte@Sun.COM 		(((t) & NSC_MEM_GLOBAL) ? "nsc_global" : "system kmem")
1884*7836SJohn.Forte@Sun.COM 
1885*7836SJohn.Forte@Sun.COM static void
nsc_mem_type(const int first,nsc_mem_t * mp)1886*7836SJohn.Forte@Sun.COM nsc_mem_type(const int first, nsc_mem_t *mp)
1887*7836SJohn.Forte@Sun.COM {
1888*7836SJohn.Forte@Sun.COM 	char *type, *name;
1889*7836SJohn.Forte@Sun.COM 
1890*7836SJohn.Forte@Sun.COM 	if (first) {
1891*7836SJohn.Forte@Sun.COM 		mdb_printf("\nregion	   typ  f      ");
1892*7836SJohn.Forte@Sun.COM 		mdb_printf("used       hwm    pgs  alloc  free\n");
1893*7836SJohn.Forte@Sun.COM 	}
1894*7836SJohn.Forte@Sun.COM 
1895*7836SJohn.Forte@Sun.COM 	type = typename(mp->type);
1896*7836SJohn.Forte@Sun.COM 	name = memname(mp->type);
1897*7836SJohn.Forte@Sun.COM 
1898*7836SJohn.Forte@Sun.COM 	mdb_printf("%16s %s %2x %9d %9d %6d  %5d %5d\n",
1899*7836SJohn.Forte@Sun.COM 	    name, type, mp->flag, mp->used, mp->hwm, mp->pagehwm,
1900*7836SJohn.Forte@Sun.COM 	    mp->nalloc, mp->nfree);
1901*7836SJohn.Forte@Sun.COM }
1902*7836SJohn.Forte@Sun.COM 
1903*7836SJohn.Forte@Sun.COM 
1904*7836SJohn.Forte@Sun.COM static int
nsc_mem_all(int argc,const mdb_arg_t * argv,int v_opt)1905*7836SJohn.Forte@Sun.COM nsc_mem_all(int argc, const mdb_arg_t *argv, int v_opt)
1906*7836SJohn.Forte@Sun.COM {
1907*7836SJohn.Forte@Sun.COM 	int first;
1908*7836SJohn.Forte@Sun.COM 	int i;
1909*7836SJohn.Forte@Sun.COM 
1910*7836SJohn.Forte@Sun.COM 	memset(type_mem, 0, sizeof (type_mem));
1911*7836SJohn.Forte@Sun.COM 
1912*7836SJohn.Forte@Sun.COM 	if (mdb_walk_dcmd("nsctl`nsc_mem",
1913*7836SJohn.Forte@Sun.COM 	    "nsctl`nsc_mem", argc, argv) == -1) {
1914*7836SJohn.Forte@Sun.COM 		mdb_warn("unable to walk 'nsc_mem'");
1915*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1916*7836SJohn.Forte@Sun.COM 	}
1917*7836SJohn.Forte@Sun.COM 
1918*7836SJohn.Forte@Sun.COM 	for (first = 1, i = 0;
1919*7836SJohn.Forte@Sun.COM 	    i < (sizeof (type_mem) / sizeof (nsc_mem_t)); first = 0, i++) {
1920*7836SJohn.Forte@Sun.COM 		if (type_mem[i].nalloc || type_mem[i].hwm) {
1921*7836SJohn.Forte@Sun.COM 			nsc_mem_type(first, &type_mem[i]);
1922*7836SJohn.Forte@Sun.COM 		}
1923*7836SJohn.Forte@Sun.COM 	}
1924*7836SJohn.Forte@Sun.COM 
1925*7836SJohn.Forte@Sun.COM 	if (v_opt)
1926*7836SJohn.Forte@Sun.COM 		nsc_rmhdr();
1927*7836SJohn.Forte@Sun.COM 
1928*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1929*7836SJohn.Forte@Sun.COM }
1930*7836SJohn.Forte@Sun.COM 
1931*7836SJohn.Forte@Sun.COM 
1932*7836SJohn.Forte@Sun.COM static int
nsc_mem(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1933*7836SJohn.Forte@Sun.COM nsc_mem(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1934*7836SJohn.Forte@Sun.COM {
1935*7836SJohn.Forte@Sun.COM 	char name[16], *type, *cp;
1936*7836SJohn.Forte@Sun.COM 	nsc_mem_t mem, *mp;
1937*7836SJohn.Forte@Sun.COM 	int v_opt;
1938*7836SJohn.Forte@Sun.COM 
1939*7836SJohn.Forte@Sun.COM 	v_opt = 0;
1940*7836SJohn.Forte@Sun.COM 
1941*7836SJohn.Forte@Sun.COM 	if (mdb_getopts(argc, argv,
1942*7836SJohn.Forte@Sun.COM 	    'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
1943*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
1944*7836SJohn.Forte@Sun.COM 
1945*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC)) {
1946*7836SJohn.Forte@Sun.COM 		return (nsc_mem_all(argc, argv, v_opt));
1947*7836SJohn.Forte@Sun.COM 	}
1948*7836SJohn.Forte@Sun.COM 
1949*7836SJohn.Forte@Sun.COM 	if (mdb_vread(&mem, sizeof (mem), addr) != sizeof (mem)) {
1950*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_mem_t at %p", addr);
1951*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1952*7836SJohn.Forte@Sun.COM 	}
1953*7836SJohn.Forte@Sun.COM 
1954*7836SJohn.Forte@Sun.COM 	if (mdb_readstr(name, sizeof (name), (uintptr_t)mem.name) == -1) {
1955*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_mem_t.name at %p", addr);
1956*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1957*7836SJohn.Forte@Sun.COM 	}
1958*7836SJohn.Forte@Sun.COM 
1959*7836SJohn.Forte@Sun.COM 	if (!mem.nalloc && !mem.hwm && !v_opt)
1960*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
1961*7836SJohn.Forte@Sun.COM 
1962*7836SJohn.Forte@Sun.COM 	if (DCMD_HDRSPEC(flags)) {
1963*7836SJohn.Forte@Sun.COM 		mdb_printf("name	     typ  f      ");
1964*7836SJohn.Forte@Sun.COM 		mdb_printf("used       hwm   pgs alloc  free     base\n");
1965*7836SJohn.Forte@Sun.COM 	}
1966*7836SJohn.Forte@Sun.COM 
1967*7836SJohn.Forte@Sun.COM 	type = typename(mem.type);
1968*7836SJohn.Forte@Sun.COM 	mp = memptr(mem.type, mem.flag);
1969*7836SJohn.Forte@Sun.COM 
1970*7836SJohn.Forte@Sun.COM 	for (cp = name; *cp; cp++)
1971*7836SJohn.Forte@Sun.COM 		if (*cp == ':')
1972*7836SJohn.Forte@Sun.COM 			*cp = ' ';
1973*7836SJohn.Forte@Sun.COM 
1974*7836SJohn.Forte@Sun.COM 	mdb_printf("%-16s %s %2x %9d %9d %5d %5d %5d %0?p\n",
1975*7836SJohn.Forte@Sun.COM 	    name, type, mem.flag, mem.used, mem.hwm, mem.pagehwm,
1976*7836SJohn.Forte@Sun.COM 	    mem.nalloc, mem.nfree, mem.base);
1977*7836SJohn.Forte@Sun.COM 
1978*7836SJohn.Forte@Sun.COM 	mp->used += mem.used;
1979*7836SJohn.Forte@Sun.COM 	mp->hwm += mem.hwm;
1980*7836SJohn.Forte@Sun.COM 	mp->pagehwm += mem.pagehwm;
1981*7836SJohn.Forte@Sun.COM 	mp->nalloc += mem.nalloc;
1982*7836SJohn.Forte@Sun.COM 	mp->nfree += mem.nfree;
1983*7836SJohn.Forte@Sun.COM 
1984*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
1985*7836SJohn.Forte@Sun.COM }
1986*7836SJohn.Forte@Sun.COM 
1987*7836SJohn.Forte@Sun.COM /*ARGSUSED*/
1988*7836SJohn.Forte@Sun.COM static int
nsc_vec(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)1989*7836SJohn.Forte@Sun.COM nsc_vec(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
1990*7836SJohn.Forte@Sun.COM {
1991*7836SJohn.Forte@Sun.COM 	nsc_vec_t *vec;
1992*7836SJohn.Forte@Sun.COM 
1993*7836SJohn.Forte@Sun.COM 	vec = mdb_zalloc(sizeof (*vec), UM_SLEEP | UM_GC);
1994*7836SJohn.Forte@Sun.COM 	if (mdb_vread(vec, sizeof (*vec), addr) != sizeof (*vec)) {
1995*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_vec at %p", addr);
1996*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
1997*7836SJohn.Forte@Sun.COM 	}
1998*7836SJohn.Forte@Sun.COM 	mdb_printf("nsc_vec_t @ 0x%p = {\n", addr);
1999*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
2000*7836SJohn.Forte@Sun.COM 	mdb_printf("sv_addr: %p\n", vec->sv_addr);
2001*7836SJohn.Forte@Sun.COM 	mdb_printf("sv_vme:  %lu\n", vec->sv_vme);
2002*7836SJohn.Forte@Sun.COM 	mdb_printf("sv_len:  %d\n", vec->sv_len);
2003*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
2004*7836SJohn.Forte@Sun.COM 	mdb_printf("};\n");
2005*7836SJohn.Forte@Sun.COM 	if (vec->sv_addr)
2006*7836SJohn.Forte@Sun.COM 		return (DCMD_OK);
2007*7836SJohn.Forte@Sun.COM 	else
2008*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2009*7836SJohn.Forte@Sun.COM }
2010*7836SJohn.Forte@Sun.COM 
2011*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
2012*7836SJohn.Forte@Sun.COM /*
2013*7836SJohn.Forte@Sun.COM  * Display an nsc_buf_t structure.
2014*7836SJohn.Forte@Sun.COM  */
2015*7836SJohn.Forte@Sun.COM 
2016*7836SJohn.Forte@Sun.COM #ifdef NSC_MULTI_TERABYTE
2017*7836SJohn.Forte@Sun.COM #define	STRCONV	"ll"
2018*7836SJohn.Forte@Sun.COM #else
2019*7836SJohn.Forte@Sun.COM #define	STRCONV	""
2020*7836SJohn.Forte@Sun.COM #endif
2021*7836SJohn.Forte@Sun.COM 
2022*7836SJohn.Forte@Sun.COM /* ARGSUSED */
2023*7836SJohn.Forte@Sun.COM static int
nsc_buf(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2024*7836SJohn.Forte@Sun.COM nsc_buf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2025*7836SJohn.Forte@Sun.COM {
2026*7836SJohn.Forte@Sun.COM 	nsc_buf_t *bh;
2027*7836SJohn.Forte@Sun.COM 	nsc_vec_t *v;
2028*7836SJohn.Forte@Sun.COM 
2029*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC))
2030*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
2031*7836SJohn.Forte@Sun.COM 
2032*7836SJohn.Forte@Sun.COM 	bh = mdb_zalloc(sizeof (*bh), UM_SLEEP | UM_GC);
2033*7836SJohn.Forte@Sun.COM 
2034*7836SJohn.Forte@Sun.COM 	if (mdb_vread(bh, sizeof (*bh), addr) != sizeof (*bh)) {
2035*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_buf at %p", addr);
2036*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2037*7836SJohn.Forte@Sun.COM 	}
2038*7836SJohn.Forte@Sun.COM 
2039*7836SJohn.Forte@Sun.COM 	mdb_printf("nsc_buf_t @ 0x%p = {\n", addr);
2040*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
2041*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_fd:    0x%p\n", bh->sb_fd);
2042*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_pos:   0x%" STRCONV "x\n", bh->sb_pos);
2043*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_len:   0x%" STRCONV "x\n", bh->sb_len);
2044*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_flag:  0x%08x <%b>\n", bh->sb_flag,
2045*7836SJohn.Forte@Sun.COM 	    bh->sb_flag, nsc_bhflag_bits);
2046*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_error: %d\n", bh->sb_error);
2047*7836SJohn.Forte@Sun.COM #ifdef NSC_MULTI_TERABYTE
2048*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_user:  0x%p\n", bh->sb_user);
2049*7836SJohn.Forte@Sun.COM #else
2050*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_user:  0x%x\n", bh->sb_user);
2051*7836SJohn.Forte@Sun.COM #endif
2052*7836SJohn.Forte@Sun.COM 	mdb_printf("sb_vec:   0x%p\n", bh->sb_vec);
2053*7836SJohn.Forte@Sun.COM 	v = bh->sb_vec++;
2054*7836SJohn.Forte@Sun.COM 	while (nsc_vec((uintptr_t)v, flags, argc, argv) == DCMD_OK)
2055*7836SJohn.Forte@Sun.COM 		v++;
2056*7836SJohn.Forte@Sun.COM 
2057*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
2058*7836SJohn.Forte@Sun.COM 	mdb_printf("};\n");
2059*7836SJohn.Forte@Sun.COM 
2060*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
2061*7836SJohn.Forte@Sun.COM }
2062*7836SJohn.Forte@Sun.COM 
2063*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
2064*7836SJohn.Forte@Sun.COM 
2065*7836SJohn.Forte@Sun.COM /* ARGSUSED */
2066*7836SJohn.Forte@Sun.COM static int
nsc_dbuf(uintptr_t addr,uint_t flags,int argc,const mdb_arg_t * argv)2067*7836SJohn.Forte@Sun.COM nsc_dbuf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
2068*7836SJohn.Forte@Sun.COM {
2069*7836SJohn.Forte@Sun.COM 	nsc_dbuf_t *bh;
2070*7836SJohn.Forte@Sun.COM 
2071*7836SJohn.Forte@Sun.COM 	if (!(flags & DCMD_ADDRSPEC))
2072*7836SJohn.Forte@Sun.COM 		return (DCMD_USAGE);
2073*7836SJohn.Forte@Sun.COM 
2074*7836SJohn.Forte@Sun.COM 	bh = mdb_zalloc(sizeof (*bh), UM_SLEEP | UM_GC);
2075*7836SJohn.Forte@Sun.COM 
2076*7836SJohn.Forte@Sun.COM 	if (mdb_vread(bh, sizeof (*bh), addr) != sizeof (*bh)) {
2077*7836SJohn.Forte@Sun.COM 		mdb_warn("failed to read nsc_dbuf at %p", addr);
2078*7836SJohn.Forte@Sun.COM 		return (DCMD_ERR);
2079*7836SJohn.Forte@Sun.COM 	}
2080*7836SJohn.Forte@Sun.COM 
2081*7836SJohn.Forte@Sun.COM 	mdb_printf("nsc_dbuf_t @ 0x%p = {\n", addr);
2082*7836SJohn.Forte@Sun.COM 	mdb_inc_indent(4);
2083*7836SJohn.Forte@Sun.COM 	mdb_printf("db_disc:    0x%p\n", bh->db_disc);
2084*7836SJohn.Forte@Sun.COM 	mdb_printf("db_addr:    0x%p\n", bh->db_addr);
2085*7836SJohn.Forte@Sun.COM 	mdb_printf("db_next:    0x%p\n", bh->db_next);
2086*7836SJohn.Forte@Sun.COM 	mdb_printf("db_maxfbas: 0x%d\n", bh->db_maxfbas);
2087*7836SJohn.Forte@Sun.COM 
2088*7836SJohn.Forte@Sun.COM 
2089*7836SJohn.Forte@Sun.COM 	mdb_dec_indent(4);
2090*7836SJohn.Forte@Sun.COM 	mdb_printf("};\n");
2091*7836SJohn.Forte@Sun.COM 
2092*7836SJohn.Forte@Sun.COM 	return (DCMD_OK);
2093*7836SJohn.Forte@Sun.COM }
2094*7836SJohn.Forte@Sun.COM /* ---------------------------------------------------------------------- */
2095*7836SJohn.Forte@Sun.COM 
2096*7836SJohn.Forte@Sun.COM /*
2097*7836SJohn.Forte@Sun.COM  * MDB module linkage information:
2098*7836SJohn.Forte@Sun.COM  */
2099*7836SJohn.Forte@Sun.COM 
2100*7836SJohn.Forte@Sun.COM static const mdb_dcmd_t dcmds[] = {
2101*7836SJohn.Forte@Sun.COM #if 0
2102*7836SJohn.Forte@Sun.COM 	{ "nsctl", NULL, "display nsctl module info", nsctl },
2103*7836SJohn.Forte@Sun.COM #endif
2104*7836SJohn.Forte@Sun.COM 	{ "nsc_buf", ":", "list nsc_buf structure", nsc_buf },
2105*7836SJohn.Forte@Sun.COM 	{ "nsc_dbuf", ":", "list nsc_dbuf structure", nsc_dbuf },
2106*7836SJohn.Forte@Sun.COM 	{ "nsc_dev", "?[-av]", "list nsc_dev structure", nsc_dev },
2107*7836SJohn.Forte@Sun.COM 	{ "nsc_devval", "?[-a]", "list nsc_devval structure", nsc_devval },
2108*7836SJohn.Forte@Sun.COM 	{ "nsc_fd", "?[-v]", "list nsc_fd structure", nsc_fd },
2109*7836SJohn.Forte@Sun.COM 	{ "nsc_iodev", "?[-v]", "list nsc_iodev structure", nsc_iodev },
2110*7836SJohn.Forte@Sun.COM 	{ "nsc_io", "?[-v]", "list nsc_io structure", nsc_io },
2111*7836SJohn.Forte@Sun.COM 	{ "nsc_mem", "?[-v]", "list nsc_mem structure", nsc_mem },
2112*7836SJohn.Forte@Sun.COM 	{ "nsc_svc", ":", "list nsc_svc structure", nsc_svc },
2113*7836SJohn.Forte@Sun.COM 	{ "nsc_service", "?[-v]", "list nsc_service structure", nsc_service },
2114*7836SJohn.Forte@Sun.COM 	{ "nsc_val", ":", "list nsc_val structure", nsc_val },
2115*7836SJohn.Forte@Sun.COM 	{ "nstset", "?[-frtv]", "list nstset structure", nstset },
2116*7836SJohn.Forte@Sun.COM 	{ "nsthread", "?[-av]", "list nsthread structure", nsthread },
2117*7836SJohn.Forte@Sun.COM 	{ NULL }
2118*7836SJohn.Forte@Sun.COM };
2119*7836SJohn.Forte@Sun.COM 
2120*7836SJohn.Forte@Sun.COM 
2121*7836SJohn.Forte@Sun.COM static const mdb_walker_t walkers[] = {
2122*7836SJohn.Forte@Sun.COM 	{ "nsc_dev", "walk nsc_dev chain",
2123*7836SJohn.Forte@Sun.COM 	    nsc_dev_winit, nsc_dev_wstep, nsc_dev_wfini, NULL },
2124*7836SJohn.Forte@Sun.COM 	{ "nsc_devval", "walk nsc_devval chain",
2125*7836SJohn.Forte@Sun.COM 	    nsc_devval_winit, nsc_devval_wstep, NULL, NULL },
2126*7836SJohn.Forte@Sun.COM 	{ "nsc_fd", "walk nsc_fd chain",
2127*7836SJohn.Forte@Sun.COM 	    nsc_fd_winit, nsc_fd_wstep, NULL, NULL },
2128*7836SJohn.Forte@Sun.COM 	{ "nsc_io", "walk nsc_io chain",
2129*7836SJohn.Forte@Sun.COM 	    nsc_io_winit, nsc_io_wstep, NULL, NULL },
2130*7836SJohn.Forte@Sun.COM 	{ "nsc_iodev", "walk nsc_iodev chain",
2131*7836SJohn.Forte@Sun.COM 	    nsc_iodev_winit, nsc_iodev_wstep, NULL, NULL },
2132*7836SJohn.Forte@Sun.COM 	{ "nsc_mem", "walk nsc_mem chain",
2133*7836SJohn.Forte@Sun.COM 	    nsc_mem_winit, nsc_mem_wstep, NULL, NULL },
2134*7836SJohn.Forte@Sun.COM 	{ "nsc_service", "walk nsc_service chain",
2135*7836SJohn.Forte@Sun.COM 	    nsc_service_winit, nsc_service_wstep, NULL, NULL },
2136*7836SJohn.Forte@Sun.COM 	{ "nsc_svc", "walk nsc_svc chain",
2137*7836SJohn.Forte@Sun.COM 	    nsc_svc_winit, nsc_svc_wstep, NULL, NULL },
2138*7836SJohn.Forte@Sun.COM 	{ "nsc_val", "walk nsc_val chain",
2139*7836SJohn.Forte@Sun.COM 	    nsc_val_winit, nsc_val_wstep, NULL, NULL },
2140*7836SJohn.Forte@Sun.COM 	{ "nstset", "walk nstset chain",
2141*7836SJohn.Forte@Sun.COM 	    nstset_winit, nstset_wstep, NULL, NULL },
2142*7836SJohn.Forte@Sun.COM 	{ "nsthread", "walk nsthread chain",
2143*7836SJohn.Forte@Sun.COM 	    nsthread_winit, nsthread_wstep, NULL, NULL },
2144*7836SJohn.Forte@Sun.COM 	{ "nst_free", "walk nsthread free/reuse list",
2145*7836SJohn.Forte@Sun.COM 	    nst_free_winit, nst_free_wstep, NULL, NULL },
2146*7836SJohn.Forte@Sun.COM 	{ NULL }
2147*7836SJohn.Forte@Sun.COM };
2148*7836SJohn.Forte@Sun.COM 
2149*7836SJohn.Forte@Sun.COM 
2150*7836SJohn.Forte@Sun.COM static const mdb_modinfo_t modinfo = {
2151*7836SJohn.Forte@Sun.COM 	MDB_API_VERSION, dcmds, walkers
2152*7836SJohn.Forte@Sun.COM };
2153*7836SJohn.Forte@Sun.COM 
2154*7836SJohn.Forte@Sun.COM 
2155*7836SJohn.Forte@Sun.COM const mdb_modinfo_t *
_mdb_init(void)2156*7836SJohn.Forte@Sun.COM _mdb_init(void)
2157*7836SJohn.Forte@Sun.COM {
2158*7836SJohn.Forte@Sun.COM 	return (&modinfo);
2159*7836SJohn.Forte@Sun.COM }
2160