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) && SOLARISREV < 10
16 typedef unsigned char uint_fast8_t;
17 typedef unsigned int uint_fast16_t;
20 /* target_ulong size spec */
21 #ifdef MIPS_HAS_MIPS64
22 #define TLSZ "%016llx"
27 typedef union fpr_t fpr_t
;
29 float64 fd
; /* ieee double precision */
30 float32 fs
[2];/* ieee single precision */
31 uint64_t d
; /* binary single fixed-point */
32 uint32_t w
[2]; /* binary single fixed-point */
34 /* define FP_ENDIAN_IDX to access the same location
35 * in the fpr_t union regardless of the host endianess
37 #if defined(WORDS_BIGENDIAN)
38 # define FP_ENDIAN_IDX 1
40 # define FP_ENDIAN_IDX 0
43 #if defined(MIPS_USES_R4K_TLB)
44 typedef struct tlb_t tlb_t
;
60 typedef struct CPUMIPSState CPUMIPSState
;
62 /* General integer registers */
64 /* Special registers */
66 #if TARGET_LONG_BITS > HOST_LONG_BITS
73 #if defined(MIPS_USES_FPU)
74 /* Floating point registers */
76 #define FPR(cpu, n) ((fpr_t*)&(cpu)->fpr[(n) / 2])
77 #define FPR_FD(cpu, n) (FPR(cpu, n)->fd)
78 #define FPR_FS(cpu, n) (FPR(cpu, n)->fs[((n) & 1) ^ FP_ENDIAN_IDX])
79 #define FPR_D(cpu, n) (FPR(cpu, n)->d)
80 #define FPR_W(cpu, n) (FPR(cpu, n)->w[((n) & 1) ^ FP_ENDIAN_IDX])
82 #ifndef USE_HOST_FLOAT_REGS
87 float_status fp_status
;
88 /* fpu implementation/revision register */
92 #define SET_FP_COND(reg) do { (reg) |= (1<<23); } while(0)
93 #define CLEAR_FP_COND(reg) do { (reg) &= ~(1<<23); } while(0)
94 #define IS_FP_COND_SET(reg) (((reg) & (1<<23)) != 0)
95 #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f)
96 #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f)
97 #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f)
98 #define SET_FP_CAUSE(reg,v) do { (reg) = ((reg) & ~(0x3f << 12)) | ((v) << 12); } while(0)
99 #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v) << 7); } while(0)
100 #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v) << 2); } while(0)
102 #define FP_UNDERFLOW 2
103 #define FP_OVERFLOW 4
105 #define FP_INVALID 16
106 #define FP_UNIMPLEMENTED 32
109 #if defined(MIPS_USES_R4K_TLB)
110 tlb_t tlb
[MIPS_TLB_MAX
];
115 target_ulong CP0_EntryLo0
;
116 target_ulong CP0_EntryLo1
;
117 target_ulong CP0_Context
;
118 int32_t CP0_PageMask
;
119 int32_t CP0_PageGrain
;
122 target_ulong CP0_BadVAddr
;
124 target_ulong CP0_EntryHi
;
161 #define CP0Ca_IP_mask 0x0000FF00
163 target_ulong CP0_EPC
;
207 #define CP0C3_DSPP 10
215 target_ulong CP0_LLAddr
;
216 target_ulong CP0_WatchLo
;
218 target_ulong CP0_XContext
;
219 int32_t CP0_Framemask
;
223 #define CP0DB_LSNM 28
224 #define CP0DB_Doze 27
225 #define CP0DB_Halt 26
227 #define CP0DB_IBEP 24
228 #define CP0DB_DBEP 21
229 #define CP0DB_IEXI 20
239 target_ulong CP0_DEPC
;
240 int32_t CP0_Performance0
;
245 target_ulong CP0_ErrorEPC
;
248 int interrupt_request
;
252 int user_mode_only
; /* user mode only simulation */
253 uint32_t hflags
; /* CPU State */
254 /* TMASK defines different execution modes */
255 #define MIPS_HFLAG_TMASK 0x007F
256 #define MIPS_HFLAG_MODE 0x001F /* execution modes */
257 #define MIPS_HFLAG_UM 0x0001 /* user mode */
258 #define MIPS_HFLAG_ERL 0x0002 /* Error mode */
259 #define MIPS_HFLAG_EXL 0x0004 /* Exception mode */
260 #define MIPS_HFLAG_DM 0x0008 /* Debug mode */
261 #define MIPS_HFLAG_SM 0x0010 /* Supervisor mode */
262 #define MIPS_HFLAG_RE 0x0040 /* Reversed endianness */
263 /* If translation is interrupted between the branch instruction and
264 * the delay slot, record what type of branch it is so that we can
265 * resume translation properly. It might be possible to reduce
266 * this from three bits to two. */
267 #define MIPS_HFLAG_BMASK 0x0380
268 #define MIPS_HFLAG_B 0x0080 /* Unconditional branch */
269 #define MIPS_HFLAG_BC 0x0100 /* Conditional branch */
270 #define MIPS_HFLAG_BL 0x0180 /* Likely branch */
271 #define MIPS_HFLAG_BR 0x0200 /* branch to register (can't link TB) */
272 target_ulong btarget
; /* Jump / branch target */
273 int bcond
; /* Branch condition (if needed) */
275 int halted
; /* TRUE if the CPU is in suspend state */
277 int SYNCI_Step
; /* Address step size for SYNCI */
278 int CCRes
; /* Cycle count resolution/divisor */
283 const char *kernel_filename
;
284 const char *kernel_cmdline
;
285 const char *initrd_filename
;
287 struct QEMUTimer
*timer
; /* Internal timer */
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__) */