devs/AHI: define PROCGW as alias to actual function
[AROS.git] / workbench / devs / AHI / Drivers / Common / library.h
blob5a933cb6073968a7809688ee5da01b239b789315
1 #ifndef AHI_Drivers_Common_library_h
2 #define AHI_Drivers_Common_library_h
4 #include <exec/types.h>
5 #include <proto/exec.h>
7 #include "DriverData.h"
9 extern const char LibName[];
10 extern const char LibIDString[];
11 extern const UWORD LibVersion;
12 extern const UWORD LibRevision;
14 void
15 ReqA( const char* text,
16 APTR args,
17 struct DriverBase* AHIsubBase );
19 #define Req(a0, args...) \
20 ({ULONG _args[] = { args }; ReqA((a0), (APTR)_args, AHIsubBase);})
22 void
23 MyKPrintFArgs( UBYTE* fmt,
24 ULONG* args,
25 struct DriverBase* AHIsubBase );
27 #if !defined(__AMIGAOS4__)
28 #define KPrintF( fmt, ... ) \
29 ({ \
30 ULONG _args[] = { __VA_ARGS__ }; \
31 MyKPrintFArgs( (fmt), _args, AHIsubBase ); \
33 #else
34 #define KPrintF DebugPrintF
35 #endif
38 #if defined(__MORPHOS__)
40 # include <emul/emulregs.h>
41 # define INTGW(q,t,n,f) \
42 q t n ## _code(void) { APTR d = (APTR) REG_A1; return f(d); } \
43 q struct EmulLibEntry n = { TRAP_LIB, 0, (APTR) n ## _code };
44 # define PROCGW(q,t,n,f) \
45 q struct EmulLibEntry n = { TRAP_LIB, 0, (APTR) f };
46 # define INTERRUPT_NODE_TYPE NT_INTERRUPT
48 #elif defined(__amithlon__)
50 # define INTGW(q,t,n,f) \
51 __asm(" .text"); \
52 __asm(" .align 4"); \
53 __asm(" .type " #n "_code,@function"); \
54 __asm(" .type " #n ",@function"); \
55 __asm(#n "_code: movl %ebp,%eax"); \
56 __asm(" bswap %eax"); \
57 __asm(" pushl %eax"); \
58 __asm(" call " #f ); \
59 __asm(" addl $4,%esp"); \
60 __asm(" ret"); \
61 __asm(#n "=" #n "_code+1"); \
62 __asm(".section .rodata"); \
63 q t n(APTR);
64 # define PROCGW(q,t,n,f) \
65 __asm(#n "=" #f "+1"); \
66 q t n(void);
67 # define INTERRUPT_NODE_TYPE NT_INTERRUPT
69 #elif defined(__AROS__)
71 # include <aros/asmcall.h>
72 # define INTGW_void(q,n,f) \
73 q AROS_INTH1(n, void *, d) { \
74 AROS_INTFUNC_INIT \
75 f(d); \
76 return FALSE; \
77 AROS_INTFUNC_EXIT \
79 # define INTGW_ULONG(q,n,f) \
80 q AROS_INTH1(n, void *, d) { \
81 AROS_INTFUNC_INIT \
82 return f(d); \
83 AROS_INTFUNC_EXIT \
85 # define INTGW(q,t,n,f) \
86 INTGW_##t(q,n,f)
87 # define PROCGW(q,t,n,f) \
88 q t n(); \
89 asm(".weak " #n "\n" \
90 "\t.set " #n "," #f \
92 # define INTERRUPT_NODE_TYPE NT_INTERRUPT
94 #elif defined(__AMIGAOS4__)
96 # define INTGW(q,t,n,f) \
97 __asm(#n "=" #f ); \
98 q t n(APTR);
99 # define PROCGW(q,t,n,f) \
100 q t n(void) {f();}
101 # define INTERRUPT_NODE_TYPE NT_EXTINTERRUPT
103 #elif defined(__amiga__) && defined(__mc68000__)
105 # define INTGW(q,t,n,f) \
106 q t n(APTR d __asm("a1")) { return f(d); }
107 # define PROCGW(q,t,n,f) \
108 asm(".stabs \"_" #n "\",11,0,0,0;.stabs \"_" #f "\",1,0,0,0"); \
109 /*q*/ t n(void);
110 # define INTERRUPT_NODE_TYPE NT_INTERRUPT
112 #else
113 # error Unknown OS/CPU
114 #endif
116 #endif /* AHI_Drivers_Common_library_h */