a7014eea137f832272e7ef6f627b945c30a233e3
[qemu] / target-mips / exec.h
1 #if !defined(__QEMU_MIPS_EXEC_H__)
2 #define __QEMU_MIPS_EXEC_H__
3
4 //#define DEBUG_OP
5
6 #include "config.h"
7 #include "mips-defs.h"
8 #include "dyngen-exec.h"
9 #include "cpu-defs.h"
10
11 register struct CPUMIPSState *env asm(AREG0);
12
13 #if defined (USE_HOST_FLOAT_REGS)
14 #error "implement me."
15 #else
16 #define FDT0 (env->ft0.fd)
17 #define FDT1 (env->ft1.fd)
18 #define FDT2 (env->ft2.fd)
19 #define FST0 (env->ft0.fs[FP_ENDIAN_IDX])
20 #define FST1 (env->ft1.fs[FP_ENDIAN_IDX])
21 #define FST2 (env->ft2.fs[FP_ENDIAN_IDX])
22 #define FSTH0 (env->ft0.fs[!FP_ENDIAN_IDX])
23 #define FSTH1 (env->ft1.fs[!FP_ENDIAN_IDX])
24 #define FSTH2 (env->ft2.fs[!FP_ENDIAN_IDX])
25 #define DT0 (env->ft0.d)
26 #define DT1 (env->ft1.d)
27 #define DT2 (env->ft2.d)
28 #define WT0 (env->ft0.w[FP_ENDIAN_IDX])
29 #define WT1 (env->ft1.w[FP_ENDIAN_IDX])
30 #define WT2 (env->ft2.w[FP_ENDIAN_IDX])
31 #define WTH0 (env->ft0.w[!FP_ENDIAN_IDX])
32 #define WTH1 (env->ft1.w[!FP_ENDIAN_IDX])
33 #define WTH2 (env->ft2.w[!FP_ENDIAN_IDX])
34 #endif
35
36 #include "cpu.h"
37 #include "exec-all.h"
38
39 #if !defined(CONFIG_USER_ONLY)
40 #include "softmmu_exec.h"
41 #endif /* !defined(CONFIG_USER_ONLY) */
42
43 void do_mtc0_status_debug(uint32_t old, uint32_t val);
44 void do_mtc0_status_irqraise_debug(void);
45 void dump_fpu(CPUState *env);
46 void fpu_dump_state(CPUState *env, FILE *f,
47                     int (*fpu_fprintf)(FILE *f, const char *fmt, ...),
48                     int flags);
49
50 int cpu_mips_handle_mmu_fault (CPUState *env, target_ulong address, int rw,
51                                int mmu_idx, int is_softmmu);
52 void do_interrupt (CPUState *env);
53 void r4k_invalidate_tlb (CPUState *env, int idx, int use_extra);
54
55 void cpu_loop_exit(void);
56 void do_raise_exception_err (uint32_t exception, int error_code);
57 void do_raise_exception (uint32_t exception);
58
59 void cpu_dump_state(CPUState *env, FILE *f,
60                     int (*cpu_fprintf)(FILE *f, const char *fmt, ...),
61                     int flags);
62 void cpu_mips_irqctrl_init (void);
63 uint32_t cpu_mips_get_random (CPUState *env);
64 uint32_t cpu_mips_get_count (CPUState *env);
65 void cpu_mips_store_count (CPUState *env, uint32_t value);
66 void cpu_mips_store_compare (CPUState *env, uint32_t value);
67 void cpu_mips_start_count(CPUState *env);
68 void cpu_mips_stop_count(CPUState *env);
69 void cpu_mips_update_irq (CPUState *env);
70 void cpu_mips_clock_init (CPUState *env);
71 void cpu_mips_tlb_flush (CPUState *env, int flush_global);
72
73 static always_inline void env_to_regs(void)
74 {
75 }
76
77 static always_inline void regs_to_env(void)
78 {
79 }
80
81 static always_inline int cpu_halted(CPUState *env)
82 {
83     if (!env->halted)
84         return 0;
85     if (env->interrupt_request &
86         (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) {
87         env->halted = 0;
88         return 0;
89     }
90     return EXCP_HALTED;
91 }
92
93 static always_inline void compute_hflags(CPUState *env)
94 {
95     env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
96                      MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU);
97     if (!(env->CP0_Status & (1 << CP0St_EXL)) &&
98         !(env->CP0_Status & (1 << CP0St_ERL)) &&
99         !(env->hflags & MIPS_HFLAG_DM)) {
100         env->hflags |= (env->CP0_Status >> CP0St_KSU) & MIPS_HFLAG_KSU;
101     }
102 #if defined(TARGET_MIPS64)
103     if (((env->hflags & MIPS_HFLAG_KSU) != MIPS_HFLAG_UM) ||
104         (env->CP0_Status & (1 << CP0St_PX)) ||
105         (env->CP0_Status & (1 << CP0St_UX)))
106         env->hflags |= MIPS_HFLAG_64;
107 #endif
108     if ((env->CP0_Status & (1 << CP0St_CU0)) ||
109         !(env->hflags & MIPS_HFLAG_KSU))
110         env->hflags |= MIPS_HFLAG_CP0;
111     if (env->CP0_Status & (1 << CP0St_CU1))
112         env->hflags |= MIPS_HFLAG_FPU;
113     if (env->CP0_Status & (1 << CP0St_FR))
114         env->hflags |= MIPS_HFLAG_F64;
115     if (env->insn_flags & ISA_MIPS32R2) {
116         if (env->fpu->fcr0 & (1 << FCR0_F64))
117             env->hflags |= MIPS_HFLAG_COP1X;
118     } else if (env->insn_flags & ISA_MIPS32) {
119         if (env->hflags & MIPS_HFLAG_64)
120             env->hflags |= MIPS_HFLAG_COP1X;
121     } else if (env->insn_flags & ISA_MIPS4) {
122         /* All supported MIPS IV CPUs use the XX (CU3) to enable
123            and disable the MIPS IV extensions to the MIPS III ISA.
124            Some other MIPS IV CPUs ignore the bit, so the check here
125            would be too restrictive for them.  */
126         if (env->CP0_Status & (1 << CP0St_CU3))
127             env->hflags |= MIPS_HFLAG_COP1X;
128     }
129 }
130
131 #endif /* !defined(__QEMU_MIPS_EXEC_H__) */