8322 nl: misleading-indentation
[unleashed/tickless.git] / usr / src / cmd / mdb / common / modules / logindmux / logindmux.c
blob2876d07b2eff5e409e1990240e66f0f0c47e7a97
1 /*
2 * CDDL HEADER START
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
20 * CDDL HEADER END
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
29 #include <mdb/mdb_modapi.h>
30 #include <mdb/mdb_ks.h>
31 #include <sys/logindmux_impl.h>
34 * Print our peer's upper queue pointer, and our lower queue pointer.
36 void
37 logdmux_uqinfo(const queue_t *q, char *buf, size_t nbytes)
39 struct tmx tmx;
40 uintptr_t peer, lower;
41 queue_t lq;
44 * First, get the pointer to our lower write queue.
46 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
47 lower = (uintptr_t)tmx.muxq;
50 * Now read in the lower's peer, and follow that to up to our peer.
52 (void) mdb_vread(&lq, sizeof (lq), (uintptr_t)tmx.peerq);
53 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)lq.q_ptr);
54 peer = (uintptr_t)tmx.rdq;
56 (void) mdb_snprintf(buf, nbytes, "peer rq : %p\nlower wq : %p",
57 peer, lower);
61 * Print our peer's lower queue pointer, and our upper queue pointer.
63 void
64 logdmux_lqinfo(const queue_t *q, char *buf, size_t nbytes)
66 struct tmx tmx;
68 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
69 (void) mdb_snprintf(buf, nbytes, "peer wq : %p\nupper rq : %p",
70 (uintptr_t)tmx.peerq, (uintptr_t)tmx.rdq);
73 uintptr_t
74 logdmux_lrnext(const queue_t *q)
76 struct tmx tmx;
78 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
79 return ((uintptr_t)tmx.rdq);
82 uintptr_t
83 logdmux_uwnext(const queue_t *q)
85 struct tmx tmx;
87 (void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
88 return ((uintptr_t)tmx.muxq);
91 static const mdb_qops_t logdmux_uqops = {
92 logdmux_uqinfo, mdb_qrnext_default, logdmux_uwnext
95 static const mdb_qops_t logdmux_lqops = {
96 logdmux_lqinfo, logdmux_lrnext, mdb_qwnext_default
99 static const mdb_modinfo_t modinfo = { MDB_API_VERSION };
101 const mdb_modinfo_t *
102 _mdb_init(void)
104 GElf_Sym sym;
106 if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0)
107 mdb_qops_install(&logdmux_uqops, (uintptr_t)sym.st_value);
108 if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0)
109 mdb_qops_install(&logdmux_lqops, (uintptr_t)sym.st_value);
111 return (&modinfo);
114 void
115 _mdb_fini(void)
117 GElf_Sym sym;
119 if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0)
120 mdb_qops_remove(&logdmux_uqops, (uintptr_t)sym.st_value);
121 if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0)
122 mdb_qops_remove(&logdmux_lqops, (uintptr_t)sym.st_value);