8 #include "jdb_module.h"
9 #include "kernel_console.h"
10 #include "static_init.h"
22 * This module handles the 'R' command that
23 * provides IRQ attachment and listing functions.
25 class Jdb_attach_irq : public Jdb_module
28 Jdb_attach_irq() FIASCO_INIT;
33 char Jdb_attach_irq::subcmd;
34 static Jdb_attach_irq jdb_attach_irq INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
37 Jdb_attach_irq::Jdb_attach_irq()
42 Jdb_module::Action_code
43 Jdb_attach_irq::action( int cmd, void *&args, char const *&, int & )
48 if ((char*)args == &subcmd)
56 unsigned n = Irq_mgr::mgr->nr_irqs();
57 for (unsigned i = 0; i < n; ++i)
59 r = static_cast<Irq*>(Irq_mgr::mgr->irq(i));
62 printf("IRQ %02x/%02d\n", i, i);
73 Jdb_attach_irq::num_cmds() const
79 Jdb_module::Cmd const *
80 Jdb_attach_irq::cmds() const
83 { { 0, "R", "irq", " [l]ist/[a]ttach: %c",
84 "R{l}\tlist IRQ threads", &subcmd }
93 #include "jdb_kobject.h"
96 class Jdb_kobject_irq : public Jdb_kobject_handler
101 /* This macro does kind of hacky magic, It uses heuristics to compare
102 * If a C++ object object has a desired type. Therefore the vtable pointer
103 * (*z) of an object is compared to a desired vtable pointer (with some fuzz).
104 * The fuzz is necessary because there is usually a prefix data structure
105 * in each vtable and the size depends on the compiler.
106 * We use a range from x to x + 6 * wordsize.
108 * It is generally uncritical if this macro delivers a false negative. In
109 * such a case the JDB may deliver less information to the user. However, it
110 * critical to have a false positive, because JDB would probably crash.
112 #define FIASCO_JDB_CMP_VTABLE(n, o) \
114 char const *const *z = reinterpret_cast<char const* const*>(o); \
115 return (*z >= n && *z <= n + 6 * sizeof(Mword)) ? (o) : 0
120 Jdb_kobject_irq::dcast_h(Irq_sender *i)
122 FIASCO_JDB_CMP_VTABLE(_ZTV10Irq_sender, i);
127 Jdb_kobject_irq::dcast_h(Irq_muxer *i)
129 FIASCO_JDB_CMP_VTABLE(_ZTV9Irq_muxer, i);
132 PUBLIC template<typename T>
135 Jdb_kobject_irq::dcast(Kobject_common *o)
137 Irq *i = Kobject::dcast<Irq*>(o);
141 return dcast_h(static_cast<T>(i));
145 Jdb_kobject_irq::Jdb_kobject_irq()
146 : Jdb_kobject_handler(Irq::static_kobj_type)
148 Jdb_kobject::module()->register_handler(this);
153 Jdb_kobject_irq::kobject_type() const
155 return JDB_ANSI_COLOR(white) "IRQ" JDB_ANSI_COLOR(default);
161 Jdb_kobject_irq::handle_key(Kobject_common *o, int key)
171 Jdb_kobject_irq::follow_link(Kobject_common *o)
173 Irq_sender *t = Jdb_kobject_irq::dcast<Irq_sender*>(o);
174 Kobject_common *k = t ? Kobject::from_dbg(Kobject_dbg::pointer_to_obj(t->owner())) : 0;
180 Jdb_kobject_irq::show_kobject(Kobject_common *, int)
185 Jdb_kobject_irq::show_kobject_short(char *buf, int max, Kobject_common *o)
187 Irq *i = Kobject::dcast<Irq*>(o);
188 Kobject_common *w = follow_link(o);
189 Irq_sender *t = Jdb_kobject_irq::dcast<Irq_sender*>(o);
191 return snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x Q=%d",
192 i->pin(), i->chip()->chip_type(), i->obj_id(),
193 w != o ? w->dbg_info()->dbg_id() : 0,
194 (unsigned)i->flags(),
195 t ? t->queued() : -1);
200 filter_irqs(Kobject_common const *o)
201 { return Kobject::dcast<Irq const *>(o); }
203 static Jdb_kobject_list::Mode INIT_PRIORITY(JDB_MODULE_INIT_PRIO) tnt("[IRQs]", filter_irqs);
205 static Jdb_kobject_irq jdb_kobject_irq INIT_PRIORITY(JDB_MODULE_INIT_PRIO);