do not use syscall to quit emulation. this can fix issues #147 & #148

This commit is contained in:
Nguyen Anh Quynh
2015-09-26 16:49:00 +08:00
parent 79b81e6ae4
commit 886946dcf4
22 changed files with 57 additions and 29 deletions

View File

@ -241,7 +241,7 @@ target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1,
helper_raise_exception(env, TT_TOVF);
}
#ifndef TARGET_SPARC64
//#ifndef TARGET_SPARC64
void helper_power_down(CPUSPARCState *env)
{
CPUState *cs = CPU(sparc_env_get_cpu(env));
@ -252,4 +252,4 @@ void helper_power_down(CPUSPARCState *env)
env->npc = env->pc + 4;
cpu_loop_exit(cs);
}
#endif
//#endif

View File

@ -1,10 +1,10 @@
DEF_HELPER_5(uc_tracecode, void, i32, ptr, ptr, i64, ptr)
DEF_HELPER_1(power_down, void, env)
#ifndef TARGET_SPARC64
DEF_HELPER_1(rett, void, env)
DEF_HELPER_2(wrpsr, void, env, tl)
DEF_HELPER_1(rdpsr, tl, env)
DEF_HELPER_1(power_down, void, env)
#else
DEF_HELPER_2(wrpil, void, env, tl)
DEF_HELPER_2(wrpstate, void, env, tl)

View File

@ -5405,6 +5405,14 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu,
if (max_insns == 0)
max_insns = CF_COUNT_MASK;
// Unicorn: early check to see if the address of this block is the until address
if (tb->pc == env->uc->addr_end) {
gen_tb_start(tcg_ctx);
save_state(dc);
gen_helper_power_down(tcg_ctx, tcg_ctx->cpu_env);
goto done_generating;
}
// Unicorn: trace this block on request
// Only hook this block if it is not broken from previous translation due to
// full translation cache
@ -5448,7 +5456,9 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu,
// gen_io_start();
// Unicorn: end address tells us to stop emulation
if (dc->pc == dc->uc->addr_end) {
insn = 0x91d02000; // generate TRAP to end this TB
save_state(dc);
gen_helper_power_down(tcg_ctx, tcg_ctx->cpu_env);
break;
} else {
last_pc = dc->pc;
insn = cpu_ldl_code(env, dc->pc);
@ -5497,6 +5507,8 @@ static inline void gen_intermediate_code_internal(SPARCCPU *cpu,
tcg_gen_exit_tb(tcg_ctx, 0);
}
}
done_generating:
gen_tb_end(tcg_ctx, tb, num_insns);
*tcg_ctx->gen_opc_ptr = INDEX_op_end;
if (spc) {