Rename intr_chain to intr_event
MODIFY
include/interrupt.h
include/interrupt.h
@@ -57,14 +57,14 @@ typedef enum {
typedef intr_filter_t driver_filter_t(void *);
typedef void driver_intr_t(void *);
-typedef struct intr_chain intr_chain_t;
+typedef struct intr_event intr_event_t;
typedef struct intr_handler intr_handler_t;
struct intr_handler {
TAILQ_ENTRY(intr_handler) ih_list;
driver_filter_t *ih_filter; /* driver interrupt filter function */
driver_intr_t *ih_handler; /* driver interrupt handler function */
- intr_chain_t *ih_chain; /* chain we are connected to */
+ intr_event_t *ih_event; /* event we are connected to */
void *ih_argument; /* argument to pass to the handler */
char *ih_name; /* name of the handler */
prio_t ih_prio; /* priority of the handler */
@@ -78,21 +78,21 @@ typedef TAILQ_HEAD(, intr_handler) intr_handler_list_t;
.ih_name = (desc), .ih_prio = (prio) \
}
-typedef struct intr_chain {
- spin_t ic_lock;
- TAILQ_ENTRY(intr_chain) ic_list;
- intr_handler_list_t ic_handlers; /* interrupt handlers */
- const char *ic_name; /* individual chain name */
- unsigned ic_irq; /* physical interrupt request line number */
- unsigned ic_count; /* number of handlers attached */
-} intr_chain_t;
-
-typedef TAILQ_HEAD(, intr_chain) intr_chain_list_t;
-
-void intr_chain_init(intr_chain_t *ic, unsigned irq, const char *name);
-void intr_chain_register(intr_chain_t *ic);
-void intr_chain_add_handler(intr_chain_t *ic, intr_handler_t *ih);
-void intr_chain_remove_handler(intr_handler_t *ih);
-void intr_chain_run_handlers(intr_chain_t *ic);
+typedef struct intr_event {
+ spin_t ie_lock;
+ TAILQ_ENTRY(intr_event) ie_list;
+ intr_handler_list_t ie_handlers; /* interrupt handlers */
+ const char *ie_name; /* individual event name */
+ unsigned ie_irq; /* physical interrupt request line number */
+ unsigned ie_count; /* number of handlers attached */
+} intr_event_t;
+
+typedef TAILQ_HEAD(, intr_event) intr_event_list_t;
+
+void intr_event_init(intr_event_t *ie, unsigned irq, const char *name);
+void intr_event_register(intr_event_t *ie);
+void intr_event_add_handler(intr_event_t *ie, intr_handler_t *ih);
+void intr_event_remove_handler(intr_handler_t *ih);
+void intr_event_run_handlers(intr_event_t *ie);
#endif /* _SYS_INTERRUPT_H_ */

MODIFY
mips/gt64120.c
mips/gt64120.c
@@ -57,7 +57,7 @@ typedef struct gt_pci_state {
rman_t isa_io_rman;
intr_handler_t intr_handler;
- intr_chain_t intr_chain[16];
+ intr_event_t intr_event[16];
uint16_t imask;
uint16_t elcr;
@@ -155,10 +155,10 @@ static void gt_pci_intr_setup(device_t *pcib, unsigned irq,
assert(pcib->parent->driver == &gt_pci_bus.driver);
gt_pci_state_t *gtpci = pcib->parent->state;
- intr_chain_t *chain = &gtpci->intr_chain[irq];
- WITH_SPIN_LOCK (&chain->ic_lock) {
- intr_chain_add_handler(chain, handler);
- if (chain->ic_count == 1)
+ intr_event_t *event = &gtpci->intr_event[irq];
+ WITH_SPIN_LOCK (&event->ie_lock) {
+ intr_event_add_handler(event, handler);
+ if (event->ie_count == 1)
gt_pci_unmask_irq(gtpci, irq);
}
}
@@ -167,11 +167,11 @@ static void gt_pci_intr_teardown(device_t *pcib, intr_handler_t *handler) {
assert(pcib->parent->driver == &gt_pci_bus.driver);
gt_pci_state_t *gtpci = pcib->parent->state;
- intr_chain_t *chain = handler->ih_chain;
- WITH_SPIN_LOCK (&chain->ic_lock) {
- if (chain->ic_count == 1)
- gt_pci_mask_irq(gtpci, chain->ic_irq);
- intr_chain_remove_handler(handler);
+ intr_event_t *event = handler->ih_event;
+ WITH_SPIN_LOCK (&event->ie_lock) {
+ if (event->ie_count == 1)
+ gt_pci_mask_irq(gtpci, event->ie_irq);
+ intr_event_remove_handler(handler);
}
}
@@ -210,9 +210,9 @@ static intr_filter_t gt_pci_intr(void *data) {
irq = (irq & OCW3_POLL_PENDING) ? (OCW3_POLL_IRQ(irq) + 8) : 2;
}
- /* Irq 2 is used for PIC chaining, ignore it. */
+ /* Irq 2 is used for PIC eventing, ignore it. */
if (irq != 2)
- intr_chain_run_handlers(&gtpci->intr_chain[irq]);
+ intr_event_run_handlers(&gtpci->intr_event[irq]);
/* Send a specific EOI to slave PIC... */
if (irq > 7) {
@@ -228,10 +228,10 @@ static intr_filter_t gt_pci_intr(void *data) {
return IF_FILTERED;
}
-static inline void gt_pci_intr_chain_init(gt_pci_state_t *gtpci, unsigned irq,
+static inline void gt_pci_intr_event_init(gt_pci_state_t *gtpci, unsigned irq,
const char *name) {
- intr_chain_init(&gtpci->intr_chain[irq], irq, name);
- intr_chain_register(&gtpci->intr_chain[irq]);
+ intr_event_init(&gtpci->intr_event[irq], irq, name);
+ intr_event_register(&gtpci->intr_event[irq]);
}
#define MALTA_CORECTRL_SIZE (MALTA_CORECTRL_END - MALTA_CORECTRL_BASE + 1)
@@ -284,22 +284,22 @@ static int gt_pci_attach(device_t *pcib) {
bus_write_1(io, PIIX_REG_ELCR + 0, LO(gtpci->elcr));
bus_write_1(io, PIIX_REG_ELCR + 1, HI(gtpci->elcr));
- gt_pci_intr_chain_init(gtpci, 0, "timer");
- gt_pci_intr_chain_init(gtpci, 1, "kbd"); /* kbd controller (keyboard) */
- gt_pci_intr_chain_init(gtpci, 2, "pic-slave"); /* PIC cascade */
- gt_pci_intr_chain_init(gtpci, 3, "uart(1)"); /* COM 2 */
- gt_pci_intr_chain_init(gtpci, 4, "uart(0)"); /* COM 1 */
- gt_pci_intr_chain_init(gtpci, 5, "unused(0)");
- gt_pci_intr_chain_init(gtpci, 6, "floppy"); /* floppy */
- gt_pci_intr_chain_init(gtpci, 7, "parallel"); /* centronics */
- gt_pci_intr_chain_init(gtpci, 8, "rtc"); /* RTC */
- gt_pci_intr_chain_init(gtpci, 9, "i2c"); /* I2C */
- gt_pci_intr_chain_init(gtpci, 10, "unused(1)");
- gt_pci_intr_chain_init(gtpci, 11, "unused(2)");
- gt_pci_intr_chain_init(gtpci, 12, "mouse"); /* kbd controller (mouse) */
- gt_pci_intr_chain_init(gtpci, 13, "unused(3)");
- gt_pci_intr_chain_init(gtpci, 14, "ide(0)"); /* IDE primary */
- gt_pci_intr_chain_init(gtpci, 15, "ide(1)"); /* IDE secondary */
+ gt_pci_intr_event_init(gtpci, 0, "timer");
+ gt_pci_intr_event_init(gtpci, 1, "kbd"); /* kbd controller (keyboard) */
+ gt_pci_intr_event_init(gtpci, 2, "pic-slave"); /* PIC cascade */
+ gt_pci_intr_event_init(gtpci, 3, "uart(1)"); /* COM 2 */
+ gt_pci_intr_event_init(gtpci, 4, "uart(0)"); /* COM 1 */
+ gt_pci_intr_event_init(gtpci, 5, "unused(0)");
+ gt_pci_intr_event_init(gtpci, 6, "floppy"); /* floppy */
+ gt_pci_intr_event_init(gtpci, 7, "parallel"); /* centronics */
+ gt_pci_intr_event_init(gtpci, 8, "rtc"); /* RTC */
+ gt_pci_intr_event_init(gtpci, 9, "i2c"); /* I2C */
+ gt_pci_intr_event_init(gtpci, 10, "unused(1)");
+ gt_pci_intr_event_init(gtpci, 11, "unused(2)");
+ gt_pci_intr_event_init(gtpci, 12, "mouse"); /* kbd controller (mouse) */
+ gt_pci_intr_event_init(gtpci, 13, "unused(3)");
+ gt_pci_intr_event_init(gtpci, 14, "ide(0)"); /* IDE primary */
+ gt_pci_intr_event_init(gtpci, 15, "ide(1)"); /* IDE secondary */
pci_bus_enumerate(pcib);

MODIFY
mips/intr.c
mips/intr.c
@@ -36,10 +36,10 @@ bool mips_intr_disabled(void) {
return (mips32_getsr() & SR_IE) == 0;
}
-static intr_chain_t mips_intr_chain[8];
+static intr_event_t mips_intr_event[8];
-#define MIPS_INTR_CHAIN(irq, name) \
- intr_chain_init(&mips_intr_chain[irq], irq, name)
+#define MIPS_INTR_EVENT(irq, name) \
+ intr_event_init(&mips_intr_event[irq], irq, name)
void mips_intr_init(void) {
/*
@@ -55,26 +55,26 @@ void mips_intr_init(void) {
/* Set vector spacing to 0. */
mips32_set_c0(C0_INTCTL, INTCTL_VS_0);
- /* Initialize software interrupts handler chains. */
- MIPS_INTR_CHAIN(MIPS_SWINT0, "swint(0)");
- MIPS_INTR_CHAIN(MIPS_SWINT1, "swint(1)");
- /* Initialize hardware interrupts handler chains. */
- MIPS_INTR_CHAIN(MIPS_HWINT0, "hwint(0)");
- MIPS_INTR_CHAIN(MIPS_HWINT1, "hwint(1)");
- MIPS_INTR_CHAIN(MIPS_HWINT2, "hwint(2)");
- MIPS_INTR_CHAIN(MIPS_HWINT3, "hwint(3)");
- MIPS_INTR_CHAIN(MIPS_HWINT4, "hwint(4)");
- MIPS_INTR_CHAIN(MIPS_HWINT5, "hwint(5)");
+ /* Initialize software interrupts handler events. */
+ MIPS_INTR_EVENT(MIPS_SWINT0, "swint(0)");
+ MIPS_INTR_EVENT(MIPS_SWINT1, "swint(1)");
+ /* Initialize hardware interrupts handler events. */
+ MIPS_INTR_EVENT(MIPS_HWINT0, "hwint(0)");
+ MIPS_INTR_EVENT(MIPS_HWINT1, "hwint(1)");
+ MIPS_INTR_EVENT(MIPS_HWINT2, "hwint(2)");
+ MIPS_INTR_EVENT(MIPS_HWINT3, "hwint(3)");
+ MIPS_INTR_EVENT(MIPS_HWINT4, "hwint(4)");
+ MIPS_INTR_EVENT(MIPS_HWINT5, "hwint(5)");
for (unsigned i = 0; i < 8; i++)
- intr_chain_register(&mips_intr_chain[i]);
+ intr_event_register(&mips_intr_event[i]);
}
void mips_intr_setup(intr_handler_t *handler, unsigned irq) {
- intr_chain_t *chain = &mips_intr_chain[irq];
- WITH_SPIN_LOCK (&chain->ic_lock) {
- intr_chain_add_handler(chain, handler);
- if (chain->ic_count == 1) {
+ intr_event_t *event = &mips_intr_event[irq];
+ WITH_SPIN_LOCK (&event->ie_lock) {
+ intr_event_add_handler(event, handler);
+ if (event->ie_count == 1) {
mips32_bs_c0(C0_STATUS, SR_IM0 << irq); /* enable interrupt */
mips32_bc_c0(C0_CAUSE, CR_IP0 << irq); /* clear pending flag */
}
@@ -82,11 +82,11 @@ void mips_intr_setup(intr_handler_t *handler, unsigned irq) {
}
void mips_intr_teardown(intr_handler_t *handler) {
- intr_chain_t *chain = handler->ih_chain;
- WITH_SPIN_LOCK (&chain->ic_lock) {
- if (chain->ic_count == 1)
- mips32_bc_c0(C0_STATUS, SR_IM0 << chain->ic_irq);
- intr_chain_remove_handler(handler);
+ intr_event_t *event = handler->ih_event;
+ WITH_SPIN_LOCK (&event->ie_lock) {
+ if (event->ie_count == 1)
+ mips32_bc_c0(C0_STATUS, SR_IM0 << event->ie_irq);
+ intr_event_remove_handler(handler);
}
}
@@ -98,7 +98,7 @@ static void mips_intr_handler(exc_frame_t *frame) {
unsigned irq = CR_IP0 << i;
if (pending & irq) {
- intr_chain_run_handlers(&mips_intr_chain[i]);
+ intr_event_run_handlers(&mips_intr_event[i]);
pending &= ~irq;
}
}

MODIFY
sys/interrupt.c
sys/interrupt.c
#include <mips/intr.h>
#include <interrupt.h>
-static mtx_t all_ichains_mtx = MTX_INITIALIZER(0);
-static intr_chain_list_t all_ichains_list =
- TAILQ_HEAD_INITIALIZER(all_ichains_list);
+static mtx_t all_ievents_mtx = MTX_INITIALIZER(0);
+static intr_event_list_t all_ievents_list =
+ TAILQ_HEAD_INITIALIZER(all_ievents_list);
bool intr_disabled(void) {
thread_t *td = thread_self();
@@ -28,44 +28,44 @@ void intr_enable(void) {
mips_intr_enable();
}
-void intr_chain_init(intr_chain_t *ic, unsigned irq, const char *name) {
- ic->ic_irq = irq;
- ic->ic_name = name;
- ic->ic_lock = SPIN_INITIALIZER(LK_RECURSE);
- TAILQ_INIT(&ic->ic_handlers);
+void intr_event_init(intr_event_t *ie, unsigned irq, const char *name) {
+ ie->ie_irq = irq;
+ ie->ie_name = name;
+ ie->ie_lock = SPIN_INITIALIZER(LK_RECURSE);
+ TAILQ_INIT(&ie->ie_handlers);
}
-void intr_chain_register(intr_chain_t *ic) {
- WITH_MTX_LOCK (&all_ichains_mtx)
- TAILQ_INSERT_TAIL(&all_ichains_list, ic, ic_list);
+void intr_event_register(intr_event_t *ie) {
+ WITH_MTX_LOCK (&all_ievents_mtx)
+ TAILQ_INSERT_TAIL(&all_ievents_list, ie, ie_list);
}
-void intr_chain_add_handler(intr_chain_t *ic, intr_handler_t *ih) {
- SCOPED_SPIN_LOCK(&ic->ic_lock);
+void intr_event_add_handler(intr_event_t *ie, intr_handler_t *ih) {
+ SCOPED_SPIN_LOCK(&ie->ie_lock);
/* Add new handler according to it's priority */
intr_handler_t *it;
- TAILQ_FOREACH (it, &ic->ic_handlers, ih_list)
+ TAILQ_FOREACH (it, &ie->ie_handlers, ih_list)
if (ih->ih_prio > it->ih_prio)
break;
if (it)
TAILQ_INSERT_BEFORE(it, ih, ih_list);
else
- TAILQ_INSERT_TAIL(&ic->ic_handlers, ih, ih_list);
+ TAILQ_INSERT_TAIL(&ie->ie_handlers, ih, ih_list);
- ih->ih_chain = ic;
- ic->ic_count++;
+ ih->ih_event = ie;
+ ie->ie_count++;
}
-void intr_chain_remove_handler(intr_handler_t *ih) {
- intr_chain_t *ic = ih->ih_chain;
+void intr_event_remove_handler(intr_handler_t *ih) {
+ intr_event_t *ie = ih->ih_event;
- SCOPED_SPIN_LOCK(&ic->ic_lock);
+ SCOPED_SPIN_LOCK(&ie->ie_lock);
- TAILQ_REMOVE(&ic->ic_handlers, ih, ih_list);
- ih->ih_chain = NULL;
- ic->ic_count--;
+ TAILQ_REMOVE(&ie->ie_handlers, ih, ih_list);
+ ih->ih_event = NULL;
+ ie->ie_count--;
}
/*
@@ -73,11 +73,11 @@ void intr_chain_remove_handler(intr_handler_t *ih) {
* With current implementation all filters have to either handle filter or
* report that it is stray interrupt.
*/
-void intr_chain_run_handlers(intr_chain_t *ic) {
+void intr_event_run_handlers(intr_event_t *ie) {
intr_handler_t *ih;
intr_filter_t status = IF_STRAY;
- TAILQ_FOREACH (ih, &ic->ic_handlers, ih_list) {
+ TAILQ_FOREACH (ih, &ie->ie_handlers, ih_list) {
assert(ih->ih_filter != NULL);
status = ih->ih_filter(ih->ih_argument);
if (status == IF_FILTERED)
@@ -90,5 +90,5 @@ void intr_chain_run_handlers(intr_chain_t *ic) {
}
}
- klog("Spurious %s interrupt!", ic->ic_name);
+ klog("Spurious %s interrupt!", ie->ie_name);
}

Rename intr_chain to intr_event (#539)