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