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 single 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 #define FPR(cpu, n) ((fpr_t*)&(cpu)->fpr[(n) / 2])
68 #define FPR_FD(cpu, n) (FPR(cpu, n)->fd)
69 #define FPR_FS(cpu, n) (FPR(cpu, n)->fs[((n) & 1) ^ FP_ENDIAN_IDX])
70 #define FPR_D(cpu, n) (FPR(cpu, n)->d)
71 #define FPR_W(cpu, n) (FPR(cpu, n)->w[((n) & 1) ^ FP_ENDIAN_IDX])
73 #ifndef USE_HOST_FLOAT_REGS
78 float_status fp_status;
79 /* fpu implementation/revision register */
83 #define SET_FP_COND(reg) do { (reg) |= (1<<23); } while(0)
84 #define CLEAR_FP_COND(reg) do { (reg) &= ~(1<<23); } while(0)
85 #define IS_FP_COND_SET(reg) (((reg) & (1<<23)) != 0)
86 #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f)
87 #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f)
88 #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f)
89 #define SET_FP_CAUSE(reg,v) do { (reg) = ((reg) & ~(0x3f << 12)) | ((v) << 12); } while(0)
90 #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v) << 7); } while(0)
91 #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v) << 2); } while(0)
93 #define FP_UNDERFLOW 2
97 #define FP_UNIMPLEMENTED 32
99 #if defined(MIPS_USES_R4K_TLB)
100 tlb_t tlb[MIPS_TLB_MAX];
105 target_ulong CP0_EntryLo0;
106 target_ulong CP0_EntryLo1;
107 target_ulong CP0_Context;
108 int32_t CP0_PageMask;
109 int32_t CP0_PageGrain;
112 target_ulong CP0_BadVAddr;
114 target_ulong CP0_EntryHi;
151 #define CP0Ca_IP_mask 0x0000FF00
153 target_ulong CP0_EPC;
197 #define CP0C3_DSPP 10
207 target_ulong CP0_LLAddr;
208 target_ulong CP0_WatchLo;
210 target_ulong CP0_XContext;
211 int32_t CP0_Framemask;
215 #define CP0DB_LSNM 28
216 #define CP0DB_Doze 27
217 #define CP0DB_Halt 26
219 #define CP0DB_IBEP 24
220 #define CP0DB_DBEP 21
221 #define CP0DB_IEXI 20
231 target_ulong CP0_DEPC;
232 int32_t CP0_Performance0;
237 target_ulong CP0_ErrorEPC;
240 int interrupt_request;
244 int user_mode_only; /* user mode only simulation */
245 uint32_t hflags; /* CPU State */
246 /* TMASK defines different execution modes */
247 #define MIPS_HFLAG_TMASK 0x007F
248 #define MIPS_HFLAG_MODE 0x001F /* execution modes */
249 #define MIPS_HFLAG_UM 0x0001 /* user mode */
250 #define MIPS_HFLAG_DM 0x0008 /* Debug mode */
251 #define MIPS_HFLAG_SM 0x0010 /* Supervisor mode */
252 #define MIPS_HFLAG_RE 0x0040 /* Reversed endianness */
253 /* If translation is interrupted between the branch instruction and
254 * the delay slot, record what type of branch it is so that we can
255 * resume translation properly. It might be possible to reduce
256 * this from three bits to two. */
257 #define MIPS_HFLAG_BMASK 0x0380
258 #define MIPS_HFLAG_B 0x0080 /* Unconditional branch */
259 #define MIPS_HFLAG_BC 0x0100 /* Conditional branch */
260 #define MIPS_HFLAG_BL 0x0180 /* Likely branch */
261 #define MIPS_HFLAG_BR 0x0200 /* branch to register (can't link TB) */
262 target_ulong btarget; /* Jump / branch target */
263 int bcond; /* Branch condition (if needed) */
265 int halted; /* TRUE if the CPU is in suspend state */
267 int SYNCI_Step; /* Address step size for SYNCI */
268 int CCRes; /* Cycle count resolution/divisor */
270 #if defined(CONFIG_USER_ONLY)
271 target_ulong tls_value;
279 const char *kernel_filename;
280 const char *kernel_cmdline;
281 const char *initrd_filename;
283 struct QEMUTimer *timer; /* Internal timer */
286 typedef struct mips_def_t mips_def_t;
287 int mips_find_by_name (const unsigned char *name, mips_def_t **def);
288 void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
289 int cpu_mips_register (CPUMIPSState *env, mips_def_t *def);
293 /* Memory access type :
294 * may be needed for precise access rights control and precise exceptions.
297 /* 1 bit to define user level / supervisor access */
300 /* 1 bit to indicate direction */
302 /* Type of instruction that generated the access */
303 ACCESS_CODE = 0x10, /* Code fetch access */
304 ACCESS_INT = 0x20, /* Integer load/store access */
305 ACCESS_FLOAT = 0x30, /* floating point load/store access */
341 EXCP_MTCP0 = 0x104, /* mtmsr instruction: */
342 /* may change privilege level */
343 EXCP_BRANCH = 0x108, /* branch instruction */
344 EXCP_ERET = 0x10C, /* return from interrupt */
345 EXCP_SYSCALL_USER = 0x110, /* System call in user mode only */
349 int cpu_mips_exec(CPUMIPSState *s);
350 CPUMIPSState *cpu_mips_init(void);
351 uint32_t cpu_mips_get_clock (void);
353 #endif /* !defined (__MIPS_CPU_H__) */