123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- #include "picorv32.h"
- #include "fw.h"
- #include "console.h"
- /* Invalid interrupt */
- static void spurious_irq_handler(unsigned int vector)
- {
- con_printf("spurious interrupt: %u\n", vector);
- mask_irq(vector);
- }
- /* Valid edge-triggered interrupt just to wake up waitirq */
- void null_irq_handler(unsigned int vector)
- {
- }
- irq_handler_t __irq_handler_table[IRQ_VECTORS] =
- { [0 ... IRQ_VECTORS-1] = spurious_irq_handler };
- irq_handler_t register_irq(unsigned int vector, irq_handler_t handler,
- bool enable)
- {
- irq_handler_t old_handler;
- if (vector >= IRQ_VECTORS)
- return NULL; /* Invalid vector */
- mask_irq(vector);
- if (!handler) {
- enable = false;
- handler = spurious_irq_handler;
- }
-
- old_handler = __irq_handler_table[vector];
- __irq_handler_table[vector] = handler;
- if (enable)
- unmask_irq(vector);
- if (old_handler == spurious_irq_handler)
- old_handler = NULL;
- con_printf("irq: register vector %u, handler = %p, mask = %08x\n",
- vector, handler, irqmask());
- return old_handler;
- }
|