Skip to content

Commit

Permalink
target-i386: Use cpu_exec_enter/exit qom hooks
Browse files Browse the repository at this point in the history
Note that the code that was within the "exit" ifdef block
was identical to the cpu_compute_eflags inline, so make that
simplification at the same time.

Signed-off-by: Richard Henderson <[email protected]>
Reviewed-by: Alex Bennée <[email protected]>
Message-id: [email protected]
Signed-off-by: Peter Maydell <[email protected]>
  • Loading branch information
rth7680 authored and pm215 committed Sep 25, 2014
1 parent 1039e12 commit 374e0cd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 12 deletions.
14 changes: 2 additions & 12 deletions cpu-exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,13 +352,7 @@ int cpu_exec(CPUArchState *env)
cpu->exit_request = 1;
}

#if defined(TARGET_I386)
/* put eflags in CPU temporary format */
CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
env->df = 1 - (2 * ((env->eflags >> 10) & 1));
CC_OP = CC_OP_EFLAGS;
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
#elif defined(TARGET_M68K)
#if defined(TARGET_M68K)
env->cc_op = CC_OP_FLAGS;
env->cc_dest = env->sr & 0xf;
env->cc_x = (env->sr >> 4) & 1;
Expand Down Expand Up @@ -811,11 +805,7 @@ int cpu_exec(CPUArchState *env)
} /* for(;;) */


#if defined(TARGET_I386)
/* restore flags in standard format */
env->eflags = env->eflags | cpu_cc_compute_all(env, CC_OP)
| (env->df & DF_MASK);
#elif defined(TARGET_M68K)
#if defined(TARGET_M68K)
cpu_m68k_flush_flags(env, env->cc_op);
env->cc_op = CC_OP_FLAGS;
env->sr = (env->sr & 0xffe0)
Expand Down
3 changes: 3 additions & 0 deletions target-i386/cpu-qom.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,7 @@ hwaddr x86_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
int x86_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
int x86_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);

void x86_cpu_exec_enter(CPUState *cpu);
void x86_cpu_exec_exit(CPUState *cpu);

#endif
2 changes: 2 additions & 0 deletions target-i386/cpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -2942,6 +2942,8 @@ static void x86_cpu_common_class_init(ObjectClass *oc, void *data)
#ifndef CONFIG_USER_ONLY
cc->debug_excp_handler = breakpoint_handler;
#endif
cc->cpu_exec_enter = x86_cpu_exec_enter;
cc->cpu_exec_exit = x86_cpu_exec_exit;
}

static const TypeInfo x86_cpu_type_info = {
Expand Down
21 changes: 21 additions & 0 deletions target-i386/helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1262,3 +1262,24 @@ void do_cpu_sipi(X86CPU *cpu)
{
}
#endif

/* Frob eflags into and out of the CPU temporary format. */

void x86_cpu_exec_enter(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;

CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
env->df = 1 - (2 * ((env->eflags >> 10) & 1));
CC_OP = CC_OP_EFLAGS;
env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
}

void x86_cpu_exec_exit(CPUState *cs)
{
X86CPU *cpu = X86_CPU(cs);
CPUX86State *env = &cpu->env;

env->eflags = cpu_compute_eflags(env);
}

0 comments on commit 374e0cd

Please sign in to comment.