~jderose/ubuntu/raring/qemu/vde-again

« back to all changes in this revision

Viewing changes to linux-user/main.c

  • Committer: Bazaar Package Importer
  • Author(s): Riku Voipio, Josh Triplett, Riku Voipio
  • Date: 2009-07-29 13:28:05 UTC
  • mfrom: (1.4.1 upstream)
  • mto: (12.1.1 sid) (10.1.13 sid)
  • mto: This revision was merged to the branch mainline in revision 13.
  • Revision ID: james.westby@ubuntu.com-20090729132805-cau7rfexh7dawyb8
Tags: 0.10.50+git20090729-1
[ Josh Triplett ]
* Remove myself from Uploaders.

[ Riku Voipio ]
* new upstream RC version
* nuke all linux-user patches (applied upstream)
  06_exit_segfault
  12_signal_powerpc_support
  21_net_soopts
  30_syscall_ipc
  32_syscall_sysctl
  35_syscall_sockaddr
  48_signal_terminate
  55_unmux_socketcall
* nuke all other applied-upstream patches
  01_nostrip (better version upstream)
  07_i386_exec_name (can be reintroduced in debian/rules)
  50_linuxbios_isa_bios_ram (shouldn't be needed anymore)
  51_linuxbios_piix_ram_size (applied)
  56_dhcp (crap)
  60_ppc_ld (reintroduce if needed)
  64_ppc_asm_constraints (ditto)
  66_tls_ld.patch (ditto)
  81_compile_dtb.patch (applied upstream)
  82_qemu-img_decimal (ditto)
* move to git
* simplify build rules
* Correct my email address

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
 *  GNU General Public License for more details.
15
15
 *
16
16
 *  You should have received a copy of the GNU General Public License
17
 
 *  along with this program; if not, write to the Free Software
18
 
 *  Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19
 
 *  MA 02110-1301, USA.
 
17
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
20
18
 */
21
19
#include <stdlib.h>
22
20
#include <stdio.h>
25
23
#include <errno.h>
26
24
#include <unistd.h>
27
25
#include <sys/mman.h>
 
26
#include <sys/syscall.h>
28
27
 
29
28
#include "qemu.h"
30
29
#include "qemu-common.h"
39
38
 
40
39
char *exec_path;
41
40
 
 
41
int singlestep;
 
42
#if defined(CONFIG_USE_GUEST_BASE)
 
43
unsigned long mmap_min_addr;
 
44
unsigned long guest_base;
 
45
int have_guest_base;
 
46
#endif
 
47
 
42
48
static const char *interp_prefix = CONFIG_QEMU_PREFIX;
43
49
const char *qemu_uname_release = CONFIG_UNAME_RELEASE;
44
50
 
82
88
    va_end(ap);
83
89
}
84
90
 
85
 
void cpu_outb(CPUState *env, int addr, int val)
86
 
{
87
 
    fprintf(stderr, "outb: port=0x%04x, data=%02x\n", addr, val);
88
 
}
89
 
 
90
 
void cpu_outw(CPUState *env, int addr, int val)
91
 
{
92
 
    fprintf(stderr, "outw: port=0x%04x, data=%04x\n", addr, val);
93
 
}
94
 
 
95
 
void cpu_outl(CPUState *env, int addr, int val)
96
 
{
97
 
    fprintf(stderr, "outl: port=0x%04x, data=%08x\n", addr, val);
98
 
}
99
 
 
100
 
int cpu_inb(CPUState *env, int addr)
101
 
{
102
 
    fprintf(stderr, "inb: port=0x%04x\n", addr);
103
 
    return 0;
104
 
}
105
 
 
106
 
int cpu_inw(CPUState *env, int addr)
107
 
{
108
 
    fprintf(stderr, "inw: port=0x%04x\n", addr);
109
 
    return 0;
110
 
}
111
 
 
112
 
int cpu_inl(CPUState *env, int addr)
113
 
