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