1 #if !defined (__MIPS_CPU_H__)
4 #define TARGET_HAS_ICE 1
11 typedef union fpr_t fpr_t;
13 float64 fd; /* ieee double precision */
14 float32 fs[2];/* ieee single precision */
15 uint64_t d; /* binary single fixed-point */
16 uint32_t w[2]; /* binary single fixed-point */
18 /* define FP_ENDIAN_IDX to access the same location
19 * in the fpr_t union regardless of the host endianess
21 #if defined(WORDS_BIGENDIAN)
22 # define FP_ENDIAN_IDX 1
24 # define FP_ENDIAN_IDX 0
27 #if defined(MIPS_USES_R4K_TLB)
28 typedef struct tlb_t tlb_t;
45 typedef struct CPUMIPSState CPUMIPSState;
47 /* General integer registers */
49 /* Special registers */
53 #if defined(MIPS_USES_FPU)
54 /* Floating point registers */
56 #define FPR(cpu, n) ((fpr_t*)&(cpu)->fpr[(n) / 2])
57 #define FPR_FD(cpu, n) (FPR(cpu, n)->fd)
58 #define FPR_FS(cpu, n) (FPR(cpu, n)->fs[((n) & 1) ^ FP_ENDIAN_IDX])
59 #define FPR_D(cpu, n) (FPR(cpu, n)->d)
60 #define FPR_W(cpu, n) (FPR(cpu, n)->w[((n) & 1) ^ FP_ENDIAN_IDX])
62 #ifndef USE_HOST_FLOAT_REGS
67 float_status fp_status;
68 /* fpu implementation/revision register */
72 #define SET_FP_COND(reg) do { (reg) |= (1<<23); } while(0)
73 #define CLEAR_FP_COND(reg) do { (reg) &= ~(1<<23); } while(0)
74 #define IS_FP_COND_SET(reg) (((reg) & (1<<23)) != 0)
75 #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f)
76 #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f)
77 #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f)
78 #define SET_FP_CAUSE(reg,v) do { (reg) = ((reg) & ~(0x3f << 12)) | ((v) << 12); } while(0)
79 #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v) << 7); } while(0)
80 #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v) << 2); } while(0)
82 #define FP_UNDERFLOW 2
86 #define FP_UNIMPLEMENTED 32
89 #if defined(MIPS_USES_R4K_TLB)
94 uint32_t CP0_EntryLo0;
95 uint32_t CP0_EntryLo1;
97 uint32_t CP0_PageMask;
99 uint32_t CP0_BadVAddr;
101 uint32_t CP0_EntryHi;
102 uint32_t CP0_Compare;
124 uint32_t CP0_Config0;
136 uint32_t CP0_Config1;
150 uint32_t CP0_WatchLo;
151 uint32_t CP0_WatchHi;
155 #define CP0DB_LSNM 28
156 #define CP0DB_Doze 27
157 #define CP0DB_Halt 26
159 #define CP0DB_IBEP 24
160 #define CP0DB_DBEP 21
161 #define CP0DB_IEXI 20
174 uint32_t CP0_ErrorEPC;
177 struct QEMUTimer *timer; /* Internal timer */
178 int interrupt_request;
182 int user_mode_only; /* user mode only simulation */
183 uint32_t hflags; /* CPU State */
184 /* TMASK defines different execution modes */
185 #define MIPS_HFLAG_TMASK 0x007F
186 #define MIPS_HFLAG_MODE 0x001F /* execution modes */
187 #define MIPS_HFLAG_UM 0x0001 /* user mode */
188 #define MIPS_HFLAG_ERL 0x0002 /* Error mode */
189 #define MIPS_HFLAG_EXL 0x0004 /* Exception mode */
190 #define MIPS_HFLAG_DM 0x0008 /* Debug mode */
191 #define MIPS_HFLAG_SM 0x0010 /* Supervisor mode */
192 #define MIPS_HFLAG_RE 0x0040 /* Reversed endianness */
193 /* If translation is interrupted between the branch instruction and
194 * the delay slot, record what type of branch it is so that we can
195 * resume translation properly. It might be possible to reduce
196 * this from three bits to two. */
197 #define MIPS_HFLAG_BMASK 0x0380
198 #define MIPS_HFLAG_B 0x0080 /* Unconditional branch */
199 #define MIPS_HFLAG_BC 0x0100 /* Conditional branch */
200 #define MIPS_HFLAG_BL 0x0180 /* Likely branch */
201 #define MIPS_HFLAG_BR 0x0200 /* branch to register (can't link TB) */
202 target_ulong btarget; /* Jump / branch target */
203 int bcond; /* Branch condition (if needed) */
205 int halted; /* TRUE if the CPU is in suspend state */
212 /* Memory access type :
213 * may be needed for precise access rights control and precise exceptions.
216 /* 1 bit to define user level / supervisor access */
219 /* 1 bit to indicate direction */
221 /* Type of instruction that generated the access */
222 ACCESS_CODE = 0x10, /* Code fetch access */
223 ACCESS_INT = 0x20, /* Integer load/store access */
224 ACCESS_FLOAT = 0x30, /* floating point load/store access */
260 EXCP_MTCP0 = 0x104, /* mtmsr instruction: */
261 /* may change privilege level */
262 EXCP_BRANCH = 0x108, /* branch instruction */
263 EXCP_ERET = 0x10C, /* return from interrupt */
264 EXCP_SYSCALL_USER = 0x110, /* System call in user mode only */
268 int cpu_mips_exec(CPUMIPSState *s);
269 CPUMIPSState *cpu_mips_init(void);
270 uint32_t cpu_mips_get_clock (void);
272 #endif /* !defined (__MIPS_CPU_H__) */