xref: /openbmc/qemu/include/user/abitypes.h (revision 22879b66)
1*22879b66SPhilippe Mathieu-Daudé #ifndef USER_ABITYPES_H
2*22879b66SPhilippe Mathieu-Daudé #define USER_ABITYPES_H
3*22879b66SPhilippe Mathieu-Daudé 
4*22879b66SPhilippe Mathieu-Daudé #ifndef CONFIG_USER_ONLY
5*22879b66SPhilippe Mathieu-Daudé #error Cannot include this header from system emulation
6*22879b66SPhilippe Mathieu-Daudé #endif
7*22879b66SPhilippe Mathieu-Daudé 
8*22879b66SPhilippe Mathieu-Daudé #include "exec/cpu-defs.h"
9*22879b66SPhilippe Mathieu-Daudé #include "exec/tswap.h"
10*22879b66SPhilippe Mathieu-Daudé #include "user/tswap-target.h"
11*22879b66SPhilippe Mathieu-Daudé 
12*22879b66SPhilippe Mathieu-Daudé #ifdef TARGET_ABI32
13*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_BITS 32
14*22879b66SPhilippe Mathieu-Daudé #else
15*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_BITS TARGET_LONG_BITS
16*22879b66SPhilippe Mathieu-Daudé #endif
17*22879b66SPhilippe Mathieu-Daudé 
18*22879b66SPhilippe Mathieu-Daudé #ifdef TARGET_M68K
19*22879b66SPhilippe Mathieu-Daudé #define ABI_INT_ALIGNMENT 2
20*22879b66SPhilippe Mathieu-Daudé #define ABI_LONG_ALIGNMENT 2
21*22879b66SPhilippe Mathieu-Daudé #define ABI_LLONG_ALIGNMENT 2
22*22879b66SPhilippe Mathieu-Daudé #endif
23*22879b66SPhilippe Mathieu-Daudé 
24*22879b66SPhilippe Mathieu-Daudé #ifdef TARGET_CRIS
25*22879b66SPhilippe Mathieu-Daudé #define ABI_SHORT_ALIGNMENT 1
26*22879b66SPhilippe Mathieu-Daudé #define ABI_INT_ALIGNMENT 1
27*22879b66SPhilippe Mathieu-Daudé #define ABI_LONG_ALIGNMENT 1
28*22879b66SPhilippe Mathieu-Daudé #define ABI_LLONG_ALIGNMENT 1
29*22879b66SPhilippe Mathieu-Daudé #endif
30*22879b66SPhilippe Mathieu-Daudé 
31*22879b66SPhilippe Mathieu-Daudé #if (defined(TARGET_I386) && !defined(TARGET_X86_64)) \
32*22879b66SPhilippe Mathieu-Daudé     || defined(TARGET_SH4) \
33*22879b66SPhilippe Mathieu-Daudé     || defined(TARGET_OPENRISC) \
34*22879b66SPhilippe Mathieu-Daudé     || defined(TARGET_MICROBLAZE)
35*22879b66SPhilippe Mathieu-Daudé #define ABI_LLONG_ALIGNMENT 4
36*22879b66SPhilippe Mathieu-Daudé #endif
37*22879b66SPhilippe Mathieu-Daudé 
38*22879b66SPhilippe Mathieu-Daudé #ifndef ABI_SHORT_ALIGNMENT
39*22879b66SPhilippe Mathieu-Daudé #define ABI_SHORT_ALIGNMENT 2
40*22879b66SPhilippe Mathieu-Daudé #endif
41*22879b66SPhilippe Mathieu-Daudé #ifndef ABI_INT_ALIGNMENT
42*22879b66SPhilippe Mathieu-Daudé #define ABI_INT_ALIGNMENT 4
43*22879b66SPhilippe Mathieu-Daudé #endif
44*22879b66SPhilippe Mathieu-Daudé #ifndef ABI_LONG_ALIGNMENT
45*22879b66SPhilippe Mathieu-Daudé #define ABI_LONG_ALIGNMENT (TARGET_ABI_BITS / 8)
46*22879b66SPhilippe Mathieu-Daudé #endif
47*22879b66SPhilippe Mathieu-Daudé #ifndef ABI_LLONG_ALIGNMENT
48*22879b66SPhilippe Mathieu-Daudé #define ABI_LLONG_ALIGNMENT 8
49*22879b66SPhilippe Mathieu-Daudé #endif
50*22879b66SPhilippe Mathieu-Daudé 
51*22879b66SPhilippe Mathieu-Daudé typedef int16_t abi_short __attribute__ ((aligned(ABI_SHORT_ALIGNMENT)));
52*22879b66SPhilippe Mathieu-Daudé typedef uint16_t abi_ushort __attribute__((aligned(ABI_SHORT_ALIGNMENT)));
53*22879b66SPhilippe Mathieu-Daudé typedef int32_t abi_int __attribute__((aligned(ABI_INT_ALIGNMENT)));
54*22879b66SPhilippe Mathieu-Daudé typedef uint32_t abi_uint __attribute__((aligned(ABI_INT_ALIGNMENT)));
55*22879b66SPhilippe Mathieu-Daudé typedef int64_t abi_llong __attribute__((aligned(ABI_LLONG_ALIGNMENT)));
56*22879b66SPhilippe Mathieu-Daudé typedef uint64_t abi_ullong __attribute__((aligned(ABI_LLONG_ALIGNMENT)));
57*22879b66SPhilippe Mathieu-Daudé 
58*22879b66SPhilippe Mathieu-Daudé #ifdef TARGET_ABI32
59*22879b66SPhilippe Mathieu-Daudé typedef uint32_t abi_ulong __attribute__((aligned(ABI_LONG_ALIGNMENT)));
60*22879b66SPhilippe Mathieu-Daudé typedef int32_t abi_long __attribute__((aligned(ABI_LONG_ALIGNMENT)));
61*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_FMT_lx "%08x"
62*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_FMT_ld "%d"
63*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_FMT_lu "%u"
64*22879b66SPhilippe Mathieu-Daudé 
tswapal(abi_ulong v)65*22879b66SPhilippe Mathieu-Daudé static inline abi_ulong tswapal(abi_ulong v)
66*22879b66SPhilippe Mathieu-Daudé {
67*22879b66SPhilippe Mathieu-Daudé     return tswap32(v);
68*22879b66SPhilippe Mathieu-Daudé }
69*22879b66SPhilippe Mathieu-Daudé 
70*22879b66SPhilippe Mathieu-Daudé #else
71*22879b66SPhilippe Mathieu-Daudé typedef target_ulong abi_ulong __attribute__((aligned(ABI_LONG_ALIGNMENT)));
72*22879b66SPhilippe Mathieu-Daudé typedef target_long abi_long __attribute__((aligned(ABI_LONG_ALIGNMENT)));
73*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_FMT_lx TARGET_FMT_lx
74*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_FMT_ld TARGET_FMT_ld
75*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI_FMT_lu TARGET_FMT_lu
76*22879b66SPhilippe Mathieu-Daudé /* for consistency, define ABI32 too */
77*22879b66SPhilippe Mathieu-Daudé #if TARGET_ABI_BITS == 32
78*22879b66SPhilippe Mathieu-Daudé #define TARGET_ABI32 1
79*22879b66SPhilippe Mathieu-Daudé #endif
80*22879b66SPhilippe Mathieu-Daudé 
tswapal(abi_ulong v)81*22879b66SPhilippe Mathieu-Daudé static inline abi_ulong tswapal(abi_ulong v)
82*22879b66SPhilippe Mathieu-Daudé {
83*22879b66SPhilippe Mathieu-Daudé     return tswapl(v);
84*22879b66SPhilippe Mathieu-Daudé }
85*22879b66SPhilippe Mathieu-Daudé 
86*22879b66SPhilippe Mathieu-Daudé #endif
87*22879b66SPhilippe Mathieu-Daudé #endif
88