1 #if !defined (__MIPS_CPU_H__)
4 #define TARGET_HAS_ICE 1
11 // uint_fast8_t and uint_fast16_t not in <sys/int_types.h>
12 // XXX: move that elsewhere
13 #if defined(HOST_SOLARIS) && SOLARISREV < 10
14 typedef unsigned char uint_fast8_t;
15 typedef unsigned int uint_fast16_t;
18 /* target_ulong size spec */
19 #ifdef MIPS_HAS_MIPS64
20 #define TLSZ "%016llx"
25 typedef union fpr_t fpr_t
;
27 float64 fd
; /* ieee double precision */
28 float32 fs
[2];/* ieee single precision */
29 uint64_t d
; /* binary single fixed-point */
30 uint32_t w
[2]; /* binary single fixed-point */
32 /* define FP_ENDIAN_IDX to access the same location
33 * in the fpr_t union regardless of the host endianess
35 #if defined(WORDS_BIGENDIAN)
36 # define FP_ENDIAN_IDX 1
38 # define FP_ENDIAN_IDX 0
41 #if defined(MIPS_USES_R4K_TLB)
42 typedef struct tlb_t tlb_t
;
59 typedef struct CPUMIPSState CPUMIPSState
;
61 /* General integer registers */
63 /* Special registers */
65 #if TARGET_LONG_BITS > HOST_LONG_BITS
72 #if defined(MIPS_USES_FPU)
73 /* Floating point registers */
75 #define FPR(cpu, n) ((fpr_t*)&(cpu)->fpr[(n) / 2])
76 #define FPR_FD(cpu, n) (FPR(cpu, n)->fd)
77 #define FPR_FS(cpu, n) (FPR(cpu, n)->fs[((n) & 1) ^ FP_ENDIAN_IDX])
78 #define FPR_D(cpu, n) (FPR(cpu, n)->d)
79 #define FPR_W(cpu, n) (FPR(cpu, n)->w[((n) & 1) ^ FP_ENDIAN_IDX])
81 #ifndef USE_HOST_FLOAT_REGS
86 float_status fp_status
;
87 /* fpu implementation/revision register */
91 #define SET_FP_COND(reg) do { (reg) |= (1<<23); } while(0)
92 #define CLEAR_FP_COND(reg) do { (reg) &= ~(1<<23); } while(0)
93 #define IS_FP_COND_SET(reg) (((reg) & (1<<23)) != 0)
94 #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f)
95 #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f)
96 #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f)
97 #define SET_FP_CAUSE(reg,v) do { (reg) = ((reg) & ~(0x3f << 12)) | ((v) << 12); } while(0)
98 #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v) << 7); } while(0)
99 #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v) << 2); } while(0)
101 #define FP_UNDERFLOW 2
102 #define FP_OVERFLOW 4
104 #define FP_INVALID 16
105 #define FP_UNIMPLEMENTED 32
108 #if defined(MIPS_USES_R4K_TLB)
109 tlb_t tlb
[MIPS_TLB_MAX
];
114 uint64_t CP0_EntryLo0
;
115 uint64_t CP0_EntryLo1
;
116 uint64_t CP0_Context
;
117 uint32_t CP0_PageMask
;
118 uint32_t CP0_PageGrain
;
121 target_ulong CP0_BadVAddr
;
123 uint64_t CP0_EntryHi
;
124 uint32_t CP0_Compare
;
160 target_ulong CP0_EPC
;
162 target_ulong CP0_EBase
;
163 uint32_t CP0_Config0
;
176 uint32_t CP0_Config1
;
192 uint32_t CP0_Config2
;
202 uint32_t CP0_Config3
;
204 #define CP0C3_DSPP 10
212 target_ulong CP0_LLAddr
;
213 uint32_t CP0_WatchLo
;
214 uint32_t CP0_WatchHi
;
215 uint32_t CP0_XContext
;
216 uint32_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 uint32_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_ERL 0x0002 /* Error mode */
256 #define MIPS_HFLAG_EXL 0x0004 /* Exception mode */
257 #define MIPS_HFLAG_DM 0x0008 /* Debug mode */
258 #define MIPS_HFLAG_SM 0x0010 /* Supervisor mode */
259 #define MIPS_HFLAG_RE 0x0040 /* Reversed endianness */
260 /* If translation is interrupted between the branch instruction and
261 * the delay slot, record what type of branch it is so that we can
262 * resume translation properly. It might be possible to reduce
263 * this from three bits to two. */
264 #define MIPS_HFLAG_BMASK 0x0380
265 #define MIPS_HFLAG_B 0x0080 /* Unconditional branch */
266 #define MIPS_HFLAG_BC 0x0100 /* Conditional branch */
267 #define MIPS_HFLAG_BL 0x0180 /* Likely branch */
268 #define MIPS_HFLAG_BR 0x0200 /* branch to register (can't link TB) */
269 target_ulong btarget
; /* Jump / branch target */
270 int bcond
; /* Branch condition (if needed) */
272 int halted
; /* TRUE if the CPU is in suspend state */
274 int SYNCI_Step
; /* Address step size for SYNCI */
275 int CCRes
; /* Cycle count resolution/divisor */
280 const char *kernel_filename
;
281 const char *kernel_cmdline
;
282 const char *initrd_filename
;
284 struct QEMUTimer
*timer
; /* Internal timer */
289 /* Memory access type :
290 * may be needed for precise access rights control and precise exceptions.
293 /* 1 bit to define user level / supervisor access */
296 /* 1 bit to indicate direction */
298 /* Type of instruction that generated the access */
299 ACCESS_CODE
= 0x10, /* Code fetch access */
300 ACCESS_INT
= 0x20, /* Integer load/store access */
301 ACCESS_FLOAT
= 0x30, /* floating point load/store access */
337 EXCP_MTCP0
= 0x104, /* mtmsr instruction: */
338 /* may change privilege level */
339 EXCP_BRANCH
= 0x108, /* branch instruction */
340 EXCP_ERET
= 0x10C, /* return from interrupt */
341 EXCP_SYSCALL_USER
= 0x110, /* System call in user mode only */
345 int cpu_mips_exec(CPUMIPSState
*s
);
346 CPUMIPSState
*cpu_mips_init(void);
347 uint32_t cpu_mips_get_clock (void);
349 #endif /* !defined (__MIPS_CPU_H__) */