mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-05 00:33:55 -06:00
exec: refactor cpu_restore_state
Refactor common code around calls to cpu_restore_state(). tb_find_pc() has now no external users, make it static. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
This commit is contained in:
parent
5b6dd8683d
commit
a8a826a3c3
23 changed files with 65 additions and 172 deletions
|
@ -710,7 +710,6 @@ uint64_t cpu_tick_get_count(CPUTimer *timer);
|
|||
void cpu_tick_set_limit(CPUTimer *timer, uint64_t limit);
|
||||
trap_state* cpu_tsptr(CPUSPARCState* env);
|
||||
#endif
|
||||
void cpu_restore_state2(CPUSPARCState *env, uintptr_t retaddr);
|
||||
|
||||
#define TB_FLAG_FPU_ENABLED (1 << 4)
|
||||
#define TB_FLAG_AM_ENABLED (1 << 5)
|
||||
|
|
|
@ -75,7 +75,7 @@ static target_ulong helper_udiv_common(CPUSPARCState *env, target_ulong a,
|
|||
x1 = (b & 0xffffffff);
|
||||
|
||||
if (x1 == 0) {
|
||||
cpu_restore_state2(env, GETPC());
|
||||
cpu_restore_state(env, GETPC());
|
||||
helper_raise_exception(env, TT_DIV_ZERO);
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ static target_ulong helper_sdiv_common(CPUSPARCState *env, target_ulong a,
|
|||
x1 = (b & 0xffffffff);
|
||||
|
||||
if (x1 == 0) {
|
||||
cpu_restore_state2(env, GETPC());
|
||||
cpu_restore_state(env, GETPC());
|
||||
helper_raise_exception(env, TT_DIV_ZERO);
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ int64_t helper_sdivx(CPUSPARCState *env, int64_t a, int64_t b)
|
|||
{
|
||||
if (b == 0) {
|
||||
/* Raise divide by zero trap. */
|
||||
cpu_restore_state2(env, GETPC());
|
||||
cpu_restore_state(env, GETPC());
|
||||
helper_raise_exception(env, TT_DIV_ZERO);
|
||||
} else if (b == -1) {
|
||||
/* Avoid overflow trap with i386 divide insn. */
|
||||
|
@ -161,7 +161,7 @@ uint64_t helper_udivx(CPUSPARCState *env, uint64_t a, uint64_t b)
|
|||
{
|
||||
if (b == 0) {
|
||||
/* Raise divide by zero trap. */
|
||||
cpu_restore_state2(env, GETPC());
|
||||
cpu_restore_state(env, GETPC());
|
||||
helper_raise_exception(env, TT_DIV_ZERO);
|
||||
}
|
||||
return a / b;
|
||||
|
@ -193,7 +193,7 @@ target_ulong helper_taddcctv(CPUSPARCState *env, target_ulong src1,
|
|||
return dst;
|
||||
|
||||
tag_overflow:
|
||||
cpu_restore_state2(env, GETPC());
|
||||
cpu_restore_state(env, GETPC());
|
||||
helper_raise_exception(env, TT_TOVF);
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,6 @@ target_ulong helper_tsubcctv(CPUSPARCState *env, target_ulong src1,
|
|||
return dst;
|
||||
|
||||
tag_overflow:
|
||||
cpu_restore_state2(env, GETPC());
|
||||
cpu_restore_state(env, GETPC());
|
||||
helper_raise_exception(env, TT_TOVF);
|
||||
}
|
||||
|
|
|
@ -2393,22 +2393,6 @@ void cpu_unassigned_access(CPUSPARCState *env, hwaddr addr,
|
|||
#endif
|
||||
#endif
|
||||
|
||||
/* XXX: make it generic ? */
|
||||
void cpu_restore_state2(CPUSPARCState *env, uintptr_t retaddr)
|
||||
{
|
||||
TranslationBlock *tb;
|
||||
|
||||
if (retaddr) {
|
||||
/* now we have a real cpu fault */
|
||||
tb = tb_find_pc(retaddr);
|
||||
if (tb) {
|
||||
/* the PC is inside the translated code. It means that we have
|
||||
a virtual CPU fault */
|
||||
cpu_restore_state(tb, env, retaddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined(CONFIG_USER_ONLY)
|
||||
static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env,
|
||||
target_ulong addr, int is_write,
|
||||
|
@ -2418,7 +2402,9 @@ static void QEMU_NORETURN do_unaligned_access(CPUSPARCState *env,
|
|||
printf("Unaligned access to 0x" TARGET_FMT_lx " from 0x" TARGET_FMT_lx
|
||||
"\n", addr, env->pc);
|
||||
#endif
|
||||
cpu_restore_state2(env, retaddr);
|
||||
if (retaddr) {
|
||||
cpu_restore_state(env, retaddr);
|
||||
}
|
||||
helper_raise_exception(env, TT_UNALIGNED);
|
||||
}
|
||||
|
||||
|
@ -2433,7 +2419,9 @@ void tlb_fill(CPUSPARCState *env, target_ulong addr, int is_write, int mmu_idx,
|
|||
|
||||
ret = cpu_sparc_handle_mmu_fault(env, addr, is_write, mmu_idx);
|
||||
if (ret) {
|
||||
cpu_restore_state2(env, retaddr);
|
||||
if (retaddr) {
|
||||
cpu_restore_state(env, retaddr);
|
||||
}
|
||||
cpu_loop_exit(env);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue