added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / arch / .unmaintained / m68k-pp-native / include / aros / machine.h
blob5d74dc8e78e154f89db549e8c6ecce5b2b4de1e7
1 #ifndef AROS_MACHINE_H
2 #define AROS_MACHINE_H
4 /*
5 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
6 $Id$
8 NOTE: This file must compile *without* any other header !
10 Desc: machine.h
11 Lang: english
14 #define EnableSetFunction 1
16 /* Information generated by machine.c */
17 #define AROS_STACK_GROWS_DOWNWARDS 1 /* Stack direction */
18 #define AROS_BIG_ENDIAN 1 /* Big or little endian */
19 #define AROS_SIZEOFULONG 4 /* Size of an ULONG */
20 #define AROS_WORDALIGN 2 /* Alignment for WORD */
21 #define AROS_LONGALIGN 4 /* Alignment for LONG */
22 #define AROS_PTRALIGN 4 /* Alignment for PTR */
23 #define AROS_IPTRALIGN 4 /* Alignment for IPTR */
24 #define AROS_DOUBLEALIGN 4 /* Alignment for double */
25 #define AROS_WORSTALIGN 8 /* Worst case alignment */
27 #define AROS_GET_SYSBASE struct ExecBase * SysBase = *(struct ExecBase **)0x4;
28 #define AROS_GET_SYSBASE_OK struct ExecBase * SysBase = *(struct ExecBase **)0x4;
29 /*#define AROS_GET_DOSBASE struct DosLibrary * DOSBase = (struct DosLibrary *)OpenLibrary((UBYTE *)"dos.library",0); \*/
30 // CloseLibrary(DOSBase);
31 #define AROS_GET_DOSBASE extern struct DosLibrary *DOSBase;
33 #define AROS_NOFPU 1
35 /* do we need a function attribute to get parameters on the stack? */
36 #define __stackparm
38 register unsigned char * AROS_GET_SP asm("%sp");
40 /* ??? */
41 #define SP_OFFSET 0
44 One entry in a libraries' jumptable. For assembler compatibility, the
45 field jmp should contain the code for an absolute jmp to a 32bit
46 address. There are also a couple of macros which you should use to
47 access the vector table from C.
49 struct JumpVec
51 unsigned short jmp;
52 unsigned char vec[4];
56 /* Any jump to an unimplemented vector will cause an access to this address */
57 #define _aros_empty_vector 0xc0edbabe
59 /* Internal macros */
60 #define __AROS_ASMJMP 0x4EF9
61 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
62 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
64 struct FullJumpVec
66 unsigned short jmp;
67 unsigned char vec[4];
69 #define __AROS_SET_FULLJMP(v,a) \
70 do \
71 { \
72 struct FullJumpVec *_v = v; \
73 _v->jmp = __AROS_ASMJMP; \
74 *((ULONG *)(_v->vec)) = (ULONG)(a)-(ULONG)(_v)-6;\
75 } while(0)
78 /* Use these to acces a vector table */
79 #define LIB_VECTSIZE (sizeof (struct JumpVec))
80 //#define __AROS_GETJUMPVEC(lib,n) ((struct JumpVec *)(((UBYTE *)lib)-(n*LIB_VECTSIZE)))
81 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-(n)])
82 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
83 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
84 #define __AROS_INITVEC(lib,n) __AROS_GETJUMPVEC(lib,n)->jmp = __AROS_ASMJMP, \
85 __AROS_SETVECADDR(lib,n,_aros_empty_vector)
88 #define SIZEOF_ALL_REGISTERS (20*4)
91 Code to use to generate stub functions.
92 It must be *printed* with a function like printf in a file
93 to be compiled with gcc.
95 - The first parameter is the function name,
96 - The second parameter is the basename,
97 - The third parameter is the library vector to be called.
98 It's value must be computed by the stub generator with this code:
99 &(__AROS_GETJUMPVEC(0, n+1)->vec), where n is the library vector position in
100 the library vectors list.
104 #define STUBCODE_INIT \
105 "#define EMITSTUB(fname, bname, vec) " \
106 ".globl fname ; " \
107 "fname : " \
108 "movl bname , %%a0; " \
109 "movl vec(%%a0),%%a0;" \
110 "jmp (%%a0);\n" \
111 "#define EMITALIAS(fname, alias) " \
112 ".weak alias; .set alias, fname\n"
113 #define STUBCODE \
114 "EMITSTUB(%s, %s, %d) "
115 #define ALIASCODE \
116 "EMITALIAS(%s, %s)\n"
119 We want to activate the execstubs and preserve all registers
120 when calling obtainsemaphore, obtainsemaphoreshared, releasesemaphore,
121 getcc, permit, forbid, enable, disable
123 #undef UseExecstubs
124 //#define UseExecstubs 1
126 /* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
127 recognise them */
128 #undef PassThroughErrnos
129 //#define PassThroughErrnos 0x40000000
130 #define PassThroughErrnos 0
132 /* Macros to test/set failure of AllocEntry() */
133 #define AROS_ALLOCENTRY_FAILED(memType) \
134 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
135 #define AROS_CHECK_ALLOCENTRY(memList) \
136 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
139 Find the next valid alignment for a structure if the next x bytes must
140 be skipped.
142 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
144 /* Prototypes */
145 extern void _aros_not_implemented ();
146 extern void aros_not_implemented ();
149 How much stack do we need ? Lots :-) ?
150 Not so much, I think (schulz) ;-))
153 #define AROS_STACKSIZE 0x4000
155 /* How to map function arguments to CPU registers */
157 The i386 processor doesn't have enough registers to map the m68k
158 register set onto them - so simply use the compiler's calling
159 convention. The library base is mapped to the last argument so that
160 it can be ignored by the function.
163 /* What to do with the library base in header, prototype and call */
164 #define __AROS_LH_BASE(basetype,basename) basetype basename
165 #define __AROS_LP_BASE(basetype,basename) void *
166 #define __AROS_LC_BASE(basetype,basename) basename
167 #define __AROS_LD_BASE(basetype,basename) basetype
169 /* How to transform an argument in header, opt prototype, call and forced
170 prototype. */
171 #define __AROS_LHA(type,name,reg) type name
172 #define __AROS_LPA(type,name,reg) type
173 #define __AROS_LCA(type,name,reg) name
174 #define __AROS_LDA(type,name,reg) type
175 #define __AROS_UFHA(type,name,reg) type name
176 #define __AROS_UFPA(type,name,reg) type
177 #define __AROS_UFCA(type,name,reg) name
178 #define __AROS_UFDA(type,name,reg) type
179 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
180 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
181 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
183 /* Prefix for library function in header, prototype and call */
184 #define __AROS_LH_PREFIX /* eps */
185 #define __AROS_LP_PREFIX /* eps */
186 #define __AROS_LC_PREFIX /* eps */
187 #define __AROS_LD_PREFIX /* eps */
188 #define __AROS_UFH_PREFIX /* eps */
189 #define __AROS_UFP_PREFIX /* eps */
190 #define __AROS_UFC_PREFIX /* eps */
191 #define __AROS_UFD_PREFIX /* eps */
193 /* if this is defined, all AROS_LP*-macros will expand to nothing. */
194 #define __AROS_USE_MACROS_FOR_LIBCALL
196 #define __UFC3R(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,p) \
198 long _n1 = (long)(n1);\
199 long _n2 = (long)(n2);\
200 long _n3 = (long)(n3);\
201 long _re;\
202 __asm__ __volatile__(\
203 "move.l %5,-(%%sp)\n\t"\
204 "move.l %4,-(%%sp)\n\t"\
205 "move.l %3,-(%%sp)\n\t"\
206 "move.l %%sp,%1\n\t"\
207 "move.l %2,%%a0\n\t"\
208 "jsr (%%a0)\n\t"\
209 "adda.l #12,%%sp\n\t"\
210 "movl %%d0,%0"\
211 : "=g"(_re), "=m"(*(APTR *)p)\
212 : "ad"(n), "g"(_n1), "g"(_n2), "g"(_n3)\
213 : "cc", "memory", "%d0" );\
214 (t)_re;\
216 #define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p)
218 #endif /* AROS_MACHINE_H */