{
114
 
    fprintf(stderr, "inl: port=0x%04x\n", addr);
115
 
    return 0;
116
 
}
117
 
 
118
91
#if defined(TARGET_I386)
119
92
int cpu_get_pic_interrupt(CPUState *env)
120
93
{
135
108
 
136
109
#endif
137
110
 
138
 
#if defined(USE_NPTL)
 
111
#if defined(CONFIG_USE_NPTL)
139
112
/***********************************************************/
140
113
/* Helper routines for implementing atomic operations.  */
141
114
 
143
116
   We don't require a full sync, only that no cpus are executing guest code.
144
117
   The alternative is to map target atomic ops onto host equivalents,
145
118
   which requires quite a lot of per host/target work.  */
 
119
static pthread_mutex_t cpu_list_mutex = PTHREAD_MUTEX_INITIALIZER;
146
120
static pthread_mutex_t exclusive_lock = PTHREAD_MUTEX_INITIALIZER;
147
121
static pthread_cond_t exclusive_cond = PTHREAD_COND_INITIALIZER;
148
122
static pthread_cond_t exclusive_resume = PTHREAD_COND_INITIALIZER;
165
139
        thread_env->next_cpu = NULL;
166
140
        pending_cpus = 0;
167
141
        pthread_mutex_init(&exclusive_lock, NULL);
 
142
        pthread_mutex_init(&cpu_list_mutex, NULL);
168
143
        pthread_cond_init(&exclusive_cond, NULL);
169
144
        pthread_cond_init(&exclusive_resume, NULL);
170
145
        pthread_mutex_init(&tb_lock, NULL);
198
173
    for (other = first_cpu; other; other = other->next_cpu) {
199
174
        if (other->running) {
200
175
            pending_cpus++;
201
 
            cpu_interrupt(other, CPU_INTERRUPT_EXIT);
 
176
            cpu_exit(other);
202
177
        }
203
178
    }
204
179
    if (pending_cpus > 1) {
237
212
    exclusive_idle();
238
213
    pthread_mutex_unlock(&exclusive_lock);
239
214
}
240
 
#else /* if !USE_NPTL */
 
215
 
 
216
void cpu_list_lock(void)
 
217
{
 
218
    pthread_mutex_lock(&cpu_list_mutex);
 
219
}
 
220
 
 
221
void cpu_list_unlock(void)
 
222
{
 
223
    pthread_mutex_unlock(&cpu_list_mutex);
 
224
}
 
225
#else /* if !CONFIG_USE_NPTL */
241
226
/* These are no-ops because we are not threadsafe.  */
242
227
static inline void cpu_exec_start(CPUState *env)
243
228
{
265
250
        gdbserver_fork(thread_env);
266
251
    }
267
252
}
 
253
 
 
254
void cpu_list_lock(void)
 
255
{
 
256
}
 
257
 
 
258
void cpu_list_unlock(void)
 
259
{
 
260
}
268
261
#endif
269
262
 
270
263
 
1058
1051
    return -1;
1059
1052
}
1060
1053
 
1061
 
#define EXCP_DUMP(env, fmt, args...)                                         \
1062
 
