diff --git a/sys/powerpc/include/intr.h b/sys/powerpc/include/intr.h --- a/sys/powerpc/include/intr.h +++ b/sys/powerpc/include/intr.h @@ -38,6 +38,11 @@ extern struct intr_event *intr2event(interrupt_t *intr); +#define INTR_FOREACH(i) \ + for (u_int INTR_FOREACH = 0; \ + ((i) = powerpc_get_irqnum(INTR_FOREACH)) < ((u_int)-1); \ + ++INTR_FOREACH) + /* FreeBSD standard interrupt controller interface */ #define INTR_VECTORS 256 @@ -73,4 +78,6 @@ void powerpc_intr_mask(u_int irq); void powerpc_intr_unmask(u_int irq); +u_int powerpc_get_irqnum(u_int idx); + #endif /* _MACHINE_INTR_MACHDEP_H_ */ diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c --- a/sys/powerpc/powerpc/intr_machdep.c +++ b/sys/powerpc/powerpc/intr_machdep.c @@ -307,6 +307,15 @@ return (NULL); } +u_int +powerpc_get_irqnum(u_int idx) +{ + + if (idx >= num_io_irqs) + return (-1); + return (powerpc_intrs[idx].irq); +} + struct intr_event * intr2event(interrupt_t *intr) { diff --git a/sys/sys/intr.h b/sys/sys/intr.h --- a/sys/sys/intr.h +++ b/sys/sys/intr.h @@ -45,6 +45,14 @@ #define intr2event(intr) ((intr) == NULL ? NULL : (intr)->isrc_event) +#define INTR_FOREACH(i) \ + for ((i) = 0; __extension__ ({ \ + do { \ + ++(i); \ + } while ((i) < intr_nirq && intr_lookup(i) == NULL); \ + (i) < intr_nirq; \ + }); ) + /* FreeBSD standard interrupt controller interface */ #define INTR_IRQ_INVALID 0xFFFFFFFF diff --git a/sys/x86/include/intr.h b/sys/x86/include/intr.h --- a/sys/x86/include/intr.h +++ b/sys/x86/include/intr.h @@ -40,6 +40,14 @@ #define intr2event(intr) ((intr) == NULL ? NULL : (intr)->is_event) +#define INTR_FOREACH(i) \ + for ((i) = 0; __extension__ ({ \ + do { \ + ++(i); \ + } while ((i) < num_io_irqs && intr_lookup(i) == NULL); \ + (i) < num_io_irqs; \ + }); ) + /* FreeBSD standard interrupt controller interface */ /*