| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
#if !defined(__DYNGEN_EXEC_H__) |
|---|
| 30 |
#define __DYNGEN_EXEC_H__ |
|---|
| 31 |
|
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 |
#ifdef __sun__ |
|---|
| 36 |
#define _FILEDEFED |
|---|
| 37 |
#endif |
|---|
| 38 |
|
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
#include <stddef.h> |
|---|
| 43 |
|
|---|
| 44 |
#ifndef VBOX |
|---|
| 45 |
|
|---|
| 46 |
typedef unsigned char uint8_t; |
|---|
| 47 |
typedef unsigned short uint16_t; |
|---|
| 48 |
typedef unsigned int uint32_t; |
|---|
| 49 |
|
|---|
| 50 |
#if !(defined (__sparc_v9__) && defined(__linux__)) |
|---|
| 51 |
|
|---|
| 52 |
#if defined (__x86_64__) || defined(__ia64) |
|---|
| 53 |
typedef unsigned long uint64_t; |
|---|
| 54 |
#else |
|---|
| 55 |
typedef unsigned long long uint64_t; |
|---|
| 56 |
#endif |
|---|
| 57 |
#endif |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 |
#ifndef __sun__ |
|---|
| 63 |
typedef signed char int8_t; |
|---|
| 64 |
#endif |
|---|
| 65 |
typedef signed short int16_t; |
|---|
| 66 |
typedef signed int int32_t; |
|---|
| 67 |
|
|---|
| 68 |
#if !(defined (__sparc_v9__) && defined(__linux__)) |
|---|
| 69 |
#if defined (__x86_64__) || defined(__ia64) |
|---|
| 70 |
typedef signed long int64_t; |
|---|
| 71 |
#else |
|---|
| 72 |
typedef signed long long int64_t; |
|---|
| 73 |
#endif |
|---|
| 74 |
#endif |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
typedef void * host_reg_t; |
|---|
| 78 |
|
|---|
| 79 |
#define INT8_MIN (-128) |
|---|
| 80 |
#define INT16_MIN (-32767-1) |
|---|
| 81 |
#define INT32_MIN (-2147483647-1) |
|---|
| 82 |
#define INT64_MIN (-(int64_t)(9223372036854775807)-1) |
|---|
| 83 |
#define INT8_MAX (127) |
|---|
| 84 |
#define INT16_MAX (32767) |
|---|
| 85 |
#define INT32_MAX (2147483647) |
|---|
| 86 |
#define INT64_MAX ((int64_t)(9223372036854775807)) |
|---|
| 87 |
#define UINT8_MAX (255) |
|---|
| 88 |
#define UINT16_MAX (65535) |
|---|
| 89 |
#define UINT32_MAX (4294967295U) |
|---|
| 90 |
#define UINT64_MAX ((uint64_t)(18446744073709551615)) |
|---|
| 91 |
|
|---|
| 92 |
typedef struct FILE FILE; |
|---|
| 93 |
extern int fprintf(FILE *, const char *, ...); |
|---|
| 94 |
extern int printf(const char *, ...); |
|---|
| 95 |
#undef NULL |
|---|
| 96 |
#define NULL 0 |
|---|
| 97 |
|
|---|
| 98 |
#else |
|---|
| 99 |
|
|---|
| 100 |
|
|---|
| 101 |
typedef void * host_reg_t; |
|---|
| 102 |
|
|---|
| 103 |
#include <iprt/stdint.h> |
|---|
| 104 |
#include <stdio.h> |
|---|
| 105 |
|
|---|
| 106 |
#endif |
|---|
| 107 |
|
|---|
| 108 |
#ifdef __i386__ |
|---|
| 109 |
#define AREG0 "ebp" |
|---|
| 110 |
#define AREG1 "ebx" |
|---|
| 111 |
#define AREG2 "esi" |
|---|
| 112 |
#define AREG3 "edi" |
|---|
| 113 |
#endif |
|---|
| 114 |
#ifdef __x86_64__ |
|---|
| 115 |
#ifdef VBOX |
|---|
| 116 |
|
|---|
| 117 |
|
|---|
| 118 |
|
|---|
| 119 |
# define AREG0 "rbx" |
|---|
| 120 |
# define AREG1 "r12" |
|---|
| 121 |
# define AREG2 "r13" |
|---|
| 122 |
# define AREG3 "r14" |
|---|
| 123 |
#else |
|---|
| 124 |
#define AREG0 "rbp" |
|---|
| 125 |
#define AREG1 "rbx" |
|---|
| 126 |
#define AREG2 "r12" |
|---|
| 127 |
#define AREG3 "r13" |
|---|
| 128 |
#endif |
|---|
| 129 |
|
|---|
| 130 |
|
|---|
| 131 |
#endif |
|---|
| 132 |
#ifdef __powerpc__ |
|---|
| 133 |
#define AREG0 "r27" |
|---|
| 134 |
#define AREG1 "r24" |
|---|
| 135 |
#define AREG2 "r25" |
|---|
| 136 |
#define AREG3 "r26" |
|---|
| 137 |
|
|---|
| 138 |
#if defined(CONFIG_USER_ONLY) |
|---|
| 139 |
#define AREG4 "r16" |
|---|
| 140 |
#define AREG5 "r17" |
|---|
| 141 |
#define AREG6 "r18" |
|---|
| 142 |
#define AREG7 "r19" |
|---|
| 143 |
#define AREG8 "r20" |
|---|
| 144 |
#define AREG9 "r21" |
|---|
| 145 |
#define AREG10 "r22" |
|---|
| 146 |
#define AREG11 "r23" |
|---|
| 147 |
#endif |
|---|
| 148 |
#define USE_INT_TO_FLOAT_HELPERS |
|---|
| 149 |
#define BUGGY_GCC_DIV64 |
|---|
| 150 |
#endif |
|---|
| 151 |
#ifdef __arm__ |
|---|
| 152 |
#define AREG0 "r7" |
|---|
| 153 |
#define AREG1 "r4" |
|---|
| 154 |
#define AREG2 "r5" |
|---|
| 155 |
#define AREG3 "r6" |
|---|
| 156 |
#endif |
|---|
| 157 |
#ifdef __mips__ |
|---|
| 158 |
#define AREG0 "s3" |
|---|
| 159 |
#define AREG1 "s0" |
|---|
| 160 |
#define AREG2 "s1" |
|---|
| 161 |
#define AREG3 "s2" |
|---|
| 162 |
#endif |
|---|
| 163 |
#ifdef __sparc__ |
|---|
| 164 |
#ifdef HOST_SOLARIS |
|---|
| 165 |
#define AREG0 "g2" |
|---|
| 166 |
#define AREG1 "g3" |
|---|
| 167 |
#define AREG2 "g4" |
|---|
| 168 |
#define AREG3 "g5" |
|---|
| 169 |
#define AREG4 "g6" |
|---|
| 170 |
#else |
|---|
| 171 |
#ifdef __sparc_v9__ |
|---|
| 172 |
#define AREG0 "g1" |
|---|
| 173 |
#define AREG1 "g4" |
|---|
| 174 |
#define AREG2 "g5" |
|---|
| 175 |
#define AREG3 "g7" |
|---|
| 176 |
#else |
|---|
| 177 |
#define AREG0 "g6" |
|---|
| 178 |
#define AREG1 "g1" |
|---|
| 179 |
#define AREG2 "g2" |
|---|
| 180 |
#define AREG3 "g3" |
|---|
| 181 |
#define AREG4 "l0" |
|---|
| 182 |
#define AREG5 "l1" |
|---|
| 183 |
#define AREG6 "l2" |
|---|
| 184 |
#define AREG7 "l3" |
|---|
| 185 |
#define AREG8 "l4" |
|---|
| 186 |
#define AREG9 "l5" |
|---|
| 187 |
#define AREG10 "l6" |
|---|
| 188 |
#define AREG11 "l7" |
|---|
| 189 |
#endif |
|---|
| 190 |
#endif |
|---|
| 191 |
#define USE_FP_CONVERT |
|---|
| 192 |
#endif |
|---|
| 193 |
#ifdef __s390__ |
|---|
| 194 |
#define AREG0 "r10" |
|---|
| 195 |
#define AREG1 "r7" |
|---|
| 196 |
#define AREG2 "r8" |
|---|
| 197 |
#define AREG3 "r9" |
|---|
| 198 |
#endif |
|---|
| 199 |
#ifdef __alpha__ |
|---|
| 200 |
|
|---|
| 201 |
|
|---|
| 202 |
#define AREG0 "$15" |
|---|
| 203 |
#define AREG1 "$9" |
|---|
| 204 |
#define AREG2 "$10" |
|---|
| 205 |
#define AREG3 "$11" |
|---|
| 206 |
#define AREG4 "$12" |
|---|
| 207 |
#define AREG5 "$13" |
|---|
| 208 |
#define AREG6 "$14" |
|---|
| 209 |
#endif |
|---|
| 210 |
#ifdef __mc68000 |
|---|
| 211 |
#define AREG0 "%a5" |
|---|
| 212 |
#define AREG1 "%a4" |
|---|
| 213 |
#define AREG2 "%d7" |
|---|
| 214 |
#define AREG3 "%d6" |
|---|
| 215 |
#define AREG4 "%d5" |
|---|
| 216 |
#endif |
|---|
| 217 |
#ifdef __ia64__ |
|---|
| 218 |
#define AREG0 "r7" |
|---|
| 219 |
#define AREG1 "r4" |
|---|
| 220 |
#define AREG2 "r5" |
|---|
| 221 |
#define AREG3 "r6" |
|---|
| 222 |
#endif |
|---|
| 223 |
|
|---|
| 224 |
|
|---|
| 225 |
#define FORCE_RET() __asm__ __volatile__("" : : : "memory"); |
|---|
| 226 |
|
|---|
| 227 |
#ifndef OPPROTO |
|---|
| 228 |
#define OPPROTO |
|---|
| 229 |
#endif |
|---|
| 230 |
|
|---|
| 231 |
#define xglue(x, y) x ## y |
|---|
| 232 |
#define glue(x, y) xglue(x, y) |
|---|
| 233 |
#define stringify(s) tostring(s) |
|---|
| 234 |
#define tostring(s) #s |
|---|
| 235 |
|
|---|
| 236 |
#ifdef __alpha__ |
|---|
| 237 |
|
|---|
| 238 |
#define __hidden __attribute__((visibility("hidden"))) |
|---|
| 239 |
#else |
|---|
| 240 |
#define __hidden |
|---|
| 241 |
#endif |
|---|
| 242 |
|
|---|
| 243 |
#if defined(__alpha__) |
|---|
| 244 |
|
|---|
| 245 |
|
|---|
| 246 |
|
|---|
| 247 |
|
|---|
| 248 |
|
|---|
| 249 |
extern int __op_param1 __hidden; |
|---|
| 250 |
extern int __op_param2 __hidden; |
|---|
| 251 |
extern int __op_param3 __hidden; |
|---|
| 252 |
#define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; }) |
|---|
| 253 |
#define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; }) |
|---|
| 254 |
#define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; }) |
|---|
| 255 |
#else |
|---|
| 256 |
#if defined(__APPLE__) |
|---|
| 257 |
static int __op_param1, __op_param2, __op_param3; |
|---|
| 258 |
#else |
|---|
| 259 |
extern int __op_param1, __op_param2, __op_param3; |
|---|
| 260 |
#endif |
|---|
| 261 |
#define PARAM1 ((long)(&__op_param1)) |
|---|
| 262 |
#define PARAM2 ((long)(&__op_param2)) |
|---|
| 263 |
#define PARAM3 ((long)(&__op_param3)) |
|---|
| 264 |
#endif |
|---|
| 265 |
|
|---|
| 266 |
extern int __op_jmp0, __op_jmp1, __op_jmp2, __op_jmp3; |
|---|
| 267 |
|
|---|
| 268 |
#if defined(_WIN32) || defined(__APPLE__) || defined(__OS2__) |
|---|
| 269 |
#define ASM_NAME(x) "_" #x |
|---|
| 270 |
#else |
|---|
| 271 |
#define ASM_NAME(x) #x |
|---|
| 272 |
#endif |
|---|
| 273 |
|
|---|
| 274 |
#ifdef __i386__ |
|---|
| 275 |
#define EXIT_TB() asm volatile ("ret") |
|---|
| 276 |
#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n) |
|---|
| 277 |
#endif |
|---|
| 278 |
#ifdef __x86_64__ |
|---|
| 279 |
#define EXIT_TB() asm volatile ("ret") |
|---|
| 280 |
#define GOTO_LABEL_PARAM(n) asm volatile ("jmp " ASM_NAME(__op_gen_label) #n) |
|---|
| 281 |
#endif |
|---|
| 282 |
#ifdef __powerpc__ |
|---|
| 283 |
#define EXIT_TB() asm volatile ("blr") |
|---|
| 284 |
#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n) |
|---|
| 285 |
#endif |
|---|
| 286 |
#ifdef __s390__ |
|---|
| 287 |
#define EXIT_TB() asm volatile ("br %r14") |
|---|
| 288 |
#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n) |
|---|
| 289 |
#endif |
|---|
| 290 |
#ifdef __alpha__ |
|---|
| 291 |
#define EXIT_TB() asm volatile ("ret") |
|---|
| 292 |
#endif |
|---|
| 293 |
#ifdef __ia64__ |
|---|
| 294 |
#define EXIT_TB() asm volatile ("br.ret.sptk.many b0;;") |
|---|
| 295 |
#define GOTO_LABEL_PARAM(n) asm volatile ("br.sptk.many " \ |
|---|
| 296 |
ASM_NAME(__op_gen_label) #n) |
|---|
| 297 |
#endif |
|---|
| 298 |
#ifdef __sparc__ |
|---|
| 299 |
#define EXIT_TB() asm volatile ("jmpl %i0 + 8, %g0; nop") |
|---|
| 300 |
#define GOTO_LABEL_PARAM(n) asm volatile ("ba " ASM_NAME(__op_gen_label) #n ";nop") |
|---|
| 301 |
#endif |
|---|
| 302 |
#ifdef __arm__ |
|---|
| 303 |
#define EXIT_TB() asm volatile ("b exec_loop") |
|---|
| 304 |
#define GOTO_LABEL_PARAM(n) asm volatile ("b " ASM_NAME(__op_gen_label) #n) |
|---|
| 305 |
#endif |
|---|
| 306 |
#ifdef __mc68000 |
|---|
| 307 |
#define EXIT_TB() asm volatile ("rts") |
|---|
| 308 |
#endif |
|---|
| 309 |
|
|---|
| 310 |
#endif |
|---|