do {                                                                          \
1063
 
    fprintf(stderr, fmt , ##args);                                            \
1064
 
    cpu_dump_state(env, stderr, fprintf, 0);                                  \
1065
 
    qemu_log(fmt, ##args);                                                   \
1066
 
    log_cpu_state(env, 0);                                                      \
 
1054
#define EXCP_DUMP(env, fmt, ...)                                        \
 
1055
do {                                                                    \
 
1056
    fprintf(stderr, fmt , ## __VA_ARGS__);                              \
 
1057
    cpu_dump_state(env, stderr, fprintf, 0);                            \
 
1058
    qemu_log(fmt, ## __VA_ARGS__);                                      \
 
1059
    if (logfile)                                                        \
 
1060
        log_cpu_state(env, 0);                                          \
1067
1061
} while (0)
1068
1062
 
1069
1063
void cpu_loop(CPUPPCState *env)
1439
1433
            ret = do_syscall(env, env->gpr[0], env->gpr[3], env->gpr[4],
1440
1434
                             env->gpr[5], env->gpr[6], env->gpr[7],
1441
1435
                             env->gpr[8]);
 
1436
            if (ret == (uint32_t)(-TARGET_QEMU_ESIGRETURN)) {
 
1437
                /* Returning from a successful sigreturn syscall.
 
1438
                   Avoid corrupting register state.  */
 
1439
                break;
 
1440
            }
1442
1441
            if (ret > (uint32_t)(-515)) {
1443
1442
                env->crf[0] |= 0x1;
1444
1443
                ret = -ret;
1598
1597
        MIPS_SYS(sys_ipc                , 6)
1599
1598
        MIPS_SYS(sys_fsync      , 1)
1600
1599
        MIPS_SYS(sys_sigreturn  , 0)
1601
 
        MIPS_SYS(sys_clone      , 0)    /* 4120 */
 
1600
        MIPS_SYS(sys_clone      , 6)    /* 4120 */
1602
1601
        MIPS_SYS(sys_setdomainname, 2)
1603
1602
        MIPS_SYS(sys_newuname   , 1)
1604
1603
        MIPS_SYS(sys_ni_syscall , 0)    /* sys_modify_ldt */
1798
1797
 
1799
1798
#undef MIPS_SYS
1800
1799
 
 
1800
static int do_store_exclusive(CPUMIPSState *env)
 
1801
{
 
1802
    target_ulong addr;
 
1803
    target_ulong page_addr;
 
1804
    target_ulong val;
 
1805
    int flags;
 
1806
    int segv = 0;
 
1807
    int reg;
 
1808
    int d;
 
1809
 
 
1810
    addr = env->CP0_LLAddr;
 
1811
    page_addr = addr & TARGET_PAGE_MASK;
 
1812
    start_exclusive();
 
1813
    mmap_lock();
 
1814
    flags = page_get_flags(page_addr);
 
1815
    if ((flags & PAGE_READ) == 0) {
 
1816
        segv = 1;
 
1817
    } else {
 
1818
        reg = env->llreg & 0x1f;
 
1819
        d = (env->llreg & 0x20) != 0;
 
1820
        if (d) {
 
1821
            segv = get_user_s64(val, addr);
 
1822
        } else {
 
1823
            segv = get_user_s32(val, addr);
 
1824
        }
 
1825
        if (!segv) {
 
1826
            if (val != env->llval) {
 
1827
                env->active_tc.gpr[reg] = 0;
 
1828
            } else {
 
1829
                if (d) {
 
1830
                    segv = put_user_u64(env->llnewval, addr);
 
1831
                } else {
 
1832
                    segv = put_user_u32(env->llnewval, addr);
 
1833
                }
 
1834
                if (!segv) {
 
1835
                    env->active_tc.gpr[reg] = 1;
 
1836
                }
 
1837
            }
 
1838
        }
 
1839
    }
 
1840
    env->CP0_LLAddr = -1;
 
1841
    if (!segv) {
 
1842
        env->active_tc.PC += 4;
 
1843
    }
 
1844
    mmap_unlock();
 
1845
    end_exclusive();
 
1846
    return segv;
 
1847
}
 
1848
 
1801
1849
void cpu_loop(CPUMIPSState *env)
1802
1850
{
1803
1851
    target_siginfo_t info;
1805
1853
    unsigned int syscall_num;
1806
1854
 
1807
1855
    for(;;) {
 
1856
        cpu_exec_start(env);
1808
1857
        trapnr = cpu_mips_exec(env);
 
1858
        cpu_exec_end(env);
1809
1859
        switch(trapnr) {
1810
1860
        case EXCP_SYSCALL:
1811
1861
            syscall_num = env->active_tc.gpr[2] - 4000;
1836
1886
                                 env->active_tc.gpr[7],
1837
1887
                                 arg5, arg6/*, arg7, arg8*/);
1838
1888
            }
 
1889
            if (ret == -TARGET_QEMU_ESIGRETURN) {
 
1890
                /* Returning from a successful sigreturn syscall.
 
1891
                   Avoid clobbering register state.  */
 
1892
                break;
 
1893
            }
1839
1894
            if ((unsigned int)ret >= (unsigned int)(-1133)) {
1840
1895
                env->active_tc.gpr[7] = 1; /* error flag */
1841
1896
                ret = -ret;
1846
1901
            break;
1847
1902
        case EXCP_TLBL:
1848
1903
        case EXCP_TLBS:
 
1904
            info.si_signo = TARGET_SIGSEGV;
 
1905
            info.si_errno = 0;
 
1906
            /* XXX: check env->error_code */
 
1907
            info.si_code = TARGET_SEGV_MAPERR;
 
1908
            info._sifields._sigfault._addr = env->CP0_BadVAddr;
 
1909
            queue_signal(env, info.si_signo, &info);
 
1910
            break;
1849
1911
        case EXCP_CpU:
1850
1912
        case EXCP_RI:
1851
1913
            info.si_signo = TARGET_SIGILL;
1870
1932
                  }
1871
1933
            }
1872
1934
            break;
 
1935
        case EXCP_SC:
 
1936
            if (do_store_exclusive(env)) {
 
1937
                info.si_signo = TARGET_SIGSEGV;
 
1938
                info.si_errno = 0;
 
1939
                info.si_code = TARGET_SEGV_MAPERR;
 
1940
                info._sifields._sigfault._addr = env->active_tc.PC;
 
1941
                queue_signal(env, info.si_signo, &info);
 
1942
            }
 
1943
            break;
1873
1944
        default:
1874
1945
            //        error:
1875
1946
            fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
1997
2068
}
1998
2069
#endif
1999
2070
 
 
2071
#ifdef TARGET_MICROBLAZE
 
2072
void cpu_loop (CPUState *env)
 
2073
{
 
2074
    int trapnr, ret;
 
2075
    target_siginfo_t info;
 
2076
    
 
2077
    while (1) {
 
2078
        trapnr = cpu_mb_exec (env);
 
2079
        switch (trapnr) {
 
2080
        case 0xaa:
 
2081
            {
 
2082
                info.si_signo = SIGSEGV;
 
2083
                info.si_errno = 0;
 
2084
                /* XXX: check env->error_code */
 
2085
                info.si_code = TARGET_SEGV_MAPERR;
 
2086
                info._sifields._sigfault._addr = 0;
 
2087
                queue_signal(env, info.si_signo, &info);
 
2088
            }
 
2089
            break;
 
2090
        case EXCP_INTERRUPT:
 
2091
          /* just indicate that signals should be handled asap */
 
2092
          break;
 
2093
        case EXCP_BREAK:
 
2094
            /* Return address is 4 bytes after the call.  */
 
2095
            env->regs[14] += 4;
 
2096
            ret = do_syscall(env, 
 
2097
                             env->regs[12], 
 
2098
                             env->regs[5], 
 
2099
                             env->regs[6], 
 
2100
                             env->regs[7], 
 
2101
                             env->regs[8], 
 
2102
                             env->regs[9], 
 
2103
                             env->regs[10]);
 
2104
            env->regs[3] = ret;
 
2105
            env->sregs[SR_PC] = env->regs[14];
 
2106
            break;
 
2107
        case EXCP_DEBUG:
 
2108
            {
 
2109
                int sig;
 
2110
 
 
2111
                sig = gdb_handlesig (env, TARGET_SIGTRAP);
 
2112
                if (sig)
 
2113
                  {
 
2114
                    info.si_signo = sig;
 
2115
                    info.si_errno = 0;
 
2116
                    info.si_code = TARGET_TRAP_BRKPT;
 
2117
                    queue_signal(env, info.si_signo, &info);
 
2118
                  }
 
2119
            }
 
2120
            break;
 
2121
        default:
 
2122
            printf ("Unhandled trap: 0x%x\n", trapnr);
 
2123
            cpu_dump_state(env, stderr, fprintf, 0);
 
2124
            exit (1);
 
2125
        }
 
2126
        process_pending_signals (env);
 
2127
    }
 
2128
}
 
2129
#endif
 
2130
 
2000
2131
#ifdef TARGET_M68K
2001
2132
 
2002
2133
void cpu_loop(CPUM68KState *env)
2180
2311
 
2181
2312
static void usage(void)
2182
2313
{
2183
 
    printf("qemu-" TARGET_ARCH " version " QEMU_VERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
 
2314
    printf("qemu-" TARGET_ARCH " version " QEMU_VERSION QEMU_PKGVERSION ", Copyright (c) 2003-2008 Fabrice Bellard\n"
2184
2315
           "usage: qemu-" TARGET_ARCH " [options] program [arguments...]\n"
2185
2316
           "Linux CPU emulator (compiled for %s emulation)\n"
2186
2317
           "\n"
2193
2324
           "-drop-ld-preload  drop LD_PRELOAD for target process\n"
2194
2325
           "-E var=value      sets/modifies targets environment variable(s)\n"
2195
2326
           "-U var            unsets targets environment variable(s)\n"
 
2327
           "-0 argv0          forces target process argv[0] to be argv0\n"
 
2328
#if defined(CONFIG_USE_GUEST_BASE)
 
2329
           "-B address        set guest_base address to address\n"
 
2330
#endif
2196
2331
           "\n"
2197
2332
           "Debug options:\n"
2198
2333
           "-d options   activate log (logfile=%s)\n"
2199
2334
           "-p pagesize  set the host page size to 'pagesize'\n"
 
2335
           "-singlestep  always run in singlestep mode\n"
2200
2336
           "-strace      log system calls\n"
2201
2337
           "\n"
2202
2338
           "Environment variables:\n"
2218
2354
 
2219
2355
THREAD CPUState *thread_env;
2220
2356
 
 
2357
void task_settid(TaskState *ts)
 
2358
{
 
2359
    if (ts->ts_tid == 0) {
 
2360
#ifdef CONFIG_USE_NPTL
 
2361
        ts->ts_tid = (pid_t)syscall(SYS_gettid);
 
2362
#else
 
2363
        /* when no threads are used, tid becomes pid */
 
2364
        ts->ts_tid = getpid();
 
2365
#endif
 
2366
    }
 
2367
}
 
2368
 
 
2369
void stop_all_tasks(void)
 
2370
{
 
2371
    /*
 
2372
     * We trust that when using NPTL, start_exclusive()
 
2373
     * handles thread stopping correctly.
 
2374
     */
 
2375
    start_exclusive();
 
2376
}
 
2377
 
2221
2378
/* Assumes contents are already zeroed.  */
2222
2379
void init_task_state(TaskState *ts)
2223
2380
{
2237
2394
    const char *cpu_model;
2238
2395
    struct target_pt_regs regs1, *regs = &regs1;
2239
2396
    struct image_info info1, *info = &info1;
 
2397
    struct linux_binprm bprm;
2240
2398
    TaskState ts1, *ts = &ts1;
2241
2399
    CPUState *env;
2242
2400
    int optind;
2243
2401
    const char *r;
2244
2402
    int gdbstub_port = 0;
2245
2403
    char **target_environ, **wrk;
 
2404
    char **target_argv;
 
2405
    int target_argc;
2246
2406
    envlist_t *envlist = NULL;
 
2407
    const char *argv0 = NULL;
 
2408
    int i;
 
2409
    int ret;
2247
2410
 
2248
2411
    if (argc <= 1)
2249
2412
        usage();
2300
2463
            r = argv[optind++];
2301
2464
            if (envlist_unsetenv(envlist, r) != 0)
2302
2465
                usage();
 
2466
        } else if (!strcmp(r, "0")) {
 
2467
            r = argv[optind++];
 
2468
            argv0 = r;
2303
2469
        } else if (!strcmp(r, "s")) {
2304
2470
            if (optind >= argc)
2305
2471
                break;
2337
2503
#endif
2338
2504
                exit(1);
2339
2505
            }
 
2506
#if defined(CONFIG_USE_GUEST_BASE)
 
2507
        } else if (!strcmp(r, "B")) {
 
2508
           guest_base = strtol(argv[optind++], NULL, 0);
 
2509
           have_guest_base = 1;
 
2510
#endif
2340
2511
        } else if (!strcmp(r, "drop-ld-preload")) {
2341
2512
            (void) envlist_unsetenv(envlist, "LD_PRELOAD");
 
2513
        } else if (!strcmp(r, "singlestep")) {
 
2514
            singlestep = 1;
2342
2515
        } else if (!strcmp(r, "strace")) {
2343
2516
            do_strace = 1;
2344
2517
        } else
2357
2530
    /* Zero out image_info */
2358
2531
    memset(info, 0, sizeof(struct image_info));
2359
2532
 
 
2533
    memset(&bprm, 0, sizeof (bprm));
 
2534
 
2360
2535
    /* Scan interp_prefix dir for replacement files. */
2361
2536
    init_paths(interp_prefix);
2362
2537
 
2368
2543
        cpu_model = "qemu32";
2369
2544
#endif
2370
2545
#elif defined(TARGET_ARM)
2371
 
        cpu_model = "arm926";
 
2546
        cpu_model = "any";
2372
2547
#elif defined(TARGET_M68K)
2373
2548
        cpu_model = "any";
2374
2549
#elif defined(TARGET_SPARC)
2410
2585
    target_environ = envlist_to_environ(envlist, NULL);
2411
2586
    envlist_free(envlist);
2412
2587
 
2413
 
    if (loader_exec(filename, argv+optind, target_environ, regs, info) != 0) {
2414
 
        printf("Error loading %s\n", filename);
 
2588
#if defined(CONFIG_USE_GUEST_BASE)
 
2589
    /*
 
2590
     * Now that page sizes are configured in cpu_init() we can do
 
2591
     * proper page alignment for guest_base.
 
2592
     */
 
2593
    guest_base = HOST_PAGE_ALIGN(guest_base);
 
2594
 
 
2595
    /*
 
2596
     * Read in mmap_min_addr kernel parameter.  This value is used
 
2597
     * When loading the ELF image to determine whether guest_base
 
2598
     * is needed.
 
2599
     *
 
2600
     * When user has explicitly set the quest base, we skip this
 
2601
     * test.
 
2602
     */
 
2603
    if (!have_guest_base) {
 
2604
        FILE *fp;
 
2605
 
 
2606
        if ((fp = fopen("/proc/sys/vm/mmap_min_addr", "r")) != NULL) {
 
2607
            unsigned long tmp;
 
2608
            if (fscanf(fp, "%lu", &tmp) == 1) {
 
2609
                mmap_min_addr = tmp;
 
2610
                qemu_log("host mmap_min_addr=0x%lx\n", mmap_min_addr);
 
2611
            }
 
2612
            fclose(fp);
 
2613
        }
 
2614
    }
 
2615
#endif /* CONFIG_USE_GUEST_BASE */
 
2616
 
 
2617
    /*
 
2618
     * Prepare copy of argv vector for target.
 
2619
     */
 
2620
    target_argc = argc - optind;
 
2621
    target_argv = calloc(target_argc + 1, sizeof (char *));
 
2622
    if (target_argv == NULL) {
 
2623
        (void) fprintf(stderr, "Unable to allocate memory for target_argv\n");
 
2624
        exit(1);
 
2625
    }
 
2626
 
 
2627
    /*
 
2628
     * If argv0 is specified (using '-0' switch) we replace
 
2629
     * argv[0] pointer with the given one.
 
2630
     */
 
2631
    i = 0;
 
2632
    if (argv0 != NULL) {
 
2633
        target_argv[i++] = strdup(argv0);
 
2634
    }
 
2635
    for (; i < target_argc; i++) {
 
2636
        target_argv[i] = strdup(argv[optind + i]);
 
2637
    }
 
2638
    target_argv[target_argc] = NULL;
 
2639
 
 
2640
    memset(ts, 0, sizeof(TaskState));
 
2641
    init_task_state(ts);
 
2642
    /* build Task State */
 
2643
    ts->info = info;
 
2644
    ts->bprm = &bprm;
 
2645
    env->opaque = ts;
 
2646
    task_settid(ts);
 
2647
 
 
2648
    ret = loader_exec(filename, target_argv, target_environ, regs,
 
2649
        info, &bprm);
 
2650
    if (ret != 0) {
 
2651
        printf("Error %d while loading %s\n", ret, filename);
2415
2652
        _exit(1);
2416
2653
    }
2417
2654
 
 
2655
    for (i = 0; i < target_argc; i++) {
 
2656
        free(target_argv[i]);
 
2657
    }
 
2658
    free(target_argv);
 
2659
 
2418
2660
    for (wrk = target_environ; *wrk; wrk++) {
2419
2661
        free(*wrk);
2420
2662
    }
2422
2664
    free(target_environ);
2423
2665
 
2424
2666
    if (qemu_log_enabled()) {
 
2667
#if defined(CONFIG_USE_GUEST_BASE)
 
2668
        qemu_log("guest_base  0x%lx\n", guest_base);
 
2669
#endif
2425
2670
        log_page_dump();
2426
2671
 
2427
2672
        qemu_log("start_brk   0x" TARGET_ABI_FMT_lx "\n", info->start_brk);
2441
2686
    syscall_init();
2442
2687
    signal_init();
2443
2688
 
2444
 
    /* build Task State */
2445
 
    memset(ts, 0, sizeof(TaskState));
2446
 
    init_task_state(ts);
2447
 
    ts->info = info;
2448
 
    env->opaque = ts;
2449
 
 
2450
2689
#if defined(TARGET_I386)
2451
2690
    cpu_x86_set_cpl(env, 3);
2452
2691
 
2620
2859
        env->sr = regs->sr;
2621
2860
        ts->sim_syscalls = 1;
2622
2861
    }
 
2862
#elif defined(TARGET_MICROBLAZE)
 
2863
    {
 
2864
        env->regs[0] = regs->r0;
 
2865
        env->regs[1] = regs->r1;
 
2866
        env->regs[2] = regs->r2;
 
2867
        env->regs[3] = regs->r3;
 
2868
        env->regs[4] = regs->r4;
 
2869
        env->regs[5] = regs->r5;
 
2870
        env->regs[6] = regs->r6;
 
2871
        env->regs[7] = regs->r7;
 
2872
        env->regs[8] = regs->r8;
 
2873
        env->regs[9] = regs->r9;
 
2874
        env->regs[10] = regs->r10;
 
2875
        env->regs[11] = regs->r11;
 
2876
        env->regs[12] = regs->r12;
 
2877
        env->regs[13] = regs->r13;
 
2878
        env->regs[14] = regs->r14;
 
2879
        env->regs[15] = regs->r15;          
 
2880
        env->regs[16] = regs->r16;          
 
2881
        env->regs[17] = regs->r17;          
 
2882
        env->regs[18] = regs->r18;          
 
2883
        env->regs[19] = regs->r19;          
 
2884
        env->regs[20] = regs->r20;          
 
2885
        env->regs[21] = regs->r21;          
 
2886
        env->regs[22] = regs->r22;          
 
2887
        env->regs[23] = regs->r23;          
 
2888
        env->regs[24] = regs->r24;          
 
2889
        env->regs[25] = regs->r25;          
 
2890
        env->regs[26] = regs->r26;          
 
2891
        env->regs[27] = regs->r27;          
 
2892
        env->regs[28] = regs->r28;          
 
2893
        env->regs[29] = regs->r29;          
 
2894
        env->regs[30] = regs->r30;          
 
2895
        env->regs[31] = regs->r31;          
 
2896
        env->sregs[SR_PC] = regs->pc;
 
2897
    }
2623
2898
#elif defined(TARGET_MIPS)
2624
2899
    {
2625
2900
        int i;