#include "irq_chip.h"
#include "irq.h"
+#include "irq_mgr.h"
#include "jdb_module.h"
#include "kernel_console.h"
#include "static_init.h"
/**
* 'IRQ' module.
- *
+ *
* This module handles the 'R' command that
* provides IRQ attachment and listing functions.
*/
Jdb_module::Action_code
Jdb_attach_irq::action( int cmd, void *&args, char const *&, int & )
{
- if (cmd!=0)
+ if (cmd)
return NOTHING;
if ((char*)args == &subcmd)
{
- switch(subcmd)
- {
- case 'l': // list
- {
- Irq *r;
- putchar('\n');
- for (unsigned i = 0; i < Config::Max_num_irqs; ++i)
- {
- r = static_cast<Irq*>(Irq_chip::hw_chip->irq(i));
- if (!r)
- continue;
- printf("IRQ %02x/%02d\n", i, i);
- }
- }
- return NOTHING;
- }
+ switch (subcmd)
+ {
+ case 'l': // list
+ {
+ Irq_base *r;
+ putchar('\n');
+ unsigned n = Irq_mgr::mgr->nr_irqs();
+ for (unsigned i = 0; i < n; ++i)
+ {
+ r = static_cast<Irq*>(Irq_mgr::mgr->irq(i));
+ if (!r)
+ continue;
+ printf("IRQ %02x/%02d\n", i, i);
+ }
+ return NOTHING;
+ }
+ }
}
return NOTHING;
}
{
};
+
+/* This macro does kind of hacky magic, It uses heuristics to compare
+ * If a C++ object object has a desired type. Therefore the vtable pointer
+ * (*z) of an object is compared to a desired vtable pointer (with some fuzz).
+ * The fuzz is necessary because there is usually a prefix data structure
+ * in each vtable and the size depends on the compiler.
+ * We use a range from x to x + 6 * wordsize.
+ *
+ * It is generally uncritical if this macro delivers a false negative. In
+ * such a case the JDB may deliver less information to the user. However, it
+ * critical to have a false positive, because JDB would probably crash.
+ */
#define FIASCO_JDB_CMP_VTABLE(n, o) \
extern char n[]; \
char const *const *z = reinterpret_cast<char const* const*>(o); \
- return *z == n + 12 ? (o) : 0
+ return (*z >= n && *z <= n + 6 * sizeof(Mword)) ? (o) : 0
PUBLIC static
PUBLIC template<typename T>
static
T
-Jdb_kobject_irq::dcast(Kobject *o)
+Jdb_kobject_irq::dcast(Kobject_common *o)
{
Irq *i = Kobject::dcast<Irq*>(o);
if (!i)
bool
Jdb_kobject_irq::handle_key(Kobject_common *o, int key)
{
- if (key != 'x')
- return false;
-
- Irq *t = Kobject::dcast<Irq*>(o);
-
- if (!t)
- return true;
-
- Irq_sender *i = static_cast<Irq_sender*>(t);
-
- printf("IRQ: owner = %p\n cnt = %d\n", i->owner(), i->queued());
-
- Jdb::getchar();
-
- return true;
+ (void)o; (void)key;
+ return false;
}
+
PUBLIC
Kobject_common *
Jdb_kobject_irq::follow_link(Kobject_common *o)
{
- Irq_sender *t = dcast<Irq_sender*>(Kobject::from_dbg(o->dbg_info()));
- if (!t || !t->owner() || (Smword)t->owner() == -1)
- return o;
-
- return Kobject::from_dbg(static_cast<Thread*>(t->owner())->dbg_info());
+ Irq_sender *t = Jdb_kobject_irq::dcast<Irq_sender*>(o);
+ Kobject_common *k = t ? Kobject::from_dbg(Kobject_dbg::pointer_to_obj(t->owner())) : 0;
+ return k ? k : o;
}
PUBLIC
bool
Jdb_kobject_irq::show_kobject(Kobject_common *, int)
{ return true; }
-#if 0
- Thread *t = Kobject::dcast<Thread*>(o);
- return show(t, level);
-#endif
PUBLIC
int
Jdb_kobject_irq::show_kobject_short(char *buf, int max, Kobject_common *o)
{
- Irq *t = Kobject::dcast<Irq*>(o);
- Kobject_common *d = follow_link(o);
- int cnt = 0;
- return cnt + snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x",
- t->irq(), t->pin()->pin_type(), t->obj_id(),
- d ? d->dbg_info()->dbg_id() : 0, (unsigned)t->pin()->flags());
+ Irq *i = Kobject::dcast<Irq*>(o);
+ Kobject_common *w = follow_link(o);
+ Irq_sender *t = Jdb_kobject_irq::dcast<Irq_sender*>(o);
+
+ return snprintf(buf, max, " I=%3lx %s L=%lx T=%lx F=%x Q=%d",
+ i->pin(), i->chip()->chip_type(), i->obj_id(),
+ w != o ? w->dbg_info()->dbg_id() : 0,
+ (unsigned)i->flags(),
+ t ? t->queued() : -1);
}
static