Added a test for MUIA_Listview_SelectChange.
[AROS.git] / arch / arm-all / include / aros / genmodule-thumb2.h
blob601bfb3042e923d8b55d69e3e25c78e0006c7ddd
1 /*
2 Copyright © 2016, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: genmodule-thumb2.h include file for arm-le systems in thumb2 mode
6 Lang: english
7 */
9 #ifndef AROS_ARM_GENMODULE_H
10 #define AROS_ARM_GENMODULE_H
12 #include <exec/execbase.h>
14 /* Macros for generating library stub functions and aliases for stack libcalls. */
16 /******************* Linklib Side Thunks ******************/
18 /* Macro: AROS_GM_LIBFUNCSTUB(functionname, libbasename, lvo)
19 This macro will generate code for a stub function for
20 the function 'functionname' of lirary with libbase
21 'libbasename' and 'lvo' number of the function in the
22 vector table. lvo has to be a constant value (not a variable)
24 #define __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
25 void __attribute__((noreturn)) __ ## fname ## _ ## libbasename ## _wrapper(void) \
26 { \
27 asm volatile( \
28 ".thumb \n" \
29 ".weak " #fname "\n" \
30 ".type " #fname ", %%function\n" \
31 #fname " :\n" \
32 /* r12 = libbase */ \
33 "\tldr r12, 1f\n" \
34 "\tldr r12, [r12]\n" \
35 /* Compute function address and jump */ \
36 "\tsub.w r12, r12, #%c0\n" \
37 "\tbx r12\n" \
38 ".align 2\n" \
39 "1: .word " #libbasename "\n" \
40 : : "i" ((lvo*LIB_VECTSIZE)) \
41 ); \
42 __builtin_unreachable(); \
44 #define AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
45 __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo)
47 /* Macro: AROS_GM_RELLIBFUNCSTUB(functionname, libbasename, lvo)
48 Same as AROS_GM_LIBFUNCSTUB but finds libbase at an offset in
49 the current libbase
51 #define __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
52 void __attribute__((noreturn)) __ ## fname ## _ ## libbasename ## _relwrapper(IPTR args) \
53 { \
54 asm volatile( \
55 ".thumb \n" \
56 ".weak " #fname "\n" \
57 ".type " #fname ", %%function\n" \
58 #fname " :\n" \
59 /* return address is in lr register */ \
60 /* Up to four parameters are in r0 - r3 , the rest are on stack */ \
61 "\tpush {r0, r1, r2, r3, lr}\n" \
62 /* r0 = __aros_getoffsettable() */ \
63 "\tbl __aros_getoffsettable\n" \
64 /* r12 = libbase */ \
65 "\tldr r1, 1f\n" \
66 "\tldr r1, [r1]\n" \
67 "\tldr r12, [r0, r1]\n" \
68 /* Restore original arguments */ \
69 "\tpop {r0, r1, r2, r3, lr}\n" \
70 /* Compute function address and jump */ \
71 "\tsub.w r12, r12, #%c0\n" \
72 "\tbx r12\n" \
73 "1: .word __aros_rellib_offset_" #libbasename "\n" \
74 "2: .word __aros_getoffsettable\n" \
75 : : "i" ((lvo*LIB_VECTSIZE)) \
76 ); \
77 __builtin_unreachable(); \
79 #define AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
80 __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo)
82 /* Macro: AROS_GM_LIBFUNCALIAS(functionname, alias)
83 This macro will generate an alias 'alias' for function
84 'functionname'
86 #define __AROS_GM_LIBFUNCALIAS(fname, alias) \
87 asm(".thumb \n" \
88 ".weak " #alias "\n" \
89 "\t.set " #alias "," #fname \
91 #define AROS_GM_LIBFUNCALIAS(fname, alias) \
92 __AROS_GM_LIBFUNCALIAS(fname, alias)
94 /******************* Library Side Thunks ******************/
96 /* This macro relies upon the fact that the
97 * caller to a stack function will have passed in
98 * the base in %r12, since the caller will
99 * have used the AROS_LIBFUNCSTUB() macro.
101 #define __GM_STRINGIZE(x) #x
102 #define __AROS_GM_STACKCALL(fname, libbasename, libfuncname) \
103 void libfuncname(void); \
104 void __attribute__((noreturn)) __ ## fname ## _stackcall(void) \
106 asm volatile( \
107 ".thumb \n" \
108 "\t" __GM_STRINGIZE(libfuncname) " :\n" \
109 /* Up to four parameters are in r0 - r3 , the rest are on stack */ \
110 "\tpush {r0, r1, r2, r3, lr}\n" \
111 "\tmov r0, r12\n" \
112 "\tbl __aros_setoffsettable\n" \
113 "\tpop {r0, r1, r2, r3, lr}\n" \
114 "\tb " #fname "\n" \
115 ); \
116 __builtin_unreachable(); \
119 #define AROS_GM_STACKCALL(fname, libbasename, lvo) \
120 __AROS_GM_STACKCALL(fname, libbasename, AROS_SLIB_ENTRY(fname, libbasename, lvo))
122 /* Macro: AROS_GM_STACKALIAS(functionname, libbasename, lvo)
123 This macro will generate an alias 'alias' for function
124 'functionname'
126 #define __AROS_GM_STACKALIAS(fname, alias) \
127 void alias(void); \
128 asm(".thumb \n" \
129 ".weak " __GM_STRINGIZE(alias) "\n" \
130 "\t.set " __GM_STRINGIZE(alias) "," #fname \
132 #define AROS_GM_STACKALIAS(fname, libbasename, lvo) \
133 __AROS_GM_STACKALIAS(fname, AROS_SLIB_ENTRY(fname, libbasename, lvo))
135 #endif /* AROS_ARM_GENMODULE_H */