fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER START
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * The contents of this file are subject to the terms of the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Common Development and Distribution License (the "License").
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You may not use this file except in compliance with the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * or http://www.opensolaris.org/os/licensing.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * See the License for the specific language governing permissions
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * and limitations under the License.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * When distributing Covered Code, include this CDDL HEADER in each
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If applicable, add the following below this CDDL HEADER, with the
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner]
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * CDDL HEADER END
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Use is subject to license terms.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/types.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/mdb_modapi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/ddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunddi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/sunldi.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsctl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/unistat/spcs_s_k.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/sv.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/sv_impl.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#include <sys/nsctl/nsvers.h>
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Walker for an array of sv_dev_t structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A global walk is assumed to start at sv_devs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestruct sv_dev_winfo {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintptr_t start;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintptr_t end;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_dev_winit(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sv_dev_winfo *winfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_dev_t *sv_devs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int sv_max_devices;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte winfo = mdb_zalloc(sizeof (struct sv_dev_winfo), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&sv_devs, "sv_devs") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read 'sv_devs'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(winfo, sizeof (struct sv_dev_winfo));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&sv_max_devices, "sv_max_devices") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read 'sv_max_devices'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(winfo, sizeof (struct sv_dev_winfo));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte winfo->start = (uintptr_t)sv_devs;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte winfo->end = (uintptr_t)(sv_devs + sv_max_devices);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = winfo->start;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = winfo;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_dev_wstep(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte struct sv_dev_winfo *winfo = wsp->walk_data;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr >= winfo->end)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr += sizeof (sv_dev_t);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_dev_wfini(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (struct sv_dev_winfo));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Walker for an sv hash chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Global walks are disallowed.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_hash_winit(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_zalloc(sizeof (sv_dev_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_hash_wstep(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sv_dev_t), wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_dev at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(((sv_dev_t *)wsp->walk_data)->sv_hash);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_hash_wfini(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (sv_dev_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Walker for an array of sv_maj_t structures.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A global walk is assumed to start at sv_majors.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_maj_t *sv_majors[SV_MAJOR_HASH_CNT + 1] = {0};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_maj_winit(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&sv_majors, "sv_majors") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read 'sv_majors'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } else {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_majors[0] = (sv_maj_t *)wsp->walk_addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)&sv_majors[0];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_zalloc(sizeof (sv_maj_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_maj_wstep(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte uintptr_t addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status = DCMD_OK;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr >= (uintptr_t)&sv_majors[SV_MAJOR_HASH_CNT])
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (addr = *(uintptr_t *)wsp->walk_addr; addr;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr = (uintptr_t)(((sv_maj_t *)wsp->walk_data)->sm_next)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data, sizeof (sv_maj_t), addr)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte != sizeof (sv_maj_t)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_maj at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = DCMD_ERR;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (status != DCMD_OK)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte break;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr += sizeof (sv_maj_t *);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_maj_wfini(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (sv_maj_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Walker for an sv gclient chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * A global walk is assumed to start at sv_gclients.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_gclient_winit(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL &&
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_readvar(&wsp->walk_addr, "sv_gclients") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("unable to read 'sv_gclients'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_data = mdb_zalloc(sizeof (sv_gclient_t), UM_SLEEP);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_NEXT);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_gclient_wstep(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int status;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (wsp->walk_addr == NULL)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sizeof (sv_gclient_t), wsp->walk_addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_gclient at %p", wsp->walk_addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (WALK_DONE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte status = wsp->walk_callback(wsp->walk_addr, wsp->walk_data,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_cbdata);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte wsp->walk_addr = (uintptr_t)(((sv_gclient_t *)wsp->walk_data)->sg_next);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (status);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic void
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_gclient_wfini(mdb_walk_state_t *wsp)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_free(wsp->walk_data, sizeof (sv_gclient_t));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display a single sv_glcient_t structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If called with no address, performs a global walk of all sv_gclients.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_gclient(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_gclient_t sg;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte char name[64];
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_USAGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * paranoid mode on: qualify walker name with module name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using '`' syntax.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_walk_dcmd("sv`sv_gclient",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "sv`sv_gclient", argc, argv) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to walk 'sv_gclient'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(&sg, sizeof (sg), addr) != sizeof (sg)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_gclient at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DCMD_HDRSPEC(flags)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%-?s %8T%-?s %8T%-16s %8T%s\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte "ADDR", "NEXT", "ID", "NAME");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readstr(name, sizeof (name), (uintptr_t)sg.sg_name) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_gclient name at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%p %8T%p %8T%llx %8T%s",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr, sg.sg_next, sg.sg_id, name);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display a single sv_maj_t structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If called with no address, performs a global walk of all sv_majs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -a : all (i.e. display all devices, even if disabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -v : verbose
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_maj(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_maj_t *maj;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int a_opt, v_opt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte a_opt = v_opt = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_getopts(argc, argv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'a', MDB_OPT_SETBITS, TRUE, &a_opt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_USAGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * paranoid mode on: qualify walker name with module name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using '`' syntax.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_walk_dcmd("sv`sv_maj", "sv`sv_maj", argc, argv) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to walk 'sv_maj'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DCMD_HDRSPEC(flags)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%-?s %8T%s\n", "ADDR", "INUSE");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj = mdb_zalloc(sizeof (*maj), UM_GC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(maj, sizeof (*maj), addr) != sizeof (*maj)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_maj at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!a_opt && maj->sm_inuse == 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%?p %8T%d\n", addr, maj->sm_inuse);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!v_opt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verbose - print the rest of the structure as well.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_inc_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("dev_ops: %a (%p)\n", maj->sm_dev_ops, maj->sm_dev_ops);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("flag: %08x %8Tsequence: %d %8Tmajor: %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj->sm_flag, maj->sm_seq, maj->sm_major);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("function pointers:\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_inc_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%-20a%-20a%\n%-20a%-20a%\n%-20a%-20a%\n%-20a%-20a%\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj->sm_open, maj->sm_close,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj->sm_read, maj->sm_write,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj->sm_aread, maj->sm_awrite,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj->sm_strategy, maj->sm_ioctl);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_dec_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("hash chain:\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_inc_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte for (i = 0; i < SV_MINOR_HASH_CNT; i++) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%?p", maj->sm_hash[i]);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf(((i % 4) == 3) ? "\n" : " %8T");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_dec_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_dec_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display a sv_dev_t hash chain.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Requires an address.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Same options as sv_dev().
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_hash(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC))
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_USAGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * paranoid mode on: qualify walker name with module name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using '`' syntax.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_pwalk_dcmd("sv`sv_hash", "sv`sv_dev", argc, argv, addr) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to walk sv_dev hash chain");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display a single sv_dev_t structure.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * If called with no address, performs a global walk of all sv_devs.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -a : all (i.e. display all devices, even if disabled
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * -v : verbose
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst mdb_bitmask_t sv_flag_bits[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "NSC_DEVICE", NSC_DEVICE, NSC_DEVICE },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "NSC_CACHE", NSC_CACHE, NSC_CACHE },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL, 0, 0 }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv_dev(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_dev_t *svp;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int a_opt, v_opt;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int dev_t_chars;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte a_opt = v_opt = FALSE;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_t_chars = sizeof (dev_t) * 2; /* # chars to display dev_t */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_getopts(argc, argv,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'a', MDB_OPT_SETBITS, TRUE, &a_opt,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte 'v', MDB_OPT_SETBITS, TRUE, &v_opt) != argc)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_USAGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp = mdb_zalloc(sizeof (*svp), UM_GC);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!(flags & DCMD_ADDRSPEC)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * paranoid mode on: qualify walker name with module name
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * using '`' syntax.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_walk_dcmd("sv`sv_dev", "sv`sv_dev", argc, argv) == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to walk 'sv_dev'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (DCMD_HDRSPEC(flags)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%-?s %8T%-*s %8T%s\n", "ADDR",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte dev_t_chars, "DEV", "STATE");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_vread(svp, sizeof (*svp), addr) != sizeof (*svp)) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("failed to read sv_dev at %p", addr);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!a_opt && svp->sv_state == SV_DISABLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%?p %8T%0*lx %8T", addr, dev_t_chars, svp->sv_dev);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (svp->sv_state == SV_DISABLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("disabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (svp->sv_state == SV_PENDING)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("pending");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte else if (svp->sv_state == SV_ENABLE)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("enabled");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (!v_opt)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte /*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * verbose - print the rest of the structure as well.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_inc_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("\n");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("hash chain: 0x%p %8Tlock: 0x%p %8Tolock: 0x%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->sv_hash,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr + OFFSETOF(sv_dev_t, sv_lock),
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte addr + OFFSETOF(sv_dev_t, sv_olock));
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("fd: 0x%p %8T\n", svp->sv_fd);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("maxfbas: %d %8Tnblocks: %d %8Tstate: %d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->sv_maxfbas, svp->sv_nblocks, svp->sv_state);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("gclients: 0x%llx %8Tgkernel: 0x%llx\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->sv_gclients, svp->sv_gkernel);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("openlcnt: %d %8Ttimestamp: 0x%lx\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->sv_openlcnt, svp->sv_timestamp);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("flags: 0x%08x <%b>\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->sv_flag, svp->sv_flag, sv_flag_bits);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("lh: 0x%p %8Tpending: 0x%p\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte svp->sv_lh, svp->sv_pending);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_dec_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * Display general sv module information.
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte#define sv_get_print(kvar, str, fmt, val) \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&(val), #kvar) == -1) { \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_dec_indent(4); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("unable to read '" #kvar "'"); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR); \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte } \
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("%-20s" fmt "\n", str ":", val)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/* ARGSUSED */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic int
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortesv(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte clock_t clock;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte int maj, min, mic, baseline, i;
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (argc != 0)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_USAGE);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&maj, "sv_major_rev") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("unable to read 'sv_major_rev'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&min, "sv_minor_rev") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("unable to read 'sv_minor_rev'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&mic, "sv_micro_rev") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("unable to read 'sv_micro_rev'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte if (mdb_readvar(&baseline, "sv_baseline_rev") == -1) {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_warn("unable to read 'sv_baseline_rev'");
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_ERR);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_printf("SV module version: kernel %d.%d.%d.%d; mdb %d.%d.%d.%d\n",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte maj, min, mic, baseline,
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte ISS_VERSION_MAJ, ISS_VERSION_MIN, ISS_VERSION_MIC, ISS_VERSION_NUM);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_inc_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_get_print(sv_config_time, "last config time", "0x%lx", clock);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_get_print(sv_stats_on, "stats on", "%d", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_get_print(sv_debug, "debug", "%d", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_get_print(sv_max_devices, "max sv devices", "%d", i);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte mdb_dec_indent(4);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (DCMD_OK);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte/*
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte * MDB module linkage information:
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte */
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_dcmd_t dcmds[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv", NULL, "display sv module info", sv },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_dev", "?[-av]", "list sv_dev structure", sv_dev },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_gclient", "?", "list sv_gclient structure", sv_gclient },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_hash", ":[-av]", "display sv_dev hash chain", sv_hash },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_maj", "?[-av]", "list sv_maj structure", sv_maj },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_walker_t walkers[] = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_dev", "walk array of sv_dev structures",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_dev_winit, sv_dev_wstep, sv_dev_wfini },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_gclient", "walk sb_gclient chain",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_gclient_winit, sv_gclient_wstep, sv_gclient_wfini },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_hash", "walk sv_dev hash chain",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_hash_winit, sv_hash_wstep, sv_hash_wfini },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { "sv_maj", "walk array of sv_maj structures",
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte sv_maj_winit, sv_maj_wstep, sv_maj_wfini },
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte { NULL }
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Fortestatic const mdb_modinfo_t modinfo = {
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte MDB_API_VERSION, dcmds, walkers
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte};
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forteconst mdb_modinfo_t *
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte_mdb_init(void)
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte{
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte return (&modinfo);
fcf3ce441efd61da9bb2884968af01cb7c1452ccJohn Forte}