Removed platform specific metatarget (sun4i)
[AROS.git] / arch / m68k-all / include / aros / genmodule.h
blobc542670350c98f0be6e610d271a0fba3fac7fcd2
1 #ifndef AROS_M68K_GENMODULE_H
2 #define AROS_M68K_GENMODULE_H
4 /*
5 Copyright © 1995-2012, The AROS Development Team. All rights reserved.
6 $Id$
8 Desc:CPU-specific genmodule definitions for Motorola m68k processors
9 Lang: english
12 #include <exec/execbase.h>
14 /* Macros for generating library stub functions and aliases for stack libcalls. */
16 /******************* Linklib Side Thunks ******************/
18 /* Macro: AROS_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 Internals: a dummy function is used that will generate some
25 unused junk code but otherwise we can't pass input arguments
26 to the asm statement
28 #define __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
29 void __ ## fname ## _ ## libbasename ## _wrapper(void) \
30 { \
31 asm volatile( \
32 ".weak " #fname "\n" \
33 #fname ":\n" \
34 "\tmove.l " #libbasename ",%%a0\n" \
35 "\tjmp %%a0@(%c0)\n" \
36 : : "i" ((-lvo*LIB_VECTSIZE)) \
37 ); \
39 #define AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo) \
40 __AROS_GM_LIBFUNCSTUB(fname, libbasename, lvo)
42 /* Macro: AROS_GM_RELLIBFUNCSTUB(functionname, libbasename, lvo)
43 Same as AROS_GM_LIBFUNCSTUB but finds libbase at an offset in
44 the current libbase
46 For the m68k C ABI, all operands are on the stack, so
47 'scratch' registers d0-d1/a0-a1 are free for use by this
48 stub.
50 #define __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
51 void __ ## fname ## _ ## libbasename ## _relwrapper(IPTR args) \
52 { \
53 asm volatile( \
54 ".weak " #fname "\n" \
55 #fname " :\n" \
56 "\tjsr __aros_getoffsettable\n" \
57 "\tmove.l __aros_rellib_offset_" #libbasename ", %%a0\n" \
58 "\tmove.l %%a0@(%%d0), %%a0\n" \
59 "\tjmp %%a0@(%c0)\n" \
60 : : "i" ((-lvo*LIB_VECTSIZE)) \
61 : \
62 ); \
64 #define AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo) \
65 __AROS_GM_RELLIBFUNCSTUB(fname, libbasename, lvo)
67 /* Macro: AROS_GM_LIBFUNCALIAS(functionname, alias)
68 This macro will generate an alias 'alias' for function
69 'functionname'
71 #define __AROS_GM_LIBFUNCALIAS(fname, alias) \
72 asm(".weak " #alias "\n" \
73 "\t.set " #alias "," #fname \
75 #define AROS_GM_LIBFUNCALIAS(fname, alias) \
76 __AROS_GM_LIBFUNCALIAS(fname, alias)
78 /******************* Library Side Thunks ******************/
80 /* This macro relies upon the fact that the
81 * caller to a stack function will have passed in
82 * the base in %a0, instead of %a6, since the caller
83 * will have used the AROS_LIBFUNCSTUB() macro.
85 #define __GM_STRINGIZE(x) #x
86 #define __AROS_GM_STACKCALL(fname, libbasename, libfuncname) \
87 void libfuncname(void); \
88 void __ ## fname ## _stackcall(void) \
89 { \
90 asm volatile( \
91 "\t" __GM_STRINGIZE(libfuncname) " :\n" \
92 "\tmove.l %a0,%sp@-\n" \
93 "\tjsr __aros_setoffsettable\n" \
94 "\taddq.l #4,%sp\n" \
95 "\tjmp " #fname "\n" \
96 ); \
99 #define AROS_GM_STACKCALL(fname, libbasename, lvo) \
100 __AROS_GM_STACKCALL(fname, libbasename, AROS_SLIB_ENTRY(fname, libbasename, lvo))
102 /* Macro: AROS_GM_STACKALIAS(functionname, libbasename, lvo)
103 This macro will generate an alias 'alias' for function
104 'functionname'
106 #define __AROS_GM_STACKALIAS(fname, alias) \
107 void alias(void); \
108 asm(".weak " __GM_STRINGIZE(alias) "\n" \
109 "\t.set " __GM_STRINGIZE(alias) "," #fname \
111 #define AROS_GM_STACKALIAS(fname, libbasename, lvo) \
112 __AROS_GM_STACKALIAS(fname, AROS_SLIB_ENTRY(fname, libbasename, lvo))
116 #endif /* AROS_M68K_GENMODULE_H */