diff -urN qemu-snapshot-2004-12-23_23.orig/cpu-exec.c qemu-snapshot-2004-12-23_23/cpu-exec.c --- qemu-snapshot-2004-12-23_23.orig/cpu-exec.c Sat Dec 25 11:09:49 2004 +++ qemu-snapshot-2004-12-23_23/cpu-exec.c Sat Dec 25 11:17:44 2004 @@ -54,7 +54,7 @@ void cpu_resume_from_signal(CPUState *env1, void *puc) { #if !defined(CONFIG_SOFTMMU) || defined(CONFIG_MMU_MAP) - struct ucontext *uc = puc; + ucontext_t *uc = puc; #endif env = env1; @@ -865,7 +865,7 @@ #if defined(USE_CODE_COPY) static void cpu_send_trap(unsigned long pc, int trap, - struct ucontext *uc) + ucontext_t *uc) { TranslationBlock *tb; @@ -883,10 +883,10 @@ } #endif -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { - struct ucontext *uc = puc; + ucontext_t *uc = puc; unsigned long pc; int trapno; @@ -896,8 +896,13 @@ #define REG_ERR ERR #define REG_TRAPNO TRAPNO #endif +#if defined(__FreeBSD__) + pc = uc->uc_mcontext.mc_eip; + trapno = uc->uc_mcontext.mc_trapno; +#else pc = uc->uc_mcontext.gregs[REG_EIP]; trapno = uc->uc_mcontext.gregs[REG_TRAPNO]; +#endif #if defined(TARGET_I386) && defined(USE_CODE_COPY) if (trapno == 0x00 || trapno == 0x05) { /* send division by zero or bound exception */ @@ -907,16 +912,20 @@ #endif return handle_cpu_signal(pc, (unsigned long)info->si_addr, trapno == 0xe ? +#if defined(__FreeBSD__) + (uc->uc_mcontext.mc_err >> 1) & 1 : 0, +#else (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0, +#endif &uc->uc_sigmask, puc); } #elif defined(__x86_64__) -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { - struct ucontext *uc = puc; + ucontext_t *uc = puc; unsigned long pc; pc = uc->uc_mcontext.gregs[REG_RIP]; @@ -954,7 +963,7 @@ #ifdef __APPLE__ # include -typedef struct ucontext SIGCONTEXT; +typedef ucontext_t SIGCONTEXT; /* All Registers access - only for local access */ # define REG_sig(reg_name, context) ((context)->uc_mcontext->ss.reg_name) # define FLOATREG_sig(reg_name, context) ((context)->uc_mcontext->fs.reg_name) @@ -977,10 +986,10 @@ # define TRAP_sig(context) EXCEPREG_sig(exception, context) /* number of powerpc exception taken */ #endif /* __APPLE__ */ -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { - struct ucontext *uc = puc; + ucontext_t *uc = puc; unsigned long pc; int is_write; @@ -1000,10 +1009,10 @@ #elif defined(__alpha__) -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { - struct ucontext *uc = puc; + ucontext_t *uc = puc; uint32_t *pc = uc->uc_mcontext.sc_pc; uint32_t insn = *pc; int is_write = 0; @@ -1029,7 +1038,7 @@ } #elif defined(__sparc__) -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { uint32_t *regs = (uint32_t *)(info + 1); @@ -1062,10 +1071,10 @@ #elif defined(__arm__) -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { - struct ucontext *uc = puc; + ucontext_t *uc = puc; unsigned long pc; int is_write; @@ -1079,10 +1088,10 @@ #elif defined(__mc68000) -int cpu_signal_handler(int host_signum, struct siginfo *info, +int cpu_signal_handler(int host_signum, siginfo_t *info, void *puc) { - struct ucontext *uc = puc; + ucontext_t *uc = puc; unsigned long pc; int is_write; diff -urN qemu-snapshot-2004-12-23_23.orig/mmu_map.h qemu-snapshot-2004-12-23_23/mmu_map.h --- qemu-snapshot-2004-12-23_23.orig/mmu_map.h Sat Dec 25 11:11:31 2004 +++ qemu-snapshot-2004-12-23_23/mmu_map.h Sat Dec 25 11:21:16 2004 @@ -114,7 +114,11 @@ { target_ulong vaddr; +#if defined(__FreeBSD__) + vaddr = addr - uc->uc_mcontext.mc_eax; +#else vaddr = addr - uc->uc_mcontext.gregs[REG_EAX]; +#endif return vaddr; } @@ -125,9 +129,17 @@ vpage = vaddr >> TARGET_PAGE_BITS; if (is_write) { +#if defined(__FreeBSD__) + uc->uc_mcontext.mc_eax = map->add_write[vpage]; +#else uc->uc_mcontext.gregs[REG_EAX] = map->add_write[vpage]; +#endif } else { +#if defined(__FreeBSD__) + uc->uc_mcontext.mc_eax = map->add_read[vpage]; +#else uc->uc_mcontext.gregs[REG_EAX] = map->add_read[vpage]; +#endif } } diff -urN qemu-snapshot-2004-12-23_23.orig/target-i386/cpu.h qemu-snapshot-2004-12-23_23/target-i386/cpu.h --- qemu-snapshot-2004-12-23_23.orig/target-i386/cpu.h Sat Dec 25 11:05:22 2004 +++ qemu-snapshot-2004-12-23_23/target-i386/cpu.h Sat Dec 25 11:21:52 2004 @@ -449,8 +449,7 @@ /* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */ -struct siginfo; -int cpu_x86_signal_handler(int host_signum, struct siginfo *info, +int cpu_x86_signal_handler(int host_signum, siginfo_t *info, void *puc); void cpu_x86_set_a20(CPUX86State *env, int a20_state);