1 #ifndef EXEC_INTERRUPTS_H
2 #define EXEC_INTERRUPTS_H
5 Copyright © 1995-2017, The AROS Development Team. All rights reserved.
8 Desc: Interrupt structures
13 # include <exec/lists.h>
16 # include <exec/nodes.h>
19 /* CPU-dependent struct ExceptionContext */
20 #if defined __x86_64__
21 #include <aros/x86_64/cpucontext.h>
22 #include <aros/irqtypes.h>
23 #elif defined __i386__
24 #include <aros/i386/cpucontext.h>
25 #include <aros/irqtypes.h>
26 #elif defined __mc68000__
27 #include <aros/m68k/cpucontext.h>
28 #elif defined __powerpc__
29 #include <aros/ppc/cpucontext.h>
30 #elif defined __aarch64__
31 #include <aros/aarch64/cpucontext.h>
33 #include <aros/arm/cpucontext.h>
35 #error unsupported CPU type
42 VOID (* is_Code
)(); /* server code entry */
50 struct Node
* iv_Node
;
60 #define SIH_PRIMASK (0xf0)
63 #define INTF_NMI (1L<<15)
65 /* Offset of kernel interrupt vectors.
68 * AddIntServer(INTB_KERNEL + irq, irq_handler);
69 * RemIntServer(INTB_KERNEL + irq, irq_handler);
71 #define INTB_KERNEL (16)
74 /* AROS helper macros.
75 * These are used to abstract away architectural
76 * differences between AROS ports.
78 #include <aros/asmcall.h>
80 /* Define a function prototype and call methods
81 * for Cause(), SetIntVector(), and AddIntServer()
82 * struct Interrupt is_Code fields.
84 * The prototype matches:
86 * ULONG func(APTR data, ULONG intmask, struct Custom *custom,
87 * VOID_FUNC code, struct ExecBase *sysBase)
88 * (A1, D1, A0, A5, A6)
90 * Handler should return TRUE (interrupt handled)
91 * or FALSE (continue interrupt processing)
93 #define AROS_INTP(n) \
95 AROS_UFPA(APTR, __ufi_data, A1), \
96 AROS_UFPA(ULONG, __ufi_intmask, D1), \
97 AROS_UFPA(APTR, __ufi_custom, A0), \
98 AROS_UFPA(VOID_FUNC, __ufi_code, A5), \
99 AROS_UFPA(struct ExecBase *, __ufi_SysBase, A6))
101 #define AROS_INTC4(n, data, intmask, custom, code) \
102 AROS_UFC5(ULONG, n, \
103 AROS_UFCA(APTR, data, A1), \
104 AROS_UFCA(ULONG, intmask, D1), \
105 AROS_UFCA(APTR, custom, A0), \
106 AROS_UFCA(VOID_FUNC, code, A5), \
107 AROS_UFCA(struct ExecBase *, SysBase, A6))
108 #define AROS_INTC3(n, data, intmask, custom) AROS_INTC4(n, data, intmask, custom, (VOID_FUNC)(n))
109 #define AROS_INTC2(n, data, intmask) AROS_INTC4(n, data, intmask, (APTR)(IPTR)0xdff000, (VOID_FUNC)(n));
110 #define AROS_INTC1(n, data) AROS_INTC4(n, data, 0, (APTR)(IPTR)0xdff000, (VOID_FUNC)(n));
112 #define AROS_INTH4(n, type, data, intmask, custom, code) \
113 AROS_UFH5(ULONG, n, \
114 AROS_UFHA(APTR, __ufi_data, A1), \
115 AROS_UFHA(ULONG, intmask, D1), \
116 AROS_UFHA(APTR, custom, A0), \
117 AROS_UFHA(VOID_FUNC, code, A5), \
118 AROS_UFHA(struct ExecBase *, SysBase, A6) \
119 ) { AROS_USERFUNC_INIT \
120 type __unused data = __ufi_data;
122 #define AROS_INTH3(n, type, data, intmask, custom) AROS_INTH4(n, type, data, intmask, custom, __ufi_code)
123 #define AROS_INTH2(n, type, data, intmask) AROS_INTH4(n, type, data, intmask, __ufi_custom, __ufi_code)
124 #define AROS_INTH1(n, type, data) AROS_INTH4(n, type, data, __ufi_intmask, __ufi_custom, __ufi_code)
125 #define AROS_INTH0(n) AROS_INTH4(n, APTR, data, __ufi_intmask, __ufi_custom, __ufi_code)
128 /* Special hack for setting the 'Z' condition code upon exit
129 * for m68k architectures.
131 #define AROS_INTFUNC_INIT inline ULONG _handler(void) {
132 #define AROS_INTFUNC_EXIT }; register ULONG _res asm ("d0") = _handler(); \
133 asm volatile ("tst.l %0\n" : : "r" (_res)); \
134 return _res; /* gcc only generates movem/unlk/rts */ \
136 #else /* ! __mc68000 */
138 #define AROS_INTFUNC_INIT
139 #define AROS_INTFUNC_EXIT AROS_USERFUNC_EXIT }
140 #endif /* ! __mc68000 */
142 #endif /* __AROS__ */
144 #endif /* EXEC_INTERRUPTS_H */