A cumulative MIPS patchset
PATCH 6/6 A cumulative MIPS patchset
Hello All,
this patch adds support for all mandatory MIPS32R2 instructions, rationalizes the instruction decoding to check always 32-bit words, reduces the number of magic constants in the code, adds a few bits which make eventually implementation of MIPS64 support and optional MIPS32 features easier.
The emulated CPU still identifies itself as a MIPS32(R1) 4Kc. Currently it doesn't throw a RI exception for R2 instructions, this is useful for Linux userland emulation, and also follows the current policy which doesn't distinguish between MIPS32R1 instructions and those of earlier ISAs.
Thiemo
target-mips/cpu.h +55 -4
@@ -99,14 +99,16 @@#endif uint32_t CP0_index;uint32_t CP0_random; -uint32_t CP0_EntryLo0; -uint32_t CP0_EntryLo1; -uint32_t CP0_Context; +uint64_t CP0_EntryLo0; +uint64_t CP0_EntryLo1; +uint64_t CP0_Context;uint32_t CP0_PageMask; +uint32_t CP0_PageGrain;uint32_t CP0_Wired; +uint32_t CP0_HWREna;uint32_t CP0_BadVAddr;uint32_t CP0_Count; -uint32_t CP0_EntryHi; +uint64_t CP0_EntryHi;uint32_t CP0_Compare;uint32_t CP0_Status;#define CP0St_CU3 31
@@ -116,19 +118,36 @@#define CP0St_RP 27#define CP0St_FR 26#define CP0St_RE 25 +#define CP0St_MX 24 +#define CP0St_PX 23#define CP0St_BEV 22#define CP0St_TS 21#define CP0St_SR 20#define CP0St_NMI 19#define CP0St_IM 8 +#define CP0St_KX 7 +#define CP0St_SX 6 +#define CP0St_UX 5#define CP0St_UM 4 +#define CP0St_R0 3#define CP0St_ERL 2#define CP0St_EXL 1#define CP0St_IE 0 +uint32_t CP0_IntCtl; +uint32_t CP0_SRSCtl;uint32_t CP0_Cause; +#define CP0Ca_BD 31 +#define CP0Ca_TI 30 +#define CP0Ca_CE 28 +#define CP0Ca_DC 27 +#define CP0Ca_PCI 26#define CP0Ca_IV 23 +#define CP0Ca_WP 22 +#define CP0Ca_IP 8 +#define CP0Ca_EC 2uint32_t CP0_EPC ;uint32_t CP0_PRid; +uint32_t CP0_EBase;uint32_t CP0_Config0;#define CP0C0_M 31#define CP0C0_K23 28
@@ -140,8 +159,10 @@#define CP0C0_AT 13#define CP0C0_AR 10#define CP0C0_MT 7 +#define CP0C0_VI 3#define CP0C0_K0 0uint32_t CP0_Config1; +#define CP0C1_M 31#define CP0C1_MMU 25#define CP0C1_IS 22#define CP0C1_IL 19
@@ -149,14 +170,38 @@#define CP0C1_DS 13#define CP0C1_DL 10#define CP0C1_DA 7 +#define CP0C1_C2 6 +#define CP0C1_MD 5#define CP0C1_PC 4#define CP0C1_WR 3#define CP0C1_CA 2#define CP0C1_EP 1#define CP0C1_FP 0 +uint32_t CP0_Config2; +#define CP0C2_M 31 +#define CP0C2_TU 28 +#define CP0C2_TS 24 +#define CP0C2_TL 20 +#define CP0C2_TA 16 +#define CP0C2_SU 12 +#define CP0C2_SS 8 +#define CP0C2_SL 4 +#define CP0C2_SA 0 +uint32_t CP0_Config3; +#define CP0C3_M 31 +#define CP0C3_DSPP 10 +#define CP0C3_LPA 7 +#define CP0C3_VEIC 6 +#define CP0C3_VInt 5 +#define CP0C3_SP 4 +#define CP0C3_MT 2 +#define CP0C3_SM 1 +#define CP0C3_TL 0uint32_t CP0_LLAddr;uint32_t CP0_WatchLo;uint32_t CP0_WatchHi; +uint32_t CP0_XContext; +uint32_t CP0_Framemask;uint32_t CP0_Debug;#define CPDB_DBD 31#define CP0DB_DM 30
@@ -177,8 +222,11 @@#define CP0DB_DBp 1#define CP0DB_DSS 0uint32_t CP0_DEPC ; +uint32_t CP0_Performance0;uint32_t CP0_TagLo;uint32_t CP0_DataLo; +uint32_t CP0_TagHi; +uint32_t CP0_DataHi;uint32_t CP0_ErrorEPC;uint32_t CP0_DESAVE ;/* Qemu */
@@ -211,6 +259,9 @@int halted;/* TRUE if the CPU is in suspend state */ +int SYNCI_Step;/* Address step size for SYNCI */ +int CCRes;/* Cycle count resolution/divisor */ +CPU_COMMON int ram_size;
target-mips/exec.h +1 -0
@@ -68,6 +68,7 @@#endif void do_mfc0_random (void );void do_mfc0_count (void ); +void do_mtc0_entryhi (uint32_t in);void do_mtc0_status_debug (uint32_t old,uint32_t val);void do_mtc0_status_irqraise_debug (void );void do_tlbwi (void );
target-mips/helper.c +0 -6
@@ -302,15 +302,9 @@#endif env->CP0_Wired =0 ; env->CP0_Config0 =MIPS_CONFIG0 ; -#if defined (MIPS_CONFIG1 ) env->CP0_Config1 =MIPS_CONFIG1 ; -#endif -#if defined (MIPS_CONFIG2 ) env->CP0_Config2 =MIPS_CONFIG2 ; -#endif -#if defined (MIPS_CONFIG3 ) env->CP0_Config3 =MIPS_CONFIG3 ; -#endif env->CP0_WatchLo =0 ; env->CP0_Status = (1 << CP0St_CU0) | (1 << CP0St_BEV); goto set_error_EPC;
target-mips/mips-defs.h +34 -16
67 lines not on this page · raw message
target-mips/op.c +400 -15
636 lines not on this page · raw message
target-mips/op_helper.c +21 -3
@@ -152,14 +152,19 @@cpu_abort (env,"mtc0 compare\n" ); } +void do_mtc0_entryhi (uint32_t val) +{ +cpu_abort (env,"mtc0 entryhi\n" ); +} +void do_mtc0_status_debug (uint32_t old,uint32_t val) { -cpu_abort (env,"mtc0 status\n" ); +cpu_abort (env,"mtc0 status debug\n" ); } -void do_mtc0_status_irqraise_debug (void ) +void do_mtc0_status_irqraise_debug (void ) { -cpu_abort (env,"mtc0 status\n" ); +cpu_abort (env,"mtc0 status irqraise debug\n" ); }void do_tlbwi (void )
@@ -200,6 +205,19 @@T0 =cpu_mips_get_count (env); } +void do_mtc0_entryhi (uint32_t in) +{ +uint32_t old; + +/* 1k pages not implemented */ +/* Ignore MIPS64 TLB for now */ + old = env->CP0_EntryHi; + env->CP0_EntryHi = in &0xFFFFE0FF ; +/* If the ASID changes, flush qemu's TLB. */ +if ((old &0xFF ) != (in &0xFF )) +cpu_mips_tlb_flush (env,1 ); +} +void do_mtc0_status_debug (uint32_t old,uint32_t val) {const uint32_t mask =0x0000FF00 ;
target-mips/translate.c +1785 -548
2,110 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.