2 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
8 #include <aros/kernel.h>
9 #include <aros/libcall.h>
10 #include <proto/exec.h>
12 #include <kernel_base.h>
13 #include <kernel_cpu.h>
14 #include <kernel_debug.h>
15 #include <kernel_interrupts.h>
16 #include <kernel_objects.h>
18 /* We use own implementation of bug(), so we don't need aros/debug.h */
21 /*****************************************************************************
24 #include <proto/kernel.h>
26 AROS_LH4(void *, KrnAddIRQHandler
,
29 AROS_LHA(uint32_t, irq
, D0
),
30 AROS_LHA(irqhandler_t
*, handler
, A0
),
31 AROS_LHA(void *, handlerData
, A1
),
32 AROS_LHA(void *, handlerData2
, A2
),
35 struct KernelBase
*, KernelBase
, 7, Kernel
)
38 Add a raw hardware IRQ handler to the chain of handlers.
41 num - hardware-specific IRQ number
42 handler - Pointer to a handler function
44 handlerData2 - User-defined data which is passed to the
47 Handler function uses a C calling convention and must be
50 void IRQHandler(void *handlerData, void *handlerData2)
52 handlerData and handlerData2 will be values passed to the
53 KrnAddExceptionHandler() function.
55 There is no return code for the IRQ handler.
58 An opaque handle that can be used for handler removal or NULL in case
59 of failure (like unsupported exception number).
72 ******************************************************************************/
76 struct IntrNode
*handle
= NULL
;
78 D(bug("[KRN] KrnAddIRQHandler(%02x, %012p, %012p, %012p):\n", irq
, handler
, handlerData
, handlerData2
));
80 if (irq
< HW_IRQ_COUNT
)
82 /* Go to supervisor mode */
85 handle
= krnAllocIntrNode();
86 D(bug("[KRN] handle=%012p\n", handle
));
90 handle
->in_Handler
= handler
;
91 handle
->in_HandlerData
= handlerData
;
92 handle
->in_HandlerData2
= handlerData2
;
93 handle
->in_type
= it_interrupt
;
98 ADDHEAD(&KERNELIRQ_LIST(irq
), &handle
->in_Node
);
100 ictl_enable_irq(irq
, KernelBase
);
113 /* Run IRQ handlers */
114 void krnRunIRQHandlers(struct KernelBase
*KernelBase
, uint8_t irq
)
116 struct IntrNode
*in
, *in2
;
118 ForeachNodeSafe(&KERNELIRQ_LIST(irq
), in
, in2
)
120 irqhandler_t h
= in
->in_Handler
;
122 h(in
->in_HandlerData
, in
->in_HandlerData2
);