void cpu_loop(CPUUniCore32State *env)

{

    CPUState *cs = CPU(uc32_env_get_cpu(env));

    int trapnr;

    unsigned int n, insn;

    target_siginfo_t info;



    for (;;) {

        cpu_exec_start(cs);

        trapnr = uc32_cpu_exec(cs);

        cpu_exec_end(cs);

        switch (trapnr) {

        case UC32_EXCP_PRIV:

            {

                /* system call */

                get_user_u32(insn, env->regs[31] - 4);

                n = insn & 0xffffff;



                if (n >= UC32_SYSCALL_BASE) {

                    /* linux syscall */

                    n -= UC32_SYSCALL_BASE;

                    if (n == UC32_SYSCALL_NR_set_tls) {

                            cpu_set_tls(env, env->regs[0]);

                            env->regs[0] = 0;

                    } else {

                        env->regs[0] = do_syscall(env,

                                                  n,

                                                  env->regs[0],

                                                  env->regs[1],

                                                  env->regs[2],

                                                  env->regs[3],

                                                  env->regs[4],

                                                  env->regs[5],

                                                  0, 0);

                    }

                } else {

                    goto error;

                }

            }

            break;

        case UC32_EXCP_DTRAP:

        case UC32_EXCP_ITRAP:

            info.si_signo = TARGET_SIGSEGV;

            info.si_errno = 0;

            /* XXX: check env->error_code */

            info.si_code = TARGET_SEGV_MAPERR;

            info._sifields._sigfault._addr = env->cp0.c4_faultaddr;

            queue_signal(env, info.si_signo, &info);

            break;

        case EXCP_INTERRUPT:

            /* just indicate that signals should be handled asap */

            break;

        case EXCP_DEBUG:

            {

                int sig;



                sig = gdb_handlesig(cs, TARGET_SIGTRAP);

                if (sig) {

                    info.si_signo = sig;

                    info.si_errno = 0;

                    info.si_code = TARGET_TRAP_BRKPT;

                    queue_signal(env, info.si_signo, &info);

                }

            }

            break;

        default:

            goto error;

        }

        process_pending_signals(env);

    }



error:

    fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);

    cpu_dump_state(cs, stderr, fprintf, 0);

    abort();

}

void cpu_loop(CPUUniCore32State *env)

{

    CPUState *cs = CPU(uc32_env_get_cpu(env));

    int trapnr;

    unsigned int n, insn;

    target_siginfo_t info;



    for (;;) {

        cpu_exec_start(cs);

        trapnr = uc32_cpu_exec(cs);

        cpu_exec_end(cs);

        switch (trapnr) {

        case UC32_EXCP_PRIV:

            {

                

                get_user_u32(insn, env->regs[31] - 4);

                n = insn & 0xffffff;



                if (n >= UC32_SYSCALL_BASE) {

                    

                    n -= UC32_SYSCALL_BASE;

                    if (n == UC32_SYSCALL_NR_set_tls) {

                            cpu_set_tls(env, env->regs[0]);

                            env->regs[0] = 0;

                    } else {

                        env->regs[0] = do_syscall(env,

                                                  n,

                                                  env->regs[0],

                                                  env->regs[1],

                                                  env->regs[2],

                                                  env->regs[3],

                                                  env->regs[4],

                                                  env->regs[5],

                                                  0, 0);

                    }

                } else {

                    goto error;

                }

            }

            break;

        case UC32_EXCP_DTRAP:

        case UC32_EXCP_ITRAP:

            info.si_signo = TARGET_SIGSEGV;

            info.si_errno = 0;

            

            info.si_code = TARGET_SEGV_MAPERR;

            info._sifields._sigfault._addr = env->cp0.c4_faultaddr;

            queue_signal(env, info.si_signo, &info);

            break;

        case EXCP_INTERRUPT:

            

            break;

        case EXCP_DEBUG:

            {

                int sig;



                sig = gdb_handlesig(cs, TARGET_SIGTRAP);

                if (sig) {

                    info.si_signo = sig;

                    info.si_errno = 0;

                    info.si_code = TARGET_TRAP_BRKPT;

                    queue_signal(env, info.si_signo, &info);

                }

            }

            break;

        default:

            goto error;

        }

        process_pending_signals(env);

    }



error:

    fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);

    cpu_dump_state(cs, stderr, fprintf, 0);

    abort();

}

void FUNC_0(CPUUniCore32State *VAR_0)

