clang doesnt support global registers
[AROS.git] / arch / arm-all / include / aros / cpu.h
blob4618441fd12ac68fa8c6312e8199c55b9ff1614a
1 #ifndef AROS_ARM_CPU_H
2 #define AROS_ARM_CPU_H
4 /*
5 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
6 $Id$
8 NOTE: This file must compile *without* any other header !
10 Desc: cpu.h include file for arm-le systems
11 Lang: english
14 /* Translate __ARM_ARCH_X__ definitions to a common one. Makes it easier to write conditional code. */
15 #ifdef __ARM_ARCH_2__
16 #define __ARM_ARCH__ 2
17 #endif
18 #ifdef __ARM_ARCH_3__
19 #define __ARM_ARCH__ 3
20 #endif
21 #ifdef __ARM_ARCH_4__
22 #define __ARM_ARCH__ 4
23 #endif
24 #ifdef __ARM_ARCH_5__
25 #define __ARM_ARCH__ 5
26 #endif
27 #ifdef __ARM_ARCH_6__
28 #define __ARM_ARCH__ 6
29 #endif
30 #ifdef __ARM_ARCH_7A__
31 #define __ARM_ARCH__ 7
32 #endif
34 /* Information about size and alignment,
35 * the defines have to be numeric constants */
36 #define AROS_STACK_GROWS_DOWNWARDS 1 /* Stack direction */
37 #define AROS_BIG_ENDIAN 0 /* Big or little endian */
38 #define AROS_SIZEOFULONG 4 /* Size of an ULONG */
39 #define AROS_SIZEOFPTR 4 /* Size of a PTR */
40 #define AROS_WORDALIGN 2 /* Alignment for WORD */
41 #define AROS_LONGALIGN 4 /* Alignment for LONG */
42 #define AROS_QUADALIGN 4 /* Alignment for QUAD */
43 #define AROS_PTRALIGN 4 /* Alignment for PTR */
44 #define AROS_IPTRALIGN 4 /* Alignment for IPTR */
45 #define AROS_DOUBLEALIGN 4 /* Alignment for double */
46 #define AROS_WORSTALIGN 16 /* Worst case alignment */
47 #define AROS_STACKALIGN 16 /* FIXME: is this really needed? */
49 /* define this if we have no support for linear varargs in the compiler */
50 #define NO_LINEAR_VARARGS 1
52 /* Do not use patched compiler. */
53 #define AROS_SLOWSTACKTAGS 1
54 #define AROS_SLOWSTACKMETHODS 1
55 #define AROS_SLOWSTACKHOOKS 1
57 #define AROS_32BIT_TYPE int
59 /* Use C pointer and string for the BCPL pointers and strings
60 * For a normal ABI these should not be defined for maximum source code
61 * compatibility.
63 #define AROS_FAST_BPTR 1
64 #define AROS_FAST_BSTR 1
66 /* do we need a function attribute to get parameters on the stack? */
67 #define __stackparm
69 /* types and limits for sig_atomic_t */
70 #define AROS_SIG_ATOMIC_T int
71 #define AROS_SIG_ATOMIC_MIN (-0x7fffffff-1)
72 #define AROS_SIG_ATOMIC_MAX 0x7fffffff
74 #if defined(__GNUC__) && !defined(__clang__)
75 register unsigned char* AROS_GET_SP __asm__("%sp");
76 #endif
79 One entry in a libraries' jumptable. For assembler compatibility, the
80 field jmp should contain the code for an absolute jmp to a 32bit
81 address. There are also a couple of macros which you should use to
82 access the vector table from C.
84 struct FullJumpVec
86 unsigned long jmp;
87 unsigned long vec;
89 #define __AROS_SET_FULLJMP(v,a) \
90 do \
91 { \
92 struct FullJumpVec *_v = (v); \
93 _v->jmp = 0xe51ff004; /* ldr pc, [pc, #-4] */ \
94 _v->vec = (ULONG)(a); /* .word target_address */ \
95 } while (0)
97 struct JumpVec
99 void * vec;
102 /* Use these to acces a vector table */
103 #define LIB_VECTSIZE (sizeof (struct JumpVec))
104 #define __AROS_GETJUMPVEC(lib,n) (&((struct JumpVec *)lib)[-(n)])
105 #define __AROS_GETVECADDR(lib,n) (__AROS_GETJUMPVEC(lib,n)->vec)
106 #define __AROS_SETVECADDR(lib,n,addr) (__AROS_GETJUMPVEC(lib,n)->vec = (addr))
107 #define __AROS_INITVEC(lib,n) __AROS_SETVECADDR(lib,n,_aros_not_implemented)
109 /* Register preservation is still useful. At least for stack swapping functions. */
110 #undef UseExecstubs
111 #define UseExecstubs 1
113 /* Macros to test/set failure of AllocEntry() */
114 #define AROS_ALLOCENTRY_FAILED(memType) \
115 ((struct MemList *)((IPTR)(memType) | 0x80ul<<(sizeof(APTR)-1)*8))
116 #define AROS_CHECK_ALLOCENTRY(memList) \
117 (!((IPTR)(memList) & 0x80ul<<(sizeof(APTR)-1)*8))
120 Find the next valid alignment for a structure if the next x bytes must
121 be skipped.
123 #define AROS_ALIGN(x) (((x)+AROS_WORSTALIGN-1)&-AROS_WORSTALIGN)
125 /* Prototypes */
126 extern void _aros_not_implemented ();
127 extern void aros_not_implemented ();
129 /* How much stack do we need ? Lots :-) */
130 #define AROS_STACKSIZE 40960
132 /* How to map function arguments to CPU registers */
134 The ARM processor does have enough registers to map the m68k
135 register set onto them but we will ignore this and use the compiler's calling
136 convention. The library base is mapped to the last argument so that
137 it can be ignored by the function.
140 /* What to do with the library base in header, prototype and call */
141 #define __AROS_LH_BASE(basetype,basename) basetype basename
142 #define __AROS_LP_BASE(basetype,basename) void *
143 #define __AROS_LC_BASE(basetype,basename) basename
144 #define __AROS_LD_BASE(basetype,basename) basetype
146 /* How to transform an argument in header, opt prototype, call and forced
147 prototype. */
148 #define __AROS_LHA(type,name,reg) type name
149 #define __AROS_LPA(type,name,reg) type
150 #define __AROS_LCA(type,name,reg) name
151 #define __AROS_LDA(type,name,reg) type
152 #define __AROS_UFHA(type,name,reg) type name
153 #define __AROS_UFPA(type,name,reg) type
154 #define __AROS_UFCA(type,name,reg) name
155 #define __AROS_UFDA(type,name,reg) type
156 #define __AROS_LHAQUAD(type,name,reg1,reg2) type name
157 #define __AROS_LPAQUAD(type,name,reg1,reg2) type
158 #define __AROS_LCAQUAD(type,name,reg1,reg2) name
159 #define __AROS_LDAQUAD(type,name,reg1,reg2) type
161 /* Prefix for library function in header, prototype and call */
162 #define __AROS_LH_PREFIX /* eps */
163 #define __AROS_LP_PREFIX /* eps */
164 #define __AROS_LC_PREFIX /* eps */
165 #define __AROS_LD_PREFIX /* eps */
166 #define __AROS_UFH_PREFIX /* eps */
167 #define __AROS_UFP_PREFIX /* eps */
168 #define __AROS_UFC_PREFIX /* eps */
169 #define __AROS_UFD_PREFIX /* eps */
172 * This must be placed before every call to host OS on hosted AROS.
173 * On ARM it tells that r9 register is clobbered. Some OSes (iOS again)
174 * define r9 as volatile. It can be used as scratchpad but calls will
175 * not preserve it.
176 * AROS code expects it is nonvolatile (as defined in the AAPCS).
178 #define AROS_HOST_BARRIER asm volatile("":::"r9");
180 #endif /* AROS_ARM_CPU_H */