only bring in as many sdl things as are strictly necessary
[tangerine.git] / arch / i386-all / include / aros / i386 / cpu.h
blob965973e15581f4efa1da135b1830eb3876d08d1d
1 #ifndef AROS_I386_CPU_H
2 #define AROS_I386_CPU_H
3 /*
4 Copyright © 1995-2008, 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 #define EnableSetFunction 1
15 /* Information about size and alignment,
16 * the defines have to be numeric constants */
17 #define AROS_STACK_GROWS_DOWNWARDS 1 /* Stack direction */
18 #define AROS_BIG_ENDIAN 0 /* Big or little endian */
19 #define AROS_SIZEOFULONG 4 /* Size of an ULONG */
20 #define AROS_SIZEOFPTR 4 /* Size of a PTR */
21 #define AROS_WORDALIGN 2 /* Alignment for WORD */
22 #define AROS_LONGALIGN 4 /* Alignment for LONG */
23 #define AROS_QUADALIGN 4 /* Alignment for QUAD */
24 #define AROS_PTRALIGN 4 /* Alignment for PTR */
25 #define AROS_IPTRALIGN 4 /* Alignment for IPTR */
26 #define AROS_DOUBLEALIGN 4 /* Alignment for double */
27 #define AROS_WORSTALIGN 4 /* Worst case alignment */
29 #define SIZEOF_FPU_STATE 512 /* 108 bytes are needed to store FPU, 512 bytes are needed to store SSE */
30 #define SIZEOF_ALL_REGISTERS (15*4 + SIZEOF_FPU_STATE + 16) /* Size of iet_Context */
32 #define AROS_32BIT_TYPE int
34 /* Use C pointer and string for the BCPL pointers and strings
35 * For a normal ABI these should not be defined for maximum source code
36 * compatibility.
38 #define AROS_FAST_BPTR 1
39 #define AROS_FAST_BSTR 1
41 /* do we need a function attribute to get parameters on the stack? */
42 #define __stackparm
44 /* types and limits for sig_atomic_t */
45 #define AROS_SIG_ATOMIC_T int
46 #define AROS_SIG_ATOMIC_MIN (-0x7fffffff-1)
47 #define AROS_SIG_ATOMIC_MAX 0x7fffffff
49 #ifndef __TINYC__
50 register unsigned char * AROS_GET_SP __asm__("%esp");
51 #endif
53 /* ??? */
54 #define SP_OFFSET 0
57 One entry in a libraries' jumptable. For assembler compatibility, the
58 field jmp should contain the code for an absolute jmp to a 32bit
59 address. There are also a couple of macros which you should use to
60 access the vector table from C.
62 struct FullJumpVec
64 unsigned char jmp;
65 unsigned char vec[4];
67 #define __AROS_SET_FULLJMP(v,a) \
68 do \
69 { \
70 struct FullJumpVec *_v = v; \
71 _v->jmp = 0xE9; \
72 *((ULONG *)(_v->vec))=(ULONG)(a)-(ULONG)(_v)-5;\
73 } while (0)
77 Extracts and stores the start address from a loaded
78 executable segment. start_address may then be used by gdb.
79 It is calculated from _v->vec set in __AROS_SET_FULLJMP.
81 #define __AROS_SET_START_ADDR(debug_segnode)\
82 do \
83 { \
84 (debug_segnode)->start_address \
85 = (IPTR)(BADDR((debug_segnode)->seglist) + 4) + 5 + *(IPTR *)((char *)(BADDR((debug_segnode)->seglist) + 4) + 1); \
86 } while (0)
88 struct JumpVec
90 unsigned char vec[4];
93 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
94 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
96 /* Use these to acces a vector table */
97 #define LIB_VECTSIZE (sizeof (struct JumpVec))
98 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-(n)])
99 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
100 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
101 #define __AROS_INITVEC(lib,n) __AROS_SETVECADDR(lib,n,_aros_not_implemented)
104 Code to use to generate stub functions.
105 It must be *printed* with a function like printf in a file
106 to be compiled with gcc.
108 - The first parameter is the function name,
109 - The second parameter is the basename,
110 - The third parameter is the library vector to be called.
111 It's value must be computed by the stub generator with this code:
112 &(__AROS_GETJUMPVEC(0, n+1)->vec), where n is the library vector position in
113 the library vectors list.
117 #define STUBCODE_INIT \
118 "#define EMITSTUB(fname, bname, vec) " \
119 ".weak fname ; " \
120 "fname : " \
121 "movl bname , %%eax; " \
122 "jmp *vec(%%eax);\n" \
123 "#define EMITALIAS(fname, alias) " \
124 ".weak alias; .set alias, fname\n"
125 #define STUBCODE \
126 "EMITSTUB(%s, %s, %d)\n"
127 #define ALIASCODE \
128 "EMITALIAS(%s, %s)\n"
131 We want to activate the execstubs and preserve all registers
132 when calling obtainsemaphore, obtainsemaphoreshared, releasesemaphore,
133 getcc, permit, forbid, enable, disable
135 #undef UseExecstubs
136 #define UseExecstubs 1
138 /* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
139 recognise them */
141 NOT DO THIS ON NATIVE
142 #undef PassThroughErrnos
143 #define PassThroughErrnos 0x40000000
146 /* Macros to test/set failure of AllocEntry() */
147 #define AROS_ALLOCENTRY_FAILED(memType) \
148 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
149 #define AROS_CHECK_ALLOCENTRY(memList) \
150 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
153 Find the next valid alignment for a structure if the next x bytes must
154 be skipped.
156 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
158 /* Prototypes */
159 extern void _aros_not_implemented ();
160 extern void aros_not_implemented ();
163 How much stack do we need ? Lots :-) ?
164 Not so much, I think (schulz) ;-))
167 #define AROS_STACKSIZE 40960
169 /* How to map function arguments to CPU registers */
171 The i386 processor doesn't have enough registers to map the m68k
172 register set onto them - so simply use the compiler's calling
173 convention. The library base is mapped to the last argument so that
174 it can be ignored by the function.
177 /* What to do with the library base in header, prototype and call */
178 #define __AROS_LH_BASE(basetype,basename) basetype basename
179 #define __AROS_LP_BASE(basetype,basename) void *
180 #define __AROS_LC_BASE(basetype,basename) basename
181 #define __AROS_LD_BASE(basetype,basename) basetype
183 /* How to transform an argument in header, opt prototype, call and forced
184 prototype. */
185 #define __AROS_LHA(type,name,reg) type name
186 #define __AROS_LPA(type,name,reg) type
187 #define __AROS_LCA(type,name,reg) name
188 #define __AROS_LDA(type,name,reg) type
189 #define __AROS_UFHA(type,name,reg) type name
190 #define __AROS_UFPA(type,name,reg) type
191 #define __AROS_UFCA(type,name,reg) name
192 #define __AROS_UFDA(type,name,reg) type
193 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
194 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
195 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
196 #define __AROS_LDAQUAD(type,name,reg1,reg2) type
198 /* Prefix for library function in header, prototype and call */
199 #define __AROS_LH_PREFIX /* eps */
200 #define __AROS_LP_PREFIX /* eps */
201 #define __AROS_LC_PREFIX /* eps */
202 #define __AROS_LD_PREFIX /* eps */
203 #define __AROS_UFH_PREFIX /* eps */
204 #define __AROS_UFP_PREFIX /* eps */
205 #define __AROS_UFC_PREFIX /* eps */
206 #define __AROS_UFD_PREFIX /* eps */
209 #define __UFC3R(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,p) \
211 long _n1 = (long)(n1);\
212 long _n2 = (long)(n2);\
213 long _n3 = (long)(n3);\
214 long _re;\
215 __asm__ __volatile__(\
216 "movl %5,%%eax\n\t"\
217 "pushl %%eax\n\t"\
218 "movl %4,%%eax\n\t"\
219 "pushl %%eax\n\t"\
220 "movl %3,%%eax\n\t"\
221 "pushl %%eax\n\t"\
222 "movl %%esp,%1\n\t"\
223 "movl %2,%%eax\n\t"\
224 "call *%%eax\n\t"\
225 "lea 12(%%esp),%%esp\n\t"\
226 "movl %%eax,%0"\
227 : "=g"(_re), "=m"(*(APTR *)p)\
228 : "ad"(n), "g"(_n1), "g"(_n2), "g"(_n3)\
229 : "cc", "memory", "%eax" );\
230 (t)_re;\
232 #define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p)
234 #endif /* AROS_I386_CPU_H */