1 #include <aros/kernel.h>
2 #include <aros/libcall.h>
3 #include <proto/exec.h>
5 #include <kernel_base.h>
6 #include <kernel_cpu.h>
7 #include <kernel_debug.h>
8 #include <kernel_interrupts.h>
9 #include <kernel_objects.h>
11 /* We use own implementation of bug(), so we don't need aros/debug.h */
14 /*****************************************************************************
17 #include <proto/kernel.h>
19 AROS_LH4(void *, KrnAddIRQHandler
,
22 AROS_LHA(uint8_t, irq
, D0
),
23 AROS_LHA(irqhandler_t
*, handler
, A0
),
24 AROS_LHA(void *, handlerData
, A1
),
25 AROS_LHA(void *, handlerData2
, A2
),
28 struct KernelBase
*, KernelBase
, 7, Kernel
)
31 Add a raw hardware IRQ handler to the chain of handlers.
34 num - hardware-specific IRQ number
35 handler - Pointer to a handler function
37 handlerData2 - User-defined data which is passed to the
40 Handler function uses a C calling convention and must be
43 void IRQHandler(void *handlerData, void *handlerData2)
45 handlerData and handlerData2 will be values passed to the
46 KrnAddExceptionHandler() function.
48 There is no return code for the IRQ handler.
51 An opaque handle that can be used for handler removal or NULL in case
52 of failure (like unsupported exception number).
65 ******************************************************************************/
69 struct IntrNode
*handle
= NULL
;
71 D(bug("[KRN] KrnAddIRQHandler(%02x, %012p, %012p, %012p):\n", irq
, handler
, handlerData
, handlerData2
));
75 /* Go to supervisor mode */
78 handle
= krnAllocIntrNode();
79 D(bug("[KRN] handle=%012p\n", handle
));
83 handle
->in_Handler
= handler
;
84 handle
->in_HandlerData
= handlerData
;
85 handle
->in_HandlerData2
= handlerData2
;
86 handle
->in_type
= it_interrupt
;
91 ADDHEAD(&KernelBase
->kb_Interrupts
[irq
], &handle
->in_Node
);
93 ictl_enable_irq(irq
, KernelBase
);
106 /* Run IRQ handlers */
107 void krnRunIRQHandlers(struct KernelBase
*KernelBase
, uint8_t irq
)
109 struct IntrNode
*in
, *in2
;
111 ForeachNodeSafe(&KernelBase
->kb_Interrupts
[irq
], in
, in2
)
113 irqhandler_t h
= in
->in_Handler
;
115 h(in
->in_HandlerData
, in
->in_HandlerData2
);