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