7 #include "jdb_module.h"
8 #include "kernel_console.h"
9 #include "static_init.h"
21 * This module handles the 'R' command that
22 * provides IRQ attachment and listing functions.
24 class Jdb_attach_irq : public Jdb_module
27 Jdb_attach_irq() FIASCO_INIT;
32 char Jdb_attach_irq::subcmd;
33 static Jdb_attach_irq jdb_attach_irq INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
36 Jdb_attach_irq::Jdb_attach_irq()
41 Jdb_module::Action_code
42 Jdb_attach_irq::action( int cmd, void *&args, char const *&, int & )
47 if ((char*)args == &subcmd)
55 for (unsigned i = 0; i < Config::Max_num_irqs; ++i)
57 r = static_cast<Irq*>(Irq_chip::hw_chip->irq(i));
60 printf("IRQ %02x/%02d\n", i, i);
71 Jdb_attach_irq::num_cmds() const
77 Jdb_module::Cmd const *
78 Jdb_attach_irq::cmds() const
81 { { 0, "R", "irq", " [l]ist/[a]ttach: %c",
82 "R{l}\tlist IRQ threads", &subcmd }
91 #include "jdb_kobject.h"
94 class Jdb_kobject_irq : public Jdb_kobject_handler
98 #define FIASCO_JDB_CMP_VTABLE(n, o) \
100 char const *const *z = reinterpret_cast<char const* const*>(o); \
101 return *z == n + 12 ? (o) : 0
106 Jdb_kobject_irq::dcast_h(Irq_sender *i)
108 FIASCO_JDB_CMP_VTABLE(_ZTV10Irq_sender, i);
113 Jdb_kobject_irq::dcast_h(Irq_muxer *i)
115 FIASCO_JDB_CMP_VTABLE(_ZTV9Irq_muxer, i);
118 PUBLIC template<typename T>
121 Jdb_kobject_irq::dcast(Kobject *o)
123 Irq *i = Kobject::dcast<Irq*>(o);
127 return dcast_h(static_cast<T>(i));
131 Jdb_kobject_irq::Jdb_kobject_irq()
132 : Jdb_kobject_handler(Irq::static_kobj_type)
134 Jdb_kobject::module()->register_handler(this);
139 Jdb_kobject_irq::kobject_type() const
141 return JDB_ANSI_COLOR(white) "IRQ" JDB_ANSI_COLOR(default);
147 Jdb_kobject_irq::handle_key(Kobject_common *o, int key)
152 Irq *t = Kobject::dcast<Irq*>(o);
157 Irq_sender *i = static_cast<Irq_sender*>(t);
159 printf("IRQ: owner = %p\n cnt = %d\n", i->owner(), i->queued());
169 Jdb_kobject_irq::follow_link(Kobject_common *o)
171 Irq_sender *t = dcast<Irq_sender*>(Kobject::from_dbg(o->dbg_info()));
172 if (!t || !t->owner() || (Smword)t->owner() == -1)
175 return Kobject::from_dbg(static_cast<Thread*>(t->owner())->dbg_info());
180 Jdb_kobject_irq::show_kobject(Kobject_common *, int)
183 Thread *t = Kobject::dcast<Thread*>(o);
184 return show(t, level);
189 Jdb_kobject_irq::show_kobject_short(char *buf, int max, Kobject_common *o)
191 Irq *t = Kobject::dcast<Irq*>(o);
192 Kobject_common *d = follow_link(o);
194 return cnt + snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x",
195 t->irq(), t->pin()->pin_type(), t->obj_id(),
196 d ? d->dbg_info()->dbg_id() : 0, (unsigned)t->pin()->flags());
201 filter_irqs(Kobject_common const *o)
202 { return Kobject::dcast<Irq const *>(o); }
204 static Jdb_kobject_list::Mode INIT_PRIORITY(JDB_MODULE_INIT_PRIO) tnt("[IRQs]", filter_irqs);
206 static Jdb_kobject_irq jdb_kobject_irq INIT_PRIORITY(JDB_MODULE_INIT_PRIO);