#include <mdb/mdb_modapi.h>
#include <mdb/mdb_ks.h>
#include <sys/logindmux_impl.h>
void
logdmux_uqinfo(const queue_t *q, char *buf, size_t nbytes)
{
struct tmx tmx;
uintptr_t peer, lower;
queue_t lq;
(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
lower = (uintptr_t)tmx.muxq;
(void) mdb_vread(&lq, sizeof (lq), (uintptr_t)tmx.peerq);
(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)lq.q_ptr);
peer = (uintptr_t)tmx.rdq;
(void) mdb_snprintf(buf, nbytes, "peer rq : %p\nlower wq : %p",
peer, lower);
}
void
logdmux_lqinfo(const queue_t *q, char *buf, size_t nbytes)
{
struct tmx tmx;
(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
(void) mdb_snprintf(buf, nbytes, "peer wq : %p\nupper rq : %p",
(uintptr_t)tmx.peerq, (uintptr_t)tmx.rdq);
}
uintptr_t
logdmux_lrnext(const queue_t *q)
{
struct tmx tmx;
(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
return ((uintptr_t)tmx.rdq);
}
uintptr_t
logdmux_uwnext(const queue_t *q)
{
struct tmx tmx;
(void) mdb_vread(&tmx, sizeof (tmx), (uintptr_t)q->q_ptr);
return ((uintptr_t)tmx.muxq);
}
static const mdb_qops_t logdmux_uqops = {
.q_info = logdmux_uqinfo,
.q_rnext = mdb_qrnext_default,
.q_wnext = logdmux_uwnext,
};
static const mdb_qops_t logdmux_lqops = {
.q_info = logdmux_lqinfo,
.q_rnext = logdmux_lrnext,
.q_wnext = mdb_qwnext_default
};
static const mdb_modinfo_t modinfo = { MDB_API_VERSION };
const mdb_modinfo_t *
_mdb_init(void)
{
GElf_Sym sym;
if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0)
mdb_qops_install(&logdmux_uqops, (uintptr_t)sym.st_value);
if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0)
mdb_qops_install(&logdmux_lqops, (uintptr_t)sym.st_value);
return (&modinfo);
}
void
_mdb_fini(void)
{
GElf_Sym sym;
if (mdb_lookup_by_obj("logindmux", "logdmuxuwinit", &sym) == 0)
mdb_qops_remove(&logdmux_uqops, (uintptr_t)sym.st_value);
if (mdb_lookup_by_obj("logindmux", "logdmuxlwinit", &sym) == 0)
mdb_qops_remove(&logdmux_lqops, (uintptr_t)sym.st_value);
}