revert between 56095 -> 55830 in arch
[AROS.git] / compiler / include / exec / interrupts.h
blob40d6d0a69abe87e8bafebb2ab4e44ce3cfe3d7bf
1 #ifndef EXEC_INTERRUPTS_H
2 #define EXEC_INTERRUPTS_H
4 /*
5 Copyright © 1995-2017, 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 __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>
32 #elif defined __arm__
33 #include <aros/arm/cpucontext.h>
34 #else
35 #error unsupported CPU type
36 #endif
38 struct Interrupt
40 struct Node is_Node;
41 APTR is_Data;
42 VOID (* is_Code)(); /* server code entry */
45 /* PRIVATE */
46 struct IntVector
48 APTR iv_Data;
49 VOID (* iv_Code)();
50 struct Node * iv_Node;
53 /* PRIVATE */
54 struct SoftIntList
56 struct List sh_List;
57 UWORD sh_Pad;
60 #define SIH_PRIMASK (0xf0)
62 #define INTB_NMI 15
63 #define INTF_NMI (1L<<15)
65 /* Offset of kernel interrupt vectors.
67 * Usage:
68 * AddIntServer(INTB_KERNEL + irq, irq_handler);
69 * RemIntServer(INTB_KERNEL + irq, irq_handler);
71 #define INTB_KERNEL (16)
73 #ifdef __AROS__
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) \
94 AROS_UFP5(ULONG, 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)
127 #ifdef __mc68000
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 */ \
135 AROS_USERFUNC_EXIT }
136 #else /* ! __mc68000 */
137 /* Everybody else */
138 #define AROS_INTFUNC_INIT
139 #define AROS_INTFUNC_EXIT AROS_USERFUNC_EXIT }
140 #endif /* ! __mc68000 */
142 #endif /* __AROS__ */
144 #endif /* EXEC_INTERRUPTS_H */