use the locations specified in the bcm2708_boot header
[AROS.git] / test / sdi / SDI_interrupt.h
blob45ed500a242a7a69f3535e67f024ab235955473f
1 #ifndef SDI_INTERRUPT_H
2 #define SDI_INTERRUPT_H
4 /* Includeheader
6 Name: SDI_interrupt.h
7 Versionstring: $VER: SDI_interrupt.h 1.1 (25.04.2006)
8 Author: Guido Mersmann
9 Distribution: PD
10 Project page: http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
11 Description: defines to hide compiler specific interrupt and
12 handler stuff
13 Id: $Id$
14 URL: $URL: svn://svn.code.sf.net/p/adtools/code/trunk/sdi/SDI_interrupt.h $
16 1.0 17.05.05 : inspired by the SDI_#?.h files made by Jens Langner
17 and Dirk Stöcker I created files to handle interrupt
18 and handler functions in an API compatible way.
19 1.1 25.04.06 : fixed MakeInterrupt() and MakeHandler() macro. (geit)
24 ** This is PD (Public Domain). This means you can do with it whatever you want
25 ** without any restrictions. I only ask you to tell me improvements, so I may
26 ** fix the main line of this files as well.
28 ** To keep confusion level low: When changing this file, please note it in
29 ** above history list and indicate that the change was not made by myself
30 ** (e.g. add your name or nick name).
32 ** Find the latest version of this file at:
33 ** http://sf.net/p/adtools/code/HEAD/tree/trunk/sdi/
35 ** Guido Mersmann <geit@gmx.de>
39 #include "SDI_compiler.h"
42 ** The INTERRUPTPROTO macro is for creating interrupts functions and the
43 ** HANDLERPROTO macro is for handler type setup like used by the
44 ** input.device.
46 ** The usage is simular to the DISPATCHERPROTO macro provided by SDI_hook.h.
48 ** It gets the function name as argument. To supply this function for use by
49 ** an interrupt structure or handler argument, use the ENTRY macro, which also
50 ** gets the function name as argument. There is also a MakeInterrupt and a
51 ** MakeHandler macro for easy structure setup.
53 ** Example:
55 ** We create a handler function for the input.device.
57 ** HANDLERPROTO( handlerfunc, ULONG, struct InputEvent *inputevent, APTR userdata)
58 ** {
59 ** ... Modify/parse input stream here
60 ** ...
61 ** return( (ULONG) inputevent );
62 ** }
63 ** MakeHandler( handlerstruct, handlerfunc, "TestHandler", &our_user_data);
65 ** As you can see usage is as simple as using SDI hooks. To create interrupt
66 ** use INTERRUPTPROTO and MakeInterrupt. Internally both macros are identically.
68 ** There are also functions to create more specific interrupt and handler
69 ** structures. By default type is NT_INTERRUPT and priority is 0.
71 ** MakeHandlerType - additional argument for type
72 ** MakeHandlerPri - additional argument for pri
73 ** MakeHandlerTypePri - additional arguments for type and pri
76 ** Notes: Since the interrupt structure is used for handlers and also foreign
77 ** handlers are using this structure I keeped the arguments definition
78 ** on the user side.
82 #ifdef __MORPHOS__
84 #ifndef SDI_TRAP_LIB /* avoid defining this twice */
86 #include <proto/alib.h>
87 #include <emul/emulregs.h>
89 #define SDI_TRAP_LIB 0xFF00 /* SDI prefix to reduce conflicts */
91 struct SDI_EmulLibEntry
93 UWORD Trap;
94 UWORD pad;
95 APTR Func;
97 #endif
99 #define INTERRUPTPROTO(name, ret, obj, data) \
100 SAVEDS ASM ret name( obj, data); \
101 static ret Trampoline_##name(void) {return name(( obj) REG_A0, \
102 (data) REG_A1);} \
103 static const struct SDI_EmulLibEntry Gate_##name = {SDI_TRAP_LIB, 0, \
104 (APTR) Trampoline_##name}; \
105 SAVEDS ASM ret name( obj, data)
107 #define HANDLERPROTO(name, ret, obj, data) \
108 SAVEDS ASM ret name( obj, data); \
109 static ret Trampoline_##name(void) {return name(( obj) REG_A0, \
110 (data) REG_A1);} \
111 static const struct SDI_EmulLibEntry Gate_##name = {SDI_TRAP_LIB, 0, \
112 (APTR) Trampoline_##name}; \
113 SAVEDS ASM ret name( obj, data)
115 #define ENTRY(func) (APTR)&Gate_##func
117 #else
119 #define INTERRUPTPROTO(name, ret, obj, data) \
120 SAVEDS ASM ret name(REG(a0, obj), REG(a1, data))
121 #define HANDLERPROTO(name, ret, obj, data) \
122 SAVEDS ASM ret name(REG(a0, obj), REG(a1, data))
124 #define ENTRY(func) (APTR)func
126 #endif /* __MORPHOS__ */
128 /* some structure creating macros for easy and more specific usage */
130 #define MakeInterrupt( name, func, title, isdata ) \
131 static struct Interrupt name = {{ NULL, NULL, NT_INTERRUPT, 0, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
133 #define MakeInterruptPri( name, func, title, isdata, pri ) \
134 static struct Interrupt name = {{ NULL, NULL, NT_INTERRUPT, pri, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
136 #define MakeInterruptType( name, func, title, isdata, type ) \
137 static struct Interrupt name = {{ NULL, NULL, type, 0, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
139 #define MakeInterruptTypePri( name, func, title, isdata, type, pri ) \
140 static struct Interrupt name = {{ NULL, NULL, type, pri, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
142 #define MakeHandler( name, func, title, isdata ) \
143 static struct Interrupt name = {{ NULL, NULL, NT_INTERRUPT, 0, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
145 #define MakeHandlerPri( name, func, title, isdata, pri ) \
146 static struct Interrupt name = {{ NULL, NULL, NT_INTERRUPT, pri, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
148 #define MakeHandlerType( name, func, title, isdata, type ) \
149 static struct Interrupt name = {{ NULL, NULL, type, 0, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
151 #define MakeHandlerTypePri( name, func, title, isdata, type, pri ) \
152 static struct Interrupt name = {{ NULL, NULL, type, pri, (STRPTR) title}, (APTR) isdata, (void (*)()) ENTRY(func) }
155 #endif /* SDI_INTERRUPT_H */