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
;
15 ReqA( const char* text
,
17 struct DriverBase
* AHIsubBase
);
19 #define Req(a0, args...) \
20 ({ULONG _args[] = { args }; ReqA((a0), (APTR)_args, AHIsubBase);})
23 MyKPrintFArgs( UBYTE
* fmt
,
25 struct DriverBase
* AHIsubBase
);
27 #if !defined(__AMIGAOS4__)
28 #define KPrintF( fmt, ... ) \
30 ULONG _args[] = { __VA_ARGS__ }; \
31 MyKPrintFArgs( (fmt), _args, AHIsubBase ); \
34 #define KPrintF DebugPrintF
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) \
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"); \
61 __asm(#n "=" #n "_code+1"); \
62 __asm(".section .rodata"); \
64 # define PROCGW(q,t,n,f) \
65 __asm(#n "=" #f "+1"); \
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) { \
79 # define INTGW_ULONG(q,n,f) \
80 q AROS_INTH1(n, void *, d) { \
85 # define INTGW(q,t,n,f) \
87 # define PROCGW(q,t,n,f) \
89 asm(".weak " #n "\n" \
92 # define INTERRUPT_NODE_TYPE NT_INTERRUPT
94 #elif defined(__AMIGAOS4__)
96 # define INTGW(q,t,n,f) \
99 # define PROCGW(q,t,n,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"); \
110 # define INTERRUPT_NODE_TYPE NT_INTERRUPT
113 # error Unknown OS/CPU
116 #endif /* AHI_Drivers_Common_library_h */