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_dirqs; ++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
99 /* This macro does kind of hacky magic, It uses heuristics to compare
100 * If a C++ object object has a desired type. Therefore the vtable pointer
101 * (*z) of an object is compared to a desired vtable pointer (with some fuzz).
102 * The fuzz is necessary because there is usually a prefix data structure
103 * in each vtable and the size depends on the compiler.
104 * We use a range from x to x + 6 * wordsize.
106 * It is generally uncritical if this macro delivers a false negative. In
107 * such a case the JDB may deliver less information to the user. However, it
108 * critical to have a false positive, because JDB would probably crash.
110 #define FIASCO_JDB_CMP_VTABLE(n, o) \
112 char const *const *z = reinterpret_cast<char const* const*>(o); \
113 return (*z >= n && *z <= n + 6 * sizeof(Mword)) ? (o) : 0
118 Jdb_kobject_irq::dcast_h(Irq_sender *i)
120 FIASCO_JDB_CMP_VTABLE(_ZTV10Irq_sender, i);
125 Jdb_kobject_irq::dcast_h(Irq_muxer *i)
127 FIASCO_JDB_CMP_VTABLE(_ZTV9Irq_muxer, i);
130 PUBLIC template<typename T>
133 Jdb_kobject_irq::dcast(Kobject_common *o)
135 Irq *i = Kobject::dcast<Irq*>(o);
139 return dcast_h(static_cast<T>(i));
143 Jdb_kobject_irq::Jdb_kobject_irq()
144 : Jdb_kobject_handler(Irq::static_kobj_type)
146 Jdb_kobject::module()->register_handler(this);
151 Jdb_kobject_irq::kobject_type() const
153 return JDB_ANSI_COLOR(white) "IRQ" JDB_ANSI_COLOR(default);
159 Jdb_kobject_irq::handle_key(Kobject_common *o, int key)
169 Jdb_kobject_irq::follow_link(Kobject_common *o)
171 Irq_sender *t = Jdb_kobject_irq::dcast<Irq_sender*>(o);
172 Kobject_common *k = t ? Kobject::pointer_to_obj(t->owner()) : 0;
178 Jdb_kobject_irq::show_kobject(Kobject_common *, int)
183 Jdb_kobject_irq::show_kobject_short(char *buf, int max, Kobject_common *o)
185 Irq *i = Kobject::dcast<Irq*>(o);
186 Kobject_common *w = follow_link(o);
187 Irq_sender *t = Jdb_kobject_irq::dcast<Irq_sender*>(o);
189 return snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x Q=%d",
190 i->irq(), i->pin()->pin_type(), i->obj_id(),
191 w != o ? w->dbg_info()->dbg_id() : 0,
192 (unsigned)i->pin()->flags(),
193 t ? t->queued() : -1);
198 filter_irqs(Kobject_common const *o)
199 { return Kobject::dcast<Irq const *>(o); }
201 static Jdb_kobject_list::Mode INIT_PRIORITY(JDB_MODULE_INIT_PRIO) tnt("[IRQs]", filter_irqs);
203 static Jdb_kobject_irq jdb_kobject_irq INIT_PRIORITY(JDB_MODULE_INIT_PRIO);