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