Add {WA_Shape, 0} to avoid Intuition and App
[tangerine.git] / arch / i386-all / machine.h
blob1b9c2ecc68cd0eebeb80d55fec6d376a8ebf5d1d
1 #ifndef AROS_MACHINE_H
2 #define AROS_MACHINE_H
3 /*
4 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
5 $Id$
7 NOTE: This file must compile *without* any other header !
9 Desc: machine.h include file for Linux/i386 and FreeBSD/i386
10 Lang: english
13 /* Information generated by machine.c */
14 #define AROS_STACK_GROWS_DOWNWARDS 1
15 #define AROS_BIG_ENDIAN 0
16 #define AROS_SIZEOFULONG 4 /* Size of an ULONG */
17 #define AROS_WORDALIGN 2 /* Alignment for WORD */
18 #define AROS_LONGALIGN 4 /* Alignment for LONG */
19 #define AROS_PTRALIGN 4 /* Alignment for PTR */
20 #define AROS_IPTRALIGN 4 /* Alignment for IPTR */
21 #define AROS_DOUBLEALIGN 4 /* Alignment for double */
22 #define AROS_WORSTALIGN 4 /* Worst case alignment */
24 #define AROS_GET_SYSBASE extern struct ExecBase *SysBase;
25 #define AROS_GET_DOSBASE extern struct DosLibrary *DOSBase;
26 #define AROS_GET_SYSBASE_OK extern struct ExecBase *SysBase;
28 /* do we need a function attribute to get parameters on the stack? */
29 #define __stackparm
31 #ifndef __TINYC__
32 register unsigned char * AROS_GET_SP asm("%esp");
33 #endif
35 /* ??? */
36 #define SP_OFFSET 0
39 One entry in a libraries' jumptable. For assembler compatibility, the
40 field jmp should contain the code for an absolute jmp to a 32bit
41 address. There are also a couple of macros which you should use to
42 access the vector table from C.
44 struct FullJumpVec
46 unsigned char jmp;
47 unsigned char vec[4];
49 #define __AROS_SET_FULLJMP(v,a) \
50 do \
51 { \
52 struct FullJumpVec *_v = v; \
53 _v->jmp = 0xE9; \
54 *((ULONG *)(_v->vec))=(ULONG)(a)-(ULONG)(_v)-5;\
55 } while (0)
58 Extracts and stores the start address from a loaded
59 executable segment. start_address may then be used by gdb.
60 It is calculated from _v->vec set in __AROS_SET_FULLJMP.
62 #define __AROS_SET_START_ADDR(debug_segnode)\
63 do \
64 { \
65 (debug_segnode)->start_address \
66 = (IPTR)((debug_segnode)->seglist + 4) + 5 + *(IPTR *)((char *)((debug_segnode)->seglist + 4) + 1); \
67 } while (0)
69 struct JumpVec
71 unsigned char vec[4];
73 /* Internal macros */
74 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
75 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
77 /* Use these to acces a vector table */
78 #define LIB_VECTSIZE (sizeof (struct JumpVec))
79 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-(n)])
80 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
81 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
82 #define __AROS_INITVEC(lib,n) __AROS_SETVECADDR(lib,n,_aros_not_implemented)
85 Code to use to generate stub functions in an assembly file.
86 It consist of two parts.
87 The first part is STUBCODE_INIT which has to be printed
88 once in a source file with fprintf or fputs.
89 The second part has to be printed for every function one wants to
90 include in the source file. It has to be printed with a printf-like
91 function and has to be followed by three parameters:
93 - The first parameter is the function name,
94 - The second parameter is the basename,
95 - The third parameter is the library vector to be called.
96 It's value must be computed by the stub generator with this code:
97 &(__AROS_GETJUMPVEC(0, n+1)->vec), where n is the library vector position in
98 the library vectors list.
102 #define STUBCODE_INIT \
103 "#define EMITSTUB(fname, bname, vec) " \
104 ".weak fname ; " \
105 "fname : " \
106 "movl bname , %%eax; " \
107 "jmp *vec(%%eax);\n" \
108 "#define EMITALIAS(fname, alias) " \
109 ".weak alias; .set alias, fname\n"
110 #define STUBCODE \
111 "EMITSTUB(%s, %s, %d)\n"
112 #define ALIASCODE \
113 "EMITALIAS(%s, %s)\n"
116 We want to activate the execstubs and preserve all registers
117 when calling obtainsemaphore, obtainsemaphoreshared, releasesemaphore,
118 getcc, permit, forbid, enable, disable
120 #undef UseExecstubs
121 #define UseExecstubs 1
123 /* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
124 recognise them */
125 #undef PassThroughErrnos
126 #define PassThroughErrnos 0x40000000
128 /* Macros to test/set failure of AllocEntry() */
129 #define AROS_ALLOCENTRY_FAILED(memType) \
130 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
131 #define AROS_CHECK_ALLOCENTRY(memList) \
132 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
135 Find the next valid alignment for a structure if the next x bytes must
136 be skipped.
138 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
140 /* Prototypes */
141 extern void _aros_not_implemented (char *);
143 /* How much stack do we need ? Lots :-) */
144 #define AROS_STACKSIZE 40960
146 /* How to map function arguments to CPU registers */
148 The i386 processor doesn't have enough registers to map the m68k
149 register set onto them - so simply use the compiler's calling
150 convention. The library base is mapped to the last argument so that
151 it can be ignored by the function.
154 /* What to do with the library base in header, prototype and call */
155 #define __AROS_LH_BASE(basetype,basename) basetype basename
156 #define __AROS_LP_BASE(basetype,basename) void *
157 #define __AROS_LC_BASE(basetype,basename) basename
158 #define __AROS_LD_BASE(basetype,basename) basetype
160 /* How to transform an argument in header, opt prototype, call and forced
161 prototype. */
162 #define __AROS_LHA(type,name,reg) type name
163 #define __AROS_LPA(type,name,reg) type
164 #define __AROS_LCA(type,name,reg) name
165 #define __AROS_LDA(type,name,reg) type
166 #define __AROS_UFHA(type,name,reg) type name
167 #define __AROS_UFPA(type,name,reg) type
168 #define __AROS_UFCA(type,name,reg) name
169 #define __AROS_UFDA(type,name,reg) type
170 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
171 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
172 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
173 #define __AROS_LDAQUAD(type,name,reg1,reg2) type
175 /* Prefix for library function in header, prototype and call */
176 #define __AROS_LH_PREFIX /* eps */
177 #define __AROS_LP_PREFIX /* eps */
178 #define __AROS_LC_PREFIX /* eps */
179 #define __AROS_LD_PREFIX /* eps */
180 #define __AROS_UFH_PREFIX /* eps */
181 #define __AROS_UFP_PREFIX /* eps */
182 #define __AROS_UFC_PREFIX /* eps */
183 #define __AROS_UFD_PREFIX /* eps */
185 /* if this is defined, all AROS_LP*-macros will expand to nothing. */
186 #define __AROS_USE_MACROS_FOR_LIBCALL
188 #define __UFC3R(_t,_n,t1,n1,r1,t2,n2,r2,t3,n3,r3,p) \
190 long _n1 = (long)(n1);\
191 long _n2 = (long)(n2);\
192 long _n3 = (long)(n3);\
193 long _re;\
194 __asm__ __volatile__(\
195 "movl %5,%%eax\n\t"\
196 "pushl %%eax\n\t"\
197 "movl %4,%%eax\n\t"\
198 "pushl %%eax\n\t"\
199 "movl %3,%%eax\n\t"\
200 "pushl %%eax\n\t"\
201 "movl %%esp,%1\n\t"\
202 "movl %2,%%eax\n\t"\
203 "call *%%eax\n\t"\
204 "lea 12(%%esp),%%esp\n\t"\
205 "movl %%eax,%0"\
206 : "=g"(_re), "=m"(*(APTR *)p)\
207 : "ad"(_n), "g"(_n1), "g"(_n2), "g"(_n3)\
208 : "cc", "memory", "%eax" );\
209 (_t)_re;\
211 #define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p)
213 #endif /* AROS_MACHINE_H */