107f5a258SMarkus Armbruster #ifndef MIPS_CPU_H 207f5a258SMarkus Armbruster #define MIPS_CPU_H 36af0bf9cSbellard 4d94f0a8eSPaolo Bonzini #define ALIGNED_ONLY 54ad40f36Sbellard 69349b4f9SAndreas Färber #define CPUArchState struct CPUMIPSState 7c2764719Spbrook 89a78eeadSStefan Weil #include "qemu-common.h" 9416bf936SPaolo Bonzini #include "cpu-qom.h" 106af0bf9cSbellard #include "mips-defs.h" 11022c62cbSPaolo Bonzini #include "exec/cpu-defs.h" 126b4c305cSPaolo Bonzini #include "fpu/softfloat.h" 136af0bf9cSbellard 14ead9360eSths struct CPUMIPSState; 156af0bf9cSbellard 16ead9360eSths typedef struct CPUMIPSTLBContext CPUMIPSTLBContext; 1751b2772fSths 18e97a391dSYongbok Kim /* MSA Context */ 19e97a391dSYongbok Kim #define MSA_WRLEN (128) 20e97a391dSYongbok Kim 21e97a391dSYongbok Kim typedef union wr_t wr_t; 22e97a391dSYongbok Kim union wr_t { 23e97a391dSYongbok Kim int8_t b[MSA_WRLEN/8]; 24e97a391dSYongbok Kim int16_t h[MSA_WRLEN/16]; 25e97a391dSYongbok Kim int32_t w[MSA_WRLEN/32]; 26e97a391dSYongbok Kim int64_t d[MSA_WRLEN/64]; 27e97a391dSYongbok Kim }; 28e97a391dSYongbok Kim 29c227f099SAnthony Liguori typedef union fpr_t fpr_t; 30c227f099SAnthony Liguori union fpr_t { 31ead9360eSths float64 fd; /* ieee double precision */ 32ead9360eSths float32 fs[2];/* ieee single precision */ 33ead9360eSths uint64_t d; /* binary double fixed-point */ 34ead9360eSths uint32_t w[2]; /* binary single fixed-point */ 35e97a391dSYongbok Kim /* FPU/MSA register mapping is not tested on big-endian hosts. */ 36e97a391dSYongbok Kim wr_t wr; /* vector data */ 37ead9360eSths }; 38ead9360eSths /* define FP_ENDIAN_IDX to access the same location 394ff9786cSStefan Weil * in the fpr_t union regardless of the host endianness 40ead9360eSths */ 41e2542fe2SJuan Quintela #if defined(HOST_WORDS_BIGENDIAN) 42ead9360eSths # define FP_ENDIAN_IDX 1 43ead9360eSths #else 44ead9360eSths # define FP_ENDIAN_IDX 0 45c570fd16Sths #endif 46ead9360eSths 47ead9360eSths typedef struct CPUMIPSFPUContext CPUMIPSFPUContext; 48ead9360eSths struct CPUMIPSFPUContext { 496af0bf9cSbellard /* Floating point registers */ 50c227f099SAnthony Liguori fpr_t fpr[32]; 516ea83fedSbellard float_status fp_status; 525a5012ecSths /* fpu implementation/revision register (fir) */ 536af0bf9cSbellard uint32_t fcr0; 547c979afdSLeon Alrae #define FCR0_FREP 29 55b4dd99a3SPetar Jovanovic #define FCR0_UFRP 28 56ba5c79f2SLeon Alrae #define FCR0_HAS2008 23 575a5012ecSths #define FCR0_F64 22 585a5012ecSths #define FCR0_L 21 595a5012ecSths #define FCR0_W 20 605a5012ecSths #define FCR0_3D 19 615a5012ecSths #define FCR0_PS 18 625a5012ecSths #define FCR0_D 17 635a5012ecSths #define FCR0_S 16 645a5012ecSths #define FCR0_PRID 8 655a5012ecSths #define FCR0_REV 0 666ea83fedSbellard /* fcsr */ 67599bc5e8SAleksandar Markovic uint32_t fcr31_rw_bitmask; 686ea83fedSbellard uint32_t fcr31; 6977be4199SAleksandar Markovic #define FCR31_FS 24 70ba5c79f2SLeon Alrae #define FCR31_ABS2008 19 71ba5c79f2SLeon Alrae #define FCR31_NAN2008 18 72f01be154Sths #define SET_FP_COND(num,env) do { ((env).fcr31) |= ((num) ? (1 << ((num) + 24)) : (1 << 23)); } while(0) 73f01be154Sths #define CLEAR_FP_COND(num,env) do { ((env).fcr31) &= ~((num) ? (1 << ((num) + 24)) : (1 << 23)); } while(0) 74f01be154Sths #define GET_FP_COND(env) ((((env).fcr31 >> 24) & 0xfe) | (((env).fcr31 >> 23) & 0x1)) 756ea83fedSbellard #define GET_FP_CAUSE(reg) (((reg) >> 12) & 0x3f) 766ea83fedSbellard #define GET_FP_ENABLE(reg) (((reg) >> 7) & 0x1f) 776ea83fedSbellard #define GET_FP_FLAGS(reg) (((reg) >> 2) & 0x1f) 785a5012ecSths #define SET_FP_CAUSE(reg,v) do { (reg) = ((reg) & ~(0x3f << 12)) | ((v & 0x3f) << 12); } while(0) 795a5012ecSths #define SET_FP_ENABLE(reg,v) do { (reg) = ((reg) & ~(0x1f << 7)) | ((v & 0x1f) << 7); } while(0) 805a5012ecSths #define SET_FP_FLAGS(reg,v) do { (reg) = ((reg) & ~(0x1f << 2)) | ((v & 0x1f) << 2); } while(0) 815a5012ecSths #define UPDATE_FP_FLAGS(reg,v) do { (reg) |= ((v & 0x1f) << 2); } while(0) 826ea83fedSbellard #define FP_INEXACT 1 836ea83fedSbellard #define FP_UNDERFLOW 2 846ea83fedSbellard #define FP_OVERFLOW 4 856ea83fedSbellard #define FP_DIV0 8 866ea83fedSbellard #define FP_INVALID 16 876ea83fedSbellard #define FP_UNIMPLEMENTED 32 88ead9360eSths }; 896ea83fedSbellard 9042c86612SJames Hogan #define NB_MMU_MODES 4 91c20d594eSRichard Henderson #define TARGET_INSN_START_EXTRA_WORDS 2 926ebbf390Sj_mayer 93ead9360eSths typedef struct CPUMIPSMVPContext CPUMIPSMVPContext; 94ead9360eSths struct CPUMIPSMVPContext { 95ead9360eSths int32_t CP0_MVPControl; 96ead9360eSths #define CP0MVPCo_CPA 3 97ead9360eSths #define CP0MVPCo_STLB 2 98ead9360eSths #define CP0MVPCo_VPC 1 99ead9360eSths #define CP0MVPCo_EVP 0 100ead9360eSths int32_t CP0_MVPConf0; 101ead9360eSths #define CP0MVPC0_M 31 102ead9360eSths #define CP0MVPC0_TLBS 29 103ead9360eSths #define CP0MVPC0_GS 28 104ead9360eSths #define CP0MVPC0_PCP 27 105ead9360eSths #define CP0MVPC0_PTLBE 16 106ead9360eSths #define CP0MVPC0_TCA 15 107ead9360eSths #define CP0MVPC0_PVPE 10 108ead9360eSths #define CP0MVPC0_PTC 0 109ead9360eSths int32_t CP0_MVPConf1; 110ead9360eSths #define CP0MVPC1_CIM 31 111ead9360eSths #define CP0MVPC1_CIF 30 112ead9360eSths #define CP0MVPC1_PCX 20 113ead9360eSths #define CP0MVPC1_PCP2 10 114ead9360eSths #define CP0MVPC1_PCP1 0 115ead9360eSths }; 116ead9360eSths 117c227f099SAnthony Liguori typedef struct mips_def_t mips_def_t; 118ead9360eSths 119ead9360eSths #define MIPS_SHADOW_SET_MAX 16 120ead9360eSths #define MIPS_TC_MAX 5 121f01be154Sths #define MIPS_FPU_MAX 1 122ead9360eSths #define MIPS_DSP_ACC 4 123e98c0d17SLeon Alrae #define MIPS_KSCRATCH_NUM 6 124f6d4dd81SYongbok Kim #define MIPS_MAAR_MAX 16 /* Must be an even number. */ 125ead9360eSths 126b5dc7732Sths typedef struct TCState TCState; 127b5dc7732Sths struct TCState { 128b5dc7732Sths target_ulong gpr[32]; 129b5dc7732Sths target_ulong PC; 130b5dc7732Sths target_ulong HI[MIPS_DSP_ACC]; 131b5dc7732Sths target_ulong LO[MIPS_DSP_ACC]; 132b5dc7732Sths target_ulong ACX[MIPS_DSP_ACC]; 133b5dc7732Sths target_ulong DSPControl; 134b5dc7732Sths int32_t CP0_TCStatus; 135b5dc7732Sths #define CP0TCSt_TCU3 31 136b5dc7732Sths #define CP0TCSt_TCU2 30 137b5dc7732Sths #define CP0TCSt_TCU1 29 138b5dc7732Sths #define CP0TCSt_TCU0 28 139b5dc7732Sths #define CP0TCSt_TMX 27 140b5dc7732Sths #define CP0TCSt_RNST 23 141b5dc7732Sths #define CP0TCSt_TDS 21 142b5dc7732Sths #define CP0TCSt_DT 20 143b5dc7732Sths #define CP0TCSt_DA 15 144b5dc7732Sths #define CP0TCSt_A 13 145b5dc7732Sths #define CP0TCSt_TKSU 11 146b5dc7732Sths #define CP0TCSt_IXMT 10 147b5dc7732Sths #define CP0TCSt_TASID 0 148b5dc7732Sths int32_t CP0_TCBind; 149b5dc7732Sths #define CP0TCBd_CurTC 21 150b5dc7732Sths #define CP0TCBd_TBE 17 151b5dc7732Sths #define CP0TCBd_CurVPE 0 152b5dc7732Sths target_ulong CP0_TCHalt; 153b5dc7732Sths target_ulong CP0_TCContext; 154b5dc7732Sths target_ulong CP0_TCSchedule; 155b5dc7732Sths target_ulong CP0_TCScheFBack; 156b5dc7732Sths int32_t CP0_Debug_tcstatus; 157d279279eSPetar Jovanovic target_ulong CP0_UserLocal; 158e97a391dSYongbok Kim 159e97a391dSYongbok Kim int32_t msacsr; 160e97a391dSYongbok Kim 161e97a391dSYongbok Kim #define MSACSR_FS 24 162e97a391dSYongbok Kim #define MSACSR_FS_MASK (1 << MSACSR_FS) 163e97a391dSYongbok Kim #define MSACSR_NX 18 164e97a391dSYongbok Kim #define MSACSR_NX_MASK (1 << MSACSR_NX) 165e97a391dSYongbok Kim #define MSACSR_CEF 2 166e97a391dSYongbok Kim #define MSACSR_CEF_MASK (0xffff << MSACSR_CEF) 167e97a391dSYongbok Kim #define MSACSR_RM 0 168e97a391dSYongbok Kim #define MSACSR_RM_MASK (0x3 << MSACSR_RM) 169e97a391dSYongbok Kim #define MSACSR_MASK (MSACSR_RM_MASK | MSACSR_CEF_MASK | MSACSR_NX_MASK | \ 170e97a391dSYongbok Kim MSACSR_FS_MASK) 171e97a391dSYongbok Kim 172e97a391dSYongbok Kim float_status msa_fp_status; 173b5dc7732Sths }; 174b5dc7732Sths 175ead9360eSths typedef struct CPUMIPSState CPUMIPSState; 176ead9360eSths struct CPUMIPSState { 177b5dc7732Sths TCState active_tc; 178f01be154Sths CPUMIPSFPUContext active_fpu; 179b5dc7732Sths 180ead9360eSths uint32_t current_tc; 181f01be154Sths uint32_t current_fpu; 182ead9360eSths 183e034e2c3Sths uint32_t SEGBITS; 1846d35524cSths uint32_t PABITS; 185e117f526SLeon Alrae #if defined(TARGET_MIPS64) 186e117f526SLeon Alrae # define PABITS_BASE 36 187e117f526SLeon Alrae #else 188e117f526SLeon Alrae # define PABITS_BASE 32 189e117f526SLeon Alrae #endif 190b6d96bedSths target_ulong SEGMask; 191284b731aSLeon Alrae uint64_t PAMask; 192e117f526SLeon Alrae #define PAMASK_BASE ((1ULL << PABITS_BASE) - 1) 19329929e34Sths 194e97a391dSYongbok Kim int32_t msair; 195e97a391dSYongbok Kim #define MSAIR_ProcID 8 196e97a391dSYongbok Kim #define MSAIR_Rev 0 197e97a391dSYongbok Kim 198a86d421eSAleksandar Markovic /* 199a86d421eSAleksandar Markovic * Summary of CP0 registers 200a86d421eSAleksandar Markovic * ======================== 201a86d421eSAleksandar Markovic * 202a86d421eSAleksandar Markovic * 203a86d421eSAleksandar Markovic * Register 0 Register 1 Register 2 Register 3 204a86d421eSAleksandar Markovic * ---------- ---------- ---------- ---------- 205a86d421eSAleksandar Markovic * 206a86d421eSAleksandar Markovic * 0 Index Random EntryLo0 EntryLo1 207a86d421eSAleksandar Markovic * 1 MVPControl VPEControl TCStatus GlobalNumber 208a86d421eSAleksandar Markovic * 2 MVPConf0 VPEConf0 TCBind 209a86d421eSAleksandar Markovic * 3 MVPConf1 VPEConf1 TCRestart 210a86d421eSAleksandar Markovic * 4 VPControl YQMask TCHalt 211a86d421eSAleksandar Markovic * 5 VPESchedule TCContext 212a86d421eSAleksandar Markovic * 6 VPEScheFBack TCSchedule 213a86d421eSAleksandar Markovic * 7 VPEOpt TCScheFBack TCOpt 214a86d421eSAleksandar Markovic * 215a86d421eSAleksandar Markovic * 216a86d421eSAleksandar Markovic * Register 4 Register 5 Register 6 Register 7 217a86d421eSAleksandar Markovic * ---------- ---------- ---------- ---------- 218a86d421eSAleksandar Markovic * 219a86d421eSAleksandar Markovic * 0 Context PageMask Wired HWREna 220a86d421eSAleksandar Markovic * 1 ContextConfig PageGrain SRSConf0 221a86d421eSAleksandar Markovic * 2 UserLocal SegCtl0 SRSConf1 222a86d421eSAleksandar Markovic * 3 XContextConfig SegCtl1 SRSConf2 223a86d421eSAleksandar Markovic * 4 DebugContextID SegCtl2 SRSConf3 224a86d421eSAleksandar Markovic * 5 MemoryMapID PWBase SRSConf4 225a86d421eSAleksandar Markovic * 6 PWField PWCtl 226a86d421eSAleksandar Markovic * 7 PWSize 227a86d421eSAleksandar Markovic * 228a86d421eSAleksandar Markovic * 229a86d421eSAleksandar Markovic * Register 8 Register 9 Register 10 Register 11 230a86d421eSAleksandar Markovic * ---------- ---------- ----------- ----------- 231a86d421eSAleksandar Markovic * 232a86d421eSAleksandar Markovic * 0 BadVAddr Count EntryHi Compare 233a86d421eSAleksandar Markovic * 1 BadInstr 234a86d421eSAleksandar Markovic * 2 BadInstrP 235a86d421eSAleksandar Markovic * 3 BadInstrX 236a86d421eSAleksandar Markovic * 4 GuestCtl1 GuestCtl0Ext 237a86d421eSAleksandar Markovic * 5 GuestCtl2 238a86d421eSAleksandar Markovic * 6 GuestCtl3 239a86d421eSAleksandar Markovic * 7 240a86d421eSAleksandar Markovic * 241a86d421eSAleksandar Markovic * 242a86d421eSAleksandar Markovic * Register 12 Register 13 Register 14 Register 15 243a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 244a86d421eSAleksandar Markovic * 245a86d421eSAleksandar Markovic * 0 Status Cause EPC PRId 246a86d421eSAleksandar Markovic * 1 IntCtl EBase 247a86d421eSAleksandar Markovic * 2 SRSCtl NestedEPC CDMMBase 248a86d421eSAleksandar Markovic * 3 SRSMap CMGCRBase 249a86d421eSAleksandar Markovic * 4 View_IPL View_RIPL BEVVA 250a86d421eSAleksandar Markovic * 5 SRSMap2 NestedExc 251a86d421eSAleksandar Markovic * 6 GuestCtl0 252a86d421eSAleksandar Markovic * 7 GTOffset 253a86d421eSAleksandar Markovic * 254a86d421eSAleksandar Markovic * 255a86d421eSAleksandar Markovic * Register 16 Register 17 Register 18 Register 19 256a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 257a86d421eSAleksandar Markovic * 258a86d421eSAleksandar Markovic * 0 Config LLAddr WatchLo WatchHi 259a86d421eSAleksandar Markovic * 1 Config1 MAAR WatchLo WatchHi 260a86d421eSAleksandar Markovic * 2 Config2 MAARI WatchLo WatchHi 261a86d421eSAleksandar Markovic * 3 Config3 WatchLo WatchHi 262a86d421eSAleksandar Markovic * 4 Config4 WatchLo WatchHi 263a86d421eSAleksandar Markovic * 5 Config5 WatchLo WatchHi 264a86d421eSAleksandar Markovic * 6 WatchLo WatchHi 265a86d421eSAleksandar Markovic * 7 WatchLo WatchHi 266a86d421eSAleksandar Markovic * 267a86d421eSAleksandar Markovic * 268a86d421eSAleksandar Markovic * Register 20 Register 21 Register 22 Register 23 269a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 270a86d421eSAleksandar Markovic * 271a86d421eSAleksandar Markovic * 0 XContext Debug 272a86d421eSAleksandar Markovic * 1 TraceControl 273a86d421eSAleksandar Markovic * 2 TraceControl2 274a86d421eSAleksandar Markovic * 3 UserTraceData1 275a86d421eSAleksandar Markovic * 4 TraceIBPC 276a86d421eSAleksandar Markovic * 5 TraceDBPC 277a86d421eSAleksandar Markovic * 6 Debug2 278a86d421eSAleksandar Markovic * 7 279a86d421eSAleksandar Markovic * 280a86d421eSAleksandar Markovic * 281a86d421eSAleksandar Markovic * Register 24 Register 25 Register 26 Register 27 282a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 283a86d421eSAleksandar Markovic * 284a86d421eSAleksandar Markovic * 0 DEPC PerfCnt ErrCtl CacheErr 285a86d421eSAleksandar Markovic * 1 PerfCnt 286a86d421eSAleksandar Markovic * 2 TraceControl3 PerfCnt 287a86d421eSAleksandar Markovic * 3 UserTraceData2 PerfCnt 288a86d421eSAleksandar Markovic * 4 PerfCnt 289a86d421eSAleksandar Markovic * 5 PerfCnt 290a86d421eSAleksandar Markovic * 6 PerfCnt 291a86d421eSAleksandar Markovic * 7 PerfCnt 292a86d421eSAleksandar Markovic * 293a86d421eSAleksandar Markovic * 294a86d421eSAleksandar Markovic * Register 28 Register 29 Register 30 Register 31 295a86d421eSAleksandar Markovic * ----------- ----------- ----------- ----------- 296a86d421eSAleksandar Markovic * 297a86d421eSAleksandar Markovic * 0 DataLo DataHi ErrorEPC DESAVE 298a86d421eSAleksandar Markovic * 1 TagLo TagHi 299a86d421eSAleksandar Markovic * 2 DataLo DataHi KScratch<n> 300a86d421eSAleksandar Markovic * 3 TagLo TagHi KScratch<n> 301a86d421eSAleksandar Markovic * 4 DataLo DataHi KScratch<n> 302a86d421eSAleksandar Markovic * 5 TagLo TagHi KScratch<n> 303a86d421eSAleksandar Markovic * 6 DataLo DataHi KScratch<n> 304a86d421eSAleksandar Markovic * 7 TagLo TagHi KScratch<n> 305a86d421eSAleksandar Markovic * 306a86d421eSAleksandar Markovic */ 30750e7edc5SAleksandar Markovic /* 30850e7edc5SAleksandar Markovic * CP0 Register 0 30950e7edc5SAleksandar Markovic */ 3109c2149c8Sths int32_t CP0_Index; 311ead9360eSths /* CP0_MVP* are per MVP registers. */ 31201bc435bSYongbok Kim int32_t CP0_VPControl; 31301bc435bSYongbok Kim #define CP0VPCtl_DIS 0 31450e7edc5SAleksandar Markovic /* 31550e7edc5SAleksandar Markovic * CP0 Register 1 31650e7edc5SAleksandar Markovic */ 3179c2149c8Sths int32_t CP0_Random; 318ead9360eSths int32_t CP0_VPEControl; 319ead9360eSths #define CP0VPECo_YSI 21 320ead9360eSths #define CP0VPECo_GSI 20 321ead9360eSths #define CP0VPECo_EXCPT 16 322ead9360eSths #define CP0VPECo_TE 15 323ead9360eSths #define CP0VPECo_TargTC 0 324ead9360eSths int32_t CP0_VPEConf0; 325ead9360eSths #define CP0VPEC0_M 31 326ead9360eSths #define CP0VPEC0_XTC 21 327ead9360eSths #define CP0VPEC0_TCS 19 328ead9360eSths #define CP0VPEC0_SCS 18 329ead9360eSths #define CP0VPEC0_DSC 17 330ead9360eSths #define CP0VPEC0_ICS 16 331ead9360eSths #define CP0VPEC0_MVP 1 332ead9360eSths #define CP0VPEC0_VPA 0 333ead9360eSths int32_t CP0_VPEConf1; 334ead9360eSths #define CP0VPEC1_NCX 20 335ead9360eSths #define CP0VPEC1_NCP2 10 336ead9360eSths #define CP0VPEC1_NCP1 0 337ead9360eSths target_ulong CP0_YQMask; 338ead9360eSths target_ulong CP0_VPESchedule; 339ead9360eSths target_ulong CP0_VPEScheFBack; 340ead9360eSths int32_t CP0_VPEOpt; 341ead9360eSths #define CP0VPEOpt_IWX7 15 342ead9360eSths #define CP0VPEOpt_IWX6 14 343ead9360eSths #define CP0VPEOpt_IWX5 13 344ead9360eSths #define CP0VPEOpt_IWX4 12 345ead9360eSths #define CP0VPEOpt_IWX3 11 346ead9360eSths #define CP0VPEOpt_IWX2 10 347ead9360eSths #define CP0VPEOpt_IWX1 9 348ead9360eSths #define CP0VPEOpt_IWX0 8 349ead9360eSths #define CP0VPEOpt_DWX7 7 350ead9360eSths #define CP0VPEOpt_DWX6 6 351ead9360eSths #define CP0VPEOpt_DWX5 5 352ead9360eSths #define CP0VPEOpt_DWX4 4 353ead9360eSths #define CP0VPEOpt_DWX3 3 354ead9360eSths #define CP0VPEOpt_DWX2 2 355ead9360eSths #define CP0VPEOpt_DWX1 1 356ead9360eSths #define CP0VPEOpt_DWX0 0 35750e7edc5SAleksandar Markovic /* 35850e7edc5SAleksandar Markovic * CP0 Register 2 35950e7edc5SAleksandar Markovic */ 360284b731aSLeon Alrae uint64_t CP0_EntryLo0; 36150e7edc5SAleksandar Markovic /* 36250e7edc5SAleksandar Markovic * CP0 Register 3 36350e7edc5SAleksandar Markovic */ 364284b731aSLeon Alrae uint64_t CP0_EntryLo1; 3652fb58b73SLeon Alrae #if defined(TARGET_MIPS64) 3662fb58b73SLeon Alrae # define CP0EnLo_RI 63 3672fb58b73SLeon Alrae # define CP0EnLo_XI 62 3682fb58b73SLeon Alrae #else 3692fb58b73SLeon Alrae # define CP0EnLo_RI 31 3702fb58b73SLeon Alrae # define CP0EnLo_XI 30 3712fb58b73SLeon Alrae #endif 37201bc435bSYongbok Kim int32_t CP0_GlobalNumber; 37301bc435bSYongbok Kim #define CP0GN_VPId 0 37450e7edc5SAleksandar Markovic /* 37550e7edc5SAleksandar Markovic * CP0 Register 4 37650e7edc5SAleksandar Markovic */ 3779c2149c8Sths target_ulong CP0_Context; 378e98c0d17SLeon Alrae target_ulong CP0_KScratch[MIPS_KSCRATCH_NUM]; 37950e7edc5SAleksandar Markovic /* 38050e7edc5SAleksandar Markovic * CP0 Register 5 38150e7edc5SAleksandar Markovic */ 3829c2149c8Sths int32_t CP0_PageMask; 3837207c7f9SLeon Alrae int32_t CP0_PageGrain_rw_bitmask; 3849c2149c8Sths int32_t CP0_PageGrain; 3857207c7f9SLeon Alrae #define CP0PG_RIE 31 3867207c7f9SLeon Alrae #define CP0PG_XIE 30 387e117f526SLeon Alrae #define CP0PG_ELPA 29 38892ceb440SLeon Alrae #define CP0PG_IEC 27 389cec56a73SJames Hogan target_ulong CP0_SegCtl0; 390cec56a73SJames Hogan target_ulong CP0_SegCtl1; 391cec56a73SJames Hogan target_ulong CP0_SegCtl2; 392cec56a73SJames Hogan #define CP0SC_PA 9 393cec56a73SJames Hogan #define CP0SC_PA_MASK (0x7FULL << CP0SC_PA) 394cec56a73SJames Hogan #define CP0SC_PA_1GMASK (0x7EULL << CP0SC_PA) 395cec56a73SJames Hogan #define CP0SC_AM 4 396cec56a73SJames Hogan #define CP0SC_AM_MASK (0x7ULL << CP0SC_AM) 397cec56a73SJames Hogan #define CP0SC_AM_UK 0ULL 398cec56a73SJames Hogan #define CP0SC_AM_MK 1ULL 399cec56a73SJames Hogan #define CP0SC_AM_MSK 2ULL 400cec56a73SJames Hogan #define CP0SC_AM_MUSK 3ULL 401cec56a73SJames Hogan #define CP0SC_AM_MUSUK 4ULL 402cec56a73SJames Hogan #define CP0SC_AM_USK 5ULL 403cec56a73SJames Hogan #define CP0SC_AM_UUSK 7ULL 404cec56a73SJames Hogan #define CP0SC_EU 3 405cec56a73SJames Hogan #define CP0SC_EU_MASK (1ULL << CP0SC_EU) 406cec56a73SJames Hogan #define CP0SC_C 0 407cec56a73SJames Hogan #define CP0SC_C_MASK (0x7ULL << CP0SC_C) 408cec56a73SJames Hogan #define CP0SC_MASK (CP0SC_C_MASK | CP0SC_EU_MASK | CP0SC_AM_MASK | \ 409cec56a73SJames Hogan CP0SC_PA_MASK) 410cec56a73SJames Hogan #define CP0SC_1GMASK (CP0SC_C_MASK | CP0SC_EU_MASK | CP0SC_AM_MASK | \ 411cec56a73SJames Hogan CP0SC_PA_1GMASK) 412cec56a73SJames Hogan #define CP0SC0_MASK (CP0SC_MASK | (CP0SC_MASK << 16)) 413cec56a73SJames Hogan #define CP0SC1_XAM 59 414cec56a73SJames Hogan #define CP0SC1_XAM_MASK (0x7ULL << CP0SC1_XAM) 415cec56a73SJames Hogan #define CP0SC1_MASK (CP0SC_MASK | (CP0SC_MASK << 16) | CP0SC1_XAM_MASK) 416cec56a73SJames Hogan #define CP0SC2_XR 56 417cec56a73SJames Hogan #define CP0SC2_XR_MASK (0xFFULL << CP0SC2_XR) 418cec56a73SJames Hogan #define CP0SC2_MASK (CP0SC_1GMASK | (CP0SC_1GMASK << 16) | CP0SC2_XR_MASK) 4195e31fdd5SYongbok Kim target_ulong CP0_PWBase; 420fa75ad14SYongbok Kim target_ulong CP0_PWField; 421fa75ad14SYongbok Kim #if defined(TARGET_MIPS64) 422fa75ad14SYongbok Kim #define CP0PF_BDI 32 /* 37..32 */ 423fa75ad14SYongbok Kim #define CP0PF_GDI 24 /* 29..24 */ 424fa75ad14SYongbok Kim #define CP0PF_UDI 18 /* 23..18 */ 425fa75ad14SYongbok Kim #define CP0PF_MDI 12 /* 17..12 */ 426fa75ad14SYongbok Kim #define CP0PF_PTI 6 /* 11..6 */ 427fa75ad14SYongbok Kim #define CP0PF_PTEI 0 /* 5..0 */ 428fa75ad14SYongbok Kim #else 429fa75ad14SYongbok Kim #define CP0PF_GDW 24 /* 29..24 */ 430fa75ad14SYongbok Kim #define CP0PF_UDW 18 /* 23..18 */ 431fa75ad14SYongbok Kim #define CP0PF_MDW 12 /* 17..12 */ 432fa75ad14SYongbok Kim #define CP0PF_PTW 6 /* 11..6 */ 433fa75ad14SYongbok Kim #define CP0PF_PTEW 0 /* 5..0 */ 434fa75ad14SYongbok Kim #endif 435*20b28ebcSYongbok Kim target_ulong CP0_PWSize; 436*20b28ebcSYongbok Kim #if defined(TARGET_MIPS64) 437*20b28ebcSYongbok Kim #define CP0PS_BDW 32 /* 37..32 */ 438*20b28ebcSYongbok Kim #endif 439*20b28ebcSYongbok Kim #define CP0PS_PS 30 440*20b28ebcSYongbok Kim #define CP0PS_GDW 24 /* 29..24 */ 441*20b28ebcSYongbok Kim #define CP0PS_UDW 18 /* 23..18 */ 442*20b28ebcSYongbok Kim #define CP0PS_MDW 12 /* 17..12 */ 443*20b28ebcSYongbok Kim #define CP0PS_PTW 6 /* 11..6 */ 444*20b28ebcSYongbok Kim #define CP0PS_PTEW 0 /* 5..0 */ 44550e7edc5SAleksandar Markovic /* 44650e7edc5SAleksandar Markovic * CP0 Register 6 44750e7edc5SAleksandar Markovic */ 4489c2149c8Sths int32_t CP0_Wired; 449ead9360eSths int32_t CP0_SRSConf0_rw_bitmask; 450ead9360eSths int32_t CP0_SRSConf0; 451ead9360eSths #define CP0SRSC0_M 31 452ead9360eSths #define CP0SRSC0_SRS3 20 453ead9360eSths #define CP0SRSC0_SRS2 10 454ead9360eSths #define CP0SRSC0_SRS1 0 455ead9360eSths int32_t CP0_SRSConf1_rw_bitmask; 456ead9360eSths int32_t CP0_SRSConf1; 457ead9360eSths #define CP0SRSC1_M 31 458ead9360eSths #define CP0SRSC1_SRS6 20 459ead9360eSths #define CP0SRSC1_SRS5 10 460ead9360eSths #define CP0SRSC1_SRS4 0 461ead9360eSths int32_t CP0_SRSConf2_rw_bitmask; 462ead9360eSths int32_t CP0_SRSConf2; 463ead9360eSths #define CP0SRSC2_M 31 464ead9360eSths #define CP0SRSC2_SRS9 20 465ead9360eSths #define CP0SRSC2_SRS8 10 466ead9360eSths #define CP0SRSC2_SRS7 0 467ead9360eSths int32_t CP0_SRSConf3_rw_bitmask; 468ead9360eSths int32_t CP0_SRSConf3; 469ead9360eSths #define CP0SRSC3_M 31 470ead9360eSths #define CP0SRSC3_SRS12 20 471ead9360eSths #define CP0SRSC3_SRS11 10 472ead9360eSths #define CP0SRSC3_SRS10 0 473ead9360eSths int32_t CP0_SRSConf4_rw_bitmask; 474ead9360eSths int32_t CP0_SRSConf4; 475ead9360eSths #define CP0SRSC4_SRS15 20 476ead9360eSths #define CP0SRSC4_SRS14 10 477ead9360eSths #define CP0SRSC4_SRS13 0 47850e7edc5SAleksandar Markovic /* 47950e7edc5SAleksandar Markovic * CP0 Register 7 48050e7edc5SAleksandar Markovic */ 4819c2149c8Sths int32_t CP0_HWREna; 48250e7edc5SAleksandar Markovic /* 48350e7edc5SAleksandar Markovic * CP0 Register 8 48450e7edc5SAleksandar Markovic */ 485c570fd16Sths target_ulong CP0_BadVAddr; 486aea14095SLeon Alrae uint32_t CP0_BadInstr; 487aea14095SLeon Alrae uint32_t CP0_BadInstrP; 48825beba9bSStefan Markovic uint32_t CP0_BadInstrX; 48950e7edc5SAleksandar Markovic /* 49050e7edc5SAleksandar Markovic * CP0 Register 9 49150e7edc5SAleksandar Markovic */ 4929c2149c8Sths int32_t CP0_Count; 49350e7edc5SAleksandar Markovic /* 49450e7edc5SAleksandar Markovic * CP0 Register 10 49550e7edc5SAleksandar Markovic */ 4969c2149c8Sths target_ulong CP0_EntryHi; 4979456c2fbSLeon Alrae #define CP0EnHi_EHINV 10 4986ec98bd7SPaul Burton target_ulong CP0_EntryHi_ASID_mask; 49950e7edc5SAleksandar Markovic /* 50050e7edc5SAleksandar Markovic * CP0 Register 11 50150e7edc5SAleksandar Markovic */ 5029c2149c8Sths int32_t CP0_Compare; 50350e7edc5SAleksandar Markovic /* 50450e7edc5SAleksandar Markovic * CP0 Register 12 50550e7edc5SAleksandar Markovic */ 5069c2149c8Sths int32_t CP0_Status; 5076af0bf9cSbellard #define CP0St_CU3 31 5086af0bf9cSbellard #define CP0St_CU2 30 5096af0bf9cSbellard #define CP0St_CU1 29 5106af0bf9cSbellard #define CP0St_CU0 28 5116af0bf9cSbellard #define CP0St_RP 27 5126ea83fedSbellard #define CP0St_FR 26 5136af0bf9cSbellard #define CP0St_RE 25 5147a387fffSths #define CP0St_MX 24 5157a387fffSths #define CP0St_PX 23 5166af0bf9cSbellard #define CP0St_BEV 22 5176af0bf9cSbellard #define CP0St_TS 21 5186af0bf9cSbellard #define CP0St_SR 20 5196af0bf9cSbellard #define CP0St_NMI 19 5206af0bf9cSbellard #define CP0St_IM 8 5217a387fffSths #define CP0St_KX 7 5227a387fffSths #define CP0St_SX 6 5237a387fffSths #define CP0St_UX 5 524623a930eSths #define CP0St_KSU 3 5256af0bf9cSbellard #define CP0St_ERL 2 5266af0bf9cSbellard #define CP0St_EXL 1 5276af0bf9cSbellard #define CP0St_IE 0 5289c2149c8Sths int32_t CP0_IntCtl; 529ead9360eSths #define CP0IntCtl_IPTI 29 53088991299SDongxue Zhang #define CP0IntCtl_IPPCI 26 531ead9360eSths #define CP0IntCtl_VS 5 5329c2149c8Sths int32_t CP0_SRSCtl; 533ead9360eSths #define CP0SRSCtl_HSS 26 534ead9360eSths #define CP0SRSCtl_EICSS 18 535ead9360eSths #define CP0SRSCtl_ESS 12 536ead9360eSths #define CP0SRSCtl_PSS 6 537ead9360eSths #define CP0SRSCtl_CSS 0 5389c2149c8Sths int32_t CP0_SRSMap; 539ead9360eSths #define CP0SRSMap_SSV7 28 540ead9360eSths #define CP0SRSMap_SSV6 24 541ead9360eSths #define CP0SRSMap_SSV5 20 542ead9360eSths #define CP0SRSMap_SSV4 16 543ead9360eSths #define CP0SRSMap_SSV3 12 544ead9360eSths #define CP0SRSMap_SSV2 8 545ead9360eSths #define CP0SRSMap_SSV1 4 546ead9360eSths #define CP0SRSMap_SSV0 0 54750e7edc5SAleksandar Markovic /* 54850e7edc5SAleksandar Markovic * CP0 Register 13 54950e7edc5SAleksandar Markovic */ 5509c2149c8Sths int32_t CP0_Cause; 5517a387fffSths #define CP0Ca_BD 31 5527a387fffSths #define CP0Ca_TI 30 5537a387fffSths #define CP0Ca_CE 28 5547a387fffSths #define CP0Ca_DC 27 5557a387fffSths #define CP0Ca_PCI 26 5566af0bf9cSbellard #define CP0Ca_IV 23 5577a387fffSths #define CP0Ca_WP 22 5587a387fffSths #define CP0Ca_IP 8 5594de9b249Sths #define CP0Ca_IP_mask 0x0000FF00 5607a387fffSths #define CP0Ca_EC 2 56150e7edc5SAleksandar Markovic /* 56250e7edc5SAleksandar Markovic * CP0 Register 14 56350e7edc5SAleksandar Markovic */ 564c570fd16Sths target_ulong CP0_EPC; 56550e7edc5SAleksandar Markovic /* 56650e7edc5SAleksandar Markovic * CP0 Register 15 56750e7edc5SAleksandar Markovic */ 5689c2149c8Sths int32_t CP0_PRid; 56974dbf824SJames Hogan target_ulong CP0_EBase; 57074dbf824SJames Hogan target_ulong CP0_EBaseWG_rw_bitmask; 57174dbf824SJames Hogan #define CP0EBase_WG 11 572c870e3f5SYongbok Kim target_ulong CP0_CMGCRBase; 57350e7edc5SAleksandar Markovic /* 57450e7edc5SAleksandar Markovic * CP0 Register 16 57550e7edc5SAleksandar Markovic */ 5769c2149c8Sths int32_t CP0_Config0; 5776af0bf9cSbellard #define CP0C0_M 31 5780413d7a5SAleksandar Markovic #define CP0C0_K23 28 /* 30..28 */ 5790413d7a5SAleksandar Markovic #define CP0C0_KU 25 /* 27..25 */ 5806af0bf9cSbellard #define CP0C0_MDU 20 581aff2bc6dSYongbok Kim #define CP0C0_MM 18 5826af0bf9cSbellard #define CP0C0_BM 16 5830413d7a5SAleksandar Markovic #define CP0C0_Impl 16 /* 24..16 */ 5846af0bf9cSbellard #define CP0C0_BE 15 5850413d7a5SAleksandar Markovic #define CP0C0_AT 13 /* 14..13 */ 5860413d7a5SAleksandar Markovic #define CP0C0_AR 10 /* 12..10 */ 5870413d7a5SAleksandar Markovic #define CP0C0_MT 7 /* 9..7 */ 5887a387fffSths #define CP0C0_VI 3 5890413d7a5SAleksandar Markovic #define CP0C0_K0 0 /* 2..0 */ 5909c2149c8Sths int32_t CP0_Config1; 5917a387fffSths #define CP0C1_M 31 5920413d7a5SAleksandar Markovic #define CP0C1_MMU 25 /* 30..25 */ 5930413d7a5SAleksandar Markovic #define CP0C1_IS 22 /* 24..22 */ 5940413d7a5SAleksandar Markovic #define CP0C1_IL 19 /* 21..19 */ 5950413d7a5SAleksandar Markovic #define CP0C1_IA 16 /* 18..16 */ 5960413d7a5SAleksandar Markovic #define CP0C1_DS 13 /* 15..13 */ 5970413d7a5SAleksandar Markovic #define CP0C1_DL 10 /* 12..10 */ 5980413d7a5SAleksandar Markovic #define CP0C1_DA 7 /* 9..7 */ 5997a387fffSths #define CP0C1_C2 6 6007a387fffSths #define CP0C1_MD 5 6016af0bf9cSbellard #define CP0C1_PC 4 6026af0bf9cSbellard #define CP0C1_WR 3 6036af0bf9cSbellard #define CP0C1_CA 2 6046af0bf9cSbellard #define CP0C1_EP 1 6056af0bf9cSbellard #define CP0C1_FP 0 6069c2149c8Sths int32_t CP0_Config2; 6077a387fffSths #define CP0C2_M 31 6080413d7a5SAleksandar Markovic #define CP0C2_TU 28 /* 30..28 */ 6090413d7a5SAleksandar Markovic #define CP0C2_TS 24 /* 27..24 */ 6100413d7a5SAleksandar Markovic #define CP0C2_TL 20 /* 23..20 */ 6110413d7a5SAleksandar Markovic #define CP0C2_TA 16 /* 19..16 */ 6120413d7a5SAleksandar Markovic #define CP0C2_SU 12 /* 15..12 */ 6130413d7a5SAleksandar Markovic #define CP0C2_SS 8 /* 11..8 */ 6140413d7a5SAleksandar Markovic #define CP0C2_SL 4 /* 7..4 */ 6150413d7a5SAleksandar Markovic #define CP0C2_SA 0 /* 3..0 */ 6169c2149c8Sths int32_t CP0_Config3; 6177a387fffSths #define CP0C3_M 31 61870409e67SMaciej W. Rozycki #define CP0C3_BPG 30 619c870e3f5SYongbok Kim #define CP0C3_CMGCR 29 620e97a391dSYongbok Kim #define CP0C3_MSAP 28 621aea14095SLeon Alrae #define CP0C3_BP 27 622aea14095SLeon Alrae #define CP0C3_BI 26 62374dbf824SJames Hogan #define CP0C3_SC 25 6240413d7a5SAleksandar Markovic #define CP0C3_PW 24 6250413d7a5SAleksandar Markovic #define CP0C3_VZ 23 6260413d7a5SAleksandar Markovic #define CP0C3_IPLV 21 /* 22..21 */ 6270413d7a5SAleksandar Markovic #define CP0C3_MMAR 18 /* 20..18 */ 62870409e67SMaciej W. Rozycki #define CP0C3_MCU 17 629bbfa8f72SNathan Froyd #define CP0C3_ISA_ON_EXC 16 6300413d7a5SAleksandar Markovic #define CP0C3_ISA 14 /* 15..14 */ 631d279279eSPetar Jovanovic #define CP0C3_ULRI 13 6327207c7f9SLeon Alrae #define CP0C3_RXI 12 63370409e67SMaciej W. Rozycki #define CP0C3_DSP2P 11 6347a387fffSths #define CP0C3_DSPP 10 6350413d7a5SAleksandar Markovic #define CP0C3_CTXTC 9 6360413d7a5SAleksandar Markovic #define CP0C3_ITL 8 6377a387fffSths #define CP0C3_LPA 7 6387a387fffSths #define CP0C3_VEIC 6 6397a387fffSths #define CP0C3_VInt 5 6407a387fffSths #define CP0C3_SP 4 64170409e67SMaciej W. Rozycki #define CP0C3_CDMM 3 6427a387fffSths #define CP0C3_MT 2 6437a387fffSths #define CP0C3_SM 1 6447a387fffSths #define CP0C3_TL 0 6458280b12cSMaciej W. Rozycki int32_t CP0_Config4; 6468280b12cSMaciej W. Rozycki int32_t CP0_Config4_rw_bitmask; 647b4160af1SPetar Jovanovic #define CP0C4_M 31 6480413d7a5SAleksandar Markovic #define CP0C4_IE 29 /* 30..29 */ 649a0c80608SPaul Burton #define CP0C4_AE 28 6500413d7a5SAleksandar Markovic #define CP0C4_VTLBSizeExt 24 /* 27..24 */ 651e98c0d17SLeon Alrae #define CP0C4_KScrExist 16 65270409e67SMaciej W. Rozycki #define CP0C4_MMUExtDef 14 6530413d7a5SAleksandar Markovic #define CP0C4_FTLBPageSize 8 /* 12..8 */ 6540413d7a5SAleksandar Markovic /* bit layout if MMUExtDef=1 */ 6550413d7a5SAleksandar Markovic #define CP0C4_MMUSizeExt 0 /* 7..0 */ 6560413d7a5SAleksandar Markovic /* bit layout if MMUExtDef=2 */ 6570413d7a5SAleksandar Markovic #define CP0C4_FTLBWays 4 /* 7..4 */ 6580413d7a5SAleksandar Markovic #define CP0C4_FTLBSets 0 /* 3..0 */ 6598280b12cSMaciej W. Rozycki int32_t CP0_Config5; 6608280b12cSMaciej W. Rozycki int32_t CP0_Config5_rw_bitmask; 661b4dd99a3SPetar Jovanovic #define CP0C5_M 31 662b4dd99a3SPetar Jovanovic #define CP0C5_K 30 663b4dd99a3SPetar Jovanovic #define CP0C5_CV 29 664b4dd99a3SPetar Jovanovic #define CP0C5_EVA 28 665b4dd99a3SPetar Jovanovic #define CP0C5_MSAEn 27 6660413d7a5SAleksandar Markovic #define CP0C5_PMJ 23 /* 25..23 */ 6670413d7a5SAleksandar Markovic #define CP0C5_WR2 22 6680413d7a5SAleksandar Markovic #define CP0C5_NMS 21 6690413d7a5SAleksandar Markovic #define CP0C5_ULS 20 6700413d7a5SAleksandar Markovic #define CP0C5_XPA 19 6710413d7a5SAleksandar Markovic #define CP0C5_CRCP 18 6720413d7a5SAleksandar Markovic #define CP0C5_MI 17 6730413d7a5SAleksandar Markovic #define CP0C5_GI 15 /* 16..15 */ 6740413d7a5SAleksandar Markovic #define CP0C5_CA2 14 675b00c7218SYongbok Kim #define CP0C5_XNP 13 6760413d7a5SAleksandar Markovic #define CP0C5_DEC 11 6770413d7a5SAleksandar Markovic #define CP0C5_L2C 10 6787c979afdSLeon Alrae #define CP0C5_UFE 9 6797c979afdSLeon Alrae #define CP0C5_FRE 8 68001bc435bSYongbok Kim #define CP0C5_VP 7 681faf1f68bSLeon Alrae #define CP0C5_SBRI 6 6825204ea79SLeon Alrae #define CP0C5_MVH 5 683ce9782f4SLeon Alrae #define CP0C5_LLB 4 684f6d4dd81SYongbok Kim #define CP0C5_MRP 3 685b4dd99a3SPetar Jovanovic #define CP0C5_UFR 2 686b4dd99a3SPetar Jovanovic #define CP0C5_NFExists 0 687e397ee33Sths int32_t CP0_Config6; 688e397ee33Sths int32_t CP0_Config7; 689f6d4dd81SYongbok Kim uint64_t CP0_MAAR[MIPS_MAAR_MAX]; 690f6d4dd81SYongbok Kim int32_t CP0_MAARI; 691ead9360eSths /* XXX: Maybe make LLAddr per-TC? */ 69250e7edc5SAleksandar Markovic /* 69350e7edc5SAleksandar Markovic * CP0 Register 17 69450e7edc5SAleksandar Markovic */ 695284b731aSLeon Alrae uint64_t lladdr; 696590bc601SPaul Brook target_ulong llval; 697590bc601SPaul Brook target_ulong llnewval; 6980b16dcd1SAleksandar Rikalo uint64_t llval_wp; 6990b16dcd1SAleksandar Rikalo uint32_t llnewval_wp; 700590bc601SPaul Brook target_ulong llreg; 701284b731aSLeon Alrae uint64_t CP0_LLAddr_rw_bitmask; 7022a6e32ddSAurelien Jarno int CP0_LLAddr_shift; 70350e7edc5SAleksandar Markovic /* 70450e7edc5SAleksandar Markovic * CP0 Register 18 70550e7edc5SAleksandar Markovic */ 706fd88b6abSths target_ulong CP0_WatchLo[8]; 70750e7edc5SAleksandar Markovic /* 70850e7edc5SAleksandar Markovic * CP0 Register 19 70950e7edc5SAleksandar Markovic */ 710fd88b6abSths int32_t CP0_WatchHi[8]; 7116ec98bd7SPaul Burton #define CP0WH_ASID 16 71250e7edc5SAleksandar Markovic /* 71350e7edc5SAleksandar Markovic * CP0 Register 20 71450e7edc5SAleksandar Markovic */ 7159c2149c8Sths target_ulong CP0_XContext; 7169c2149c8Sths int32_t CP0_Framemask; 71750e7edc5SAleksandar Markovic /* 71850e7edc5SAleksandar Markovic * CP0 Register 23 71950e7edc5SAleksandar Markovic */ 7209c2149c8Sths int32_t CP0_Debug; 721ead9360eSths #define CP0DB_DBD 31 7226af0bf9cSbellard #define CP0DB_DM 30 7236af0bf9cSbellard #define CP0DB_LSNM 28 7246af0bf9cSbellard #define CP0DB_Doze 27 7256af0bf9cSbellard #define CP0DB_Halt 26 7266af0bf9cSbellard #define CP0DB_CNT 25 7276af0bf9cSbellard #define CP0DB_IBEP 24 7286af0bf9cSbellard #define CP0DB_DBEP 21 7296af0bf9cSbellard #define CP0DB_IEXI 20 7306af0bf9cSbellard #define CP0DB_VER 15 7316af0bf9cSbellard #define CP0DB_DEC 10 7326af0bf9cSbellard #define CP0DB_SSt 8 7336af0bf9cSbellard #define CP0DB_DINT 5 7346af0bf9cSbellard #define CP0DB_DIB 4 7356af0bf9cSbellard #define CP0DB_DDBS 3 7366af0bf9cSbellard #define CP0DB_DDBL 2 7376af0bf9cSbellard #define CP0DB_DBp 1 7386af0bf9cSbellard #define CP0DB_DSS 0 73950e7edc5SAleksandar Markovic /* 74050e7edc5SAleksandar Markovic * CP0 Register 24 74150e7edc5SAleksandar Markovic */ 742c570fd16Sths target_ulong CP0_DEPC; 74350e7edc5SAleksandar Markovic /* 74450e7edc5SAleksandar Markovic * CP0 Register 25 74550e7edc5SAleksandar Markovic */ 7469c2149c8Sths int32_t CP0_Performance0; 74750e7edc5SAleksandar Markovic /* 74850e7edc5SAleksandar Markovic * CP0 Register 26 74950e7edc5SAleksandar Markovic */ 7500d74a222SLeon Alrae int32_t CP0_ErrCtl; 7510d74a222SLeon Alrae #define CP0EC_WST 29 7520d74a222SLeon Alrae #define CP0EC_SPR 28 7530d74a222SLeon Alrae #define CP0EC_ITC 26 75450e7edc5SAleksandar Markovic /* 75550e7edc5SAleksandar Markovic * CP0 Register 28 75650e7edc5SAleksandar Markovic */ 757284b731aSLeon Alrae uint64_t CP0_TagLo; 7589c2149c8Sths int32_t CP0_DataLo; 75950e7edc5SAleksandar Markovic /* 76050e7edc5SAleksandar Markovic * CP0 Register 29 76150e7edc5SAleksandar Markovic */ 7629c2149c8Sths int32_t CP0_TagHi; 7639c2149c8Sths int32_t CP0_DataHi; 76450e7edc5SAleksandar Markovic /* 76550e7edc5SAleksandar Markovic * CP0 Register 30 76650e7edc5SAleksandar Markovic */ 767c570fd16Sths target_ulong CP0_ErrorEPC; 76850e7edc5SAleksandar Markovic /* 76950e7edc5SAleksandar Markovic * CP0 Register 31 77050e7edc5SAleksandar Markovic */ 7719c2149c8Sths int32_t CP0_DESAVE; 77250e7edc5SAleksandar Markovic 773b5dc7732Sths /* We waste some space so we can handle shadow registers like TCs. */ 774b5dc7732Sths TCState tcs[MIPS_SHADOW_SET_MAX]; 775f01be154Sths CPUMIPSFPUContext fpus[MIPS_FPU_MAX]; 7765cbdb3a3SStefan Weil /* QEMU */ 7776af0bf9cSbellard int error_code; 778aea14095SLeon Alrae #define EXCP_TLB_NOMATCH 0x1 779aea14095SLeon Alrae #define EXCP_INST_NOTAVAIL 0x2 /* No valid instruction word for BadInstr */ 7806af0bf9cSbellard uint32_t hflags; /* CPU State */ 7816af0bf9cSbellard /* TMASK defines different execution modes */ 78242c86612SJames Hogan #define MIPS_HFLAG_TMASK 0x1F5807FF 78379ef2c4cSNathan Froyd #define MIPS_HFLAG_MODE 0x00007 /* execution modes */ 784623a930eSths /* The KSU flags must be the lowest bits in hflags. The flag order 785623a930eSths must be the same as defined for CP0 Status. This allows to use 786623a930eSths the bits as the value of mmu_idx. */ 78779ef2c4cSNathan Froyd #define MIPS_HFLAG_KSU 0x00003 /* kernel/supervisor/user mode mask */ 78879ef2c4cSNathan Froyd #define MIPS_HFLAG_UM 0x00002 /* user mode flag */ 78979ef2c4cSNathan Froyd #define MIPS_HFLAG_SM 0x00001 /* supervisor mode flag */ 79079ef2c4cSNathan Froyd #define MIPS_HFLAG_KM 0x00000 /* kernel mode flag */ 79179ef2c4cSNathan Froyd #define MIPS_HFLAG_DM 0x00004 /* Debug mode */ 79279ef2c4cSNathan Froyd #define MIPS_HFLAG_64 0x00008 /* 64-bit instructions enabled */ 79379ef2c4cSNathan Froyd #define MIPS_HFLAG_CP0 0x00010 /* CP0 enabled */ 79479ef2c4cSNathan Froyd #define MIPS_HFLAG_FPU 0x00020 /* FPU enabled */ 79579ef2c4cSNathan Froyd #define MIPS_HFLAG_F64 0x00040 /* 64-bit FPU enabled */ 796b8aa4598Sths /* True if the MIPS IV COP1X instructions can be used. This also 797b8aa4598Sths controls the non-COP1X instructions RECIP.S, RECIP.D, RSQRT.S 798b8aa4598Sths and RSQRT.D. */ 79979ef2c4cSNathan Froyd #define MIPS_HFLAG_COP1X 0x00080 /* COP1X instructions enabled */ 80079ef2c4cSNathan Froyd #define MIPS_HFLAG_RE 0x00100 /* Reversed endianness */ 80101f72885SLeon Alrae #define MIPS_HFLAG_AWRAP 0x00200 /* 32-bit compatibility address wrapping */ 80279ef2c4cSNathan Froyd #define MIPS_HFLAG_M16 0x00400 /* MIPS16 mode flag */ 80379ef2c4cSNathan Froyd #define MIPS_HFLAG_M16_SHIFT 10 8044ad40f36Sbellard /* If translation is interrupted between the branch instruction and 8054ad40f36Sbellard * the delay slot, record what type of branch it is so that we can 8064ad40f36Sbellard * resume translation properly. It might be possible to reduce 8074ad40f36Sbellard * this from three bits to two. */ 808339cd2a8SLeon Alrae #define MIPS_HFLAG_BMASK_BASE 0x803800 80979ef2c4cSNathan Froyd #define MIPS_HFLAG_B 0x00800 /* Unconditional branch */ 81079ef2c4cSNathan Froyd #define MIPS_HFLAG_BC 0x01000 /* Conditional branch */ 81179ef2c4cSNathan Froyd #define MIPS_HFLAG_BL 0x01800 /* Likely branch */ 81279ef2c4cSNathan Froyd #define MIPS_HFLAG_BR 0x02000 /* branch to register (can't link TB) */ 81379ef2c4cSNathan Froyd /* Extra flags about the current pending branch. */ 814b231c103SYongbok Kim #define MIPS_HFLAG_BMASK_EXT 0x7C000 81579ef2c4cSNathan Froyd #define MIPS_HFLAG_B16 0x04000 /* branch instruction was 16 bits */ 81679ef2c4cSNathan Froyd #define MIPS_HFLAG_BDS16 0x08000 /* branch requires 16-bit delay slot */ 81779ef2c4cSNathan Froyd #define MIPS_HFLAG_BDS32 0x10000 /* branch requires 32-bit delay slot */ 818b231c103SYongbok Kim #define MIPS_HFLAG_BDS_STRICT 0x20000 /* Strict delay slot size */ 819b231c103SYongbok Kim #define MIPS_HFLAG_BX 0x40000 /* branch exchanges execution mode */ 82079ef2c4cSNathan Froyd #define MIPS_HFLAG_BMASK (MIPS_HFLAG_BMASK_BASE | MIPS_HFLAG_BMASK_EXT) 821853c3240SJia Liu /* MIPS DSP resources access. */ 822908f6be1SStefan Markovic #define MIPS_HFLAG_DSP 0x080000 /* Enable access to DSP resources. */ 823908f6be1SStefan Markovic #define MIPS_HFLAG_DSP_R2 0x100000 /* Enable access to DSP R2 resources. */ 824908f6be1SStefan Markovic #define MIPS_HFLAG_DSP_R3 0x20000000 /* Enable access to DSP R3 resources. */ 825d279279eSPetar Jovanovic /* Extra flag about HWREna register. */ 826b231c103SYongbok Kim #define MIPS_HFLAG_HWRENA_ULR 0x200000 /* ULR bit from HWREna is set. */ 827faf1f68bSLeon Alrae #define MIPS_HFLAG_SBRI 0x400000 /* R6 SDBBP causes RI excpt. in user mode */ 828339cd2a8SLeon Alrae #define MIPS_HFLAG_FBNSLOT 0x800000 /* Forbidden slot */ 829e97a391dSYongbok Kim #define MIPS_HFLAG_MSA 0x1000000 8307c979afdSLeon Alrae #define MIPS_HFLAG_FRE 0x2000000 /* FRE enabled */ 831e117f526SLeon Alrae #define MIPS_HFLAG_ELPA 0x4000000 8320d74a222SLeon Alrae #define MIPS_HFLAG_ITC_CACHE 0x8000000 /* CACHE instr. operates on ITC tag */ 83342c86612SJames Hogan #define MIPS_HFLAG_ERL 0x10000000 /* error level flag */ 8346af0bf9cSbellard target_ulong btarget; /* Jump / branch target */ 8351ba74fb8Saurel32 target_ulong bcond; /* Branch condition (if needed) */ 836a316d335Sbellard 8377a387fffSths int SYNCI_Step; /* Address step size for SYNCI */ 8387a387fffSths int CCRes; /* Cycle count resolution/divisor */ 839ead9360eSths uint32_t CP0_Status_rw_bitmask; /* Read/write bits in CP0_Status */ 840ead9360eSths uint32_t CP0_TCStatus_rw_bitmask; /* Read/write bits in CP0_TCStatus */ 841f9c9cd63SPhilippe Mathieu-Daudé uint64_t insn_flags; /* Supported instruction set */ 8427a387fffSths 8431f5c00cfSAlex Bennée /* Fields up to this point are cleared by a CPU reset */ 8441f5c00cfSAlex Bennée struct {} end_reset_fields; 8451f5c00cfSAlex Bennée 846a316d335Sbellard CPU_COMMON 8476ae81775Sths 848f0c3c505SAndreas Färber /* Fields from here on are preserved across CPU reset. */ 84951cc2e78SBlue Swirl CPUMIPSMVPContext *mvp; 8503c7b48b7SPaul Brook #if !defined(CONFIG_USER_ONLY) 85151cc2e78SBlue Swirl CPUMIPSTLBContext *tlb; 8523c7b48b7SPaul Brook #endif 85351cc2e78SBlue Swirl 854c227f099SAnthony Liguori const mips_def_t *cpu_model; 85533ac7f16Sths void *irq[8]; 8561246b259SStefan Weil QEMUTimer *timer; /* Internal timer */ 85734fa7e83SLeon Alrae MemoryRegion *itc_tag; /* ITC Configuration Tags */ 85889777fd1SLeon Alrae target_ulong exception_base; /* ExceptionBase input to the core */ 8596af0bf9cSbellard }; 8606af0bf9cSbellard 861416bf936SPaolo Bonzini /** 862416bf936SPaolo Bonzini * MIPSCPU: 863416bf936SPaolo Bonzini * @env: #CPUMIPSState 864416bf936SPaolo Bonzini * 865416bf936SPaolo Bonzini * A MIPS CPU. 866416bf936SPaolo Bonzini */ 867416bf936SPaolo Bonzini struct MIPSCPU { 868416bf936SPaolo Bonzini /*< private >*/ 869416bf936SPaolo Bonzini CPUState parent_obj; 870416bf936SPaolo Bonzini /*< public >*/ 871416bf936SPaolo Bonzini 872416bf936SPaolo Bonzini CPUMIPSState env; 873416bf936SPaolo Bonzini }; 874416bf936SPaolo Bonzini 875416bf936SPaolo Bonzini static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env) 876416bf936SPaolo Bonzini { 877416bf936SPaolo Bonzini return container_of(env, MIPSCPU, env); 878416bf936SPaolo Bonzini } 879416bf936SPaolo Bonzini 880416bf936SPaolo Bonzini #define ENV_GET_CPU(e) CPU(mips_env_get_cpu(e)) 881416bf936SPaolo Bonzini 882416bf936SPaolo Bonzini #define ENV_OFFSET offsetof(MIPSCPU, env) 883416bf936SPaolo Bonzini 8849a78eeadSStefan Weil void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf); 885647de6caSths 8869467d44cSths #define cpu_signal_handler cpu_mips_signal_handler 887c732abe2Sj_mayer #define cpu_list mips_cpu_list 8889467d44cSths 889084d0497SRichard Henderson extern void cpu_wrdsp(uint32_t rs, uint32_t mask_num, CPUMIPSState *env); 890084d0497SRichard Henderson extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env); 891084d0497SRichard Henderson 892623a930eSths /* MMU modes definitions. We carefully match the indices with our 893623a930eSths hflags layout. */ 8946ebbf390Sj_mayer #define MMU_MODE0_SUFFIX _kernel 895623a930eSths #define MMU_MODE1_SUFFIX _super 896623a930eSths #define MMU_MODE2_SUFFIX _user 89742c86612SJames Hogan #define MMU_MODE3_SUFFIX _error 898623a930eSths #define MMU_USER_IDX 2 899b0fc6003SJames Hogan 900b0fc6003SJames Hogan static inline int hflags_mmu_index(uint32_t hflags) 901b0fc6003SJames Hogan { 90242c86612SJames Hogan if (hflags & MIPS_HFLAG_ERL) { 90342c86612SJames Hogan return 3; /* ERL */ 90442c86612SJames Hogan } else { 905b0fc6003SJames Hogan return hflags & MIPS_HFLAG_KSU; 906b0fc6003SJames Hogan } 90742c86612SJames Hogan } 908b0fc6003SJames Hogan 90997ed5ccdSBenjamin Herrenschmidt static inline int cpu_mmu_index (CPUMIPSState *env, bool ifetch) 9106ebbf390Sj_mayer { 911b0fc6003SJames Hogan return hflags_mmu_index(env->hflags); 9126ebbf390Sj_mayer } 9136ebbf390Sj_mayer 914022c62cbSPaolo Bonzini #include "exec/cpu-all.h" 9156af0bf9cSbellard 9166af0bf9cSbellard /* Memory access type : 9176af0bf9cSbellard * may be needed for precise access rights control and precise exceptions. 9186af0bf9cSbellard */ 9196af0bf9cSbellard enum { 9206af0bf9cSbellard /* 1 bit to define user level / supervisor access */ 9216af0bf9cSbellard ACCESS_USER = 0x00, 9226af0bf9cSbellard ACCESS_SUPER = 0x01, 9236af0bf9cSbellard /* 1 bit to indicate direction */ 9246af0bf9cSbellard ACCESS_STORE = 0x02, 9256af0bf9cSbellard /* Type of instruction that generated the access */ 9266af0bf9cSbellard ACCESS_CODE = 0x10, /* Code fetch access */ 9276af0bf9cSbellard ACCESS_INT = 0x20, /* Integer load/store access */ 9286af0bf9cSbellard ACCESS_FLOAT = 0x30, /* floating point load/store access */ 9296af0bf9cSbellard }; 9306af0bf9cSbellard 9316af0bf9cSbellard /* Exceptions */ 9326af0bf9cSbellard enum { 9336af0bf9cSbellard EXCP_NONE = -1, 9346af0bf9cSbellard EXCP_RESET = 0, 9356af0bf9cSbellard EXCP_SRESET, 9366af0bf9cSbellard EXCP_DSS, 9376af0bf9cSbellard EXCP_DINT, 93814e51cc7Sths EXCP_DDBL, 93914e51cc7Sths EXCP_DDBS, 9406af0bf9cSbellard EXCP_NMI, 9416af0bf9cSbellard EXCP_MCHECK, 94214e51cc7Sths EXCP_EXT_INTERRUPT, /* 8 */ 9436af0bf9cSbellard EXCP_DFWATCH, 94414e51cc7Sths EXCP_DIB, 9456af0bf9cSbellard EXCP_IWATCH, 9466af0bf9cSbellard EXCP_AdEL, 9476af0bf9cSbellard EXCP_AdES, 9486af0bf9cSbellard EXCP_TLBF, 9496af0bf9cSbellard EXCP_IBE, 95014e51cc7Sths EXCP_DBp, /* 16 */ 9516af0bf9cSbellard EXCP_SYSCALL, 95214e51cc7Sths EXCP_BREAK, 9534ad40f36Sbellard EXCP_CpU, 9546af0bf9cSbellard EXCP_RI, 9556af0bf9cSbellard EXCP_OVERFLOW, 9566af0bf9cSbellard EXCP_TRAP, 9575a5012ecSths EXCP_FPE, 95814e51cc7Sths EXCP_DWATCH, /* 24 */ 9596af0bf9cSbellard EXCP_LTLBL, 9606af0bf9cSbellard EXCP_TLBL, 9616af0bf9cSbellard EXCP_TLBS, 9626af0bf9cSbellard EXCP_DBE, 963ead9360eSths EXCP_THREAD, 96414e51cc7Sths EXCP_MDMX, 96514e51cc7Sths EXCP_C2E, 96614e51cc7Sths EXCP_CACHE, /* 32 */ 967853c3240SJia Liu EXCP_DSPDIS, 968e97a391dSYongbok Kim EXCP_MSADIS, 969e97a391dSYongbok Kim EXCP_MSAFPE, 97092ceb440SLeon Alrae EXCP_TLBXI, 97192ceb440SLeon Alrae EXCP_TLBRI, 97214e51cc7Sths 97392ceb440SLeon Alrae EXCP_LAST = EXCP_TLBRI, 9746af0bf9cSbellard }; 975590bc601SPaul Brook /* Dummy exception for conditional stores. */ 976590bc601SPaul Brook #define EXCP_SC 0x100 9776af0bf9cSbellard 978f249412cSEdgar E. Iglesias /* 97926aa3d9aSPhilippe Mathieu-Daudé * This is an internally generated WAKE request line. 980f249412cSEdgar E. Iglesias * It is driven by the CPU itself. Raised when the MT 981f249412cSEdgar E. Iglesias * block wants to wake a VPE from an inactive state and 982f249412cSEdgar E. Iglesias * cleared when VPE goes from active to inactive. 983f249412cSEdgar E. Iglesias */ 984f249412cSEdgar E. Iglesias #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 985f249412cSEdgar E. Iglesias 986388bb21aSths int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); 9876af0bf9cSbellard 988a7519f2bSIgor Mammedov #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU 989a7519f2bSIgor Mammedov #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX 9900dacec87SIgor Mammedov #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU 991a7519f2bSIgor Mammedov 992a7519f2bSIgor Mammedov bool cpu_supports_cps_smp(const char *cpu_type); 993a7519f2bSIgor Mammedov bool cpu_supports_isa(const char *cpu_type, unsigned int isa); 99489777fd1SLeon Alrae void cpu_set_exception_base(int vp_index, target_ulong address); 99530bf942dSAndreas Färber 9965dc5d9f0SAurelien Jarno /* mips_int.c */ 9977db13faeSAndreas Färber void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level); 9985dc5d9f0SAurelien Jarno 999f9480ffcSths /* helper.c */ 10001239b472SKwok Cheung Yeung target_ulong exception_resume_pc (CPUMIPSState *env); 1001f9480ffcSths 1002599bc5e8SAleksandar Markovic static inline void restore_snan_bit_mode(CPUMIPSState *env) 1003599bc5e8SAleksandar Markovic { 1004599bc5e8SAleksandar Markovic set_snan_bit_is_one((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) == 0, 1005599bc5e8SAleksandar Markovic &env->active_fpu.fp_status); 1006599bc5e8SAleksandar Markovic } 1007599bc5e8SAleksandar Markovic 10087db13faeSAndreas Färber static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc, 100989fee74aSEmilio G. Cota target_ulong *cs_base, uint32_t *flags) 10106b917547Saliguori { 10116b917547Saliguori *pc = env->active_tc.PC; 10126b917547Saliguori *cs_base = 0; 1013d279279eSPetar Jovanovic *flags = env->hflags & (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK | 1014d279279eSPetar Jovanovic MIPS_HFLAG_HWRENA_ULR); 10156b917547Saliguori } 10166b917547Saliguori 101707f5a258SMarkus Armbruster #endif /* MIPS_CPU_H */ 1018