define AROS_32BIT_TYPE to be int
[tangerine.git] / arch / i386-all / include / aros / i386 / cpu.h
blobce0069c087dda0b1f0d8859f6d5333640b0802f2
1 #ifndef AROS_I386_CPU_H
2 #define AROS_I386_CPU_H
3 /*
4 Copyright © 1995-2007, 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 /* do we need a function attribute to get parameters on the stack? */
35 #define __stackparm
37 /* types and limits for sig_atomic_t */
38 #define AROS_SIG_ATOMIC_T int
39 #define AROS_SIG_ATOMIC_MIN (-0x7fffffff-1)
40 #define AROS_SIG_ATOMIC_MAX 0x7fffffff
42 #ifndef __TINYC__
43 register unsigned char * AROS_GET_SP __asm__("%esp");
44 #endif
46 /* ??? */
47 #define SP_OFFSET 0
50 One entry in a libraries' jumptable. For assembler compatibility, the
51 field jmp should contain the code for an absolute jmp to a 32bit
52 address. There are also a couple of macros which you should use to
53 access the vector table from C.
55 struct FullJumpVec
57 unsigned char jmp;
58 unsigned char vec[4];
60 #define __AROS_SET_FULLJMP(v,a) \
61 do \
62 { \
63 struct FullJumpVec *_v = v; \
64 _v->jmp = 0xE9; \
65 *((ULONG *)(_v->vec))=(ULONG)(a)-(ULONG)(_v)-5;\
66 } while (0)
70 Extracts and stores the start address from a loaded
71 executable segment. start_address may then be used by gdb.
72 It is calculated from _v->vec set in __AROS_SET_FULLJMP.
74 #define __AROS_SET_START_ADDR(debug_segnode)\
75 do \
76 { \
77 (debug_segnode)->start_address \
78 = (IPTR)((debug_segnode)->seglist + 4) + 5 + *(IPTR *)((char *)((debug_segnode)->seglist + 4) + 1); \
79 } while (0)
81 struct JumpVec
83 unsigned char vec[4];
86 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
87 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
89 /* Use these to acces a vector table */
90 #define LIB_VECTSIZE (sizeof (struct JumpVec))
91 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-(n)])
92 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
93 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
94 #define __AROS_INITVEC(lib,n) __AROS_SETVECADDR(lib,n,_aros_not_implemented)
97 Code to use to generate stub functions.
98 It must be *printed* with a function like printf in a file
99 to be compiled with gcc.
101 - The first parameter is the function name,
102 - The second parameter is the basename,
103 - The third parameter is the library vector to be called.
104 It's value must be computed by the stub generator with this code:
105 &(__AROS_GETJUMPVEC(0, n+1)->vec), where n is the library vector position in
106 the library vectors list.
110 #define STUBCODE_INIT \
111 "#define EMITSTUB(fname, bname, vec) " \
112 ".weak fname ; " \
113 "fname : " \
114 "movl bname , %%eax; " \
115 "jmp *vec(%%eax);\n" \
116 "#define EMITALIAS(fname, alias) " \
117 ".weak alias; .set alias, fname\n"
118 #define STUBCODE \
119 "EMITSTUB(%s, %s, %d)\n"
120 #define ALIASCODE \
121 "EMITALIAS(%s, %s)\n"
124 We want to activate the execstubs and preserve all registers
125 when calling obtainsemaphore, obtainsemaphoreshared, releasesemaphore,
126 getcc, permit, forbid, enable, disable
128 #undef UseExecstubs
129 #define UseExecstubs 1
131 /* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
132 recognise them */
134 NOT DO THIS ON NATIVE
135 #undef PassThroughErrnos
136 #define PassThroughErrnos 0x40000000
139 /* Macros to test/set failure of AllocEntry() */
140 #define AROS_ALLOCENTRY_FAILED(memType) \
141 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
142 #define AROS_CHECK_ALLOCENTRY(memList) \
143 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
146 Find the next valid alignment for a structure if the next x bytes must
147 be skipped.
149 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
151 /* Prototypes */
152 extern void _aros_not_implemented ();
153 extern void aros_not_implemented ();
156 How much stack do we need ? Lots :-) ?
157 Not so much, I think (schulz) ;-))
160 #define AROS_STACKSIZE 40960
162 /* How to map function arguments to CPU registers */
164 The i386 processor doesn't have enough registers to map the m68k
165 register set onto them - so simply use the compiler's calling
166 convention. The library base is mapped to the last argument so that
167 it can be ignored by the function.
170 /* What to do with the library base in header, prototype and call */
171 #define __AROS_LH_BASE(basetype,basename) basetype basename
172 #define __AROS_LP_BASE(basetype,basename) void *
173 #define __AROS_LC_BASE(basetype,basename) basename
174 #define __AROS_LD_BASE(basetype,basename) basetype
176 /* How to transform an argument in header, opt prototype, call and forced
177 prototype. */
178 #define __AROS_LHA(type,name,reg) type name
179 #define __AROS_LPA(type,name,reg) type
180 #define __AROS_LCA(type,name,reg) name
181 #define __AROS_LDA(type,name,reg) type
182 #define __AROS_UFHA(type,name,reg) type name
183 #define __AROS_UFPA(type,name,reg) type
184 #define __AROS_UFCA(type,name,reg) name
185 #define __AROS_UFDA(type,name,reg) type
186 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
187 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
188 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
189 #define __AROS_LDAQUAD(type,name,reg1,reg2) type
191 /* Prefix for library function in header, prototype and call */
192 #define __AROS_LH_PREFIX /* eps */
193 #define __AROS_LP_PREFIX /* eps */
194 #define __AROS_LC_PREFIX /* eps */
195 #define __AROS_LD_PREFIX /* eps */
196 #define __AROS_UFH_PREFIX /* eps */
197 #define __AROS_UFP_PREFIX /* eps */
198 #define __AROS_UFC_PREFIX /* eps */
199 #define __AROS_UFD_PREFIX /* eps */
201 /* if this is defined, all AROS_LP*-macros will expand to nothing. */
202 #define __AROS_USE_MACROS_FOR_LIBCALL
204 #define __UFC3R(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,p) \
206 long _n1 = (long)(n1);\
207 long _n2 = (long)(n2);\
208 long _n3 = (long)(n3);\
209 long _re;\
210 __asm__ __volatile__(\
211 "movl %5,%%eax\n\t"\
212 "pushl %%eax\n\t"\
213 "movl %4,%%eax\n\t"\
214 "pushl %%eax\n\t"\
215 "movl %3,%%eax\n\t"\
216 "pushl %%eax\n\t"\
217 "movl %%esp,%1\n\t"\
218 "movl %2,%%eax\n\t"\
219 "call *%%eax\n\t"\
220 "lea 12(%%esp),%%esp\n\t"\
221 "movl %%eax,%0"\
222 : "=g"(_re), "=m"(*(APTR *)p)\
223 : "ad"(n), "g"(_n1), "g"(_n2), "g"(_n3)\
224 : "cc", "memory", "%eax" );\
225 (t)_re;\
227 #define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p)
229 #endif /* AROS_I386_CPU_H */