107f5a258SMarkus Armbruster #ifndef MIPS_CPU_H 207f5a258SMarkus Armbruster #define MIPS_CPU_H 36af0bf9cSbellard 4416bf936SPaolo Bonzini #include "cpu-qom.h" 5022c62cbSPaolo Bonzini #include "exec/cpu-defs.h" 6502700d0SAlex Bennée #include "fpu/softfloat-types.h" 774433bf0SRichard Henderson #include "mips-defs.h" 86af0bf9cSbellard 90454728cSAleksandar Markovic #define TCG_GUEST_DEFAULT_MO (0) 100454728cSAleksandar Markovic 11ead9360eSths typedef struct CPUMIPSTLBContext CPUMIPSTLBContext; 1251b2772fSths 13e97a391dSYongbok Kim /* MSA Context */ 14e97a391dSYongbok Kim #define MSA_WRLEN (128) 15e97a391dSYongbok Kim 16e97a391dSYongbok Kim typedef union wr_t wr_t; 17e97a391dSYongbok Kim union wr_t { 18e97a391dSYongbok Kim int8_t b[MSA_WRLEN / 8]; 19e97a391dSYongbok Kim int16_t h[MSA_WRLEN / 16]; 20e97a391dSYongbok Kim int32_t w[MSA_WRLEN / 32]; 21e97a391dSYongbok Kim int64_t d[MSA_WRLEN / 64]; 22e97a391dSYongbok Kim }; 23e97a391dSYongbok Kim 24c227f099SAnthony Liguori typedef union fpr_t fpr_t; 25c227f099SAnthony Liguori union fpr_t { 26ead9360eSths float64 fd; /* ieee double precision */ 27ead9360eSths float32 fs[2];/* ieee single precision */ 28ead9360eSths uint64_t d; /* binary double fixed-point */ 29ead9360eSths uint32_t w[2]; /* binary single fixed-point */ 30e97a391dSYongbok Kim /* FPU/MSA register mapping is not tested on big-endian hosts. */ 31e97a391dSYongbok Kim wr_t wr; /* vector data */ 32ead9360eSths }; 339e72f33dSJules Irenge /* 349e72f33dSJules Irenge *define FP_ENDIAN_IDX to access the same location 354ff9786cSStefan Weil * in the fpr_t union regardless of the host endianness 36ead9360eSths */ 37e2542fe2SJuan Quintela #if defined(HOST_WORDS_BIGENDIAN) 38ead9360eSths # define FP_ENDIAN_IDX 1 39ead9360eSths #else 40ead9360eSths # define FP_ENDIAN_IDX 0 41c570fd16Sths #endif 42ead9360eSths 43ead9360eSths typedef struct CPUMIPSFPUContext CPUMIPSFPUContext; 44ead9360eSths struct CPUMIPSFPUContext { 456af0bf9cSbellard /* Floating point registers */ 46c227f099SAnthony Liguori fpr_t fpr[32]; 476ea83fedSbellard float_status fp_status; 485a5012ecSths /* fpu implementation/revision register (fir) */ 496af0bf9cSbellard uint32_t fcr0; 507c979afdSLeon Alrae #define FCR0_FREP 29 51b4dd99a3SPetar Jovanovic #define FCR0_UFRP 28 52ba5c79f2SLeon Alrae #define FCR0_HAS2008 23 535a5012ecSths #define FCR0_F64 22 545a5012ecSths #define FCR0_L 21 555a5012ecSths #define FCR0_W 20 565a5012ecSths #define FCR0_3D 19 575a5012ecSths #define FCR0_PS 18 585a5012ecSths #define FCR0_D 17 595a5012ecSths #define FCR0_S 16 605a5012ecSths #define FCR0_PRID 8 615a5012ecSths #define FCR0_REV 0 626ea83fedSbellard /* fcsr */ 63599bc5e8SAleksandar Markovic uint32_t fcr31_rw_bitmask; 646ea83fedSbellard uint32_t fcr31; 6577be4199SAleksandar Markovic #define FCR31_FS 24 66ba5c79f2SLeon Alrae #define FCR31_ABS2008 19 67ba5c79f2SLeon Alrae #define FCR31_NAN2008 18 688ebf2e1aSJules Irenge #define SET_FP_COND(num, env) do { ((env).fcr31) |= \ 698ebf2e1aSJules Irenge ((num) ? (1 << ((num) + 24)) : \ 708ebf2e1aSJules Irenge (1 << 23)); \ 718ebf2e1aSJules Irenge } while (0) 728ebf2e1aSJules Irenge #define CLEAR_FP_COND(num, env) do { ((env).fcr31) &= \ 738ebf2e1aSJules Irenge ~((num) ? (1 << ((num) + 24)) : \ 748ebf2e1aSJules Irenge (1 << 23)); \ 758ebf2e1aSJules Irenge } while (0) 768ebf2e1aSJules Irenge #define GET_FP_COND(env) ((((env).fcr31 >> 24) & 0xfe) | \ 778ebf2e1aSJules Irenge (((env).fcr31 >> 23) & 0x1)) 786ea83fedSbellard #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f) 796ea83fedSbellard #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f) 806ea83fedSbellard #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f) 818ebf2e1aSJules Irenge #define SET_FP_CAUSE(reg, v) do { (reg) = ((reg) & ~(0x3f << 12)) | \ 828ebf2e1aSJules Irenge ((v & 0x3f) << 12); \ 838ebf2e1aSJules Irenge } while (0) 848ebf2e1aSJules Irenge #define SET_FP_ENABLE(reg, v) do { (reg) = ((reg) & ~(0x1f << 7)) | \ 858ebf2e1aSJules Irenge ((v & 0x1f) << 7); \ 868ebf2e1aSJules Irenge } while (0) 878ebf2e1aSJules Irenge #define SET_FP_FLAGS(reg, v) do { (reg) = ((reg) & ~(0x1f << 2)) | \ 888ebf2e1aSJules Irenge ((v & 0x1f) << 2); \ 898ebf2e1aSJules Irenge } while (0) 905a5012ecSths #define UPDATE_FP_FLAGS(reg, v) do { (reg) |= ((v & 0x1f) << 2); } while (0) 916ea83fedSbellard #define FP_INEXACT 1 926ea83fedSbellard #define FP_UNDERFLOW 2 936ea83fedSbellard #define FP_OVERFLOW 4 946ea83fedSbellard #define FP_DIV0 8 956ea83fedSbellard #define FP_INVALID 16 966ea83fedSbellard #define FP_UNIMPLEMENTED 32 97ead9360eSths }; 986ea83fedSbellard 99c20d594eSRichard Henderson #define TARGET_INSN_START_EXTRA_WORDS 2 1006ebbf390Sj_mayer 101ead9360eSths typedef struct CPUMIPSMVPContext CPUMIPSMVPContext; 102ead9360eSths struct CPUMIPSMVPContext { 103ead9360eSths int32_t CP0_MVPControl; 104ead9360eSths #define CP0MVPCo_CPA 3 105ead9360eSths #define CP0MVPCo_STLB 2 106ead9360eSths #define CP0MVPCo_VPC 1 107ead9360eSths #define CP0MVPCo_EVP 0 108ead9360eSths int32_t CP0_MVPConf0; 109ead9360eSths #define CP0MVPC0_M 31 110ead9360eSths #define CP0MVPC0_TLBS 29 111ead9360eSths #define CP0MVPC0_GS 28 112ead9360eSths #define CP0MVPC0_PCP 27 113ead9360eSths #define CP0MVPC0_PTLBE 16 114ead9360eSths #define CP0MVPC0_TCA 15 115ead9360eSths #define CP0MVPC0_PVPE 10 116ead9360eSths #define CP0MVPC0_PTC 0 117ead9360eSths int32_t CP0_MVPConf1; 118ead9360eSths #define CP0MVPC1_CIM 31 119ead9360eSths #define CP0MVPC1_CIF 30 120ead9360eSths #define CP0MVPC1_PCX 20 121ead9360eSths #define CP0MVPC1_PCP2 10 122ead9360eSths #define CP0MVPC1_PCP1 0 123ead9360eSths }; 124ead9360eSths 125c227f099SAnthony Liguori typedef struct mips_def_t mips_def_t; 126ead9360eSths 127ead9360eSths #define MIPS_SHADOW_SET_MAX 16 128ead9360eSths #define MIPS_TC_MAX 5 129f01be154Sths #define MIPS_FPU_MAX 1 130ead9360eSths #define MIPS_DSP_ACC 4 131e98c0d17SLeon Alrae #define MIPS_KSCRATCH_NUM 6 132f6d4dd81SYongbok Kim #define MIPS_MAAR_MAX 16 /* Must be an even number. */ 133ead9360eSths 134e97a391dSYongbok Kim 135a86d421eSAleksandar Markovic /* 136a86d421eSAleksandar Markovic * Summary of CP0 registers 137a86d421eSAleksandar Markovic * ======================== 138a86d421eSAleksandar Markovic * 139a86d421eSAleksandar Markovic * 140a86d421eSAleksandar Markovic * Register 0 Register 1 Register 2 Register 3 141a86d421eSAleksandar Markovic * ---------- ---------- ---------- ---------- 142a86d421eSAleksandar Markovic * 143a86d421eSAleksandar Markovic * 0 Index Random EntryLo0 EntryLo1 144a86d421eSAleksandar Markovic * 1 MVPControl VPEControl TCStatus GlobalNumber 145a86d421eSAleksandar Markovic * 2 MVPConf0 VPEConf0 TCBind 146a86d421eSAleksandar Markovic * 3 MVPConf1 VPEConf1 TCRestart 147a86d421eSAleksandar Markovic * 4 VPControl YQMask TCHalt 148a86d421eSAleksandar Markovic * 5 VPESchedule TCContext 149a86d421eSAleksandar Markovic * 6 VPEScheFBack TCSchedule 150a86d421eSAleksandar Markovic * 7 VPEOpt TCScheFBack TCOpt 151a86d421eSAleksandar Markovic * 152a86d421eSAleksandar Markovic * 153a86d421eSAleksandar Markovic * Register 4 Register 5 Register 6 Register 7 154a86d421eSAleksandar Markovic * ---------- ---------- ---------- ---------- 155a86d421eSAleksandar Markovic * 156a86d421eSAleksandar Markovic * 0 Context PageMask Wired HWREna 157a86d421eSAleksandar Markovic * 1 ContextConfig PageGrain SRSConf0 158a86d421eSAleksandar Markovic * 2 UserLocal SegCtl0 SRSConf1 159a86d421eSAleksandar Markovic * 3 XContextConfig SegCtl1 SRSConf2 160a86d421eSAleksandar Markovic * 4 DebugContextID SegCtl2 SRSConf3 161a86d421eSAleksandar Markovic * 5 MemoryMapID PWBase SRSConf4 162a86d421eSAleksandar Markovic * 6 PWField PWCtl 163a86d421eSAleksandar Markovic * 7 PWSize 164a86d421eSAleksandar Markovic * 165a86d421eSAleksandar Markovic * 166a86d421eSAleksandar Markovic * Register 8 Register 9 Register 10 Register 11 167a86d421eSAleksandar Markovic * ---------- ---------- ----------- ----------- 168a86d421eSAleksandar Markovic * 169a86d421eSAleksandar Markovic * 0 BadVAddr Count EntryHi Compare 170a86d421eSAleksandar Markovic * 1 BadInstr 171a86d421eSAleksandar Markovic * 2 BadInstrP 172a86d421eSAleksandar Markovic * 3 BadInstrX 173a86d421eSAleksandar Markovic * 4 GuestCtl1 GuestCtl0Ext 174a86d421eSAleksandar Markovic * 5 GuestCtl2 175167db30eSYongbok Kim * 6 SAARI GuestCtl3 176167db30eSYongbok Kim * 7 SAAR 177a86d421eSAleksandar Markovic * 178a86d421eSAleksandar Markovic * 179a86d421eSAleksandar Markovic * Register 12 Register 13 Register 14 Register 15 180a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 181a86d421eSAleksandar Markovic * 182a86d421eSAleksandar Markovic * 0 Status Cause EPC PRId 183a86d421eSAleksandar Markovic * 1 IntCtl EBase 184a86d421eSAleksandar Markovic * 2 SRSCtl NestedEPC CDMMBase 185a86d421eSAleksandar Markovic * 3 SRSMap CMGCRBase 186a86d421eSAleksandar Markovic * 4 View_IPL View_RIPL BEVVA 187a86d421eSAleksandar Markovic * 5 SRSMap2 NestedExc 188a86d421eSAleksandar Markovic * 6 GuestCtl0 189a86d421eSAleksandar Markovic * 7 GTOffset 190a86d421eSAleksandar Markovic * 191a86d421eSAleksandar Markovic * 192a86d421eSAleksandar Markovic * Register 16 Register 17 Register 18 Register 19 193a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 194a86d421eSAleksandar Markovic * 195e8dcfe82SAleksandar Markovic * 0 Config LLAddr WatchLo0 WatchHi 196e8dcfe82SAleksandar Markovic * 1 Config1 MAAR WatchLo1 WatchHi 197e8dcfe82SAleksandar Markovic * 2 Config2 MAARI WatchLo2 WatchHi 198e8dcfe82SAleksandar Markovic * 3 Config3 WatchLo3 WatchHi 199e8dcfe82SAleksandar Markovic * 4 Config4 WatchLo4 WatchHi 200e8dcfe82SAleksandar Markovic * 5 Config5 WatchLo5 WatchHi 201af868995SHuacai Chen * 6 Config6 WatchLo6 WatchHi 202af868995SHuacai Chen * 7 Config7 WatchLo7 WatchHi 203a86d421eSAleksandar Markovic * 204a86d421eSAleksandar Markovic * 205a86d421eSAleksandar Markovic * Register 20 Register 21 Register 22 Register 23 206a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 207a86d421eSAleksandar Markovic * 208a86d421eSAleksandar Markovic * 0 XContext Debug 209a86d421eSAleksandar Markovic * 1 TraceControl 210a86d421eSAleksandar Markovic * 2 TraceControl2 211a86d421eSAleksandar Markovic * 3 UserTraceData1 212a86d421eSAleksandar Markovic * 4 TraceIBPC 213a86d421eSAleksandar Markovic * 5 TraceDBPC 214a86d421eSAleksandar Markovic * 6 Debug2 215a86d421eSAleksandar Markovic * 7 216a86d421eSAleksandar Markovic * 217a86d421eSAleksandar Markovic * 218a86d421eSAleksandar Markovic * Register 24 Register 25 Register 26 Register 27 219a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 220a86d421eSAleksandar Markovic * 221a86d421eSAleksandar Markovic * 0 DEPC PerfCnt ErrCtl CacheErr 222a86d421eSAleksandar Markovic * 1 PerfCnt 223a86d421eSAleksandar Markovic * 2 TraceControl3 PerfCnt 224a86d421eSAleksandar Markovic * 3 UserTraceData2 PerfCnt 225a86d421eSAleksandar Markovic * 4 PerfCnt 226a86d421eSAleksandar Markovic * 5 PerfCnt 227a86d421eSAleksandar Markovic * 6 PerfCnt 228a86d421eSAleksandar Markovic * 7 PerfCnt 229a86d421eSAleksandar Markovic * 230a86d421eSAleksandar Markovic * 231a86d421eSAleksandar Markovic * Register 28 Register 29 Register 30 Register 31 232a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 233a86d421eSAleksandar Markovic * 234a86d421eSAleksandar Markovic * 0 DataLo DataHi ErrorEPC DESAVE 235a86d421eSAleksandar Markovic * 1 TagLo TagHi 236af4bb6daSAleksandar Markovic * 2 DataLo1 DataHi1 KScratch<n> 237af4bb6daSAleksandar Markovic * 3 TagLo1 TagHi1 KScratch<n> 238af4bb6daSAleksandar Markovic * 4 DataLo2 DataHi2 KScratch<n> 239af4bb6daSAleksandar Markovic * 5 TagLo2 TagHi2 KScratch<n> 240af4bb6daSAleksandar Markovic * 6 DataLo3 DataHi3 KScratch<n> 241af4bb6daSAleksandar Markovic * 7 TagLo3 TagHi3 KScratch<n> 242a86d421eSAleksandar Markovic * 243a86d421eSAleksandar Markovic */ 24404992c8cSAleksandar Markovic #define CP0_REGISTER_00 0 24504992c8cSAleksandar Markovic #define CP0_REGISTER_01 1 24604992c8cSAleksandar Markovic #define CP0_REGISTER_02 2 24704992c8cSAleksandar Markovic #define CP0_REGISTER_03 3 24804992c8cSAleksandar Markovic #define CP0_REGISTER_04 4 24904992c8cSAleksandar Markovic #define CP0_REGISTER_05 5 25004992c8cSAleksandar Markovic #define CP0_REGISTER_06 6 25104992c8cSAleksandar Markovic #define CP0_REGISTER_07 7 25204992c8cSAleksandar Markovic #define CP0_REGISTER_08 8 25304992c8cSAleksandar Markovic #define CP0_REGISTER_09 9 25404992c8cSAleksandar Markovic #define CP0_REGISTER_10 10 25504992c8cSAleksandar Markovic #define CP0_REGISTER_11 11 25604992c8cSAleksandar Markovic #define CP0_REGISTER_12 12 25704992c8cSAleksandar Markovic #define CP0_REGISTER_13 13 25804992c8cSAleksandar Markovic #define CP0_REGISTER_14 14 25904992c8cSAleksandar Markovic #define CP0_REGISTER_15 15 26004992c8cSAleksandar Markovic #define CP0_REGISTER_16 16 26104992c8cSAleksandar Markovic #define CP0_REGISTER_17 17 26204992c8cSAleksandar Markovic #define CP0_REGISTER_18 18 26304992c8cSAleksandar Markovic #define CP0_REGISTER_19 19 26404992c8cSAleksandar Markovic #define CP0_REGISTER_20 20 26504992c8cSAleksandar Markovic #define CP0_REGISTER_21 21 26604992c8cSAleksandar Markovic #define CP0_REGISTER_22 22 26704992c8cSAleksandar Markovic #define CP0_REGISTER_23 23 26804992c8cSAleksandar Markovic #define CP0_REGISTER_24 24 26904992c8cSAleksandar Markovic #define CP0_REGISTER_25 25 27004992c8cSAleksandar Markovic #define CP0_REGISTER_26 26 27104992c8cSAleksandar Markovic #define CP0_REGISTER_27 27 27204992c8cSAleksandar Markovic #define CP0_REGISTER_28 28 27304992c8cSAleksandar Markovic #define CP0_REGISTER_29 29 27404992c8cSAleksandar Markovic #define CP0_REGISTER_30 30 27504992c8cSAleksandar Markovic #define CP0_REGISTER_31 31 27604992c8cSAleksandar Markovic 27704992c8cSAleksandar Markovic 27804992c8cSAleksandar Markovic /* CP0 Register 00 */ 27904992c8cSAleksandar Markovic #define CP0_REG00__INDEX 0 2801b142da5SAleksandar Markovic #define CP0_REG00__MVPCONTROL 1 2811b142da5SAleksandar Markovic #define CP0_REG00__MVPCONF0 2 2821b142da5SAleksandar Markovic #define CP0_REG00__MVPCONF1 3 28304992c8cSAleksandar Markovic #define CP0_REG00__VPCONTROL 4 28404992c8cSAleksandar Markovic /* CP0 Register 01 */ 28530deb460SAleksandar Markovic #define CP0_REG01__RANDOM 0 28630deb460SAleksandar Markovic #define CP0_REG01__VPECONTROL 1 28730deb460SAleksandar Markovic #define CP0_REG01__VPECONF0 2 28830deb460SAleksandar Markovic #define CP0_REG01__VPECONF1 3 28930deb460SAleksandar Markovic #define CP0_REG01__YQMASK 4 29030deb460SAleksandar Markovic #define CP0_REG01__VPESCHEDULE 5 29130deb460SAleksandar Markovic #define CP0_REG01__VPESCHEFBACK 6 29230deb460SAleksandar Markovic #define CP0_REG01__VPEOPT 7 29304992c8cSAleksandar Markovic /* CP0 Register 02 */ 29404992c8cSAleksandar Markovic #define CP0_REG02__ENTRYLO0 0 2956d27d5bdSAleksandar Markovic #define CP0_REG02__TCSTATUS 1 2966d27d5bdSAleksandar Markovic #define CP0_REG02__TCBIND 2 2976d27d5bdSAleksandar Markovic #define CP0_REG02__TCRESTART 3 2986d27d5bdSAleksandar Markovic #define CP0_REG02__TCHALT 4 2996d27d5bdSAleksandar Markovic #define CP0_REG02__TCCONTEXT 5 3006d27d5bdSAleksandar Markovic #define CP0_REG02__TCSCHEDULE 6 3016d27d5bdSAleksandar Markovic #define CP0_REG02__TCSCHEFBACK 7 30204992c8cSAleksandar Markovic /* CP0 Register 03 */ 30304992c8cSAleksandar Markovic #define CP0_REG03__ENTRYLO1 0 30404992c8cSAleksandar Markovic #define CP0_REG03__GLOBALNUM 1 305acd37316SAleksandar Markovic #define CP0_REG03__TCOPT 7 30604992c8cSAleksandar Markovic /* CP0 Register 04 */ 30704992c8cSAleksandar Markovic #define CP0_REG04__CONTEXT 0 308020fe379SAleksandar Markovic #define CP0_REG04__CONTEXTCONFIG 1 30904992c8cSAleksandar Markovic #define CP0_REG04__USERLOCAL 2 310020fe379SAleksandar Markovic #define CP0_REG04__XCONTEXTCONFIG 3 31104992c8cSAleksandar Markovic #define CP0_REG04__DBGCONTEXTID 4 31299029be1SYongbok Kim #define CP0_REG04__MMID 5 31304992c8cSAleksandar Markovic /* CP0 Register 05 */ 31404992c8cSAleksandar Markovic #define CP0_REG05__PAGEMASK 0 31504992c8cSAleksandar Markovic #define CP0_REG05__PAGEGRAIN 1 316a1e76353SAleksandar Markovic #define CP0_REG05__SEGCTL0 2 317a1e76353SAleksandar Markovic #define CP0_REG05__SEGCTL1 3 318a1e76353SAleksandar Markovic #define CP0_REG05__SEGCTL2 4 319a1e76353SAleksandar Markovic #define CP0_REG05__PWBASE 5 320a1e76353SAleksandar Markovic #define CP0_REG05__PWFIELD 6 321a1e76353SAleksandar Markovic #define CP0_REG05__PWSIZE 7 32204992c8cSAleksandar Markovic /* CP0 Register 06 */ 32304992c8cSAleksandar Markovic #define CP0_REG06__WIRED 0 3249023594bSAleksandar Markovic #define CP0_REG06__SRSCONF0 1 3259023594bSAleksandar Markovic #define CP0_REG06__SRSCONF1 2 3269023594bSAleksandar Markovic #define CP0_REG06__SRSCONF2 3 3279023594bSAleksandar Markovic #define CP0_REG06__SRSCONF3 4 3289023594bSAleksandar Markovic #define CP0_REG06__SRSCONF4 5 3299023594bSAleksandar Markovic #define CP0_REG06__PWCTL 6 33004992c8cSAleksandar Markovic /* CP0 Register 07 */ 33104992c8cSAleksandar Markovic #define CP0_REG07__HWRENA 0 33204992c8cSAleksandar Markovic /* CP0 Register 08 */ 33304992c8cSAleksandar Markovic #define CP0_REG08__BADVADDR 0 33404992c8cSAleksandar Markovic #define CP0_REG08__BADINSTR 1 33504992c8cSAleksandar Markovic #define CP0_REG08__BADINSTRP 2 33667d167d2SAleksandar Markovic #define CP0_REG08__BADINSTRX 3 33704992c8cSAleksandar Markovic /* CP0 Register 09 */ 33804992c8cSAleksandar Markovic #define CP0_REG09__COUNT 0 33904992c8cSAleksandar Markovic #define CP0_REG09__SAARI 6 34004992c8cSAleksandar Markovic #define CP0_REG09__SAAR 7 34104992c8cSAleksandar Markovic /* CP0 Register 10 */ 34204992c8cSAleksandar Markovic #define CP0_REG10__ENTRYHI 0 34304992c8cSAleksandar Markovic #define CP0_REG10__GUESTCTL1 4 34404992c8cSAleksandar Markovic #define CP0_REG10__GUESTCTL2 5 345860ffef0SAleksandar Markovic #define CP0_REG10__GUESTCTL3 6 34604992c8cSAleksandar Markovic /* CP0 Register 11 */ 34704992c8cSAleksandar Markovic #define CP0_REG11__COMPARE 0 34804992c8cSAleksandar Markovic #define CP0_REG11__GUESTCTL0EXT 4 34904992c8cSAleksandar Markovic /* CP0 Register 12 */ 35004992c8cSAleksandar Markovic #define CP0_REG12__STATUS 0 35104992c8cSAleksandar Markovic #define CP0_REG12__INTCTL 1 35204992c8cSAleksandar Markovic #define CP0_REG12__SRSCTL 2 3532b084867SAleksandar Markovic #define CP0_REG12__SRSMAP 3 3542b084867SAleksandar Markovic #define CP0_REG12__VIEW_IPL 4 3552b084867SAleksandar Markovic #define CP0_REG12__SRSMAP2 5 35604992c8cSAleksandar Markovic #define CP0_REG12__GUESTCTL0 6 35704992c8cSAleksandar Markovic #define CP0_REG12__GTOFFSET 7 35804992c8cSAleksandar Markovic /* CP0 Register 13 */ 35904992c8cSAleksandar Markovic #define CP0_REG13__CAUSE 0 360e3c7559dSAleksandar Markovic #define CP0_REG13__VIEW_RIPL 4 361e3c7559dSAleksandar Markovic #define CP0_REG13__NESTEDEXC 5 36204992c8cSAleksandar Markovic /* CP0 Register 14 */ 36304992c8cSAleksandar Markovic #define CP0_REG14__EPC 0 36435e4b54dSAleksandar Markovic #define CP0_REG14__NESTEDEPC 2 36504992c8cSAleksandar Markovic /* CP0 Register 15 */ 36604992c8cSAleksandar Markovic #define CP0_REG15__PRID 0 36704992c8cSAleksandar Markovic #define CP0_REG15__EBASE 1 36804992c8cSAleksandar Markovic #define CP0_REG15__CDMMBASE 2 36904992c8cSAleksandar Markovic #define CP0_REG15__CMGCRBASE 3 3704466cd49SAleksandar Markovic #define CP0_REG15__BEVVA 4 37104992c8cSAleksandar Markovic /* CP0 Register 16 */ 37204992c8cSAleksandar Markovic #define CP0_REG16__CONFIG 0 37304992c8cSAleksandar Markovic #define CP0_REG16__CONFIG1 1 37404992c8cSAleksandar Markovic #define CP0_REG16__CONFIG2 2 37504992c8cSAleksandar Markovic #define CP0_REG16__CONFIG3 3 37604992c8cSAleksandar Markovic #define CP0_REG16__CONFIG4 4 37704992c8cSAleksandar Markovic #define CP0_REG16__CONFIG5 5 378433efb4cSAleksandar Markovic #define CP0_REG16__CONFIG6 6 379433efb4cSAleksandar Markovic #define CP0_REG16__CONFIG7 7 38004992c8cSAleksandar Markovic /* CP0 Register 17 */ 38104992c8cSAleksandar Markovic #define CP0_REG17__LLADDR 0 38204992c8cSAleksandar Markovic #define CP0_REG17__MAAR 1 38304992c8cSAleksandar Markovic #define CP0_REG17__MAARI 2 38404992c8cSAleksandar Markovic /* CP0 Register 18 */ 38504992c8cSAleksandar Markovic #define CP0_REG18__WATCHLO0 0 38604992c8cSAleksandar Markovic #define CP0_REG18__WATCHLO1 1 38704992c8cSAleksandar Markovic #define CP0_REG18__WATCHLO2 2 38804992c8cSAleksandar Markovic #define CP0_REG18__WATCHLO3 3 389e8dcfe82SAleksandar Markovic #define CP0_REG18__WATCHLO4 4 390e8dcfe82SAleksandar Markovic #define CP0_REG18__WATCHLO5 5 391e8dcfe82SAleksandar Markovic #define CP0_REG18__WATCHLO6 6 392e8dcfe82SAleksandar Markovic #define CP0_REG18__WATCHLO7 7 39304992c8cSAleksandar Markovic /* CP0 Register 19 */ 39404992c8cSAleksandar Markovic #define CP0_REG19__WATCHHI0 0 39504992c8cSAleksandar Markovic #define CP0_REG19__WATCHHI1 1 39604992c8cSAleksandar Markovic #define CP0_REG19__WATCHHI2 2 39704992c8cSAleksandar Markovic #define CP0_REG19__WATCHHI3 3 398be274dc1SAleksandar Markovic #define CP0_REG19__WATCHHI4 4 399be274dc1SAleksandar Markovic #define CP0_REG19__WATCHHI5 5 400be274dc1SAleksandar Markovic #define CP0_REG19__WATCHHI6 6 401be274dc1SAleksandar Markovic #define CP0_REG19__WATCHHI7 7 40204992c8cSAleksandar Markovic /* CP0 Register 20 */ 40304992c8cSAleksandar Markovic #define CP0_REG20__XCONTEXT 0 40404992c8cSAleksandar Markovic /* CP0 Register 21 */ 40504992c8cSAleksandar Markovic /* CP0 Register 22 */ 40604992c8cSAleksandar Markovic /* CP0 Register 23 */ 40704992c8cSAleksandar Markovic #define CP0_REG23__DEBUG 0 4084cbf4b6dSAleksandar Markovic #define CP0_REG23__TRACECONTROL 1 4094cbf4b6dSAleksandar Markovic #define CP0_REG23__TRACECONTROL2 2 4104cbf4b6dSAleksandar Markovic #define CP0_REG23__USERTRACEDATA1 3 4114cbf4b6dSAleksandar Markovic #define CP0_REG23__TRACEIBPC 4 4124cbf4b6dSAleksandar Markovic #define CP0_REG23__TRACEDBPC 5 4134cbf4b6dSAleksandar Markovic #define CP0_REG23__DEBUG2 6 41404992c8cSAleksandar Markovic /* CP0 Register 24 */ 41504992c8cSAleksandar Markovic #define CP0_REG24__DEPC 0 41604992c8cSAleksandar Markovic /* CP0 Register 25 */ 41704992c8cSAleksandar Markovic #define CP0_REG25__PERFCTL0 0 41804992c8cSAleksandar Markovic #define CP0_REG25__PERFCNT0 1 41904992c8cSAleksandar Markovic #define CP0_REG25__PERFCTL1 2 42004992c8cSAleksandar Markovic #define CP0_REG25__PERFCNT1 3 42104992c8cSAleksandar Markovic #define CP0_REG25__PERFCTL2 4 42204992c8cSAleksandar Markovic #define CP0_REG25__PERFCNT2 5 42304992c8cSAleksandar Markovic #define CP0_REG25__PERFCTL3 6 42404992c8cSAleksandar Markovic #define CP0_REG25__PERFCNT3 7 42504992c8cSAleksandar Markovic /* CP0 Register 26 */ 426dbbf08b2SAleksandar Markovic #define CP0_REG26__ERRCTL 0 42704992c8cSAleksandar Markovic /* CP0 Register 27 */ 42804992c8cSAleksandar Markovic #define CP0_REG27__CACHERR 0 42904992c8cSAleksandar Markovic /* CP0 Register 28 */ 430a30e2f21SAleksandar Markovic #define CP0_REG28__TAGLO 0 431a30e2f21SAleksandar Markovic #define CP0_REG28__DATALO 1 432a30e2f21SAleksandar Markovic #define CP0_REG28__TAGLO1 2 433a30e2f21SAleksandar Markovic #define CP0_REG28__DATALO1 3 434a30e2f21SAleksandar Markovic #define CP0_REG28__TAGLO2 4 435a30e2f21SAleksandar Markovic #define CP0_REG28__DATALO2 5 436a30e2f21SAleksandar Markovic #define CP0_REG28__TAGLO3 6 437a30e2f21SAleksandar Markovic #define CP0_REG28__DATALO3 7 43804992c8cSAleksandar Markovic /* CP0 Register 29 */ 439af4bb6daSAleksandar Markovic #define CP0_REG29__TAGHI 0 440af4bb6daSAleksandar Markovic #define CP0_REG29__DATAHI 1 441af4bb6daSAleksandar Markovic #define CP0_REG29__TAGHI1 2 442af4bb6daSAleksandar Markovic #define CP0_REG29__DATAHI1 3 443af4bb6daSAleksandar Markovic #define CP0_REG29__TAGHI2 4 444af4bb6daSAleksandar Markovic #define CP0_REG29__DATAHI2 5 445af4bb6daSAleksandar Markovic #define CP0_REG29__TAGHI3 6 446af4bb6daSAleksandar Markovic #define CP0_REG29__DATAHI3 7 44704992c8cSAleksandar Markovic /* CP0 Register 30 */ 44804992c8cSAleksandar Markovic #define CP0_REG30__ERROREPC 0 44904992c8cSAleksandar Markovic /* CP0 Register 31 */ 45004992c8cSAleksandar Markovic #define CP0_REG31__DESAVE 0 45104992c8cSAleksandar Markovic #define CP0_REG31__KSCRATCH1 2 45204992c8cSAleksandar Markovic #define CP0_REG31__KSCRATCH2 3 45304992c8cSAleksandar Markovic #define CP0_REG31__KSCRATCH3 4 45404992c8cSAleksandar Markovic #define CP0_REG31__KSCRATCH4 5 45504992c8cSAleksandar Markovic #define CP0_REG31__KSCRATCH5 6 45604992c8cSAleksandar Markovic #define CP0_REG31__KSCRATCH6 7 457ea9c5e83SAleksandar Markovic 458ea9c5e83SAleksandar Markovic 459ea9c5e83SAleksandar Markovic typedef struct TCState TCState; 460ea9c5e83SAleksandar Markovic struct TCState { 461ea9c5e83SAleksandar Markovic target_ulong gpr[32]; 462ea9c5e83SAleksandar Markovic target_ulong PC; 463ea9c5e83SAleksandar Markovic target_ulong HI[MIPS_DSP_ACC]; 464ea9c5e83SAleksandar Markovic target_ulong LO[MIPS_DSP_ACC]; 465ea9c5e83SAleksandar Markovic target_ulong ACX[MIPS_DSP_ACC]; 466ea9c5e83SAleksandar Markovic target_ulong DSPControl; 467ea9c5e83SAleksandar Markovic int32_t CP0_TCStatus; 468ea9c5e83SAleksandar Markovic #define CP0TCSt_TCU3 31 469ea9c5e83SAleksandar Markovic #define CP0TCSt_TCU2 30 470ea9c5e83SAleksandar Markovic #define CP0TCSt_TCU1 29 471ea9c5e83SAleksandar Markovic #define CP0TCSt_TCU0 28 472ea9c5e83SAleksandar Markovic #define CP0TCSt_TMX 27 473ea9c5e83SAleksandar Markovic #define CP0TCSt_RNST 23 474ea9c5e83SAleksandar Markovic #define CP0TCSt_TDS 21 475ea9c5e83SAleksandar Markovic #define CP0TCSt_DT 20 476ea9c5e83SAleksandar Markovic #define CP0TCSt_DA 15 477ea9c5e83SAleksandar Markovic #define CP0TCSt_A 13 478ea9c5e83SAleksandar Markovic #define CP0TCSt_TKSU 11 479ea9c5e83SAleksandar Markovic #define CP0TCSt_IXMT 10 480ea9c5e83SAleksandar Markovic #define CP0TCSt_TASID 0 481ea9c5e83SAleksandar Markovic int32_t CP0_TCBind; 482ea9c5e83SAleksandar Markovic #define CP0TCBd_CurTC 21 483ea9c5e83SAleksandar Markovic #define CP0TCBd_TBE 17 484ea9c5e83SAleksandar Markovic #define CP0TCBd_CurVPE 0 485ea9c5e83SAleksandar Markovic target_ulong CP0_TCHalt; 486ea9c5e83SAleksandar Markovic target_ulong CP0_TCContext; 487ea9c5e83SAleksandar Markovic target_ulong CP0_TCSchedule; 488ea9c5e83SAleksandar Markovic target_ulong CP0_TCScheFBack; 489ea9c5e83SAleksandar Markovic int32_t CP0_Debug_tcstatus; 490ea9c5e83SAleksandar Markovic target_ulong CP0_UserLocal; 491ea9c5e83SAleksandar Markovic 492ea9c5e83SAleksandar Markovic int32_t msacsr; 493ea9c5e83SAleksandar Markovic 494ea9c5e83SAleksandar Markovic #define MSACSR_FS 24 495ea9c5e83SAleksandar Markovic #define MSACSR_FS_MASK (1 << MSACSR_FS) 496ea9c5e83SAleksandar Markovic #define MSACSR_NX 18 497ea9c5e83SAleksandar Markovic #define MSACSR_NX_MASK (1 << MSACSR_NX) 498ea9c5e83SAleksandar Markovic #define MSACSR_CEF 2 499ea9c5e83SAleksandar Markovic #define MSACSR_CEF_MASK (0xffff << MSACSR_CEF) 500ea9c5e83SAleksandar Markovic #define MSACSR_RM 0 501ea9c5e83SAleksandar Markovic #define MSACSR_RM_MASK (0x3 << MSACSR_RM) 502ea9c5e83SAleksandar Markovic #define MSACSR_MASK (MSACSR_RM_MASK | MSACSR_CEF_MASK | MSACSR_NX_MASK | \ 503ea9c5e83SAleksandar Markovic MSACSR_FS_MASK) 504ea9c5e83SAleksandar Markovic 505ea9c5e83SAleksandar Markovic float_status msa_fp_status; 506ea9c5e83SAleksandar Markovic 507a168a796SFredrik Noring /* Upper 64-bit MMRs (multimedia registers); the lower 64-bit are GPRs */ 508a168a796SFredrik Noring uint64_t mmr[32]; 509a168a796SFredrik Noring 510ea9c5e83SAleksandar Markovic #define NUMBER_OF_MXU_REGISTERS 16 511ea9c5e83SAleksandar Markovic target_ulong mxu_gpr[NUMBER_OF_MXU_REGISTERS - 1]; 512ea9c5e83SAleksandar Markovic target_ulong mxu_cr; 513ea9c5e83SAleksandar Markovic #define MXU_CR_LC 31 514ea9c5e83SAleksandar Markovic #define MXU_CR_RC 30 515ea9c5e83SAleksandar Markovic #define MXU_CR_BIAS 2 516ea9c5e83SAleksandar Markovic #define MXU_CR_RD_EN 1 517ea9c5e83SAleksandar Markovic #define MXU_CR_MXU_EN 0 518ea9c5e83SAleksandar Markovic 519ea9c5e83SAleksandar Markovic }; 520ea9c5e83SAleksandar Markovic 521043715d1SYongbok Kim struct MIPSITUState; 522ea9c5e83SAleksandar Markovic typedef struct CPUMIPSState CPUMIPSState; 523ea9c5e83SAleksandar Markovic struct CPUMIPSState { 524ea9c5e83SAleksandar Markovic TCState active_tc; 525ea9c5e83SAleksandar Markovic CPUMIPSFPUContext active_fpu; 526ea9c5e83SAleksandar Markovic 527ea9c5e83SAleksandar Markovic uint32_t current_tc; 528ea9c5e83SAleksandar Markovic uint32_t current_fpu; 529ea9c5e83SAleksandar Markovic 530ea9c5e83SAleksandar Markovic uint32_t SEGBITS; 531ea9c5e83SAleksandar Markovic uint32_t PABITS; 532ea9c5e83SAleksandar Markovic #if defined(TARGET_MIPS64) 533ea9c5e83SAleksandar Markovic # define PABITS_BASE 36 534ea9c5e83SAleksandar Markovic #else 535ea9c5e83SAleksandar Markovic # define PABITS_BASE 32 536ea9c5e83SAleksandar Markovic #endif 537ea9c5e83SAleksandar Markovic target_ulong SEGMask; 538ea9c5e83SAleksandar Markovic uint64_t PAMask; 539ea9c5e83SAleksandar Markovic #define PAMASK_BASE ((1ULL << PABITS_BASE) - 1) 540ea9c5e83SAleksandar Markovic 541ea9c5e83SAleksandar Markovic int32_t msair; 542ea9c5e83SAleksandar Markovic #define MSAIR_ProcID 8 543ea9c5e83SAleksandar Markovic #define MSAIR_Rev 0 544ea9c5e83SAleksandar Markovic 54550e7edc5SAleksandar Markovic /* 54650e7edc5SAleksandar Markovic * CP0 Register 0 54750e7edc5SAleksandar Markovic */ 5489c2149c8Sths int32_t CP0_Index; 549ead9360eSths /* CP0_MVP* are per MVP registers. */ 55001bc435bSYongbok Kim int32_t CP0_VPControl; 55101bc435bSYongbok Kim #define CP0VPCtl_DIS 0 55250e7edc5SAleksandar Markovic /* 55350e7edc5SAleksandar Markovic * CP0 Register 1 55450e7edc5SAleksandar Markovic */ 5559c2149c8Sths int32_t CP0_Random; 556ead9360eSths int32_t CP0_VPEControl; 557ead9360eSths #define CP0VPECo_YSI 21 558ead9360eSths #define CP0VPECo_GSI 20 559ead9360eSths #define CP0VPECo_EXCPT 16 560ead9360eSths #define CP0VPECo_TE 15 561ead9360eSths #define CP0VPECo_TargTC 0 562ead9360eSths int32_t CP0_VPEConf0; 563ead9360eSths #define CP0VPEC0_M 31 564ead9360eSths #define CP0VPEC0_XTC 21 565ead9360eSths #define CP0VPEC0_TCS 19 566ead9360eSths #define CP0VPEC0_SCS 18 567ead9360eSths #define CP0VPEC0_DSC 17 568ead9360eSths #define CP0VPEC0_ICS 16 569ead9360eSths #define CP0VPEC0_MVP 1 570ead9360eSths #define CP0VPEC0_VPA 0 571ead9360eSths int32_t CP0_VPEConf1; 572ead9360eSths #define CP0VPEC1_NCX 20 573ead9360eSths #define CP0VPEC1_NCP2 10 574ead9360eSths #define CP0VPEC1_NCP1 0 575ead9360eSths target_ulong CP0_YQMask; 576ead9360eSths target_ulong CP0_VPESchedule; 577ead9360eSths target_ulong CP0_VPEScheFBack; 578ead9360eSths int32_t CP0_VPEOpt; 579ead9360eSths #define CP0VPEOpt_IWX7 15 580ead9360eSths #define CP0VPEOpt_IWX6 14 581ead9360eSths #define CP0VPEOpt_IWX5 13 582ead9360eSths #define CP0VPEOpt_IWX4 12 583ead9360eSths #define CP0VPEOpt_IWX3 11 584ead9360eSths #define CP0VPEOpt_IWX2 10 585ead9360eSths #define CP0VPEOpt_IWX1 9 586ead9360eSths #define CP0VPEOpt_IWX0 8 587ead9360eSths #define CP0VPEOpt_DWX7 7 588ead9360eSths #define CP0VPEOpt_DWX6 6 589ead9360eSths #define CP0VPEOpt_DWX5 5 590ead9360eSths #define CP0VPEOpt_DWX4 4 591ead9360eSths #define CP0VPEOpt_DWX3 3 592ead9360eSths #define CP0VPEOpt_DWX2 2 593ead9360eSths #define CP0VPEOpt_DWX1 1 594ead9360eSths #define CP0VPEOpt_DWX0 0 59550e7edc5SAleksandar Markovic /* 59650e7edc5SAleksandar Markovic * CP0 Register 2 59750e7edc5SAleksandar Markovic */ 598284b731aSLeon Alrae uint64_t CP0_EntryLo0; 59950e7edc5SAleksandar Markovic /* 60050e7edc5SAleksandar Markovic * CP0 Register 3 60150e7edc5SAleksandar Markovic */ 602284b731aSLeon Alrae uint64_t CP0_EntryLo1; 6032fb58b73SLeon Alrae #if defined(TARGET_MIPS64) 6042fb58b73SLeon Alrae # define CP0EnLo_RI 63 6052fb58b73SLeon Alrae # define CP0EnLo_XI 62 6062fb58b73SLeon Alrae #else 6072fb58b73SLeon Alrae # define CP0EnLo_RI 31 6082fb58b73SLeon Alrae # define CP0EnLo_XI 30 6092fb58b73SLeon Alrae #endif 61001bc435bSYongbok Kim int32_t CP0_GlobalNumber; 61101bc435bSYongbok Kim #define CP0GN_VPId 0 61250e7edc5SAleksandar Markovic /* 61350e7edc5SAleksandar Markovic * CP0 Register 4 61450e7edc5SAleksandar Markovic */ 6159c2149c8Sths target_ulong CP0_Context; 6163ef521eeSAleksandar Markovic int32_t CP0_MemoryMapID; 61750e7edc5SAleksandar Markovic /* 61850e7edc5SAleksandar Markovic * CP0 Register 5 61950e7edc5SAleksandar Markovic */ 6209c2149c8Sths int32_t CP0_PageMask; 6217207c7f9SLeon Alrae int32_t CP0_PageGrain_rw_bitmask; 6229c2149c8Sths int32_t CP0_PageGrain; 6237207c7f9SLeon Alrae #define CP0PG_RIE 31 6247207c7f9SLeon Alrae #define CP0PG_XIE 30 625e117f526SLeon Alrae #define CP0PG_ELPA 29 62692ceb440SLeon Alrae #define CP0PG_IEC 27 627cec56a73SJames Hogan target_ulong CP0_SegCtl0; 628cec56a73SJames Hogan target_ulong CP0_SegCtl1; 629cec56a73SJames Hogan target_ulong CP0_SegCtl2; 630cec56a73SJames Hogan #define CP0SC_PA 9 631cec56a73SJames Hogan #define CP0SC_PA_MASK (0x7FULL << CP0SC_PA) 632cec56a73SJames Hogan #define CP0SC_PA_1GMASK (0x7EULL << CP0SC_PA) 633cec56a73SJames Hogan #define CP0SC_AM 4 634cec56a73SJames Hogan #define CP0SC_AM_MASK (0x7ULL << CP0SC_AM) 635cec56a73SJames Hogan #define CP0SC_AM_UK 0ULL 636cec56a73SJames Hogan #define CP0SC_AM_MK 1ULL 637cec56a73SJames Hogan #define CP0SC_AM_MSK 2ULL 638cec56a73SJames Hogan #define CP0SC_AM_MUSK 3ULL 639cec56a73SJames Hogan #define CP0SC_AM_MUSUK 4ULL 640cec56a73SJames Hogan #define CP0SC_AM_USK 5ULL 641cec56a73SJames Hogan #define CP0SC_AM_UUSK 7ULL 642cec56a73SJames Hogan #define CP0SC_EU 3 643cec56a73SJames Hogan #define CP0SC_EU_MASK (1ULL << CP0SC_EU) 644cec56a73SJames Hogan #define CP0SC_C 0 645cec56a73SJames Hogan #define CP0SC_C_MASK (0x7ULL << CP0SC_C) 646cec56a73SJames Hogan #define CP0SC_MASK (CP0SC_C_MASK | CP0SC_EU_MASK | CP0SC_AM_MASK | \ 647cec56a73SJames Hogan CP0SC_PA_MASK) 648cec56a73SJames Hogan #define CP0SC_1GMASK (CP0SC_C_MASK | CP0SC_EU_MASK | CP0SC_AM_MASK | \ 649cec56a73SJames Hogan CP0SC_PA_1GMASK) 650cec56a73SJames Hogan #define CP0SC0_MASK (CP0SC_MASK | (CP0SC_MASK << 16)) 651cec56a73SJames Hogan #define CP0SC1_XAM 59 652cec56a73SJames Hogan #define CP0SC1_XAM_MASK (0x7ULL << CP0SC1_XAM) 653cec56a73SJames Hogan #define CP0SC1_MASK (CP0SC_MASK | (CP0SC_MASK << 16) | CP0SC1_XAM_MASK) 654cec56a73SJames Hogan #define CP0SC2_XR 56 655cec56a73SJames Hogan #define CP0SC2_XR_MASK (0xFFULL << CP0SC2_XR) 656cec56a73SJames Hogan #define CP0SC2_MASK (CP0SC_1GMASK | (CP0SC_1GMASK << 16) | CP0SC2_XR_MASK) 6575e31fdd5SYongbok Kim target_ulong CP0_PWBase; 658fa75ad14SYongbok Kim target_ulong CP0_PWField; 659fa75ad14SYongbok Kim #if defined(TARGET_MIPS64) 660fa75ad14SYongbok Kim #define CP0PF_BDI 32 /* 37..32 */ 661fa75ad14SYongbok Kim #define CP0PF_GDI 24 /* 29..24 */ 662fa75ad14SYongbok Kim #define CP0PF_UDI 18 /* 23..18 */ 663fa75ad14SYongbok Kim #define CP0PF_MDI 12 /* 17..12 */ 664fa75ad14SYongbok Kim #define CP0PF_PTI 6 /* 11..6 */ 665fa75ad14SYongbok Kim #define CP0PF_PTEI 0 /* 5..0 */ 666fa75ad14SYongbok Kim #else 667fa75ad14SYongbok Kim #define CP0PF_GDW 24 /* 29..24 */ 668fa75ad14SYongbok Kim #define CP0PF_UDW 18 /* 23..18 */ 669fa75ad14SYongbok Kim #define CP0PF_MDW 12 /* 17..12 */ 670fa75ad14SYongbok Kim #define CP0PF_PTW 6 /* 11..6 */ 671fa75ad14SYongbok Kim #define CP0PF_PTEW 0 /* 5..0 */ 672fa75ad14SYongbok Kim #endif 67320b28ebcSYongbok Kim target_ulong CP0_PWSize; 67420b28ebcSYongbok Kim #if defined(TARGET_MIPS64) 67520b28ebcSYongbok Kim #define CP0PS_BDW 32 /* 37..32 */ 67620b28ebcSYongbok Kim #endif 67720b28ebcSYongbok Kim #define CP0PS_PS 30 67820b28ebcSYongbok Kim #define CP0PS_GDW 24 /* 29..24 */ 67920b28ebcSYongbok Kim #define CP0PS_UDW 18 /* 23..18 */ 68020b28ebcSYongbok Kim #define CP0PS_MDW 12 /* 17..12 */ 68120b28ebcSYongbok Kim #define CP0PS_PTW 6 /* 11..6 */ 68220b28ebcSYongbok Kim #define CP0PS_PTEW 0 /* 5..0 */ 68350e7edc5SAleksandar Markovic /* 68450e7edc5SAleksandar Markovic * CP0 Register 6 68550e7edc5SAleksandar Markovic */ 6869c2149c8Sths int32_t CP0_Wired; 687103be64cSYongbok Kim int32_t CP0_PWCtl; 688103be64cSYongbok Kim #define CP0PC_PWEN 31 689103be64cSYongbok Kim #if defined(TARGET_MIPS64) 690103be64cSYongbok Kim #define CP0PC_PWDIREXT 30 691103be64cSYongbok Kim #define CP0PC_XK 28 692103be64cSYongbok Kim #define CP0PC_XS 27 693103be64cSYongbok Kim #define CP0PC_XU 26 694103be64cSYongbok Kim #endif 695103be64cSYongbok Kim #define CP0PC_DPH 7 696103be64cSYongbok Kim #define CP0PC_HUGEPG 6 697103be64cSYongbok Kim #define CP0PC_PSN 0 /* 5..0 */ 698ead9360eSths int32_t CP0_SRSConf0_rw_bitmask; 699ead9360eSths int32_t CP0_SRSConf0; 700ead9360eSths #define CP0SRSC0_M 31 701ead9360eSths #define CP0SRSC0_SRS3 20 702ead9360eSths #define CP0SRSC0_SRS2 10 703ead9360eSths #define CP0SRSC0_SRS1 0 704ead9360eSths int32_t CP0_SRSConf1_rw_bitmask; 705ead9360eSths int32_t CP0_SRSConf1; 706ead9360eSths #define CP0SRSC1_M 31 707ead9360eSths #define CP0SRSC1_SRS6 20 708ead9360eSths #define CP0SRSC1_SRS5 10 709ead9360eSths #define CP0SRSC1_SRS4 0 710ead9360eSths int32_t CP0_SRSConf2_rw_bitmask; 711ead9360eSths int32_t CP0_SRSConf2; 712ead9360eSths #define CP0SRSC2_M 31 713ead9360eSths #define CP0SRSC2_SRS9 20 714ead9360eSths #define CP0SRSC2_SRS8 10 715ead9360eSths #define CP0SRSC2_SRS7 0 716ead9360eSths int32_t CP0_SRSConf3_rw_bitmask; 717ead9360eSths int32_t CP0_SRSConf3; 718ead9360eSths #define CP0SRSC3_M 31 719ead9360eSths #define CP0SRSC3_SRS12 20 720ead9360eSths #define CP0SRSC3_SRS11 10 721ead9360eSths #define CP0SRSC3_SRS10 0 722ead9360eSths int32_t CP0_SRSConf4_rw_bitmask; 723ead9360eSths int32_t CP0_SRSConf4; 724ead9360eSths #define CP0SRSC4_SRS15 20 725ead9360eSths #define CP0SRSC4_SRS14 10 726ead9360eSths #define CP0SRSC4_SRS13 0 72750e7edc5SAleksandar Markovic /* 72850e7edc5SAleksandar Markovic * CP0 Register 7 72950e7edc5SAleksandar Markovic */ 7309c2149c8Sths int32_t CP0_HWREna; 73150e7edc5SAleksandar Markovic /* 73250e7edc5SAleksandar Markovic * CP0 Register 8 73350e7edc5SAleksandar Markovic */ 734c570fd16Sths target_ulong CP0_BadVAddr; 735aea14095SLeon Alrae uint32_t CP0_BadInstr; 736aea14095SLeon Alrae uint32_t CP0_BadInstrP; 73725beba9bSStefan Markovic uint32_t CP0_BadInstrX; 73850e7edc5SAleksandar Markovic /* 73950e7edc5SAleksandar Markovic * CP0 Register 9 74050e7edc5SAleksandar Markovic */ 7419c2149c8Sths int32_t CP0_Count; 742167db30eSYongbok Kim uint32_t CP0_SAARI; 743167db30eSYongbok Kim #define CP0SAARI_TARGET 0 /* 5..0 */ 744167db30eSYongbok Kim uint64_t CP0_SAAR[2]; 745167db30eSYongbok Kim #define CP0SAAR_BASE 12 /* 43..12 */ 746167db30eSYongbok Kim #define CP0SAAR_SIZE 1 /* 5..1 */ 747167db30eSYongbok Kim #define CP0SAAR_EN 0 74850e7edc5SAleksandar Markovic /* 74950e7edc5SAleksandar Markovic * CP0 Register 10 75050e7edc5SAleksandar Markovic */ 7519c2149c8Sths target_ulong CP0_EntryHi; 7529456c2fbSLeon Alrae #define CP0EnHi_EHINV 10 7536ec98bd7SPaul Burton target_ulong CP0_EntryHi_ASID_mask; 75450e7edc5SAleksandar Markovic /* 75550e7edc5SAleksandar Markovic * CP0 Register 11 75650e7edc5SAleksandar Markovic */ 7579c2149c8Sths int32_t CP0_Compare; 75850e7edc5SAleksandar Markovic /* 75950e7edc5SAleksandar Markovic * CP0 Register 12 76050e7edc5SAleksandar Markovic */ 7619c2149c8Sths int32_t CP0_Status; 7626af0bf9cSbellard #define CP0St_CU3 31 7636af0bf9cSbellard #define CP0St_CU2 30 7646af0bf9cSbellard #define CP0St_CU1 29 7656af0bf9cSbellard #define CP0St_CU0 28 7666af0bf9cSbellard #define CP0St_RP 27 7676ea83fedSbellard #define CP0St_FR 26 7686af0bf9cSbellard #define CP0St_RE 25 7697a387fffSths #define CP0St_MX 24 7707a387fffSths #define CP0St_PX 23 7716af0bf9cSbellard #define CP0St_BEV 22 7726af0bf9cSbellard #define CP0St_TS 21 7736af0bf9cSbellard #define CP0St_SR 20 7746af0bf9cSbellard #define CP0St_NMI 19 7756af0bf9cSbellard #define CP0St_IM 8 7767a387fffSths #define CP0St_KX 7 7777a387fffSths #define CP0St_SX 6 7787a387fffSths #define CP0St_UX 5 779623a930eSths #define CP0St_KSU 3 7806af0bf9cSbellard #define CP0St_ERL 2 7816af0bf9cSbellard #define CP0St_EXL 1 7826af0bf9cSbellard #define CP0St_IE 0 7839c2149c8Sths int32_t CP0_IntCtl; 784ead9360eSths #define CP0IntCtl_IPTI 29 78588991299SDongxue Zhang #define CP0IntCtl_IPPCI 26 786ead9360eSths #define CP0IntCtl_VS 5 7879c2149c8Sths int32_t CP0_SRSCtl; 788ead9360eSths #define CP0SRSCtl_HSS 26 789ead9360eSths #define CP0SRSCtl_EICSS 18 790ead9360eSths #define CP0SRSCtl_ESS 12 791ead9360eSths #define CP0SRSCtl_PSS 6 792ead9360eSths #define CP0SRSCtl_CSS 0 7939c2149c8Sths int32_t CP0_SRSMap; 794ead9360eSths #define CP0SRSMap_SSV7 28 795ead9360eSths #define CP0SRSMap_SSV6 24 796ead9360eSths #define CP0SRSMap_SSV5 20 797ead9360eSths #define CP0SRSMap_SSV4 16 798ead9360eSths #define CP0SRSMap_SSV3 12 799ead9360eSths #define CP0SRSMap_SSV2 8 800ead9360eSths #define CP0SRSMap_SSV1 4 801ead9360eSths #define CP0SRSMap_SSV0 0 80250e7edc5SAleksandar Markovic /* 80350e7edc5SAleksandar Markovic * CP0 Register 13 80450e7edc5SAleksandar Markovic */ 8059c2149c8Sths int32_t CP0_Cause; 8067a387fffSths #define CP0Ca_BD 31 8077a387fffSths #define CP0Ca_TI 30 8087a387fffSths #define CP0Ca_CE 28 8097a387fffSths #define CP0Ca_DC 27 8107a387fffSths #define CP0Ca_PCI 26 8116af0bf9cSbellard #define CP0Ca_IV 23 8127a387fffSths #define CP0Ca_WP 22 8137a387fffSths #define CP0Ca_IP 8 8144de9b249Sths #define CP0Ca_IP_mask 0x0000FF00 8157a387fffSths #define CP0Ca_EC 2 81650e7edc5SAleksandar Markovic /* 81750e7edc5SAleksandar Markovic * CP0 Register 14 81850e7edc5SAleksandar Markovic */ 819c570fd16Sths target_ulong CP0_EPC; 82050e7edc5SAleksandar Markovic /* 82150e7edc5SAleksandar Markovic * CP0 Register 15 82250e7edc5SAleksandar Markovic */ 8239c2149c8Sths int32_t CP0_PRid; 82474dbf824SJames Hogan target_ulong CP0_EBase; 82574dbf824SJames Hogan target_ulong CP0_EBaseWG_rw_bitmask; 82674dbf824SJames Hogan #define CP0EBase_WG 11 827c870e3f5SYongbok Kim target_ulong CP0_CMGCRBase; 82850e7edc5SAleksandar Markovic /* 82950e7edc5SAleksandar Markovic * CP0 Register 16 83050e7edc5SAleksandar Markovic */ 8319c2149c8Sths int32_t CP0_Config0; 8326af0bf9cSbellard #define CP0C0_M 31 8330413d7a5SAleksandar Markovic #define CP0C0_K23 28 /* 30..28 */ 8340413d7a5SAleksandar Markovic #define CP0C0_KU 25 /* 27..25 */ 8356af0bf9cSbellard #define CP0C0_MDU 20 836aff2bc6dSYongbok Kim #define CP0C0_MM 18 8376af0bf9cSbellard #define CP0C0_BM 16 8380413d7a5SAleksandar Markovic #define CP0C0_Impl 16 /* 24..16 */ 8396af0bf9cSbellard #define CP0C0_BE 15 8400413d7a5SAleksandar Markovic #define CP0C0_AT 13 /* 14..13 */ 8410413d7a5SAleksandar Markovic #define CP0C0_AR 10 /* 12..10 */ 8420413d7a5SAleksandar Markovic #define CP0C0_MT 7 /* 9..7 */ 8437a387fffSths #define CP0C0_VI 3 8440413d7a5SAleksandar Markovic #define CP0C0_K0 0 /* 2..0 */ 8459c2149c8Sths int32_t CP0_Config1; 8467a387fffSths #define CP0C1_M 31 8470413d7a5SAleksandar Markovic #define CP0C1_MMU 25 /* 30..25 */ 8480413d7a5SAleksandar Markovic #define CP0C1_IS 22 /* 24..22 */ 8490413d7a5SAleksandar Markovic #define CP0C1_IL 19 /* 21..19 */ 8500413d7a5SAleksandar Markovic #define CP0C1_IA 16 /* 18..16 */ 8510413d7a5SAleksandar Markovic #define CP0C1_DS 13 /* 15..13 */ 8520413d7a5SAleksandar Markovic #define CP0C1_DL 10 /* 12..10 */ 8530413d7a5SAleksandar Markovic #define CP0C1_DA 7 /* 9..7 */ 8547a387fffSths #define CP0C1_C2 6 8557a387fffSths #define CP0C1_MD 5 8566af0bf9cSbellard #define CP0C1_PC 4 8576af0bf9cSbellard #define CP0C1_WR 3 8586af0bf9cSbellard #define CP0C1_CA 2 8596af0bf9cSbellard #define CP0C1_EP 1 8606af0bf9cSbellard #define CP0C1_FP 0 8619c2149c8Sths int32_t CP0_Config2; 8627a387fffSths #define CP0C2_M 31 8630413d7a5SAleksandar Markovic #define CP0C2_TU 28 /* 30..28 */ 8640413d7a5SAleksandar Markovic #define CP0C2_TS 24 /* 27..24 */ 8650413d7a5SAleksandar Markovic #define CP0C2_TL 20 /* 23..20 */ 8660413d7a5SAleksandar Markovic #define CP0C2_TA 16 /* 19..16 */ 8670413d7a5SAleksandar Markovic #define CP0C2_SU 12 /* 15..12 */ 8680413d7a5SAleksandar Markovic #define CP0C2_SS 8 /* 11..8 */ 8690413d7a5SAleksandar Markovic #define CP0C2_SL 4 /* 7..4 */ 8700413d7a5SAleksandar Markovic #define CP0C2_SA 0 /* 3..0 */ 8719c2149c8Sths int32_t CP0_Config3; 8727a387fffSths #define CP0C3_M 31 87370409e67SMaciej W. Rozycki #define CP0C3_BPG 30 874c870e3f5SYongbok Kim #define CP0C3_CMGCR 29 875e97a391dSYongbok Kim #define CP0C3_MSAP 28 876aea14095SLeon Alrae #define CP0C3_BP 27 877aea14095SLeon Alrae #define CP0C3_BI 26 87874dbf824SJames Hogan #define CP0C3_SC 25 8790413d7a5SAleksandar Markovic #define CP0C3_PW 24 8800413d7a5SAleksandar Markovic #define CP0C3_VZ 23 8810413d7a5SAleksandar Markovic #define CP0C3_IPLV 21 /* 22..21 */ 8820413d7a5SAleksandar Markovic #define CP0C3_MMAR 18 /* 20..18 */ 88370409e67SMaciej W. Rozycki #define CP0C3_MCU 17 884bbfa8f72SNathan Froyd #define CP0C3_ISA_ON_EXC 16 8850413d7a5SAleksandar Markovic #define CP0C3_ISA 14 /* 15..14 */ 886d279279eSPetar Jovanovic #define CP0C3_ULRI 13 8877207c7f9SLeon Alrae #define CP0C3_RXI 12 88870409e67SMaciej W. Rozycki #define CP0C3_DSP2P 11 8897a387fffSths #define CP0C3_DSPP 10 8900413d7a5SAleksandar Markovic #define CP0C3_CTXTC 9 8910413d7a5SAleksandar Markovic #define CP0C3_ITL 8 8927a387fffSths #define CP0C3_LPA 7 8937a387fffSths #define CP0C3_VEIC 6 8947a387fffSths #define CP0C3_VInt 5 8957a387fffSths #define CP0C3_SP 4 89670409e67SMaciej W. Rozycki #define CP0C3_CDMM 3 8977a387fffSths #define CP0C3_MT 2 8987a387fffSths #define CP0C3_SM 1 8997a387fffSths #define CP0C3_TL 0 9008280b12cSMaciej W. Rozycki int32_t CP0_Config4; 9018280b12cSMaciej W. Rozycki int32_t CP0_Config4_rw_bitmask; 902b4160af1SPetar Jovanovic #define CP0C4_M 31 9030413d7a5SAleksandar Markovic #define CP0C4_IE 29 /* 30..29 */ 904a0c80608SPaul Burton #define CP0C4_AE 28 9050413d7a5SAleksandar Markovic #define CP0C4_VTLBSizeExt 24 /* 27..24 */ 906e98c0d17SLeon Alrae #define CP0C4_KScrExist 16 90770409e67SMaciej W. Rozycki #define CP0C4_MMUExtDef 14 9080413d7a5SAleksandar Markovic #define CP0C4_FTLBPageSize 8 /* 12..8 */ 9090413d7a5SAleksandar Markovic /* bit layout if MMUExtDef=1 */ 9100413d7a5SAleksandar Markovic #define CP0C4_MMUSizeExt 0 /* 7..0 */ 9110413d7a5SAleksandar Markovic /* bit layout if MMUExtDef=2 */ 9120413d7a5SAleksandar Markovic #define CP0C4_FTLBWays 4 /* 7..4 */ 9130413d7a5SAleksandar Markovic #define CP0C4_FTLBSets 0 /* 3..0 */ 9148280b12cSMaciej W. Rozycki int32_t CP0_Config5; 9158280b12cSMaciej W. Rozycki int32_t CP0_Config5_rw_bitmask; 916b4dd99a3SPetar Jovanovic #define CP0C5_M 31 917b4dd99a3SPetar Jovanovic #define CP0C5_K 30 918b4dd99a3SPetar Jovanovic #define CP0C5_CV 29 919b4dd99a3SPetar Jovanovic #define CP0C5_EVA 28 920b4dd99a3SPetar Jovanovic #define CP0C5_MSAEn 27 9210413d7a5SAleksandar Markovic #define CP0C5_PMJ 23 /* 25..23 */ 9220413d7a5SAleksandar Markovic #define CP0C5_WR2 22 9230413d7a5SAleksandar Markovic #define CP0C5_NMS 21 9240413d7a5SAleksandar Markovic #define CP0C5_ULS 20 9250413d7a5SAleksandar Markovic #define CP0C5_XPA 19 9260413d7a5SAleksandar Markovic #define CP0C5_CRCP 18 9270413d7a5SAleksandar Markovic #define CP0C5_MI 17 9280413d7a5SAleksandar Markovic #define CP0C5_GI 15 /* 16..15 */ 9290413d7a5SAleksandar Markovic #define CP0C5_CA2 14 930b00c7218SYongbok Kim #define CP0C5_XNP 13 9310413d7a5SAleksandar Markovic #define CP0C5_DEC 11 9320413d7a5SAleksandar Markovic #define CP0C5_L2C 10 9337c979afdSLeon Alrae #define CP0C5_UFE 9 9347c979afdSLeon Alrae #define CP0C5_FRE 8 93501bc435bSYongbok Kim #define CP0C5_VP 7 936faf1f68bSLeon Alrae #define CP0C5_SBRI 6 9375204ea79SLeon Alrae #define CP0C5_MVH 5 938ce9782f4SLeon Alrae #define CP0C5_LLB 4 939f6d4dd81SYongbok Kim #define CP0C5_MRP 3 940b4dd99a3SPetar Jovanovic #define CP0C5_UFR 2 941b4dd99a3SPetar Jovanovic #define CP0C5_NFExists 0 942e397ee33Sths int32_t CP0_Config6; 943af868995SHuacai Chen int32_t CP0_Config6_rw_bitmask; 944af868995SHuacai Chen #define CP0C6_BPPASS 31 945af868995SHuacai Chen #define CP0C6_KPOS 24 946af868995SHuacai Chen #define CP0C6_KE 23 947af868995SHuacai Chen #define CP0C6_VTLBONLY 22 948af868995SHuacai Chen #define CP0C6_LASX 21 949af868995SHuacai Chen #define CP0C6_SSEN 20 950af868995SHuacai Chen #define CP0C6_DISDRTIME 19 951af868995SHuacai Chen #define CP0C6_PIXNUEN 18 952af868995SHuacai Chen #define CP0C6_SCRAND 17 953af868995SHuacai Chen #define CP0C6_LLEXCEN 16 954af868995SHuacai Chen #define CP0C6_DISVC 15 955af868995SHuacai Chen #define CP0C6_VCLRU 14 956af868995SHuacai Chen #define CP0C6_DCLRU 13 957af868995SHuacai Chen #define CP0C6_PIXUEN 12 958af868995SHuacai Chen #define CP0C6_DISBLKLYEN 11 959af868995SHuacai Chen #define CP0C6_UMEMUALEN 10 960af868995SHuacai Chen #define CP0C6_SFBEN 8 961af868995SHuacai Chen #define CP0C6_FLTINT 7 962af868995SHuacai Chen #define CP0C6_VLTINT 6 963af868995SHuacai Chen #define CP0C6_DISBTB 5 964af868995SHuacai Chen #define CP0C6_STPREFCTL 2 965af868995SHuacai Chen #define CP0C6_INSTPREF 1 966af868995SHuacai Chen #define CP0C6_DATAPREF 0 967e397ee33Sths int32_t CP0_Config7; 968af868995SHuacai Chen int64_t CP0_Config7_rw_bitmask; 969af868995SHuacai Chen #define CP0C7_NAPCGEN 2 970af868995SHuacai Chen #define CP0C7_UNIMUEN 1 971af868995SHuacai Chen #define CP0C7_VFPUCGEN 0 972c7c7e1e9SLeon Alrae uint64_t CP0_LLAddr; 973f6d4dd81SYongbok Kim uint64_t CP0_MAAR[MIPS_MAAR_MAX]; 974f6d4dd81SYongbok Kim int32_t CP0_MAARI; 975ead9360eSths /* XXX: Maybe make LLAddr per-TC? */ 97650e7edc5SAleksandar Markovic /* 97750e7edc5SAleksandar Markovic * CP0 Register 17 97850e7edc5SAleksandar Markovic */ 979c7c7e1e9SLeon Alrae target_ulong lladdr; /* LL virtual address compared against SC */ 980590bc601SPaul Brook target_ulong llval; 9810b16dcd1SAleksandar Rikalo uint64_t llval_wp; 9820b16dcd1SAleksandar Rikalo uint32_t llnewval_wp; 983284b731aSLeon Alrae uint64_t CP0_LLAddr_rw_bitmask; 9842a6e32ddSAurelien Jarno int CP0_LLAddr_shift; 98550e7edc5SAleksandar Markovic /* 98650e7edc5SAleksandar Markovic * CP0 Register 18 98750e7edc5SAleksandar Markovic */ 988fd88b6abSths target_ulong CP0_WatchLo[8]; 98950e7edc5SAleksandar Markovic /* 99050e7edc5SAleksandar Markovic * CP0 Register 19 99150e7edc5SAleksandar Markovic */ 992feafe82cSYongbok Kim uint64_t CP0_WatchHi[8]; 9936ec98bd7SPaul Burton #define CP0WH_ASID 16 99450e7edc5SAleksandar Markovic /* 99550e7edc5SAleksandar Markovic * CP0 Register 20 99650e7edc5SAleksandar Markovic */ 9979c2149c8Sths target_ulong CP0_XContext; 9989c2149c8Sths int32_t CP0_Framemask; 99950e7edc5SAleksandar Markovic /* 100050e7edc5SAleksandar Markovic * CP0 Register 23 100150e7edc5SAleksandar Markovic */ 10029c2149c8Sths int32_t CP0_Debug; 1003ead9360eSths #define CP0DB_DBD 31 10046af0bf9cSbellard #define CP0DB_DM 30 10056af0bf9cSbellard #define CP0DB_LSNM 28 10066af0bf9cSbellard #define CP0DB_Doze 27 10076af0bf9cSbellard #define CP0DB_Halt 26 10086af0bf9cSbellard #define CP0DB_CNT 25 10096af0bf9cSbellard #define CP0DB_IBEP 24 10106af0bf9cSbellard #define CP0DB_DBEP 21 10116af0bf9cSbellard #define CP0DB_IEXI 20 10126af0bf9cSbellard #define CP0DB_VER 15 10136af0bf9cSbellard #define CP0DB_DEC 10 10146af0bf9cSbellard #define CP0DB_SSt 8 10156af0bf9cSbellard #define CP0DB_DINT 5 10166af0bf9cSbellard #define CP0DB_DIB 4 10176af0bf9cSbellard #define CP0DB_DDBS 3 10186af0bf9cSbellard #define CP0DB_DDBL 2 10196af0bf9cSbellard #define CP0DB_DBp 1 10206af0bf9cSbellard #define CP0DB_DSS 0 102150e7edc5SAleksandar Markovic /* 102250e7edc5SAleksandar Markovic * CP0 Register 24 102350e7edc5SAleksandar Markovic */ 1024c570fd16Sths target_ulong CP0_DEPC; 102550e7edc5SAleksandar Markovic /* 102650e7edc5SAleksandar Markovic * CP0 Register 25 102750e7edc5SAleksandar Markovic */ 10289c2149c8Sths int32_t CP0_Performance0; 102950e7edc5SAleksandar Markovic /* 103050e7edc5SAleksandar Markovic * CP0 Register 26 103150e7edc5SAleksandar Markovic */ 10320d74a222SLeon Alrae int32_t CP0_ErrCtl; 10330d74a222SLeon Alrae #define CP0EC_WST 29 10340d74a222SLeon Alrae #define CP0EC_SPR 28 10350d74a222SLeon Alrae #define CP0EC_ITC 26 103650e7edc5SAleksandar Markovic /* 103750e7edc5SAleksandar Markovic * CP0 Register 28 103850e7edc5SAleksandar Markovic */ 1039284b731aSLeon Alrae uint64_t CP0_TagLo; 10409c2149c8Sths int32_t CP0_DataLo; 104150e7edc5SAleksandar Markovic /* 104250e7edc5SAleksandar Markovic * CP0 Register 29 104350e7edc5SAleksandar Markovic */ 10449c2149c8Sths int32_t CP0_TagHi; 10459c2149c8Sths int32_t CP0_DataHi; 104650e7edc5SAleksandar Markovic /* 104750e7edc5SAleksandar Markovic * CP0 Register 30 104850e7edc5SAleksandar Markovic */ 1049c570fd16Sths target_ulong CP0_ErrorEPC; 105050e7edc5SAleksandar Markovic /* 105150e7edc5SAleksandar Markovic * CP0 Register 31 105250e7edc5SAleksandar Markovic */ 10539c2149c8Sths int32_t CP0_DESAVE; 105414d92efdSAleksandar Markovic target_ulong CP0_KScratch[MIPS_KSCRATCH_NUM]; 105550e7edc5SAleksandar Markovic 1056b5dc7732Sths /* We waste some space so we can handle shadow registers like TCs. */ 1057b5dc7732Sths TCState tcs[MIPS_SHADOW_SET_MAX]; 1058f01be154Sths CPUMIPSFPUContext fpus[MIPS_FPU_MAX]; 10595cbdb3a3SStefan Weil /* QEMU */ 10606af0bf9cSbellard int error_code; 1061aea14095SLeon Alrae #define EXCP_TLB_NOMATCH 0x1 1062aea14095SLeon Alrae #define EXCP_INST_NOTAVAIL 0x2 /* No valid instruction word for BadInstr */ 10636af0bf9cSbellard uint32_t hflags; /* CPU State */ 10646af0bf9cSbellard /* TMASK defines different execution modes */ 106542c86612SJames Hogan #define MIPS_HFLAG_TMASK 0x1F5807FF 106679ef2c4cSNathan Froyd #define MIPS_HFLAG_MODE 0x00007 /* execution modes */ 10679e72f33dSJules Irenge /* 10689e72f33dSJules Irenge * The KSU flags must be the lowest bits in hflags. The flag order 10699e72f33dSJules Irenge * must be the same as defined for CP0 Status. This allows to use 10709e72f33dSJules Irenge * the bits as the value of mmu_idx. 10719e72f33dSJules Irenge */ 107279ef2c4cSNathan Froyd #define MIPS_HFLAG_KSU 0x00003 /* kernel/supervisor/user mode mask */ 107379ef2c4cSNathan Froyd #define MIPS_HFLAG_UM 0x00002 /* user mode flag */ 107479ef2c4cSNathan Froyd #define MIPS_HFLAG_SM 0x00001 /* supervisor mode flag */ 107579ef2c4cSNathan Froyd #define MIPS_HFLAG_KM 0x00000 /* kernel mode flag */ 107679ef2c4cSNathan Froyd #define MIPS_HFLAG_DM 0x00004 /* Debug mode */ 107779ef2c4cSNathan Froyd #define MIPS_HFLAG_64 0x00008 /* 64-bit instructions enabled */ 107879ef2c4cSNathan Froyd #define MIPS_HFLAG_CP0 0x00010 /* CP0 enabled */ 107979ef2c4cSNathan Froyd #define MIPS_HFLAG_FPU 0x00020 /* FPU enabled */ 108079ef2c4cSNathan Froyd #define MIPS_HFLAG_F64 0x00040 /* 64-bit FPU enabled */ 10819e72f33dSJules Irenge /* 10829e72f33dSJules Irenge * True if the MIPS IV COP1X instructions can be used. This also 10839e72f33dSJules Irenge * controls the non-COP1X instructions RECIP.S, RECIP.D, RSQRT.S 10849e72f33dSJules Irenge * and RSQRT.D. 10859e72f33dSJules Irenge */ 108679ef2c4cSNathan Froyd #define MIPS_HFLAG_COP1X 0x00080 /* COP1X instructions enabled */ 108779ef2c4cSNathan Froyd #define MIPS_HFLAG_RE 0x00100 /* Reversed endianness */ 108801f72885SLeon Alrae #define MIPS_HFLAG_AWRAP 0x00200 /* 32-bit compatibility address wrapping */ 108979ef2c4cSNathan Froyd #define MIPS_HFLAG_M16 0x00400 /* MIPS16 mode flag */ 109079ef2c4cSNathan Froyd #define MIPS_HFLAG_M16_SHIFT 10 10919e72f33dSJules Irenge /* 10929e72f33dSJules Irenge * If translation is interrupted between the branch instruction and 10934ad40f36Sbellard * the delay slot, record what type of branch it is so that we can 10944ad40f36Sbellard * resume translation properly. It might be possible to reduce 10959e72f33dSJules Irenge * this from three bits to two. 10969e72f33dSJules Irenge */ 1097339cd2a8SLeon Alrae #define MIPS_HFLAG_BMASK_BASE 0x803800 109879ef2c4cSNathan Froyd #define MIPS_HFLAG_B 0x00800 /* Unconditional branch */ 109979ef2c4cSNathan Froyd #define MIPS_HFLAG_BC 0x01000 /* Conditional branch */ 110079ef2c4cSNathan Froyd #define MIPS_HFLAG_BL 0x01800 /* Likely branch */ 110179ef2c4cSNathan Froyd #define MIPS_HFLAG_BR 0x02000 /* branch to register (can't link TB) */ 110279ef2c4cSNathan Froyd /* Extra flags about the current pending branch. */ 1103b231c103SYongbok Kim #define MIPS_HFLAG_BMASK_EXT 0x7C000 110479ef2c4cSNathan Froyd #define MIPS_HFLAG_B16 0x04000 /* branch instruction was 16 bits */ 110579ef2c4cSNathan Froyd #define MIPS_HFLAG_BDS16 0x08000 /* branch requires 16-bit delay slot */ 110679ef2c4cSNathan Froyd #define MIPS_HFLAG_BDS32 0x10000 /* branch requires 32-bit delay slot */ 1107b231c103SYongbok Kim #define MIPS_HFLAG_BDS_STRICT 0x20000 /* Strict delay slot size */ 1108b231c103SYongbok Kim #define MIPS_HFLAG_BX 0x40000 /* branch exchanges execution mode */ 110979ef2c4cSNathan Froyd #define MIPS_HFLAG_BMASK (MIPS_HFLAG_BMASK_BASE | MIPS_HFLAG_BMASK_EXT) 1110853c3240SJia Liu /* MIPS DSP resources access. */ 1111908f6be1SStefan Markovic #define MIPS_HFLAG_DSP 0x080000 /* Enable access to DSP resources. */ 1112908f6be1SStefan Markovic #define MIPS_HFLAG_DSP_R2 0x100000 /* Enable access to DSP R2 resources. */ 1113908f6be1SStefan Markovic #define MIPS_HFLAG_DSP_R3 0x20000000 /* Enable access to DSP R3 resources. */ 1114d279279eSPetar Jovanovic /* Extra flag about HWREna register. */ 1115b231c103SYongbok Kim #define MIPS_HFLAG_HWRENA_ULR 0x200000 /* ULR bit from HWREna is set. */ 1116faf1f68bSLeon Alrae #define MIPS_HFLAG_SBRI 0x400000 /* R6 SDBBP causes RI excpt. in user mode */ 1117339cd2a8SLeon Alrae #define MIPS_HFLAG_FBNSLOT 0x800000 /* Forbidden slot */ 1118e97a391dSYongbok Kim #define MIPS_HFLAG_MSA 0x1000000 11197c979afdSLeon Alrae #define MIPS_HFLAG_FRE 0x2000000 /* FRE enabled */ 1120e117f526SLeon Alrae #define MIPS_HFLAG_ELPA 0x4000000 11210d74a222SLeon Alrae #define MIPS_HFLAG_ITC_CACHE 0x8000000 /* CACHE instr. operates on ITC tag */ 112242c86612SJames Hogan #define MIPS_HFLAG_ERL 0x10000000 /* error level flag */ 11236af0bf9cSbellard target_ulong btarget; /* Jump / branch target */ 11241ba74fb8Saurel32 target_ulong bcond; /* Branch condition (if needed) */ 1125a316d335Sbellard 11267a387fffSths int SYNCI_Step; /* Address step size for SYNCI */ 11277a387fffSths int CCRes; /* Cycle count resolution/divisor */ 1128ead9360eSths uint32_t CP0_Status_rw_bitmask; /* Read/write bits in CP0_Status */ 1129ead9360eSths uint32_t CP0_TCStatus_rw_bitmask; /* Read/write bits in CP0_TCStatus */ 1130f9c9cd63SPhilippe Mathieu-Daudé uint64_t insn_flags; /* Supported instruction set */ 11315fb2dcd1SYongbok Kim int saarp; 11327a387fffSths 11331f5c00cfSAlex Bennée /* Fields up to this point are cleared by a CPU reset */ 11341f5c00cfSAlex Bennée struct {} end_reset_fields; 11351f5c00cfSAlex Bennée 1136f0c3c505SAndreas Färber /* Fields from here on are preserved across CPU reset. */ 113751cc2e78SBlue Swirl CPUMIPSMVPContext *mvp; 11383c7b48b7SPaul Brook #if !defined(CONFIG_USER_ONLY) 113951cc2e78SBlue Swirl CPUMIPSTLBContext *tlb; 11403c7b48b7SPaul Brook #endif 114151cc2e78SBlue Swirl 1142c227f099SAnthony Liguori const mips_def_t *cpu_model; 114333ac7f16Sths void *irq[8]; 11441246b259SStefan Weil QEMUTimer *timer; /* Internal timer */ 1145043715d1SYongbok Kim struct MIPSITUState *itu; 114634fa7e83SLeon Alrae MemoryRegion *itc_tag; /* ITC Configuration Tags */ 114789777fd1SLeon Alrae target_ulong exception_base; /* ExceptionBase input to the core */ 1148d225b512SPhilippe Mathieu-Daudé uint64_t cp0_count_ns; /* CP0_Count clock period (in nanoseconds) */ 11496af0bf9cSbellard }; 11506af0bf9cSbellard 1151416bf936SPaolo Bonzini /** 1152416bf936SPaolo Bonzini * MIPSCPU: 1153416bf936SPaolo Bonzini * @env: #CPUMIPSState 1154*d0bec217SPhilippe Mathieu-Daudé * @cp0_count_rate: rate at which the coprocessor 0 counter increments 1155416bf936SPaolo Bonzini * 1156416bf936SPaolo Bonzini * A MIPS CPU. 1157416bf936SPaolo Bonzini */ 1158416bf936SPaolo Bonzini struct MIPSCPU { 1159416bf936SPaolo Bonzini /*< private >*/ 1160416bf936SPaolo Bonzini CPUState parent_obj; 1161416bf936SPaolo Bonzini /*< public >*/ 1162416bf936SPaolo Bonzini 11635b146dc7SRichard Henderson CPUNegativeOffsetState neg; 1164416bf936SPaolo Bonzini CPUMIPSState env; 1165*d0bec217SPhilippe Mathieu-Daudé /* 1166*d0bec217SPhilippe Mathieu-Daudé * The Count register acts as a timer, incrementing at a constant rate, 1167*d0bec217SPhilippe Mathieu-Daudé * whether or not an instruction is executed, retired, or any forward 1168*d0bec217SPhilippe Mathieu-Daudé * progress is made through the pipeline. The rate at which the counter 1169*d0bec217SPhilippe Mathieu-Daudé * increments is implementation dependent, and is a function of the 1170*d0bec217SPhilippe Mathieu-Daudé * pipeline clock of the processor, not the issue width of the processor. 1171*d0bec217SPhilippe Mathieu-Daudé */ 1172*d0bec217SPhilippe Mathieu-Daudé unsigned cp0_count_rate; 1173416bf936SPaolo Bonzini }; 1174416bf936SPaolo Bonzini 1175416bf936SPaolo Bonzini 11760442428aSMarkus Armbruster void mips_cpu_list(void); 1177647de6caSths 11789467d44cSths #define cpu_signal_handler cpu_mips_signal_handler 1179c732abe2Sj_mayer #define cpu_list mips_cpu_list 11809467d44cSths 1181084d0497SRichard Henderson extern void cpu_wrdsp(uint32_t rs, uint32_t mask_num, CPUMIPSState *env); 1182084d0497SRichard Henderson extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env); 1183084d0497SRichard Henderson 11849e72f33dSJules Irenge /* 11859e72f33dSJules Irenge * MMU modes definitions. We carefully match the indices with our 11869e72f33dSJules Irenge * hflags layout. 11879e72f33dSJules Irenge */ 1188623a930eSths #define MMU_USER_IDX 2 1189b0fc6003SJames Hogan 1190b0fc6003SJames Hogan static inline int hflags_mmu_index(uint32_t hflags) 1191b0fc6003SJames Hogan { 119242c86612SJames Hogan if (hflags & MIPS_HFLAG_ERL) { 119342c86612SJames Hogan return 3; /* ERL */ 119442c86612SJames Hogan } else { 1195b0fc6003SJames Hogan return hflags & MIPS_HFLAG_KSU; 1196b0fc6003SJames Hogan } 119742c86612SJames Hogan } 1198b0fc6003SJames Hogan 119997ed5ccdSBenjamin Herrenschmidt static inline int cpu_mmu_index(CPUMIPSState *env, bool ifetch) 12006ebbf390Sj_mayer { 1201b0fc6003SJames Hogan return hflags_mmu_index(env->hflags); 12026ebbf390Sj_mayer } 12036ebbf390Sj_mayer 12044f7c64b3SRichard Henderson typedef CPUMIPSState CPUArchState; 12052161a612SRichard Henderson typedef MIPSCPU ArchCPU; 12064f7c64b3SRichard Henderson 1207022c62cbSPaolo Bonzini #include "exec/cpu-all.h" 12086af0bf9cSbellard 12099e72f33dSJules Irenge /* 12109e72f33dSJules Irenge * Memory access type : 12116af0bf9cSbellard * may be needed for precise access rights control and precise exceptions. 12126af0bf9cSbellard */ 12136af0bf9cSbellard enum { 12146af0bf9cSbellard /* 1 bit to define user level / supervisor access */ 12156af0bf9cSbellard ACCESS_USER = 0x00, 12166af0bf9cSbellard ACCESS_SUPER = 0x01, 12176af0bf9cSbellard /* 1 bit to indicate direction */ 12186af0bf9cSbellard ACCESS_STORE = 0x02, 12196af0bf9cSbellard /* Type of instruction that generated the access */ 12206af0bf9cSbellard ACCESS_CODE = 0x10, /* Code fetch access */ 12216af0bf9cSbellard ACCESS_INT = 0x20, /* Integer load/store access */ 12226af0bf9cSbellard ACCESS_FLOAT = 0x30, /* floating point load/store access */ 12236af0bf9cSbellard }; 12246af0bf9cSbellard 12256af0bf9cSbellard /* Exceptions */ 12266af0bf9cSbellard enum { 12276af0bf9cSbellard EXCP_NONE = -1, 12286af0bf9cSbellard EXCP_RESET = 0, 12296af0bf9cSbellard EXCP_SRESET, 12306af0bf9cSbellard EXCP_DSS, 12316af0bf9cSbellard EXCP_DINT, 123214e51cc7Sths EXCP_DDBL, 123314e51cc7Sths EXCP_DDBS, 12346af0bf9cSbellard EXCP_NMI, 12356af0bf9cSbellard EXCP_MCHECK, 123614e51cc7Sths EXCP_EXT_INTERRUPT, /* 8 */ 12376af0bf9cSbellard EXCP_DFWATCH, 123814e51cc7Sths EXCP_DIB, 12396af0bf9cSbellard EXCP_IWATCH, 12406af0bf9cSbellard EXCP_AdEL, 12416af0bf9cSbellard EXCP_AdES, 12426af0bf9cSbellard EXCP_TLBF, 12436af0bf9cSbellard EXCP_IBE, 124414e51cc7Sths EXCP_DBp, /* 16 */ 12456af0bf9cSbellard EXCP_SYSCALL, 124614e51cc7Sths EXCP_BREAK, 12474ad40f36Sbellard EXCP_CpU, 12486af0bf9cSbellard EXCP_RI, 12496af0bf9cSbellard EXCP_OVERFLOW, 12506af0bf9cSbellard EXCP_TRAP, 12515a5012ecSths EXCP_FPE, 125214e51cc7Sths EXCP_DWATCH, /* 24 */ 12536af0bf9cSbellard EXCP_LTLBL, 12546af0bf9cSbellard EXCP_TLBL, 12556af0bf9cSbellard EXCP_TLBS, 12566af0bf9cSbellard EXCP_DBE, 1257ead9360eSths EXCP_THREAD, 125814e51cc7Sths EXCP_MDMX, 125914e51cc7Sths EXCP_C2E, 126014e51cc7Sths EXCP_CACHE, /* 32 */ 1261853c3240SJia Liu EXCP_DSPDIS, 1262e97a391dSYongbok Kim EXCP_MSADIS, 1263e97a391dSYongbok Kim EXCP_MSAFPE, 126492ceb440SLeon Alrae EXCP_TLBXI, 126592ceb440SLeon Alrae EXCP_TLBRI, 126614e51cc7Sths 126792ceb440SLeon Alrae EXCP_LAST = EXCP_TLBRI, 12686af0bf9cSbellard }; 12696af0bf9cSbellard 1270f249412cSEdgar E. Iglesias /* 127126aa3d9aSPhilippe Mathieu-Daudé * This is an internally generated WAKE request line. 1272f249412cSEdgar E. Iglesias * It is driven by the CPU itself. Raised when the MT 1273f249412cSEdgar E. Iglesias * block wants to wake a VPE from an inactive state and 1274f249412cSEdgar E. Iglesias * cleared when VPE goes from active to inactive. 1275f249412cSEdgar E. Iglesias */ 1276f249412cSEdgar E. Iglesias #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 1277f249412cSEdgar E. Iglesias 1278388bb21aSths int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); 12796af0bf9cSbellard 1280a7519f2bSIgor Mammedov #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU 1281a7519f2bSIgor Mammedov #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX 12820dacec87SIgor Mammedov #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU 1283a7519f2bSIgor Mammedov 1284a7519f2bSIgor Mammedov bool cpu_supports_cps_smp(const char *cpu_type); 12855b1e0981SAleksandar Markovic bool cpu_supports_isa(const char *cpu_type, uint64_t isa); 128689777fd1SLeon Alrae void cpu_set_exception_base(int vp_index, target_ulong address); 128730bf942dSAndreas Färber 12885dc5d9f0SAurelien Jarno /* mips_int.c */ 12897db13faeSAndreas Färber void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level); 12905dc5d9f0SAurelien Jarno 1291043715d1SYongbok Kim /* mips_itu.c */ 1292043715d1SYongbok Kim void itc_reconfigure(struct MIPSITUState *tag); 1293043715d1SYongbok Kim 1294f9480ffcSths /* helper.c */ 12951239b472SKwok Cheung Yeung target_ulong exception_resume_pc(CPUMIPSState *env); 1296f9480ffcSths 12977db13faeSAndreas Färber static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc, 129889fee74aSEmilio G. Cota target_ulong *cs_base, uint32_t *flags) 12996b917547Saliguori { 13006b917547Saliguori *pc = env->active_tc.PC; 13016b917547Saliguori *cs_base = 0; 1302d279279eSPetar Jovanovic *flags = env->hflags & (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK | 1303d279279eSPetar Jovanovic MIPS_HFLAG_HWRENA_ULR); 13046b917547Saliguori } 13056b917547Saliguori 130607f5a258SMarkus Armbruster #endif /* MIPS_CPU_H */ 1307