#include "irq_chip.h"
#include "irq.h"
+#include "semaphore.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_attach_irq() FIASCO_INIT;
private:
static char subcmd;
- static unsigned irq;
};
char Jdb_attach_irq::subcmd;
-unsigned Jdb_attach_irq::irq;
static Jdb_attach_irq jdb_attach_irq INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
IMPLEMENT
PUBLIC
Jdb_module::Action_code
-Jdb_attach_irq::action( int cmd, void *&args, char const *&fmt, int & )
+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 'a': // attach
- args = &irq;
- fmt = " irq: %i\n";
- return EXTRA_INPUT;
-
- 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;
- }
- }
- else if (args == (void*)&irq)
- {
- Irq *i = static_cast<Irq*>(Irq_chip::hw_chip->irq(irq));
- if (i)
- i->alloc((Receiver*)-1);
+ 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/%02u\n", i, i);
+ }
+ return NOTHING;
+ }
+ }
}
return NOTHING;
}
{
static Cmd cs[] =
{ { 0, "R", "irq", " [l]ist/[a]ttach: %c",
- "R{l|a<num>}\tlist IRQ threads, attach Jdb to IRQ", &subcmd }
+ "R{l}\tlist IRQ threads", &subcmd }
};
return cs;
{
};
+
PUBLIC inline
Jdb_kobject_irq::Jdb_kobject_irq()
- : Jdb_kobject_handler(Irq::static_kobj_type)
+ : Jdb_kobject_handler((Irq*)0)
{
Jdb_kobject::module()->register_handler(this);
}
PUBLIC
char const *
-Jdb_kobject_irq::kobject_type() const
+Jdb_kobject_irq::kobject_type(Kobject_common *o) const
{
+ if (cxx::dyn_cast<Irq_sender*>(o))
+ return JDB_ANSI_COLOR(white) "IRQ ipc" JDB_ANSI_COLOR(default);
+ if (cxx::dyn_cast<Irq_muxer*>(o))
+ return JDB_ANSI_COLOR(white) "IRQ mux" JDB_ANSI_COLOR(default);
+ if (cxx::dyn_cast<Semaphore*>(o))
+ return JDB_ANSI_COLOR(white) "IRQ sem" JDB_ANSI_COLOR(default);
+
return JDB_ANSI_COLOR(white) "IRQ" JDB_ANSI_COLOR(default);
}
+
PUBLIC
-Kobject *
-Jdb_kobject_irq::follow_link(Kobject *o)
+bool
+Jdb_kobject_irq::handle_key(Kobject_common *o, int key)
{
- Irq *t = Kobject::dcast<Irq*>(o);
- if (!t->owner() || (Smword)t->owner() == -1)
- return o;
+ (void)o; (void)key;
+ return false;
+}
+
+
- return static_cast<Thread*>(t->owner())->kobject();
+PUBLIC
+Kobject_common *
+Jdb_kobject_irq::follow_link(Kobject_common *o)
+{
+ Irq_sender *t = cxx::dyn_cast<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 *, int)
+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 *o)
+void
+Jdb_kobject_irq::show_kobject_short(String_buffer *buf, Kobject_common *o)
{
- Irq *t = Kobject::dcast<Irq*>(o);
- Kobject *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_id() : 0, (unsigned)t->pin()->flags());
+ Irq *i = cxx::dyn_cast<Irq*>(o);
+ Kobject_common *w = follow_link(o);
+
+ buf->printf(" I=%3lx %s F=%x",
+ i->pin(), i->chip()->chip_type(),
+ (unsigned)i->flags());
+
+ if (Irq_sender *t = cxx::dyn_cast<Irq_sender*>(i))
+ buf->printf(" L=%lx T=%lx Q=%d",
+ i->obj_id(),
+ w != o ? w->dbg_info()->dbg_id() : 0,
+ t ? t->queued() : -1);
+
+ if (Semaphore *t = cxx::dyn_cast<Semaphore*>(i))
+ buf->printf(" Q=%ld",
+ t->_queued);
}
static
bool
-filter_irqs(Kobject const *o)
-{ return Kobject::dcast<Irq const *>(o); }
+filter_irqs(Kobject_common const *o)
+{ return cxx::dyn_cast<Irq const *>(o); }
static Jdb_kobject_list::Mode INIT_PRIORITY(JDB_MODULE_INIT_PRIO) tnt("[IRQs]", filter_irqs);