⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cpu-exec.c.svn-base

📁 我们自己开发的一个OSEK操作系统!不知道可不可以?
💻 SVN-BASE
📖 第 1 页 / 共 4 页
字号:
}#if defined(TARGET_I386) && defined(CONFIG_USER_ONLY)void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector){    CPUX86State *saved_env;    saved_env = env;    env = s;    if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK)) {        selector &= 0xffff;        cpu_x86_load_seg_cache(env, seg_reg, selector,                               (selector << 4), 0xffff, 0);    } else {        load_seg(seg_reg, selector);    }    env = saved_env;}void cpu_x86_fsave(CPUX86State *s, target_ulong ptr, int data32){    CPUX86State *saved_env;    saved_env = env;    env = s;    helper_fsave(ptr, data32);    env = saved_env;}void cpu_x86_frstor(CPUX86State *s, target_ulong ptr, int data32){    CPUX86State *saved_env;    saved_env = env;    env = s;    helper_frstor(ptr, data32);    env = saved_env;}#endif /* TARGET_I386 */#if !defined(CONFIG_SOFTMMU)#if defined(TARGET_I386)/* 'pc' is the host PC at which the exception was raised. 'address' is   the effective address of the memory exception. 'is_write' is 1 if a   write caused the exception and otherwise 0'. 'old_set' is the   signal set which should be restored */static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#if defined(DEBUG_SIGNAL)    qemu_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(h2g(address), pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_x86_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }    if (ret == 1) {#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(env->exception_index, env->error_code);    } else {        /* activate soft MMU for this block */        env->hflags |= HF_SOFTMMU_MASK;        cpu_resume_from_signal(env, puc);    }    /* never comes here */    return 1;}#elif defined(TARGET_ARM)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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(h2g(address), pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_arm_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }    /* we restore the process signal mask as the sigreturn should       do it (XXX: use sigsetjmp) */    sigprocmask(SIG_SETMASK, old_set, NULL);    cpu_loop_exit();}#elif defined(TARGET_SPARC)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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(h2g(address), pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_sparc_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }    /* we restore the process signal mask as the sigreturn should       do it (XXX: use sigsetjmp) */    sigprocmask(SIG_SETMASK, old_set, NULL);    cpu_loop_exit();}#elif defined (TARGET_PPC)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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(h2g(address), pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_ppc_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }    if (ret == 1) {#if 0        printf("PF exception: NIP=0x%08x error=0x%x %p\n",               env->nip, env->error_code, tb);#endif    /* we restore the process signal mask as the sigreturn should       do it (XXX: use sigsetjmp) */        sigprocmask(SIG_SETMASK, old_set, NULL);        do_raise_exception_err(env->exception_index, env->error_code);    } else {        /* activate soft MMU for this block */        cpu_resume_from_signal(env, puc);    }    /* never comes here */    return 1;}#elif defined(TARGET_M68K)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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, pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_m68k_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }    /* we restore the process signal mask as the sigreturn should       do it (XXX: use sigsetjmp) */    sigprocmask(SIG_SETMASK, old_set, NULL);    cpu_loop_exit();    /* never comes here */    return 1;}#elif defined (TARGET_MIPS)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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(h2g(address), pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_mips_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }    if (ret == 1) {#if 0        printf("PF exception: PC=0x" TARGET_FMT_lx " error=0x%x %p\n",               env->PC, env->error_code, tb);#endif    /* we restore the process signal mask as the sigreturn should       do it (XXX: use sigsetjmp) */        sigprocmask(SIG_SETMASK, old_set, NULL);        do_raise_exception_err(env->exception_index, env->error_code);    } else {        /* activate soft MMU for this block */        cpu_resume_from_signal(env, puc);    }    /* never comes here */    return 1;}#elif defined (TARGET_SH4)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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(h2g(address), pc, puc)) {        return 1;    }    /* see if it is an MMU fault */    ret = cpu_sh4_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);    if (ret < 0)        return 0; /* not an MMU fault */    if (ret == 0)        return 1; /* the MMU fault was handled without causing real CPU fault */    /* 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, puc);    }#if 0        printf("PF exception: NIP=0x%08x error=0x%x %p\n",               env->nip, env->error_code, tb);#endif    /* we restore the process signal mask as the sigreturn should       do it (XXX: use sigsetjmp) */    sigprocmask(SIG_SETMASK, old_set, NULL);    cpu_loop_exit();    /* never comes here */    return 1;}#elif defined (TARGET_ALPHA)static inline int handle_cpu_signal(unsigned long pc, unsigned long address,                                    int is_write, sigset_t *old_set,                                    void *puc){    TranslationBlock *tb;    int ret;    if (cpu_single_env)        env = cpu_single_env; /* XXX: find a correct solution for multithread */#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(h2g(address), pc, puc)) {        return 1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -