bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 1 | #if !defined(__QEMU_MIPS_EXEC_H__) |
| 2 | #define __QEMU_MIPS_EXEC_H__ |
| 3 | |
bellard | 01dbbdf | 2005-12-17 01:11:12 +0000 | [diff] [blame] | 4 | //#define DEBUG_OP |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 5 | |
ths | c570fd1 | 2006-12-21 01:19:56 +0000 | [diff] [blame] | 6 | #include "config.h" |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 7 | #include "mips-defs.h" |
| 8 | #include "dyngen-exec.h" |
ths | 01179c3 | 2007-04-29 21:26:37 +0000 | [diff] [blame] | 9 | #include "cpu-defs.h" |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 10 | |
| 11 | register struct CPUMIPSState *env asm(AREG0); |
| 12 | |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 13 | #include "cpu.h" |
| 14 | #include "exec-all.h" |
| 15 | |
| 16 | #if !defined(CONFIG_USER_ONLY) |
bellard | a9049a0 | 2005-10-30 18:16:26 +0000 | [diff] [blame] | 17 | #include "softmmu_exec.h" |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 18 | #endif /* !defined(CONFIG_USER_ONLY) */ |
| 19 | |
aliguori | 6a4955a | 2009-04-24 18:03:20 +0000 | [diff] [blame] | 20 | static inline int cpu_has_work(CPUState *env) |
| 21 | { |
| 22 | return (env->interrupt_request & |
| 23 | (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)); |
| 24 | } |
| 25 | |
| 26 | |
ths | c904ef0 | 2008-07-23 16:16:31 +0000 | [diff] [blame] | 27 | static inline int cpu_halted(CPUState *env) |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 28 | { |
ths | bfed01f | 2007-06-03 17:44:37 +0000 | [diff] [blame] | 29 | if (!env->halted) |
| 30 | return 0; |
aliguori | 6a4955a | 2009-04-24 18:03:20 +0000 | [diff] [blame] | 31 | if (cpu_has_work(env)) { |
ths | bfed01f | 2007-06-03 17:44:37 +0000 | [diff] [blame] | 32 | env->halted = 0; |
| 33 | return 0; |
| 34 | } |
| 35 | return EXCP_HALTED; |
| 36 | } |
| 37 | |
ths | c904ef0 | 2008-07-23 16:16:31 +0000 | [diff] [blame] | 38 | static inline void compute_hflags(CPUState *env) |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 39 | { |
ths | b8aa459 | 2007-12-30 15:36:58 +0000 | [diff] [blame] | 40 | env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 | |
aurel32 | 2623c1e | 2008-11-11 11:39:33 +0000 | [diff] [blame] | 41 | MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU | |
| 42 | MIPS_HFLAG_UX); |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 43 | if (!(env->CP0_Status & (1 << CP0St_EXL)) && |
| 44 | !(env->CP0_Status & (1 << CP0St_ERL)) && |
ths | 671880e | 2007-09-29 19:21:36 +0000 | [diff] [blame] | 45 | !(env->hflags & MIPS_HFLAG_DM)) { |
ths | 623a930 | 2007-10-28 19:45:05 +0000 | [diff] [blame] | 46 | env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU; |
ths | 671880e | 2007-09-29 19:21:36 +0000 | [diff] [blame] | 47 | } |
ths | d26bc21 | 2007-11-08 18:05:37 +0000 | [diff] [blame] | 48 | #if defined(TARGET_MIPS64) |
ths | 623a930 | 2007-10-28 19:45:05 +0000 | [diff] [blame] | 49 | if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) || |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 50 | (env->CP0_Status & (1 << CP0St_PX)) || |
| 51 | (env->CP0_Status & (1 << CP0St_UX))) |
| 52 | env->hflags |= MIPS_HFLAG_64; |
aurel32 | 2623c1e | 2008-11-11 11:39:33 +0000 | [diff] [blame] | 53 | if (env->CP0_Status & (1 << CP0St_UX)) |
| 54 | env->hflags |= MIPS_HFLAG_UX; |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 55 | #endif |
ths | 671880e | 2007-09-29 19:21:36 +0000 | [diff] [blame] | 56 | if ((env->CP0_Status & (1 << CP0St_CU0)) || |
ths | 623a930 | 2007-10-28 19:45:05 +0000 | [diff] [blame] | 57 | !(env->hflags & MIPS_HFLAG_KSU)) |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 58 | env->hflags |= MIPS_HFLAG_CP0; |
| 59 | if (env->CP0_Status & (1 << CP0St_CU1)) |
| 60 | env->hflags |= MIPS_HFLAG_FPU; |
| 61 | if (env->CP0_Status & (1 << CP0St_FR)) |
| 62 | env->hflags |= MIPS_HFLAG_F64; |
ths | b8aa459 | 2007-12-30 15:36:58 +0000 | [diff] [blame] | 63 | if (env->insn_flags & ISA_MIPS32R2) { |
ths | f01be15 | 2008-09-18 11:57:27 +0000 | [diff] [blame] | 64 | if (env->active_fpu.fcr0 & (1 << FCR0_F64)) |
ths | b8aa459 | 2007-12-30 15:36:58 +0000 | [diff] [blame] | 65 | env->hflags |= MIPS_HFLAG_COP1X; |
| 66 | } else if (env->insn_flags & ISA_MIPS32) { |
| 67 | if (env->hflags & MIPS_HFLAG_64) |
| 68 | env->hflags |= MIPS_HFLAG_COP1X; |
| 69 | } else if (env->insn_flags & ISA_MIPS4) { |
| 70 | /* All supported MIPS IV CPUs use the XX (CU3) to enable |
| 71 | and disable the MIPS IV extensions to the MIPS III ISA. |
| 72 | Some other MIPS IV CPUs ignore the bit, so the check here |
| 73 | would be too restrictive for them. */ |
| 74 | if (env->CP0_Status & (1 << CP0St_CU3)) |
| 75 | env->hflags |= MIPS_HFLAG_COP1X; |
| 76 | } |
ths | 08fa4ba | 2007-09-26 23:52:06 +0000 | [diff] [blame] | 77 | } |
| 78 | |
Paolo Bonzini | 10eb0cc | 2010-06-29 09:58:50 +0200 | [diff] [blame] | 79 | static inline void cpu_pc_from_tb(CPUState *env, TranslationBlock *tb) |
| 80 | { |
| 81 | env->active_tc.PC = tb->pc; |
| 82 | env->hflags &= ~MIPS_HFLAG_BMASK; |
| 83 | env->hflags |= tb->flags & MIPS_HFLAG_BMASK; |
| 84 | } |
| 85 | |
bellard | 6af0bf9 | 2005-07-02 14:58:51 +0000 | [diff] [blame] | 86 | #endif /* !defined(__QEMU_MIPS_EXEC_H__) */ |