Commit bfed01fc79cb2da1c6ca700bb0ce9238ce2974c7
1 parent
08ab123c
Clean up of some target specifics in exec.c/cpu-exec.c.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2936 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
12 changed files
with
92 additions
and
92 deletions
cpu-exec.c
| @@ -40,14 +40,14 @@ int tb_invalidated_flag; | @@ -40,14 +40,14 @@ int tb_invalidated_flag; | ||
| 40 | //#define DEBUG_EXEC | 40 | //#define DEBUG_EXEC |
| 41 | //#define DEBUG_SIGNAL | 41 | //#define DEBUG_SIGNAL |
| 42 | 42 | ||
| 43 | -#if defined(TARGET_ARM) || defined(TARGET_SPARC) || defined(TARGET_M68K) || \ | ||
| 44 | - defined(TARGET_ALPHA) | ||
| 45 | -/* XXX: unify with i386 target */ | ||
| 46 | void cpu_loop_exit(void) | 43 | void cpu_loop_exit(void) |
| 47 | { | 44 | { |
| 45 | + /* NOTE: the register at this point must be saved by hand because | ||
| 46 | + longjmp restore them */ | ||
| 47 | + regs_to_env(); | ||
| 48 | longjmp(env->jmp_env, 1); | 48 | longjmp(env->jmp_env, 1); |
| 49 | } | 49 | } |
| 50 | -#endif | 50 | + |
| 51 | #if !(defined(TARGET_SPARC) || defined(TARGET_SH4) || defined(TARGET_M68K)) | 51 | #if !(defined(TARGET_SPARC) || defined(TARGET_SH4) || defined(TARGET_M68K)) |
| 52 | #define reg_T2 | 52 | #define reg_T2 |
| 53 | #endif | 53 | #endif |
| @@ -249,65 +249,8 @@ int cpu_exec(CPUState *env1) | @@ -249,65 +249,8 @@ int cpu_exec(CPUState *env1) | ||
| 249 | TranslationBlock *tb; | 249 | TranslationBlock *tb; |
| 250 | uint8_t *tc_ptr; | 250 | uint8_t *tc_ptr; |
| 251 | 251 | ||
| 252 | -#if defined(TARGET_I386) | ||
| 253 | - /* handle exit of HALTED state */ | ||
| 254 | - if (env1->hflags & HF_HALTED_MASK) { | ||
| 255 | - /* disable halt condition */ | ||
| 256 | - if ((env1->interrupt_request & CPU_INTERRUPT_HARD) && | ||
| 257 | - (env1->eflags & IF_MASK)) { | ||
| 258 | - env1->hflags &= ~HF_HALTED_MASK; | ||
| 259 | - } else { | ||
| 260 | - return EXCP_HALTED; | ||
| 261 | - } | ||
| 262 | - } | ||
| 263 | -#elif defined(TARGET_PPC) | ||
| 264 | - if (env1->halted) { | ||
| 265 | - if (env1->msr[MSR_EE] && | ||
| 266 | - (env1->interrupt_request & CPU_INTERRUPT_HARD)) { | ||
| 267 | - env1->halted = 0; | ||
| 268 | - } else { | ||
| 269 | - return EXCP_HALTED; | ||
| 270 | - } | ||
| 271 | - } | ||
| 272 | -#elif defined(TARGET_SPARC) | ||
| 273 | - if (env1->halted) { | ||
| 274 | - if ((env1->interrupt_request & CPU_INTERRUPT_HARD) && | ||
| 275 | - (env1->psret != 0)) { | ||
| 276 | - env1->halted = 0; | ||
| 277 | - } else { | ||
| 278 | - return EXCP_HALTED; | ||
| 279 | - } | ||
| 280 | - } | ||
| 281 | -#elif defined(TARGET_ARM) | ||
| 282 | - if (env1->halted) { | ||
| 283 | - /* An interrupt wakes the CPU even if the I and F CPSR bits are | ||
| 284 | - set. We use EXITTB to silently wake CPU without causing an | ||
| 285 | - actual interrupt. */ | ||
| 286 | - if (env1->interrupt_request & | ||
| 287 | - (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB)) { | ||
| 288 | - env1->halted = 0; | ||
| 289 | - } else { | ||
| 290 | - return EXCP_HALTED; | ||
| 291 | - } | ||
| 292 | - } | ||
| 293 | -#elif defined(TARGET_MIPS) | ||
| 294 | - if (env1->halted) { | ||
| 295 | - if (env1->interrupt_request & | ||
| 296 | - (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) { | ||
| 297 | - env1->halted = 0; | ||
| 298 | - } else { | ||
| 299 | - return EXCP_HALTED; | ||
| 300 | - } | ||
| 301 | - } | ||
| 302 | -#elif defined(TARGET_ALPHA) || defined(TARGET_M68K) | ||
| 303 | - if (env1->halted) { | ||
| 304 | - if (env1->interrupt_request & CPU_INTERRUPT_HARD) { | ||
| 305 | - env1->halted = 0; | ||
| 306 | - } else { | ||
| 307 | - return EXCP_HALTED; | ||
| 308 | - } | ||
| 309 | - } | ||
| 310 | -#endif | 252 | + if (cpu_halted(env1) == EXCP_HALTED) |
| 253 | + return EXCP_HALTED; | ||
| 311 | 254 | ||
| 312 | cpu_single_env = env1; | 255 | cpu_single_env = env1; |
| 313 | 256 |
target-alpha/exec.h
| @@ -79,4 +79,14 @@ int cpu_alpha_mtpr (CPUState *env, int iprn, uint64_t val, uint64_t *oldvalp); | @@ -79,4 +79,14 @@ int cpu_alpha_mtpr (CPUState *env, int iprn, uint64_t val, uint64_t *oldvalp); | ||
| 79 | 79 | ||
| 80 | void do_interrupt (CPUState *env); | 80 | void do_interrupt (CPUState *env); |
| 81 | 81 | ||
| 82 | +static inline int cpu_halted(CPUState *env) { | ||
| 83 | + if (!env->halted) | ||
| 84 | + return 0; | ||
| 85 | + if (env->interrupt_request & CPU_INTERRUPT_HARD) { | ||
| 86 | + env->halted = 0; | ||
| 87 | + return 0; | ||
| 88 | + } | ||
| 89 | + return EXCP_HALTED; | ||
| 90 | +} | ||
| 91 | + | ||
| 82 | #endif /* !defined (__ALPHA_EXEC_H__) */ | 92 | #endif /* !defined (__ALPHA_EXEC_H__) */ |
target-arm/exec.h
| @@ -48,6 +48,20 @@ static inline void regs_to_env(void) | @@ -48,6 +48,20 @@ static inline void regs_to_env(void) | ||
| 48 | int cpu_arm_handle_mmu_fault (CPUState *env, target_ulong address, int rw, | 48 | int cpu_arm_handle_mmu_fault (CPUState *env, target_ulong address, int rw, |
| 49 | int is_user, int is_softmmu); | 49 | int is_user, int is_softmmu); |
| 50 | 50 | ||
| 51 | +static inline int cpu_halted(CPUState *env) { | ||
| 52 | + if (!env->halted) | ||
| 53 | + return 0; | ||
| 54 | + /* An interrupt wakes the CPU even if the I and F CPSR bits are | ||
| 55 | + set. We use EXITTB to silently wake CPU without causing an | ||
| 56 | + actual interrupt. */ | ||
| 57 | + if (env->interrupt_request & | ||
| 58 | + (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD | CPU_INTERRUPT_EXITTB)) { | ||
| 59 | + env->halted = 0; | ||
| 60 | + return 0; | ||
| 61 | + } | ||
| 62 | + return EXCP_HALTED; | ||
| 63 | +} | ||
| 64 | + | ||
| 51 | #if !defined(CONFIG_USER_ONLY) | 65 | #if !defined(CONFIG_USER_ONLY) |
| 52 | #include "softmmu_exec.h" | 66 | #include "softmmu_exec.h" |
| 53 | #endif | 67 | #endif |
target-i386/exec.h
| @@ -575,3 +575,16 @@ static inline void regs_to_env(void) | @@ -575,3 +575,16 @@ static inline void regs_to_env(void) | ||
| 575 | env->regs[R_EDI] = EDI; | 575 | env->regs[R_EDI] = EDI; |
| 576 | #endif | 576 | #endif |
| 577 | } | 577 | } |
| 578 | + | ||
| 579 | +static inline int cpu_halted(CPUState *env) { | ||
| 580 | + /* handle exit of HALTED state */ | ||
| 581 | + if (env->hflags & HF_HALTED_MASK) | ||
| 582 | + return 0; | ||
| 583 | + /* disable halt condition */ | ||
| 584 | + if ((env->interrupt_request & CPU_INTERRUPT_HARD) && | ||
| 585 | + (env->eflags & IF_MASK)) { | ||
| 586 | + env->hflags &= ~HF_HALTED_MASK; | ||
| 587 | + return 0; | ||
| 588 | + } | ||
| 589 | + return EXCP_HALTED; | ||
| 590 | +} |
target-i386/helper.c
| @@ -106,14 +106,6 @@ void cpu_unlock(void) | @@ -106,14 +106,6 @@ void cpu_unlock(void) | ||
| 106 | spin_unlock(&global_cpu_lock); | 106 | spin_unlock(&global_cpu_lock); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | -void cpu_loop_exit(void) | ||
| 110 | -{ | ||
| 111 | - /* NOTE: the register at this point must be saved by hand because | ||
| 112 | - longjmp restore them */ | ||
| 113 | - regs_to_env(); | ||
| 114 | - longjmp(env->jmp_env, 1); | ||
| 115 | -} | ||
| 116 | - | ||
| 117 | /* return non zero if error */ | 109 | /* return non zero if error */ |
| 118 | static inline int load_segment(uint32_t *e1_ptr, uint32_t *e2_ptr, | 110 | static inline int load_segment(uint32_t *e1_ptr, uint32_t *e2_ptr, |
| 119 | int selector) | 111 | int selector) |
target-m68k/exec.h
| @@ -49,3 +49,13 @@ float64 helper_sub_cmpf64(CPUM68KState *env, float64 src0, float64 src1); | @@ -49,3 +49,13 @@ float64 helper_sub_cmpf64(CPUM68KState *env, float64 src0, float64 src1); | ||
| 49 | void helper_movec(CPUM68KState *env, int reg, uint32_t val); | 49 | void helper_movec(CPUM68KState *env, int reg, uint32_t val); |
| 50 | 50 | ||
| 51 | void cpu_loop_exit(void); | 51 | void cpu_loop_exit(void); |
| 52 | + | ||
| 53 | +static inline int cpu_halted(CPUState *env) { | ||
| 54 | + if (!env->halted) | ||
| 55 | + return 0; | ||
| 56 | + if (env->interrupt_request & CPU_INTERRUPT_HARD) { | ||
| 57 | + env->halted = 0; | ||
| 58 | + return 0; | ||
| 59 | + } | ||
| 60 | + return EXCP_HALTED; | ||
| 61 | +} |
target-mips/exec.h
| @@ -56,14 +56,6 @@ register target_ulong T2 asm(AREG3); | @@ -56,14 +56,6 @@ register target_ulong T2 asm(AREG3); | ||
| 56 | #include "softmmu_exec.h" | 56 | #include "softmmu_exec.h" |
| 57 | #endif /* !defined(CONFIG_USER_ONLY) */ | 57 | #endif /* !defined(CONFIG_USER_ONLY) */ |
| 58 | 58 | ||
| 59 | -static inline void env_to_regs(void) | ||
| 60 | -{ | ||
| 61 | -} | ||
| 62 | - | ||
| 63 | -static inline void regs_to_env(void) | ||
| 64 | -{ | ||
| 65 | -} | ||
| 66 | - | ||
| 67 | #ifdef TARGET_MIPS64 | 59 | #ifdef TARGET_MIPS64 |
| 68 | #if TARGET_LONG_BITS > HOST_LONG_BITS | 60 | #if TARGET_LONG_BITS > HOST_LONG_BITS |
| 69 | void do_dsll (void); | 61 | void do_dsll (void); |
| @@ -240,4 +232,23 @@ FOP_PROTO(le) | @@ -240,4 +232,23 @@ FOP_PROTO(le) | ||
| 240 | FOP_PROTO(ngt) | 232 | FOP_PROTO(ngt) |
| 241 | #undef FOP_PROTO | 233 | #undef FOP_PROTO |
| 242 | 234 | ||
| 235 | +static inline void env_to_regs(void) | ||
| 236 | +{ | ||
| 237 | +} | ||
| 238 | + | ||
| 239 | +static inline void regs_to_env(void) | ||
| 240 | +{ | ||
| 241 | +} | ||
| 242 | + | ||
| 243 | +static inline int cpu_halted(CPUState *env) { | ||
| 244 | + if (!env->halted) | ||
| 245 | + return 0; | ||
| 246 | + if (env->interrupt_request & | ||
| 247 | + (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) { | ||
| 248 | + env->halted = 0; | ||
| 249 | + return 0; | ||
| 250 | + } | ||
| 251 | + return EXCP_HALTED; | ||
| 252 | +} | ||
| 253 | + | ||
| 243 | #endif /* !defined(__QEMU_MIPS_EXEC_H__) */ | 254 | #endif /* !defined(__QEMU_MIPS_EXEC_H__) */ |
target-mips/op_helper.c
| @@ -24,10 +24,6 @@ | @@ -24,10 +24,6 @@ | ||
| 24 | 24 | ||
| 25 | /*****************************************************************************/ | 25 | /*****************************************************************************/ |
| 26 | /* Exceptions processing helpers */ | 26 | /* Exceptions processing helpers */ |
| 27 | -void cpu_loop_exit(void) | ||
| 28 | -{ | ||
| 29 | - longjmp(env->jmp_env, 1); | ||
| 30 | -} | ||
| 31 | 27 | ||
| 32 | void do_raise_exception_err (uint32_t exception, int error_code) | 28 | void do_raise_exception_err (uint32_t exception, int error_code) |
| 33 | { | 29 | { |
target-ppc/exec.h
| @@ -122,4 +122,14 @@ static inline void regs_to_env(void) | @@ -122,4 +122,14 @@ static inline void regs_to_env(void) | ||
| 122 | int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, | 122 | int cpu_ppc_handle_mmu_fault (CPUState *env, target_ulong address, int rw, |
| 123 | int is_user, int is_softmmu); | 123 | int is_user, int is_softmmu); |
| 124 | 124 | ||
| 125 | +static inline int cpu_halted(CPUState *env) { | ||
| 126 | + if (!env->halted) | ||
| 127 | + return 0; | ||
| 128 | + if (env->msr[MSR_EE] && (env->interrupt_request & CPU_INTERRUPT_HARD)) { | ||
| 129 | + env->halted = 0; | ||
| 130 | + return 0; | ||
| 131 | + } | ||
| 132 | + return EXCP_HALTED; | ||
| 133 | +} | ||
| 134 | + | ||
| 125 | #endif /* !defined (__PPC_H__) */ | 135 | #endif /* !defined (__PPC_H__) */ |
target-ppc/op_helper.c
| @@ -40,10 +40,6 @@ | @@ -40,10 +40,6 @@ | ||
| 40 | 40 | ||
| 41 | /*****************************************************************************/ | 41 | /*****************************************************************************/ |
| 42 | /* Exceptions processing helpers */ | 42 | /* Exceptions processing helpers */ |
| 43 | -void cpu_loop_exit (void) | ||
| 44 | -{ | ||
| 45 | - longjmp(env->jmp_env, 1); | ||
| 46 | -} | ||
| 47 | 43 | ||
| 48 | void do_raise_exception_err (uint32_t exception, int error_code) | 44 | void do_raise_exception_err (uint32_t exception, int error_code) |
| 49 | { | 45 | { |
target-sh4/op_helper.c
| @@ -20,11 +20,6 @@ | @@ -20,11 +20,6 @@ | ||
| 20 | #include <assert.h> | 20 | #include <assert.h> |
| 21 | #include "exec.h" | 21 | #include "exec.h" |
| 22 | 22 | ||
| 23 | -void cpu_loop_exit(void) | ||
| 24 | -{ | ||
| 25 | - longjmp(env->jmp_env, 1); | ||
| 26 | -} | ||
| 27 | - | ||
| 28 | void do_raise_exception(void) | 23 | void do_raise_exception(void) |
| 29 | { | 24 | { |
| 30 | cpu_loop_exit(); | 25 | cpu_loop_exit(); |
target-sparc/exec.h
| @@ -115,4 +115,14 @@ static inline void regs_to_env(void) | @@ -115,4 +115,14 @@ static inline void regs_to_env(void) | ||
| 115 | int cpu_sparc_handle_mmu_fault(CPUState *env, target_ulong address, int rw, | 115 | int cpu_sparc_handle_mmu_fault(CPUState *env, target_ulong address, int rw, |
| 116 | int is_user, int is_softmmu); | 116 | int is_user, int is_softmmu); |
| 117 | 117 | ||
| 118 | +static inline int cpu_halted(CPUState *env) { | ||
| 119 | + if (!env->halted) | ||
| 120 | + return 0; | ||
| 121 | + if ((env->interrupt_request & CPU_INTERRUPT_HARD) && (env->psret != 0)) { | ||
| 122 | + env->halted = 0; | ||
| 123 | + return 0; | ||
| 124 | + } | ||
| 125 | + return EXCP_HALTED; | ||
| 126 | +} | ||
| 127 | + | ||
| 118 | #endif | 128 | #endif |