1 #if !defined (__MIPS_CPU_H__)
4 #define TARGET_HAS_ICE 1
6 #define ELF_MACHINE EM_MIPS
11 #include "softfloat.h"
13 // uint_fast8_t and uint_fast16_t not in <sys/int_types.h>
14 // XXX: move that elsewhere
15 #if defined(HOST_SOLARIS) && HOST_SOLARIS < 10
16 typedef unsigned char uint_fast8_t;
17 typedef unsigned int uint_fast16_t;
20 typedef union fpr_t fpr_t;
22 float64 fd; /* ieee double precision */
23 float32 fs[2];/* ieee single precision */
24 uint64_t d; /* binary double fixed-point */
25 uint32_t w[2]; /* binary single fixed-point */
27 /* define FP_ENDIAN_IDX to access the same location
28 * in the fpr_t union regardless of the host endianess
30 #if defined(WORDS_BIGENDIAN)
31 # define FP_ENDIAN_IDX 1
33 # define FP_ENDIAN_IDX 0
36 #if defined(MIPS_USES_R4K_TLB)
37 typedef struct tlb_t tlb_t;
53 typedef struct CPUMIPSState CPUMIPSState;
55 /* General integer registers */
57 /* Special registers */
59 #if TARGET_LONG_BITS > HOST_LONG_BITS
65 /* Floating point registers */
67 #ifndef USE_HOST_FLOAT_REGS
72 float_status fp_status;
73 /* fpu implementation/revision register (fir) */
86 #define SET_FP_COND(num,env) do { (env->fcr31) |= ((num) ? (1 << ((num) + 24)) : (1 << ((num) + 23))); } while(0)
87 #define CLEAR_FP_COND(num,env) do { (env->fcr31) &= ~((num) ? (1 << ((num) + 24)) : (1 << ((num) + 23))); } while(0)
88 #define IS_FP_COND_SET(num,env) (((env->fcr31) & ((num) ? (1 << ((num) + 24)) : (1 << ((num) + 23)))) != 0)
89 #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f)
90 #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f)
91 #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f)
92 #define SET_FP_CAUSE(reg,v) do { (reg) = ((reg) & ~(0x3f << 12)) | ((v & 0x3f) << 12); } while(0)
93 #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v & 0x1f) << 7); } while(0)
94 #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v & 0x1f) << 2); } while(0)
95 #define UPDATE_FP_FLAGS(reg,v) do { (reg) |= ((v & 0x1f) << 2); } while(0)
97 #define FP_UNDERFLOW 2
100 #define FP_INVALID 16
101 #define FP_UNIMPLEMENTED 32
103 #if defined(MIPS_USES_R4K_TLB)
104 tlb_t tlb[MIPS_TLB_MAX];
110 target_ulong CP0_EntryLo0;
111 target_ulong CP0_EntryLo1;
112 target_ulong CP0_Context;
113 int32_t CP0_PageMask;
114 int32_t CP0_PageGrain;
117 target_ulong CP0_BadVAddr;
119 target_ulong CP0_EntryHi;
156 #define CP0Ca_IP_mask 0x0000FF00
158 target_ulong CP0_EPC;
202 #define CP0C3_DSPP 10
212 target_ulong CP0_LLAddr;
213 target_ulong CP0_WatchLo;
215 target_ulong CP0_XContext;
216 int32_t CP0_Framemask;
220 #define CP0DB_LSNM 28
221 #define CP0DB_Doze 27
222 #define CP0DB_Halt 26
224 #define CP0DB_IBEP 24
225 #define CP0DB_DBEP 21
226 #define CP0DB_IEXI 20
236 target_ulong CP0_DEPC;
237 int32_t CP0_Performance0;
242 target_ulong CP0_ErrorEPC;
245 int interrupt_request;
249 int user_mode_only; /* user mode only simulation */
250 uint32_t hflags; /* CPU State */
251 /* TMASK defines different execution modes */
252 #define MIPS_HFLAG_TMASK 0x007F
253 #define MIPS_HFLAG_MODE 0x001F /* execution modes */
254 #define MIPS_HFLAG_UM 0x0001 /* user mode */
255 #define MIPS_HFLAG_DM 0x0008 /* Debug mode */
256 #define MIPS_HFLAG_SM 0x0010 /* Supervisor mode */
257 #define MIPS_HFLAG_RE 0x0040 /* Reversed endianness */
258 /* If translation is interrupted between the branch instruction and
259 * the delay slot, record what type of branch it is so that we can
260 * resume translation properly. It might be possible to reduce
261 * this from three bits to two. */
262 #define MIPS_HFLAG_BMASK 0x0380
263 #define MIPS_HFLAG_B 0x0080 /* Unconditional branch */
264 #define MIPS_HFLAG_BC 0x0100 /* Conditional branch */
265 #define MIPS_HFLAG_BL 0x0180 /* Likely branch */
266 #define MIPS_HFLAG_BR 0x0200 /* branch to register (can't link TB) */
267 target_ulong btarget; /* Jump / branch target */
268 int bcond; /* Branch condition (if needed) */
270 int halted; /* TRUE if the CPU is in suspend state */
272 int SYNCI_Step; /* Address step size for SYNCI */
273 int CCRes; /* Cycle count resolution/divisor */
274 int Status_rw_bitmask; /* Read/write bits in CP0_Status */
276 #if defined(CONFIG_USER_ONLY)
277 target_ulong tls_value;
285 const char *kernel_filename;
286 const char *kernel_cmdline;
287 const char *initrd_filename;
289 struct QEMUTimer *timer; /* Internal timer */
292 typedef struct mips_def_t mips_def_t;
293 int mips_find_by_name (const unsigned char *name, mips_def_t **def);
294 void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
295 int cpu_mips_register (CPUMIPSState *env, mips_def_t *def);
299 /* Memory access type :
300 * may be needed for precise access rights control and precise exceptions.
303 /* 1 bit to define user level / supervisor access */
306 /* 1 bit to indicate direction */
308 /* Type of instruction that generated the access */
309 ACCESS_CODE = 0x10, /* Code fetch access */
310 ACCESS_INT = 0x20, /* Integer load/store access */
311 ACCESS_FLOAT = 0x30, /* floating point load/store access */
348 EXCP_MTCP0 = 0x104, /* mtmsr instruction: */
349 /* may change privilege level */
350 EXCP_BRANCH = 0x108, /* branch instruction */
351 EXCP_ERET = 0x10C, /* return from interrupt */
352 EXCP_SYSCALL_USER = 0x110, /* System call in user mode only */
356 int cpu_mips_exec(CPUMIPSState *s);
357 CPUMIPSState *cpu_mips_init(void);
358 uint32_t cpu_mips_get_clock (void);
360 #endif /* !defined (__MIPS_CPU_H__) */