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 typedef struct r4k_tlb_t r4k_tlb_t
;
51 typedef struct CPUMIPSState CPUMIPSState
;
53 /* General integer registers */
55 /* Special registers */
57 #if TARGET_LONG_BITS > HOST_LONG_BITS
63 /* Floating point registers */
65 #ifndef USE_HOST_FLOAT_REGS
70 float_status fp_status
;
71 /* fpu implementation/revision register (fir) */
84 #define SET_FP_COND(num,env) do { ((env)->fcr31) |= ((num) ? (1 << ((num) + 24)) : (1 << 23)); } while(0)
85 #define CLEAR_FP_COND(num,env) do { ((env)->fcr31) &= ~((num) ? (1 << ((num) + 24)) : (1 << 23)); } while(0)
86 #define GET_FP_COND(env) ((((env)->fcr31 >> 24) & 0xfe) | (((env)->fcr31 >> 23) & 0x1))
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 & 0x3f) << 12); } while(0)
91 #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v & 0x1f) << 7); } while(0)
92 #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v & 0x1f) << 2); } while(0)
93 #define UPDATE_FP_FLAGS(reg,v) do { (reg) |= ((v & 0x1f) << 2); } while(0)
95 #define FP_UNDERFLOW 2
99 #define FP_UNIMPLEMENTED 32
103 int (*map_address
) (CPUMIPSState
*env
, target_ulong
*physical
, int *prot
, target_ulong address
, int rw
, int access_type
);
104 void (*do_tlbwi
) (void);
105 void (*do_tlbwr
) (void);
106 void (*do_tlbp
) (void);
107 void (*do_tlbr
) (void);
110 r4k_tlb_t tlb
[MIPS_TLB_MAX
];
116 target_ulong CP0_EntryLo0
;
117 target_ulong CP0_EntryLo1
;
118 target_ulong CP0_Context
;
119 int32_t CP0_PageMask
;
120 int32_t CP0_PageGrain
;
123 target_ulong CP0_BadVAddr
;
125 target_ulong CP0_EntryHi
;
162 #define CP0Ca_IP_mask 0x0000FF00
164 target_ulong CP0_EPC
;
208 #define CP0C3_DSPP 10
218 target_ulong CP0_LLAddr
;
219 target_ulong CP0_WatchLo
[8];
220 int32_t CP0_WatchHi
[8];
221 target_ulong CP0_XContext
;
222 int32_t CP0_Framemask
;
226 #define CP0DB_LSNM 28
227 #define CP0DB_Doze 27
228 #define CP0DB_Halt 26
230 #define CP0DB_IBEP 24
231 #define CP0DB_DBEP 21
232 #define CP0DB_IEXI 20
242 target_ulong CP0_DEPC
;
243 int32_t CP0_Performance0
;
248 target_ulong CP0_ErrorEPC
;
251 int interrupt_request
;
255 int user_mode_only
; /* user mode only simulation */
256 uint32_t hflags
; /* CPU State */
257 /* TMASK defines different execution modes */
258 #define MIPS_HFLAG_TMASK 0x007F
259 #define MIPS_HFLAG_MODE 0x0007 /* execution modes */
260 #define MIPS_HFLAG_UM 0x0001 /* user mode */
261 #define MIPS_HFLAG_DM 0x0002 /* Debug mode */
262 #define MIPS_HFLAG_SM 0x0004 /* Supervisor mode */
263 #define MIPS_HFLAG_64 0x0008 /* 64-bit instructions enabled */
264 #define MIPS_HFLAG_FPU 0x0010 /* FPU enabled */
265 #define MIPS_HFLAG_F64 0x0020 /* 64-bit FPU enabled */
266 #define MIPS_HFLAG_RE 0x0040 /* Reversed endianness */
267 /* If translation is interrupted between the branch instruction and
268 * the delay slot, record what type of branch it is so that we can
269 * resume translation properly. It might be possible to reduce
270 * this from three bits to two. */
271 #define MIPS_HFLAG_BMASK 0x0380
272 #define MIPS_HFLAG_B 0x0080 /* Unconditional branch */
273 #define MIPS_HFLAG_BC 0x0100 /* Conditional branch */
274 #define MIPS_HFLAG_BL 0x0180 /* Likely branch */
275 #define MIPS_HFLAG_BR 0x0200 /* branch to register (can't link TB) */
276 target_ulong btarget
; /* Jump / branch target */
277 int bcond
; /* Branch condition (if needed) */
279 int halted
; /* TRUE if the CPU is in suspend state */
281 int SYNCI_Step
; /* Address step size for SYNCI */
282 int CCRes
; /* Cycle count resolution/divisor */
283 int Status_rw_bitmask
; /* Read/write bits in CP0_Status */
285 #if defined(CONFIG_USER_ONLY)
286 target_ulong tls_value
;
294 const char *kernel_filename
;
295 const char *kernel_cmdline
;
296 const char *initrd_filename
;
298 struct QEMUTimer
*timer
; /* Internal timer */
301 int no_mmu_map_address (CPUMIPSState
*env
, target_ulong
*physical
, int *prot
,
302 target_ulong address
, int rw
, int access_type
);
303 int fixed_mmu_map_address (CPUMIPSState
*env
, target_ulong
*physical
, int *prot
,
304 target_ulong address
, int rw
, int access_type
);
305 int r4k_map_address (CPUMIPSState
*env
, target_ulong
*physical
, int *prot
,
306 target_ulong address
, int rw
, int access_type
);
307 void r4k_do_tlbwi (void);
308 void r4k_do_tlbwr (void);
309 void r4k_do_tlbp (void);
310 void r4k_do_tlbr (void);
311 typedef struct mips_def_t mips_def_t
;
312 int mips_find_by_name (const unsigned char *name
, mips_def_t
**def
);
313 void mips_cpu_list (FILE *f
, int (*cpu_fprintf
)(FILE *f
, const char *fmt
, ...));
314 int cpu_mips_register (CPUMIPSState
*env
, mips_def_t
*def
);
318 /* Memory access type :
319 * may be needed for precise access rights control and precise exceptions.
322 /* 1 bit to define user level / supervisor access */
325 /* 1 bit to indicate direction */
327 /* Type of instruction that generated the access */
328 ACCESS_CODE
= 0x10, /* Code fetch access */
329 ACCESS_INT
= 0x20, /* Integer load/store access */
330 ACCESS_FLOAT
= 0x30, /* floating point load/store access */
367 EXCP_MTCP0
= 0x104, /* mtmsr instruction: */
368 /* may change privilege level */
369 EXCP_BRANCH
= 0x108, /* branch instruction */
370 EXCP_ERET
= 0x10C, /* return from interrupt */
371 EXCP_SYSCALL_USER
= 0x110, /* System call in user mode only */
375 int cpu_mips_exec(CPUMIPSState
*s
);
376 CPUMIPSState
*cpu_mips_init(void);
377 uint32_t cpu_mips_get_clock (void);
378 int cpu_mips_signal_handler(int host_signum
, void *pinfo
, void *puc
);
380 #endif /* !defined (__MIPS_CPU_H__) */