[95518e59] | 1 | #include <rtems.h> |
---|
| 2 | #include <bsp.h> |
---|
| 3 | #include <bsp/irq-generic.h> |
---|
| 4 | |
---|
| 5 | static inline void bsp_dispatch_irq(int irq) |
---|
| 6 | { |
---|
| 7 | bsp_interrupt_handler_entry *e = |
---|
| 8 | &bsp_interrupt_handler_table[bsp_interrupt_handler_index(irq)]; |
---|
| 9 | |
---|
| 10 | while (e != NULL) { |
---|
| 11 | (*e->handler)(e->arg); |
---|
| 12 | e = e->next; |
---|
| 13 | } |
---|
| 14 | } |
---|
| 15 | |
---|
| 16 | /* Called directly from IRQ trap handler TRAP[0x10..0x1F] = IRQ[0..15] */ |
---|
| 17 | static void BSP_ISR_handler(rtems_vector_number vector) |
---|
| 18 | { |
---|
| 19 | int irq = vector - 0x10; |
---|
| 20 | |
---|
| 21 | /* Let BSP fixup and/or handle incomming IRQ */ |
---|
| 22 | irq = bsp_irq_fixup(irq); |
---|
| 23 | |
---|
| 24 | bsp_dispatch_irq(irq); |
---|
| 25 | } |
---|
| 26 | |
---|
| 27 | /* Initialize interrupts */ |
---|
[dd8df59] | 28 | void BSP_shared_interrupt_init(void) |
---|
[95518e59] | 29 | { |
---|
| 30 | rtems_vector_number vector; |
---|
| 31 | rtems_isr_entry previous_isr; |
---|
| 32 | int sc, i; |
---|
| 33 | |
---|
| 34 | for (i=0; i <= BSP_INTERRUPT_VECTOR_MAX_STD; i++) { |
---|
| 35 | vector = SPARC_ASYNCHRONOUS_TRAP(i) + 0x10; |
---|
| 36 | rtems_interrupt_catch(BSP_ISR_handler, vector, &previous_isr); |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | /* Initalize interrupt support */ |
---|
[dd8df59] | 40 | bsp_interrupt_initialize(); |
---|
[95518e59] | 41 | } |
---|
| 42 | |
---|
| 43 | /* Callback from bsp_interrupt_initialize() */ |
---|
| 44 | rtems_status_code bsp_interrupt_facility_initialize(void) |
---|
| 45 | { |
---|
| 46 | return RTEMS_SUCCESSFUL; |
---|
| 47 | } |
---|
| 48 | |
---|
| 49 | rtems_status_code bsp_interrupt_vector_enable(rtems_vector_number vector) |
---|
| 50 | { |
---|
| 51 | BSP_Unmask_interrupt((int)vector); |
---|
| 52 | |
---|
| 53 | return RTEMS_SUCCESSFUL; |
---|
| 54 | } |
---|
| 55 | |
---|
| 56 | rtems_status_code bsp_interrupt_vector_disable(rtems_vector_number vector) |
---|
| 57 | { |
---|
| 58 | BSP_Mask_interrupt((int)vector); |
---|
| 59 | |
---|
| 60 | return RTEMS_SUCCESSFUL; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | void BSP_shared_interrupt_mask(int irq) |
---|
| 64 | { |
---|
| 65 | BSP_Mask_interrupt(irq); |
---|
| 66 | } |
---|
| 67 | |
---|
| 68 | void BSP_shared_interrupt_unmask(int irq) |
---|
| 69 | { |
---|
| 70 | BSP_Unmask_interrupt(irq); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | void BSP_shared_interrupt_clear(int irq) |
---|
| 74 | { |
---|
| 75 | /* We don't have to interrupt lock here, because the register is only |
---|
| 76 | * written and self clearing |
---|
| 77 | */ |
---|
| 78 | BSP_Clear_interrupt(irq); |
---|
| 79 | } |
---|