{

    CPUState *cs = CPU(uc32_env_get_cpu(VAR_0));

    int VAR_1;

    unsigned int VAR_2, VAR_3;

    target_siginfo_t info;



    for (;;) {

        cpu_exec_start(cs);

        VAR_1 = uc32_cpu_exec(cs);

        cpu_exec_end(cs);

        switch (VAR_1) {

        case UC32_EXCP_PRIV:

            {

                

                get_user_u32(VAR_3, VAR_0->regs[31] - 4);

                VAR_2 = VAR_3 & 0xffffff;



                if (VAR_2 >= UC32_SYSCALL_BASE) {

                    

                    VAR_2 -= UC32_SYSCALL_BASE;

                    if (VAR_2 == UC32_SYSCALL_NR_set_tls) {

                            cpu_set_tls(VAR_0, VAR_0->regs[0]);

                            VAR_0->regs[0] = 0;

                    } else {

                        VAR_0->regs[0] = do_syscall(VAR_0,

                                                  VAR_2,

                                                  VAR_0->regs[0],

                                                  VAR_0->regs[1],

                                                  VAR_0->regs[2],

                                                  VAR_0->regs[3],

                                                  VAR_0->regs[4],

                                                  VAR_0->regs[5],

                                                  0, 0);

                    }

                } else {

                    goto error;

                }

            }

            break;

        case UC32_EXCP_DTRAP:

        case UC32_EXCP_ITRAP:

            info.si_signo = TARGET_SIGSEGV;

            info.si_errno = 0;

            

            info.si_code = TARGET_SEGV_MAPERR;

            info._sifields._sigfault._addr = VAR_0->cp0.c4_faultaddr;

            queue_signal(VAR_0, info.si_signo, &info);

            break;

        case EXCP_INTERRUPT:

            

            break;

        case EXCP_DEBUG:

            {

                int VAR_4;



                VAR_4 = gdb_handlesig(cs, TARGET_SIGTRAP);

                if (VAR_4) {

                    info.si_signo = VAR_4;

                    info.si_errno = 0;

                    info.si_code = TARGET_TRAP_BRKPT;

                    queue_signal(VAR_0, info.si_signo, &info);

                }

            }

            break;

        default:

            goto error;

        }

        process_pending_signals(VAR_0);

    }



error:

    fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\VAR_2", VAR_1);

    cpu_dump_state(cs, stderr, fprintf, 0);

    abort();

}

void FUNC_0(CPUUniCore32State *VAR_0)
{ CPUState *cs = CPU(uc32_env_get_cpu(VAR_0)); int VAR_1; unsigned int VAR_2, VAR_3; target_siginfo_t info; for (;;) { cpu_exec_start(cs); VAR_1 = uc32_cpu_exec(cs); cpu_exec_end(cs); switch (VAR_1) { case UC32_EXCP_PRIV:
{ get_user_u32(VAR_3, VAR_0->regs[31] - 4); VAR_2 = VAR_3 & 0xffffff; if (VAR_2 >= UC32_SYSCALL_BASE) { VAR_2 -= UC32_SYSCALL_BASE; if (VAR_2 == UC32_SYSCALL_NR_set_tls) { cpu_set_tls(VAR_0, VAR_0->regs[0]); VAR_0->regs[0] = 0; } else { VAR_0->regs[0] = do_syscall(VAR_0,
VAR_2,
VAR_0->regs[0],
VAR_0->regs[1],
VAR_0->regs[2],
VAR_0->regs[3],
VAR_0->regs[4],
VAR_0->regs[5],
0, 0); } } else { goto error; } } break; case UC32_EXCP_DTRAP:
case UC32_EXCP_ITRAP:
info.si_signo = TARGET_SIGSEGV; info.si_errno = 0; info.si_code = TARGET_SEGV_MAPERR; info._sifields._sigfault._addr = VAR_0->cp0.c4_faultaddr; queue_signal(VAR_0, info.si_signo, &info); break; case EXCP_INTERRUPT:
break; case EXCP_DEBUG:
{ int VAR_4; VAR_4 = gdb_handlesig(cs, TARGET_SIGTRAP); if (VAR_4) { info.si_signo = VAR_4; info.si_errno = 0; info.si_code = TARGET_TRAP_BRKPT; queue_signal(VAR_0, info.si_signo, &info); } } break; default:
goto error; } process_pending_signals(VAR_0); } error:
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\VAR_2", VAR_1); cpu_dump_state(cs, stderr, fprintf, 0); abort(); }