xref: /titanic_51/usr/src/cmd/mdb/common/modules/ii/ii.c (revision 5c5f137104b2d56181283389fa902220f2023809)
1fcf3ce44SJohn Forte /*
2fcf3ce44SJohn Forte  * CDDL HEADER START
3fcf3ce44SJohn Forte  *
4fcf3ce44SJohn Forte  * The contents of this file are subject to the terms of the
5fcf3ce44SJohn Forte  * Common Development and Distribution License (the "License").
6fcf3ce44SJohn Forte  * You may not use this file except in compliance with the License.
7fcf3ce44SJohn Forte  *
8fcf3ce44SJohn Forte  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9fcf3ce44SJohn Forte  * or http://www.opensolaris.org/os/licensing.
10fcf3ce44SJohn Forte  * See the License for the specific language governing permissions
11fcf3ce44SJohn Forte  * and limitations under the License.
12fcf3ce44SJohn Forte  *
13fcf3ce44SJohn Forte  * When distributing Covered Code, include this CDDL HEADER in each
14fcf3ce44SJohn Forte  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15fcf3ce44SJohn Forte  * If applicable, add the following below this CDDL HEADER, with the
16fcf3ce44SJohn Forte  * fields enclosed by brackets "[]" replaced with your own identifying
17fcf3ce44SJohn Forte  * information: Portions Copyright [yyyy] [name of copyright owner]
18fcf3ce44SJohn Forte  *
19fcf3ce44SJohn Forte  * CDDL HEADER END
20fcf3ce44SJohn Forte  */
21fcf3ce44SJohn Forte /*
22fcf3ce44SJohn Forte  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
23fcf3ce44SJohn Forte  * Use is subject to license terms.
24fcf3ce44SJohn Forte  */
25fcf3ce44SJohn Forte 
26*5c5f1371SRichard Lowe #include <stddef.h>
27*5c5f1371SRichard Lowe 
28fcf3ce44SJohn Forte #include <sys/types.h>
29fcf3ce44SJohn Forte #include <sys/mdb_modapi.h>
30fcf3ce44SJohn Forte 
31fcf3ce44SJohn Forte #include <sys/nsctl/nsctl.h>
32fcf3ce44SJohn Forte #include <sys/unistat/spcs_s.h>
33fcf3ce44SJohn Forte #include <sys/unistat/spcs_s_k.h>
34fcf3ce44SJohn Forte 
35fcf3ce44SJohn Forte 
36fcf3ce44SJohn Forte #include <sys/nsctl/dsw.h>
37fcf3ce44SJohn Forte #include <sys/nsctl/dsw_dev.h>
38fcf3ce44SJohn Forte 
39fcf3ce44SJohn Forte #include <sys/nsctl/nsvers.h>
40fcf3ce44SJohn Forte 
41fcf3ce44SJohn Forte 
42fcf3ce44SJohn Forte const mdb_bitmask_t bi_flags_bits[] = {
43fcf3ce44SJohn Forte 	{ "DSW_GOLDEN", DSW_GOLDEN, DSW_GOLDEN },
44fcf3ce44SJohn Forte 	{ "DSW_COPYINGP", DSW_COPYINGP, DSW_COPYINGP },
45fcf3ce44SJohn Forte 	{ "DSW_COPYINGM", DSW_COPYINGM, DSW_COPYINGM },
46fcf3ce44SJohn Forte 	{ "DSW_COPYINGS", DSW_COPYINGS, DSW_COPYINGS },
47fcf3ce44SJohn Forte 	{ "DSW_COPYINGX", DSW_COPYINGX, DSW_COPYINGX },
48fcf3ce44SJohn Forte 	{ "DSW_BMPOFFLINE", DSW_BMPOFFLINE, DSW_BMPOFFLINE },
49fcf3ce44SJohn Forte 	{ "DSW_SHDOFFLINE", DSW_SHDOFFLINE, DSW_SHDOFFLINE },
50fcf3ce44SJohn Forte 	{ "DSW_MSTOFFLINE", DSW_MSTOFFLINE, DSW_MSTOFFLINE },
51fcf3ce44SJohn Forte 	{ "DSW_OVROFFLINE", DSW_OVROFFLINE, DSW_OVROFFLINE },
52fcf3ce44SJohn Forte 	{ "DSW_TREEMAP", DSW_TREEMAP, DSW_TREEMAP },
53fcf3ce44SJohn Forte 	{ "DSW_OVERFLOW", DSW_OVERFLOW, DSW_OVERFLOW },
54fcf3ce44SJohn Forte 	{ "DSW_SHDEXPORT", DSW_SHDEXPORT, DSW_SHDEXPORT },
55fcf3ce44SJohn Forte 	{ "DSW_SHDIMPORT", DSW_SHDIMPORT, DSW_SHDIMPORT },
56fcf3ce44SJohn Forte 	{ "DSW_VOVERFLOW", DSW_VOVERFLOW, DSW_VOVERFLOW },
57fcf3ce44SJohn Forte 	{ "DSW_HANGING", DSW_HANGING, DSW_HANGING },
58fcf3ce44SJohn Forte 	{ "DSW_CFGOFFLINE", DSW_CFGOFFLINE, DSW_CFGOFFLINE },
59fcf3ce44SJohn Forte 	{ "DSW_OVRHDRDRTY", DSW_OVRHDRDRTY, DSW_OVRHDRDRTY },
60fcf3ce44SJohn Forte 	{ "DSW_RESIZED", DSW_RESIZED, DSW_RESIZED },
61fcf3ce44SJohn Forte 	{ "DSW_FRECLAIM", DSW_FRECLAIM, DSW_FRECLAIM },
62fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
63fcf3ce44SJohn Forte };
64fcf3ce44SJohn Forte 
65fcf3ce44SJohn Forte const mdb_bitmask_t bi_state_bits[] = {
66fcf3ce44SJohn Forte 	{ "DSW_IOCTL", DSW_IOCTL, DSW_IOCTL },
67fcf3ce44SJohn Forte 	{ "DSW_CLOSING", DSW_CLOSING, DSW_CLOSING },
68fcf3ce44SJohn Forte 	{ "DSW_MSTTARGET", DSW_MSTTARGET, DSW_MSTTARGET },
69fcf3ce44SJohn Forte 	{ "DSW_MULTIMST", DSW_MULTIMST, DSW_MULTIMST },
70fcf3ce44SJohn Forte 	{ NULL, 0, 0 }
71fcf3ce44SJohn Forte };
72fcf3ce44SJohn Forte static uintptr_t nextaddr;
73fcf3ce44SJohn Forte /*
74fcf3ce44SJohn Forte  * Display a ii_fd_t
75fcf3ce44SJohn Forte  * Requires an address.
76fcf3ce44SJohn Forte  */
77fcf3ce44SJohn Forte /*ARGSUSED*/
78fcf3ce44SJohn Forte static int
79fcf3ce44SJohn Forte ii_fd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
80fcf3ce44SJohn Forte {
81fcf3ce44SJohn Forte 	ii_fd_t fd;
82fcf3ce44SJohn Forte 
83fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
84fcf3ce44SJohn Forte 		return (DCMD_USAGE);
85fcf3ce44SJohn Forte 
86fcf3ce44SJohn Forte 	if (mdb_vread(&fd, sizeof (fd), addr) != sizeof (fd)) {
87fcf3ce44SJohn Forte 		mdb_warn("failed to read ii_fd_t at 0x%p", addr);
88fcf3ce44SJohn Forte 		return (DCMD_ERR);
89fcf3ce44SJohn Forte 	}
90fcf3ce44SJohn Forte 
91fcf3ce44SJohn Forte 	mdb_inc_indent(4);
92fcf3ce44SJohn Forte 	mdb_printf("ii_info: 0x%p ii_bmp: %d ii_shd: %d ii_ovr: %d ii_optr: "
93fcf3ce44SJohn Forte 	    "0x%p\nii_oflags: 0x%x\n", fd.ii_info, fd.ii_bmp, fd.ii_shd,
94fcf3ce44SJohn Forte 	    fd.ii_ovr, fd.ii_optr, fd.ii_oflags);
95fcf3ce44SJohn Forte 	mdb_dec_indent(4);
96fcf3ce44SJohn Forte 
97fcf3ce44SJohn Forte 	return (DCMD_OK);
98fcf3ce44SJohn Forte }
99fcf3ce44SJohn Forte 
100fcf3ce44SJohn Forte /*
101fcf3ce44SJohn Forte  * displays a ii_info_dev structure.
102fcf3ce44SJohn Forte  */
103fcf3ce44SJohn Forte /*ARGSUSED*/
104fcf3ce44SJohn Forte static int
105fcf3ce44SJohn Forte ii_info_dev(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
106fcf3ce44SJohn Forte {
107fcf3ce44SJohn Forte 	_ii_info_dev_t ipdev;
108fcf3ce44SJohn Forte 
109fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
110fcf3ce44SJohn Forte 		return (DCMD_USAGE);
111fcf3ce44SJohn Forte 
112fcf3ce44SJohn Forte 	if (mdb_vread(&ipdev, sizeof (ipdev), addr) != sizeof (ipdev)) {
113fcf3ce44SJohn Forte 		mdb_warn("failed to read ii_info_dev_t at 0x%p", addr);
114fcf3ce44SJohn Forte 		return (DCMD_ERR);
115fcf3ce44SJohn Forte 	}
116fcf3ce44SJohn Forte 
117fcf3ce44SJohn Forte 	mdb_inc_indent(4);
118fcf3ce44SJohn Forte 	mdb_printf("bi_fd: 0x%p bi_iodev: 0x%p bi_tok: 0x%p\n",
119fcf3ce44SJohn Forte 	    ipdev.bi_fd, ipdev.bi_iodev, ipdev.bi_tok);
120fcf3ce44SJohn Forte 	mdb_printf("bi_ref: %d bi_rsrv: %d bi_orsrv: %d\n",
121fcf3ce44SJohn Forte 	    ipdev.bi_ref, ipdev.bi_rsrv, ipdev.bi_orsrv);
122fcf3ce44SJohn Forte 
123fcf3ce44SJohn Forte 	/*
124fcf3ce44SJohn Forte 	 * use nsc_fd to dump the fd details.... if present.
125fcf3ce44SJohn Forte 	 */
126fcf3ce44SJohn Forte 	if (ipdev.bi_fd) {
127fcf3ce44SJohn Forte 		mdb_printf("nsc_fd structure:\n");
128fcf3ce44SJohn Forte 		mdb_inc_indent(4);
129fcf3ce44SJohn Forte 		mdb_call_dcmd("nsc_fd", (uintptr_t)(ipdev.bi_fd),
130fcf3ce44SJohn Forte 		    flags, 0, NULL);
131fcf3ce44SJohn Forte 		mdb_dec_indent(4);
132fcf3ce44SJohn Forte 	}
133fcf3ce44SJohn Forte 	mdb_dec_indent(4);
134fcf3ce44SJohn Forte 	return (DCMD_OK);
135fcf3ce44SJohn Forte }
136fcf3ce44SJohn Forte 
137fcf3ce44SJohn Forte /*
138fcf3ce44SJohn Forte  * Displays an _ii_overflow structure
139fcf3ce44SJohn Forte  */
140fcf3ce44SJohn Forte /*ARGSUSED*/
141fcf3ce44SJohn Forte static int
142fcf3ce44SJohn Forte ii_overflow(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
143fcf3ce44SJohn Forte {
144fcf3ce44SJohn Forte 	_ii_overflow_t ii_overflow;
145fcf3ce44SJohn Forte 
146fcf3ce44SJohn Forte 	nextaddr = 0;
147fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
148fcf3ce44SJohn Forte 		return (DCMD_USAGE);
149fcf3ce44SJohn Forte 
150fcf3ce44SJohn Forte 	if (mdb_vread(&ii_overflow, sizeof (ii_overflow), addr)
151fcf3ce44SJohn Forte 		!= sizeof (ii_overflow)) {
152fcf3ce44SJohn Forte 		mdb_warn("failed to read ii_overflow_t at 0x%p", addr);
153fcf3ce44SJohn Forte 		return (DCMD_ERR);
154fcf3ce44SJohn Forte 	}
155fcf3ce44SJohn Forte 
156fcf3ce44SJohn Forte 	mdb_inc_indent(4);
157fcf3ce44SJohn Forte 	mdb_printf("_ii_overflow at 0x%p\n", addr);
158fcf3ce44SJohn Forte 	mdb_printf("_ii_doverflow_t\n");
159fcf3ce44SJohn Forte 	mdb_inc_indent(4);
160fcf3ce44SJohn Forte 	mdb_printf("ii_dvolname: %s\n", ii_overflow.ii_volname);
161fcf3ce44SJohn Forte 	mdb_printf("ii_dhmagic: %x\n", ii_overflow.ii_hmagic);
162fcf3ce44SJohn Forte 	mdb_printf("ii_dhversion: %x\n", ii_overflow.ii_hversion);
163fcf3ce44SJohn Forte 	mdb_printf("ii_ddrefcnt: %x\n", ii_overflow.ii_drefcnt);
164fcf3ce44SJohn Forte 	mdb_printf("ii_dflags: %x\n", ii_overflow.ii_flags);
165fcf3ce44SJohn Forte 	mdb_printf("ii_dfreehead: %x\n", ii_overflow.ii_freehead);
166fcf3ce44SJohn Forte 	mdb_printf("ii_dnchunks: %x\n", ii_overflow.ii_nchunks);
167fcf3ce44SJohn Forte 	mdb_printf("ii_dunused: %x\n", ii_overflow.ii_unused);
168fcf3ce44SJohn Forte 	mdb_printf("ii_dused: %x\n", ii_overflow.ii_used);
169fcf3ce44SJohn Forte 	mdb_printf("ii_urefcnt: %x\n", ii_overflow.ii_urefcnt);
170fcf3ce44SJohn Forte 	mdb_dec_indent(4);
171fcf3ce44SJohn Forte 
172fcf3ce44SJohn Forte 	mdb_printf("ii_mutex: %x\n", ii_overflow.ii_mutex);
173fcf3ce44SJohn Forte 	mdb_printf("ii_kstat_mutex: %x\n", ii_overflow.ii_kstat_mutex);
174fcf3ce44SJohn Forte 	mdb_printf("ii_crefcnt: %d\n", ii_overflow.ii_crefcnt);
175fcf3ce44SJohn Forte 	mdb_printf("ii_detachcnt: %d\n", ii_overflow.ii_detachcnt);
176fcf3ce44SJohn Forte 	mdb_printf("ii_next: %x\n", ii_overflow.ii_next);
177fcf3ce44SJohn Forte 
178fcf3ce44SJohn Forte 	mdb_printf("Overflow volume:\n");
179fcf3ce44SJohn Forte 	if (ii_overflow.ii_dev)
180fcf3ce44SJohn Forte 		ii_info_dev((uintptr_t)ii_overflow.ii_dev, flags, 0, NULL);
181fcf3ce44SJohn Forte 
182fcf3ce44SJohn Forte 	mdb_printf("  ii_ioname: %s\n", &ii_overflow.ii_ioname);
183fcf3ce44SJohn Forte 	mdb_dec_indent(4);
184fcf3ce44SJohn Forte 
185fcf3ce44SJohn Forte 	nextaddr = (uintptr_t)ii_overflow.ii_next;
186fcf3ce44SJohn Forte 	return (DCMD_OK);
187fcf3ce44SJohn Forte }
188fcf3ce44SJohn Forte /*ARGSUSED*/
189fcf3ce44SJohn Forte static int
190fcf3ce44SJohn Forte ii_info(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
191fcf3ce44SJohn Forte {
192fcf3ce44SJohn Forte 	_ii_info_t ii_info = {0};
193fcf3ce44SJohn Forte 	char string[DSW_NAMELEN];
194fcf3ce44SJohn Forte 
195fcf3ce44SJohn Forte 	nextaddr = 0;
196fcf3ce44SJohn Forte 	if (!(flags & DCMD_ADDRSPEC))
197fcf3ce44SJohn Forte 		return (DCMD_USAGE);
198fcf3ce44SJohn Forte 
199fcf3ce44SJohn Forte 	if (mdb_vread(&ii_info, sizeof (ii_info), addr) != sizeof (ii_info)) {
200fcf3ce44SJohn Forte 		mdb_warn("failed to read ii_info_t at 0x%p", addr);
201fcf3ce44SJohn Forte 		return (DCMD_ERR);
202fcf3ce44SJohn Forte 	}
203fcf3ce44SJohn Forte 
204fcf3ce44SJohn Forte 	mdb_printf(
205fcf3ce44SJohn Forte 		"bi_next: 0x%p\n"
206fcf3ce44SJohn Forte 		"bi_head: 0x%p\t"
207fcf3ce44SJohn Forte 		"bi_sibling: 0x%p\n"
208fcf3ce44SJohn Forte 		"bi_master: 0x%p\t"
209fcf3ce44SJohn Forte 		"bi_nextmst: 0x%p\n",
210fcf3ce44SJohn Forte 		ii_info.bi_next, ii_info.bi_head, ii_info.bi_sibling,
211fcf3ce44SJohn Forte 		ii_info.bi_master, ii_info.bi_nextmst);
212fcf3ce44SJohn Forte 
213fcf3ce44SJohn Forte 	mdb_printf("bi_mutex: 0x%p\n", ii_info.bi_mutex);
214fcf3ce44SJohn Forte 
215fcf3ce44SJohn Forte 	/*
216fcf3ce44SJohn Forte 	 * Print out all the fds by using ii_info_dev
217fcf3ce44SJohn Forte 	 */
218fcf3ce44SJohn Forte 	mdb_printf("Cache master:\n");
219fcf3ce44SJohn Forte 	if (ii_info.bi_mstdev)
220fcf3ce44SJohn Forte 		ii_info_dev((uintptr_t)ii_info.bi_mstdev, flags, 0, NULL);
221fcf3ce44SJohn Forte 
222fcf3ce44SJohn Forte 	mdb_printf("Raw master:\n");
223fcf3ce44SJohn Forte 	if (ii_info.bi_mstrdev)
224fcf3ce44SJohn Forte 		ii_info_dev((uintptr_t)ii_info.bi_mstrdev, flags, 0, NULL);
225fcf3ce44SJohn Forte 
226fcf3ce44SJohn Forte 	mdb_printf("Cache shadow:\n");
227fcf3ce44SJohn Forte 	ii_info_dev((uintptr_t)(addr + offsetof(_ii_info_t, bi_shddev)),
228fcf3ce44SJohn Forte 	    flags, 0, NULL);
229fcf3ce44SJohn Forte 
230fcf3ce44SJohn Forte 	mdb_printf("Raw shadow:\n");
231fcf3ce44SJohn Forte 	ii_info_dev((uintptr_t)(addr + offsetof(_ii_info_t, bi_shdrdev)),
232fcf3ce44SJohn Forte 	    flags, 0, NULL);
233fcf3ce44SJohn Forte 
234fcf3ce44SJohn Forte 	mdb_printf("Bitmap:\n");
235fcf3ce44SJohn Forte 	ii_info_dev((uintptr_t)(addr + offsetof(_ii_info_t, bi_bmpdev)),
236fcf3ce44SJohn Forte 	    flags, 0, NULL);
237fcf3ce44SJohn Forte 
238fcf3ce44SJohn Forte 	mdb_printf("bi_keyname: %-*s\n", DSW_NAMELEN, ii_info.bi_keyname);
239fcf3ce44SJohn Forte 	mdb_printf("bi_bitmap: 0x%p\n", ii_info.bi_bitmap);
240fcf3ce44SJohn Forte 
241fcf3ce44SJohn Forte 	if ((ii_info.bi_cluster == NULL) ||
242fcf3ce44SJohn Forte 	    (mdb_vread(&string, sizeof (string), (uintptr_t)ii_info.bi_cluster)
243fcf3ce44SJohn Forte 		!= sizeof (string)))
244fcf3ce44SJohn Forte 		string[0] = 0;
245fcf3ce44SJohn Forte 	mdb_printf("bi_cluster: %s\n", string);
246fcf3ce44SJohn Forte 
247fcf3ce44SJohn Forte 	if ((ii_info.bi_group == NULL) ||
248fcf3ce44SJohn Forte 	    (mdb_vread(&string, sizeof (string), (uintptr_t)ii_info.bi_group)
249fcf3ce44SJohn Forte 			!= sizeof (string)))
250fcf3ce44SJohn Forte 		string[0] = 0;
251fcf3ce44SJohn Forte 	mdb_printf("bi_group: %s\n", string);
252fcf3ce44SJohn Forte 
253fcf3ce44SJohn Forte 	mdb_printf("bi_busy: 0x%p\n", ii_info.bi_busy);
254fcf3ce44SJohn Forte 
255fcf3ce44SJohn Forte 	mdb_printf("bi_shdfba: %0x\t", ii_info.bi_shdfba);
256fcf3ce44SJohn Forte 	mdb_printf("bi_shdbits: %0x\n", ii_info.bi_shdbits);
257fcf3ce44SJohn Forte 	mdb_printf("bi_copyfba: %0x\t", ii_info.bi_copyfba);
258fcf3ce44SJohn Forte 	mdb_printf("bi_copybits: %0x\n", ii_info.bi_copybits);
259fcf3ce44SJohn Forte 
260fcf3ce44SJohn Forte 	mdb_printf("bi_size: %0x\n", ii_info.bi_size);
261fcf3ce44SJohn Forte 
262fcf3ce44SJohn Forte 	mdb_printf("bi_flags: 0x%x <%b>\n",
263fcf3ce44SJohn Forte 		ii_info.bi_flags, ii_info.bi_flags, bi_flags_bits);
264fcf3ce44SJohn Forte 
265fcf3ce44SJohn Forte 	mdb_printf("bi_state: 0x%x <%b>\n",
266fcf3ce44SJohn Forte 		ii_info.bi_state, ii_info.bi_state, bi_state_bits);
267fcf3ce44SJohn Forte 
268fcf3ce44SJohn Forte 	mdb_printf("bi_disabled: %d\n", ii_info.bi_disabled);
269fcf3ce44SJohn Forte 	mdb_printf("bi_ioctl: %d\n", ii_info.bi_ioctl);
270fcf3ce44SJohn Forte 	mdb_printf("bi_release: %d\t", ii_info.bi_release);
271fcf3ce44SJohn Forte 	mdb_printf("bi_rsrvcnt: %d\n", ii_info.bi_rsrvcnt);
272fcf3ce44SJohn Forte 
273fcf3ce44SJohn Forte 	mdb_printf("bi_copydonecv: %x\t", ii_info.bi_copydonecv);
274fcf3ce44SJohn Forte 	mdb_printf("bi_reservecv: %x\n", ii_info.bi_reservecv);
275fcf3ce44SJohn Forte 	mdb_printf("bi_releasecv: %x\t", ii_info.bi_releasecv);
276fcf3ce44SJohn Forte 	mdb_printf("bi_closingcv: %x\n", ii_info.bi_closingcv);
277fcf3ce44SJohn Forte 	mdb_printf("bi_ioctlcv: %x\t", ii_info.bi_ioctlcv);
278fcf3ce44SJohn Forte 	mdb_printf("bi_busycv: %x\n", ii_info.bi_busycv);
279fcf3ce44SJohn Forte 	mdb_call_dcmd("rwlock", (uintptr_t)(addr +
280fcf3ce44SJohn Forte 	    offsetof(_ii_info_t, bi_busyrw)), flags, 0, NULL);
281fcf3ce44SJohn Forte 	mdb_printf("bi_bitmap_ops: 0x%p\n", ii_info.bi_bitmap_ops);
282fcf3ce44SJohn Forte 
283fcf3ce44SJohn Forte 	mdb_printf("bi_rsrvmutex: %x\t", ii_info.bi_rsrvmutex);
284fcf3ce44SJohn Forte 	mdb_printf("bi_rlsemutex: %x\n", ii_info.bi_rlsemutex);
285fcf3ce44SJohn Forte 	mdb_printf("bi_bmpmutex: %x\n", ii_info.bi_bmpmutex);
286fcf3ce44SJohn Forte 
287fcf3ce44SJohn Forte 	mdb_printf("bi_mstchks: %d\t", ii_info.bi_mstchks);
288fcf3ce44SJohn Forte 	mdb_printf("bi_shdchks: %d\n", ii_info.bi_shdchks);
289fcf3ce44SJohn Forte 	mdb_printf("bi_shdchkused: %d\t", ii_info.bi_shdchkused);
290fcf3ce44SJohn Forte 	mdb_printf("bi_shdfchk: %d\n", ii_info.bi_shdfchk);
291fcf3ce44SJohn Forte 
292fcf3ce44SJohn Forte 	mdb_printf("bi_overflow\n");
293fcf3ce44SJohn Forte 	if (ii_info.bi_overflow)
294fcf3ce44SJohn Forte 		ii_overflow((uintptr_t)ii_info.bi_overflow, flags, 0, NULL);
295fcf3ce44SJohn Forte 
296fcf3ce44SJohn Forte 	mdb_printf("bi_iifd:\n");
297fcf3ce44SJohn Forte 	if (ii_info.bi_iifd)
298fcf3ce44SJohn Forte 		(void) ii_fd((uintptr_t)ii_info.bi_iifd, flags, 0, NULL);
299fcf3ce44SJohn Forte 
300fcf3ce44SJohn Forte 	mdb_printf("bi_throttle_unit: %d\t", ii_info.bi_throttle_unit);
301fcf3ce44SJohn Forte 	mdb_printf("bi_throttle_delay: %d\n", ii_info.bi_throttle_delay);
302fcf3ce44SJohn Forte 
303fcf3ce44SJohn Forte 	mdb_printf("bi_linkrw:\n");
304fcf3ce44SJohn Forte 	mdb_call_dcmd("rwlock", (uintptr_t)(addr +
305fcf3ce44SJohn Forte 	    offsetof(_ii_info_t, bi_linkrw)), flags, 0, NULL);
306fcf3ce44SJohn Forte 
307fcf3ce44SJohn Forte 	mdb_printf("bi_chksmutex: %x\n", ii_info.bi_chksmutex);
308fcf3ce44SJohn Forte 	mdb_printf("bi_locked_pid: %x\n", ii_info.bi_locked_pid);
309fcf3ce44SJohn Forte 	mdb_printf("bi_kstat: 0x%p\n", ii_info.bi_kstat);
310fcf3ce44SJohn Forte 	/* ii_kstat_info_t bi_kstat_io; */
311fcf3ce44SJohn Forte 
312fcf3ce44SJohn Forte 	nextaddr = (uintptr_t)ii_info.bi_next;
313fcf3ce44SJohn Forte 	return (DCMD_OK);
314fcf3ce44SJohn Forte }
315fcf3ce44SJohn Forte 
316fcf3ce44SJohn Forte /*
317fcf3ce44SJohn Forte  * This should be a walker surely.
318fcf3ce44SJohn Forte  */
319fcf3ce44SJohn Forte /*ARGSUSED*/
320fcf3ce44SJohn Forte static int
321fcf3ce44SJohn Forte ii_info_all(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
322fcf3ce44SJohn Forte {
323fcf3ce44SJohn Forte 	uintptr_t myaddr;
324fcf3ce44SJohn Forte 	/*
325fcf3ce44SJohn Forte 	 * we use the global address.
326fcf3ce44SJohn Forte 	 */
327fcf3ce44SJohn Forte 	if (flags & DCMD_ADDRSPEC)
328fcf3ce44SJohn Forte 		return (DCMD_USAGE);
329fcf3ce44SJohn Forte 
330fcf3ce44SJohn Forte 	if (mdb_readsym(&myaddr, sizeof (myaddr), "_ii_info_top") !=
331fcf3ce44SJohn Forte 	    sizeof (myaddr)) {
332fcf3ce44SJohn Forte 		return (DCMD_ERR);
333fcf3ce44SJohn Forte 	}
334fcf3ce44SJohn Forte 
335fcf3ce44SJohn Forte 	mdb_printf("_ii_info_top contains 0x%lx\n", myaddr);
336fcf3ce44SJohn Forte 
337fcf3ce44SJohn Forte 	while (myaddr) {
338fcf3ce44SJohn Forte 		ii_info(myaddr, DCMD_ADDRSPEC, 0, NULL);
339fcf3ce44SJohn Forte 		myaddr = nextaddr;
340fcf3ce44SJohn Forte 	}
341fcf3ce44SJohn Forte 	return (DCMD_OK);
342fcf3ce44SJohn Forte }
343fcf3ce44SJohn Forte 
344fcf3ce44SJohn Forte /*
345fcf3ce44SJohn Forte  * Display general ii module information.
346fcf3ce44SJohn Forte  */
347fcf3ce44SJohn Forte 
348fcf3ce44SJohn Forte #define	ii_get_print(kvar, str, fmt, val)		\
349fcf3ce44SJohn Forte 	if (mdb_readvar(&(val), #kvar) == -1) {		\
350fcf3ce44SJohn Forte 		mdb_dec_indent(4);			\
351fcf3ce44SJohn Forte 		mdb_warn("unable to read '" #kvar "'");	\
352fcf3ce44SJohn Forte 		return (DCMD_ERR);			\
353fcf3ce44SJohn Forte 	}						\
354fcf3ce44SJohn Forte 	mdb_printf("%-20s" fmt "\n", str ":", val)
355fcf3ce44SJohn Forte 
356fcf3ce44SJohn Forte /* ARGSUSED */
357fcf3ce44SJohn Forte static int
358fcf3ce44SJohn Forte ii(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
359fcf3ce44SJohn Forte {
360fcf3ce44SJohn Forte 	int maj, min, mic, baseline, i;
361fcf3ce44SJohn Forte 
362fcf3ce44SJohn Forte 	if (argc != 0)
363fcf3ce44SJohn Forte 		return (DCMD_USAGE);
364fcf3ce44SJohn Forte 
365fcf3ce44SJohn Forte 	if (mdb_readvar(&maj, "dsw_major_rev") == -1) {
366fcf3ce44SJohn Forte 		mdb_warn("unable to read 'dsw_major_rev'");
367fcf3ce44SJohn Forte 		return (DCMD_ERR);
368fcf3ce44SJohn Forte 	}
369fcf3ce44SJohn Forte 
370fcf3ce44SJohn Forte 	if (mdb_readvar(&min, "dsw_minor_rev") == -1) {
371fcf3ce44SJohn Forte 		mdb_warn("unable to read 'dsw_minor_rev'");
372fcf3ce44SJohn Forte 		return (DCMD_ERR);
373fcf3ce44SJohn Forte 	}
374fcf3ce44SJohn Forte 
375fcf3ce44SJohn Forte 	if (mdb_readvar(&mic, "dsw_micro_rev") == -1) {
376fcf3ce44SJohn Forte 		mdb_warn("unable to read 'dsw_micro_rev'");
377fcf3ce44SJohn Forte 		return (DCMD_ERR);
378fcf3ce44SJohn Forte 	}
379fcf3ce44SJohn Forte 
380fcf3ce44SJohn Forte 	if (mdb_readvar(&baseline, "dsw_baseline_rev") == -1) {
381fcf3ce44SJohn Forte 		mdb_warn("unable to read 'dsw_baseline_rev'");
382fcf3ce44SJohn Forte 		return (DCMD_ERR);
383fcf3ce44SJohn Forte 	}
384fcf3ce44SJohn Forte 
385fcf3ce44SJohn Forte 	mdb_printf("Point-in-Time Copy module version: kernel %d.%d.%d.%d; "
386fcf3ce44SJohn Forte 	    "mdb %d.%d.%d.%d\n", maj, min, mic, baseline,
387fcf3ce44SJohn Forte 	    ISS_VERSION_MAJ, ISS_VERSION_MIN, ISS_VERSION_MIC, ISS_VERSION_NUM);
388fcf3ce44SJohn Forte 
389fcf3ce44SJohn Forte 	mdb_inc_indent(4);
390fcf3ce44SJohn Forte 	ii_get_print(ii_debug, "debug", "%d", i);
391fcf3ce44SJohn Forte 	ii_get_print(ii_bitmap, "bitmaps", "%d", i);
392fcf3ce44SJohn Forte 	mdb_dec_indent(4);
393fcf3ce44SJohn Forte 
394fcf3ce44SJohn Forte 	return (DCMD_OK);
395fcf3ce44SJohn Forte }
396fcf3ce44SJohn Forte 
397fcf3ce44SJohn Forte 
398fcf3ce44SJohn Forte /*
399fcf3ce44SJohn Forte  * MDB module linkage information:
400fcf3ce44SJohn Forte  */
401fcf3ce44SJohn Forte 
402fcf3ce44SJohn Forte static const mdb_dcmd_t dcmds[] = {
403fcf3ce44SJohn Forte { "ii", NULL, "display ii module info", ii },
404fcf3ce44SJohn Forte { "ii_fd", NULL, "display ii_fd structure", ii_fd },
405fcf3ce44SJohn Forte { "ii_info", NULL, "display ii_info structure", ii_info },
406fcf3ce44SJohn Forte { "ii_info_all", NULL, "display all ii_info structures", ii_info_all },
407fcf3ce44SJohn Forte { "ii_info_dev", NULL, "display ii_info_dev structure", ii_info_dev},
408fcf3ce44SJohn Forte { "ii_overflow", NULL, "display ii_overflow structure", ii_overflow},
409fcf3ce44SJohn Forte { NULL }
410fcf3ce44SJohn Forte };
411fcf3ce44SJohn Forte 
412fcf3ce44SJohn Forte 
413fcf3ce44SJohn Forte static const mdb_walker_t walkers[] = {
414fcf3ce44SJohn Forte 	{ NULL }
415fcf3ce44SJohn Forte };
416fcf3ce44SJohn Forte 
417fcf3ce44SJohn Forte 
418fcf3ce44SJohn Forte static const mdb_modinfo_t modinfo = {
419fcf3ce44SJohn Forte 	MDB_API_VERSION, dcmds, walkers
420fcf3ce44SJohn Forte };
421fcf3ce44SJohn Forte 
422fcf3ce44SJohn Forte 
423fcf3ce44SJohn Forte const mdb_modinfo_t *
424fcf3ce44SJohn Forte _mdb_init(void)
425fcf3ce44SJohn Forte {
426fcf3ce44SJohn Forte 	return (&modinfo);
427fcf3ce44SJohn Forte }
428