diff options
Diffstat (limited to 'cpu-exec.c')
-rw-r--r-- | cpu-exec.c | 59 |
1 files changed, 52 insertions, 7 deletions
diff --git a/cpu-exec.c b/cpu-exec.c index 5bbace345f..5507c04dd0 100644 --- a/cpu-exec.c +++ b/cpu-exec.c @@ -133,6 +133,7 @@ int cpu_exec(CPUState *env1) env->cpsr = psr & ~0xf0000000; } #elif defined(TARGET_SPARC) +#elif defined(TARGET_PPC) #else #error unsupported target CPU #endif @@ -228,6 +229,8 @@ int cpu_exec(CPUState *env1) env->cpsr &= ~0xf0000000; #elif defined(TARGET_SPARC) cpu_sparc_dump_state (env, logfile, 0); +#elif defined(TARGET_PPC) + cpu_ppc_dump_state(env, logfile, 0); #else #error unsupported target CPU #endif @@ -246,13 +249,17 @@ int cpu_exec(CPUState *env1) cs_base = 0; pc = (uint8_t *)env->regs[15]; #elif defined(TARGET_SPARC) - flags = 0; - cs_base = 0; - if (env->npc) { - env->pc = env->npc; - env->npc = 0; - } - pc = (uint8_t *) env->pc; + flags = 0; + cs_base = 0; + if (env->npc) { + env->pc = env->npc; + env->npc = 0; + } + pc = (uint8_t *) env->pc; +#elif defined(TARGET_PPC) + flags = 0; + cs_base = 0; + pc = (uint8_t *)env->nip; #else #error unsupported CPU #endif @@ -376,6 +383,7 @@ int cpu_exec(CPUState *env1) #elif defined(TARGET_ARM) env->cpsr = compute_cpsr(); #elif defined(TARGET_SPARC) +#elif defined(TARGET_PPC) #else #error unsupported target CPU #endif @@ -513,6 +521,43 @@ static inline int handle_cpu_signal(unsigned long pc, unsigned long address, { return 0; } +#elif defined (TARGET_PPC) +static inline int handle_cpu_signal(unsigned long pc, unsigned long address, + int is_write, sigset_t *old_set) +{ + TranslationBlock *tb; + +#if 0 + if (cpu_single_env) + env = cpu_single_env; /* XXX: find a correct solution for multithread */ +#endif +#if defined(DEBUG_SIGNAL) + printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n", + pc, address, is_write, *(unsigned long *)old_set); +#endif + /* XXX: locking issue */ + if (is_write && page_unprotect(address)) { + return 1; + } + + /* now we have a real cpu fault */ + tb = tb_find_pc(pc); + if (tb) { + /* the PC is inside the translated code. It means that we have + a virtual CPU fault */ + cpu_restore_state(tb, env, pc); + } +#if 0 + printf("PF exception: EIP=0x%08x CR2=0x%08x error=0x%x\n", + env->eip, env->cr[2], env->error_code); +#endif + /* we restore the process signal mask as the sigreturn should + do it (XXX: use sigsetjmp) */ + sigprocmask(SIG_SETMASK, old_set, NULL); + raise_exception_err(EXCP_PROGRAM, env->error_code); + /* never comes here */ + return 1; +} #else #error unsupported target CPU #endif |