add flag for spinning tasks
[AROS.git] / compiler / include / exec / interrupts.h
blobdc9557289588c570f7e7b2f91081850bfdbeebbf
1 #ifndef EXEC_INTERRUPTS_H
2 #define EXEC_INTERRUPTS_H
4 /*
5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc: Interrupt structures
9 Lang: english
12 #ifndef EXEC_LISTS_H
13 # include <exec/lists.h>
14 #endif
15 #ifndef EXEC_NODES_H
16 # include <exec/nodes.h>
17 #endif
19 /* CPU-dependent struct ExceptionContext */
20 #if defined __i386__
21 #include <aros/i386/cpucontext.h>
22 #elif defined __x86_64__
23 #include <aros/x86_64/cpucontext.h>
24 #elif defined __mc68000__
25 #include <aros/m68k/cpucontext.h>
26 #elif defined __powerpc__
27 #include <aros/ppc/cpucontext.h>
28 #elif defined __arm__
29 #include <aros/arm/cpucontext.h>
30 #else
31 #error unsupported CPU type
32 #endif
34 struct Interrupt
36 struct Node is_Node;
37 APTR is_Data;
38 VOID (* is_Code)(); /* server code entry */
41 /* PRIVATE */
42 struct IntVector
44 APTR iv_Data;
45 VOID (* iv_Code)();
46 struct Node * iv_Node;
49 /* PRIVATE */
50 struct SoftIntList
52 struct List sh_List;
53 UWORD sh_Pad;
56 #define SIH_PRIMASK (0xf0)
58 #define INTB_NMI 15
59 #define INTF_NMI (1L<<15)
61 /* Offset of kernel interrupt vectors.
63 * Usage:
64 * AddIntServer(INTB_KERNEL + irq, irq_handler);
65 * RemIntServer(INTB_KERNEL + irq, irq_handler);
67 #define INTB_KERNEL (16)
69 #ifdef __AROS__
70 /* AROS helper macros.
71 * These are used to abstract away architectural
72 * differences between AROS ports.
74 #include <aros/asmcall.h>
76 /* Define a function prototype and call methods
77 * for Cause(), SetIntVector(), and AddIntServer()
78 * struct Interrupt is_Code fields.
80 * The prototype matches:
82 * ULONG func(APTR data, ULONG intmask, struct Custom *custom,
83 * VOID_FUNC code, struct ExecBase *sysBase)
84 * (A1, D1, A0, A5, A6)
86 * Handler should return TRUE (interrupt handled)
87 * or FALSE (continue interrupt processing)
89 #define AROS_INTP(n) \
90 AROS_UFP5(ULONG, n, \
91 AROS_UFPA(APTR, __ufi_data, A1), \
92 AROS_UFPA(ULONG, __ufi_intmask, D1), \
93 AROS_UFPA(APTR, __ufi_custom, A0), \
94 AROS_UFPA(VOID_FUNC, __ufi_code, A5), \
95 AROS_UFPA(struct ExecBase *, __ufi_SysBase, A6))
97 #define AROS_INTC4(n, data, intmask, custom, code) \
98 AROS_UFC5(ULONG, n, \
99 AROS_UFCA(APTR, data, A1), \
100 AROS_UFCA(ULONG, intmask, D1), \
101 AROS_UFCA(APTR, custom, A0), \
102 AROS_UFCA(VOID_FUNC, code, A5), \
103 AROS_UFCA(struct ExecBase *, SysBase, A6))
104 #define AROS_INTC3(n, data, intmask, custom) AROS_INTC4(n, data, intmask, custom, (VOID_FUNC)(n))
105 #define AROS_INTC2(n, data, intmask) AROS_INTC4(n, data, intmask, (APTR)(IPTR)0xdff000, (VOID_FUNC)(n));
106 #define AROS_INTC1(n, data) AROS_INTC4(n, data, 0, (APTR)(IPTR)0xdff000, (VOID_FUNC)(n));
108 #define AROS_INTH4(n, type, data, intmask, custom, code) \
109 AROS_UFH5(ULONG, n, \
110 AROS_UFHA(APTR, __ufi_data, A1), \
111 AROS_UFHA(ULONG, intmask, D1), \
112 AROS_UFHA(APTR, custom, A0), \
113 AROS_UFHA(VOID_FUNC, code, A5), \
114 AROS_UFHA(struct ExecBase *, SysBase, A6) \
115 ) { AROS_USERFUNC_INIT \
116 type __unused data = __ufi_data;
118 #define AROS_INTH3(n, type, data, intmask, custom) AROS_INTH4(n, type, data, intmask, custom, __ufi_code)
119 #define AROS_INTH2(n, type, data, intmask) AROS_INTH4(n, type, data, intmask, __ufi_custom, __ufi_code)
120 #define AROS_INTH1(n, type, data) AROS_INTH4(n, type, data, __ufi_intmask, __ufi_custom, __ufi_code)
121 #define AROS_INTH0(n) AROS_INTH4(n, APTR, data, __ufi_intmask, __ufi_custom, __ufi_code)
123 #ifdef __mc68000
124 /* Special hack for setting the 'Z' condition code upon exit
125 * for m68k architectures.
127 #define AROS_INTFUNC_INIT inline ULONG _handler(void) {
128 #define AROS_INTFUNC_EXIT }; register ULONG _res asm ("d0") = _handler(); \
129 asm volatile ("tst.l %0\n" : : "r" (_res)); \
130 return _res; /* gcc only generates movem/unlk/rts */ \
131 AROS_USERFUNC_EXIT }
132 #else /* ! __mc68000 */
133 /* Everybody else */
134 #define AROS_INTFUNC_INIT
135 #define AROS_INTFUNC_EXIT AROS_USERFUNC_EXIT }
136 #endif /* ! __mc68000 */
138 #endif /* __AROS__ */
140 #endif /* EXEC_INTERRUPTS_H */