4 Copyright © 1995-2006, The AROS Development Team. All rights reserved.
7 NOTE: This file must compile *without* any other header !
9 Desc: machine.h include file for Linux/PPC
13 #define AROS_STACK_GROWS_DOWNWARDS 1 /* Stack direction */
14 #define AROS_BIG_ENDIAN 1 /* Big or little endian */
15 #define AROS_SIZEOFULONG 4 /* Size of an ULONG */
16 #define AROS_WORDALIGN 2 /* Alignment for WORD */
17 #define AROS_LONGALIGN 4 /* Alignment for LONG */
18 #define AROS_PTRALIGN 4 /* Alignment for PTR */
19 #define AROS_IPTRALIGN 4 /* Alignment for IPTR */
20 #define AROS_DOUBLEALIGN 4 /* Alignment for double */
21 #define AROS_WORSTALIGN 8 /* Worst case alignment */
23 #define AROS_GET_SYSBASE extern struct ExecBase *SysBase;
24 #define AROS_GET_DOSBASE extern struct DosLibrary *DOSBase;
25 #define AROS_GET_SYSBASE_OK extern struct ExecBase *SysBase;
27 /* do we need a function attribute to get parameters on the stack? */
28 #define __stackparm __attribute__((stackparm))
30 register unsigned char* AROS_GET_SP
asm("%sp");
32 #define FLUSH_CACHES 1
33 #define CACHE_BLOCK_SIZE 32
35 #define DATA_CACHE_BST(x) \
36 __asm__ __volatile__ ( \
41 #define INSTR_CACHE_BINV(x) \
42 __asm__ __volatile__ ( \
47 #define SYNC __asm__ __volatile__ ("sync" )
48 #define ISYNC __asm__ __volatile__ ("isync")
51 An offset value sometimes added to
52 or subtracted from the stack limits.
58 One entry in a libraries' jumptable. For assembler compatibility, the
59 field jmp should contain the code for an absolute jmp to a 32bit
60 address. There are also a couple of macros which you should use to
61 access the vector table from C.
65 unsigned long addis
; // simplified: lis 11, a@h
66 unsigned long ori
; // : li 11, a@l
67 unsigned long mtspr
; // : mtctr 11
68 unsigned long jmp
; // bcctr : bctr 11
70 /* browse MPCFPE32B.pdf to understand opcode creation */
71 #define __AROS_SET_FULLJMP(v,a)\
73 struct FullJumpVec *_v = (v); \
74 _v->addis = (15 << 26) | (11 << 21) | ((ULONG)(a) >> 16); \
75 _v->ori = (24 << 26) | (11 << 21) | (11 << 16) | ((ULONG)(a) & 0x0000FFFF);\
76 _v->mtspr = (31 << 26) | (11 << 21) | ( 9 << 16) | (467 << 1); \
77 _v->jmp = (19 << 26) | (20 << 21) | (528 << 1); \
81 Extracts and stores the start address from a loaded
82 executable segment. start_address may then be used by gdb.
84 #define __AROS_SET_START_ADDR(debug_segnode)\
86 struct FullJumpVec *_v = (struct FullJumpVec *) ((debug_segnode)->seglist + 4);\
87 (debug_segnode)->start_address = (IPTR) ((_v->addis & 0x0000FFFF) << 16); \
88 (debug_segnode)->start_address |= (IPTR) (_v->ori & 0x0000FFFF); \
97 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
98 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
100 /* Use these to acces a vector table */
101 #define LIB_VECTSIZE (sizeof (struct JumpVec))
102 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-(n)])
103 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
104 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
105 #define __AROS_INITVEC(lib,n) __AROS_SETVECADDR(lib,n,_aros_not_implemented)
108 Code to use to generate stub functions.
109 It must be *printed* with a function like printf in a file
110 to be compiled with gcc.
112 - The first parameter is the function name,
113 - The second parameter is the basename,
114 i.e. bname is the address of a pointer to the library base,
115 - The third parameter is the library vector to be called.
117 It's value must be computed by the stub generator with this code:
118 &(__AROS_GETJUMPVEC(0, n+1)->vec), where n is the library vector position in
119 the library vectors list.
122 #define STUBCODE_INIT \
123 "#define EMITSTUB(fname, bname, vec) " \
126 "lis 11,bname@ha; " \
127 "lwz 11,bname@l(11); " \
131 "#define EMITALIAS(fname, alias) " \
132 ".weak alias; .set alias, fname\n"
134 "EMITSTUB(%s, %s, %d) "
136 "EMITALIAS(%s, %s)\n"
138 We want to activate the execstubs and preserve all registers
139 when calling obtainsemaphore, obtainsemaphoreshared, releasesemaphore,
140 getcc, permit, forbid, enable, disable
143 #define UseExecstubs 1
145 /* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
147 #undef PassThroughErrnos
148 #define PassThroughErrnos 0x40000000
150 /* Macros to test/set failure of AllocEntry() */
151 #define AROS_ALLOCENTRY_FAILED(memType) \
152 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
153 #define AROS_CHECK_ALLOCENTRY(memList) \
154 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
157 Find the next valid alignment for a structure if the next x bytes must
160 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
163 extern void _aros_not_implemented (char *);
165 /* How much stack do we need ? Lots :-) */
166 #define AROS_STACKSIZE 40960
168 /* How to map function arguments to CPU registers */
170 The i386 processor doesn't have enough registers to map the m68k
171 register set onto them - so simply use the compiler's calling
172 convention. The library base is mapped to the last argument so that
173 it can be ignored by the function.
176 /* What to do with the library base in header, prototype and call */
177 #define __AROS_LH_BASE(basetype,basename) basetype basename
178 #define __AROS_LP_BASE(basetype,basename) void *
179 #define __AROS_LC_BASE(basetype,basename) basename
180 #define __AROS_LD_BASE(basetype,basename) basetype
182 /* How to transform an argument in header, opt prototype, call and forced
184 #define __AROS_LHA(type,name,reg) type name
185 #define __AROS_LPA(type,name,reg) type
186 #define __AROS_LCA(type,name,reg) name
187 #define __AROS_LDA(type,name,reg) type
188 #define __AROS_UFHA(type,name,reg) type name
189 #define __AROS_UFPA(type,name,reg) type
190 #define __AROS_UFCA(type,name,reg) name
191 #define __AROS_UFDA(type,name,reg) type
192 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
193 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
194 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
195 #define __AROS_LDAQUAD(type,name,reg1,reg2) type
197 /* Prefix for library function in header, prototype and call */
198 #define __AROS_LH_PREFIX /* eps */
199 #define __AROS_LP_PREFIX /* eps */
200 #define __AROS_LC_PREFIX /* eps */
201 #define __AROS_LD_PREFIX /* eps */
202 #define __AROS_UFH_PREFIX /* eps */
203 #define __AROS_UFP_PREFIX /* eps */
204 #define __AROS_UFC_PREFIX /* eps */
205 #define __AROS_UFD_PREFIX /* eps */
207 /* if this is defined, all AROS_LP*-macros will expand to nothing. */
208 #define __AROS_USE_MACROS_FOR_LIBCALL
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);\
215 __asm__ __volatile__(\
221 "stwu 1,-12(1)\n\t" \
231 : "=r"(_re), "=m"(*(APTR *)p)\
232 : "r"(_n), "r"(_n1), "r"(_n2), "r"(_n3)\
233 : "cc", "memory", "0", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13");\
236 #define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p)
237 #endif /* AROS_MACHINE_H */