blob: af61b54dcf0aa24353710a09e0379255d0126063 [file] [log] [blame]
bellard6af0bf92005-07-02 14:58:51 +00001#if !defined(__QEMU_MIPS_EXEC_H__)
2#define __QEMU_MIPS_EXEC_H__
3
bellard01dbbdf2005-12-17 01:11:12 +00004//#define DEBUG_OP
bellard6af0bf92005-07-02 14:58:51 +00005
thsc570fd12006-12-21 01:19:56 +00006#include "config.h"
bellard6af0bf92005-07-02 14:58:51 +00007#include "mips-defs.h"
8#include "dyngen-exec.h"
ths01179c32007-04-29 21:26:37 +00009#include "cpu-defs.h"
bellard6af0bf92005-07-02 14:58:51 +000010
11register struct CPUMIPSState *env asm(AREG0);
12
bellard6af0bf92005-07-02 14:58:51 +000013#include "cpu.h"
14#include "exec-all.h"
15
16#if !defined(CONFIG_USER_ONLY)
bellarda9049a02005-10-30 18:16:26 +000017#include "softmmu_exec.h"
bellard6af0bf92005-07-02 14:58:51 +000018#endif /* !defined(CONFIG_USER_ONLY) */
19
aliguori6a4955a2009-04-24 18:03:20 +000020static inline int cpu_has_work(CPUState *env)
21{
22 return (env->interrupt_request &
23 (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER));
24}
25
26
thsc904ef02008-07-23 16:16:31 +000027static inline int cpu_halted(CPUState *env)
ths08fa4ba2007-09-26 23:52:06 +000028{
thsbfed01f2007-06-03 17:44:37 +000029 if (!env->halted)
30 return 0;
aliguori6a4955a2009-04-24 18:03:20 +000031 if (cpu_has_work(env)) {
thsbfed01f2007-06-03 17:44:37 +000032 env->halted = 0;
33 return 0;
34 }
35 return EXCP_HALTED;
36}
37
thsc904ef02008-07-23 16:16:31 +000038static inline void compute_hflags(CPUState *env)
ths08fa4ba2007-09-26 23:52:06 +000039{
thsb8aa4592007-12-30 15:36:58 +000040 env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
aurel322623c1e2008-11-11 11:39:33 +000041 MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU |
42 MIPS_HFLAG_UX);
ths08fa4ba2007-09-26 23:52:06 +000043 if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
44 !(env->CP0_Status & (1 << CP0St_ERL)) &&
ths671880e2007-09-29 19:21:36 +000045 !(env->hflags & MIPS_HFLAG_DM)) {
ths623a9302007-10-28 19:45:05 +000046 env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;
ths671880e2007-09-29 19:21:36 +000047 }
thsd26bc212007-11-08 18:05:37 +000048#if defined(TARGET_MIPS64)
ths623a9302007-10-28 19:45:05 +000049 if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) ||
ths08fa4ba2007-09-26 23:52:06 +000050 (env->CP0_Status & (1 << CP0St_PX)) ||
51 (env->CP0_Status & (1 << CP0St_UX)))
52 env->hflags |= MIPS_HFLAG_64;
aurel322623c1e2008-11-11 11:39:33 +000053 if (env->CP0_Status & (1 << CP0St_UX))
54 env->hflags |= MIPS_HFLAG_UX;
ths08fa4ba2007-09-26 23:52:06 +000055#endif
ths671880e2007-09-29 19:21:36 +000056 if ((env->CP0_Status & (1 << CP0St_CU0)) ||
ths623a9302007-10-28 19:45:05 +000057 !(env->hflags & MIPS_HFLAG_KSU))
ths08fa4ba2007-09-26 23:52:06 +000058 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;
thsb8aa4592007-12-30 15:36:58 +000063 if (env->insn_flags & ISA_MIPS32R2) {
thsf01be152008-09-18 11:57:27 +000064 if (env->active_fpu.fcr0 & (1 << FCR0_F64))
thsb8aa4592007-12-30 15:36:58 +000065 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 }
ths08fa4ba2007-09-26 23:52:06 +000077}
78
Paolo Bonzini10eb0cc2010-06-29 09:58:50 +020079static 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
bellard6af0bf92005-07-02 14:58:51 +000086#endif /* !defined(__QEMU_MIPS_EXEC_H__) */