2 Copyright © 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>
20 /*****************************************************************************
23 #include <proto/kernel.h>
25 AROS_LH4(void *, KrnAddIRQHandler
,
28 AROS_LHA(uint32_t, irq
, D0
),
29 AROS_LHA(irqhandler_t
*, handler
, A0
),
30 AROS_LHA(void *, handlerData
, A1
),
31 AROS_LHA(void *, handlerData2
, A2
),
34 struct KernelBase
*, KernelBase
, 7, Kernel
)
37 Add a raw hardware IRQ handler to the chain of handlers.
40 num - hardware-specific IRQ number
41 handler - Pointer to a handler function
43 handlerData2 - User-defined data which is passed to the
46 Handler function uses a C calling convention and must be
49 void IRQHandler(void *handlerData, void *handlerData2)
51 handlerData and handlerData2 will be values passed to the
52 KrnAddExceptionHandler() function.
54 There is no return code for the IRQ handler.
57 An opaque handle that can be used for handler removal or NULL in case
58 of failure (like unsupported exception number).
71 ******************************************************************************/
75 struct PlatformData
*pdata
= KernelBase
->kb_PlatformData
;
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
) || (pdata
->kb_PDFlags
& PLATFORMF_HAVEMSI
))
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 if (irq
< HW_IRQ_COUNT
)
100 ADDHEAD(&KERNELIRQ_LIST(irq
), &handle
->in_Node
);
102 ictl_enable_irq(irq
, KernelBase
);
106 core_APIC_RegisterMSI(handle
);
119 /* Run IRQ handlers */
120 void krnRunIRQHandlers(struct KernelBase
*KernelBase
, uint8_t irq
)
122 struct IntrNode
*in
, *in2
;
124 ForeachNodeSafe(&KERNELIRQ_LIST(irq
), in
, in2
)
126 irqhandler_t h
= in
->in_Handler
;
128 h(in
->in_HandlerData
, in
->in_HandlerData2
);