Fixed binary search: no more infinite loops when vendor is unknown.
[tangerine.git] / arch / .unmaintained / arm-all / include / aros / machine.h
blobd1b3226c8da21c62529ff3183f80d54362ee9b04
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 a ULONG */
20 #define AROS_WORDALIGN 4 /* 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 SIZEOF_ALL_REGISTERS (20*4)
29 #define AROS_GET_SYSBASE struct ExecBase * SysBase = *(struct ExecBase **)0x4;
30 #define AROS_GET_DOSBASE struct DosLibrary * DOSBase = (struct DosLibrary *)OpenLibrary((UBYTE *)"dos.library",0); \
31 CloseLibrary(DOSBase);
32 #define AROS_GET_SYSBASE_OK struct ExecBase * SysBase = *(struct ExecBase **)0x4;
34 /* do we need a function attribute to get parameters on the stack? */
35 #define __stackparm
37 /* ??? */
38 #define SP_OFFSET 0
41 One entry in a libraries' jumptable. For assembler compatibility, the
42 field jmp should contain the code for an absolute jmp to a 32bit
43 address. There are also a couple of macros which you should use to
44 access the vector table from C.
46 struct FullJumpVec
48 unsigned short jmp; // not necessary - if this leaves, change machine.i offsets!
49 unsigned char vec[4];
52 struct JumpVec
54 unsigned char vec[4];
57 /* Internal macros */
58 #define __AROS_SET_VEC(v,a) (*(ULONG*)(v)->vec=(ULONG)(a))
59 #define __AROS_GET_VEC(v) ((APTR)(*(ULONG*)(v)->vec))
62 /* Use these to acces a vector table */
63 #define LIB_VECTSIZE (sizeof (struct JumpVec))
64 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-n])
65 #define __AROS_GETVECADDR(lib,n) (__AROS_GET_VEC(__AROS_GETJUMPVEC(lib,n)))
66 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_SET_VEC(__AROS_GETJUMPVEC(lib,n),(APTR)(addr)))
67 #define __AROS_INITVEC(lib,n) __AROS_SETVECADDR(lib,n,_aros_not_implemented)
72 Code to use to generate stub functions.
73 It must be *printed* with a function like printf in a file
74 to be compiled with gcc.
76 - The first parameter is the function name,
77 - The second parameter is the basename,
78 - The third parameter is the library vector to be called.
79 It's value must be computed by the stub generator with this code:
80 &(__AROS_GETJUMPVEC(0, n+1)->vec), where n is the library vector position in
81 the library vectors list.
85 #define STUBCODE \
86 "#define EMITSTUB(fname, bname, vec) " \
87 ".globl fname ; " \
88 "fname : " \
89 "ldr r0, .L1; " \
90 "ldr r0 , [r0, $ vec ]; " \
91 "mov pc, r0;" \
92 ".L1: .word bname;\n" \
93 "EMITSTUB(%s, %s, %d) "
96 We want to activate the execstubs and preserve all registers
97 when calling obtainsemaphore, obtainsemaphoreshared, releasesemaphore,
98 getcc, permit, forbid, enable, disable
100 #undef UseExecstubs
101 //#define UseExecstubs 1
103 /* For debugging only: Pass errnos from the emulated OS. dos/Fault() will
104 recognise them */
105 #undef PassThroughErrnos
106 #define PassThroughErrnos 0x40000000
108 /* Macros to test/set failure of AllocEntry() */
109 #define AROS_ALLOCENTRY_FAILED(memType) \
110 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
111 #define AROS_CHECK_ALLOCENTRY(memList) \
112 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
115 Find the next valid alignment for a structure if the next x bytes must
116 be skipped.
118 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
120 /* Prototypes */
121 extern void _aros_not_implemented ();
122 extern void aros_not_implemented ();
125 How much stack do we need ? Lots :-) ?
126 Not so much, I think (schulz) ;-))
129 #define AROS_STACKSIZE 0x4000
131 /* How to map function arguments to CPU registers */
133 The ARM processor has enough registers to map the m68k
134 registers set onto them - but right now I don't care.
135 I just use the calling convention of the compiler.
138 /* What to do with the library base in header, prototype and call */
139 #define __AROS_LH_BASE(basetype,basename) basetype basename
140 #define __AROS_LP_BASE(basetype,basename) void *
141 #define __AROS_LC_BASE(basetype,basename) basename
142 #define __AROS_LD_BASE(basetype,basename) basetype
144 /* How to transform an argument in header, opt prototype, call and forced
145 prototype. */
146 #define __AROS_LHA(type,name,reg) type name
147 #define __AROS_LPA(type,name,reg) type
148 #define __AROS_LCA(type,name,reg) name
149 #define __AROS_LDA(type,name,reg) type
150 #define __AROS_UFHA(type,name,reg) type name
151 #define __AROS_UFPA(type,name,reg) type
152 #define __AROS_UFCA(type,name,reg) name
153 #define __AROS_UFDA(type,name,reg) type
154 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
155 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
156 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
158 /* Prefix for library function in header, prototype and call */
159 #define __AROS_LH_PREFIX /* eps */
160 #define __AROS_LP_PREFIX /* eps */
161 #define __AROS_LC_PREFIX /* eps */
162 #define __AROS_LD_PREFIX /* eps */
163 #define __AROS_UFH_PREFIX /* eps */
164 #define __AROS_UFP_PREFIX /* eps */
165 #define __AROS_UFC_PREFIX /* eps */
166 #define __AROS_UFD_PREFIX /* eps */
168 /* if this is defined, all AROS_LP*-macros will expand to nothing. */
169 #define __AROS_USE_MACROS_FOR_LIBCALL
171 #define __UFC3R(t,n,t1,n1,r1,t2,n2,r2,t3,n3,r3,p) \
173 long _n1 = (long)(n1);\
174 long _n2 = (long)(n2);\
175 long _n3 = (long)(n3);\
176 long _re;\
177 __asm__ __volatile__(\
178 "ldr %%r0, %1\n\t"\
179 "str %%sp,[%%r0, $0]\n\t"\
180 "mov %%r2,%5\n\t"\
181 "mov %%r1,%4\n\t"\
182 "mov %%r0,%3\n\t"\
183 "mov %%lr,%%pc\n\t"\
184 "mov %%pc,%2\n\t"\
185 "str %%r0,%0"\
186 : "=m"(_re), "=m"(*(int *)p)\
187 : "r"(n), "r"(_n1), "r"(_n2), "r"(_n3)\
188 : "cc", "memory", "%r0", "%r1", "%r2" );\
189 (t)_re;\
191 #define AROS_UFC3R(t,n,a1,a2,a3,p,ss) __UFC3R(t,n,a1,a2,a3,p)
193 #endif /* AROS_MACHINE_H */