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 1989c2149c8Sths int32_t CP0_Index; 199ead9360eSths /* CP0_MVP* are per MVP registers. */ 20001bc435bSYongbok Kim int32_t CP0_VPControl; 20101bc435bSYongbok Kim #define CP0VPCtl_DIS 0 2029c2149c8Sths int32_t CP0_Random; 203ead9360eSths int32_t CP0_VPEControl; 204ead9360eSths #define CP0VPECo_YSI 21 205ead9360eSths #define CP0VPECo_GSI 20 206ead9360eSths #define CP0VPECo_EXCPT 16 207ead9360eSths #define CP0VPECo_TE 15 208ead9360eSths #define CP0VPECo_TargTC 0 209ead9360eSths int32_t CP0_VPEConf0; 210ead9360eSths #define CP0VPEC0_M 31 211ead9360eSths #define CP0VPEC0_XTC 21 212ead9360eSths #define CP0VPEC0_TCS 19 213ead9360eSths #define CP0VPEC0_SCS 18 214ead9360eSths #define CP0VPEC0_DSC 17 215ead9360eSths #define CP0VPEC0_ICS 16 216ead9360eSths #define CP0VPEC0_MVP 1 217ead9360eSths #define CP0VPEC0_VPA 0 218ead9360eSths int32_t CP0_VPEConf1; 219ead9360eSths #define CP0VPEC1_NCX 20 220ead9360eSths #define CP0VPEC1_NCP2 10 221ead9360eSths #define CP0VPEC1_NCP1 0 222ead9360eSths target_ulong CP0_YQMask; 223ead9360eSths target_ulong CP0_VPESchedule; 224ead9360eSths target_ulong CP0_VPEScheFBack; 225ead9360eSths int32_t CP0_VPEOpt; 226ead9360eSths #define CP0VPEOpt_IWX7 15 227ead9360eSths #define CP0VPEOpt_IWX6 14 228ead9360eSths #define CP0VPEOpt_IWX5 13 229ead9360eSths #define CP0VPEOpt_IWX4 12 230ead9360eSths #define CP0VPEOpt_IWX3 11 231ead9360eSths #define CP0VPEOpt_IWX2 10 232ead9360eSths #define CP0VPEOpt_IWX1 9 233ead9360eSths #define CP0VPEOpt_IWX0 8 234ead9360eSths #define CP0VPEOpt_DWX7 7 235ead9360eSths #define CP0VPEOpt_DWX6 6 236ead9360eSths #define CP0VPEOpt_DWX5 5 237ead9360eSths #define CP0VPEOpt_DWX4 4 238ead9360eSths #define CP0VPEOpt_DWX3 3 239ead9360eSths #define CP0VPEOpt_DWX2 2 240ead9360eSths #define CP0VPEOpt_DWX1 1 241ead9360eSths #define CP0VPEOpt_DWX0 0 242284b731aSLeon Alrae uint64_t CP0_EntryLo0; 243284b731aSLeon Alrae uint64_t CP0_EntryLo1; 2442fb58b73SLeon Alrae #if defined(TARGET_MIPS64) 2452fb58b73SLeon Alrae # define CP0EnLo_RI 63 2462fb58b73SLeon Alrae # define CP0EnLo_XI 62 2472fb58b73SLeon Alrae #else 2482fb58b73SLeon Alrae # define CP0EnLo_RI 31 2492fb58b73SLeon Alrae # define CP0EnLo_XI 30 2502fb58b73SLeon Alrae #endif 25101bc435bSYongbok Kim int32_t CP0_GlobalNumber; 25201bc435bSYongbok Kim #define CP0GN_VPId 0 2539c2149c8Sths target_ulong CP0_Context; 254e98c0d17SLeon Alrae target_ulong CP0_KScratch[MIPS_KSCRATCH_NUM]; 2559c2149c8Sths int32_t CP0_PageMask; 2567207c7f9SLeon Alrae int32_t CP0_PageGrain_rw_bitmask; 2579c2149c8Sths int32_t CP0_PageGrain; 2587207c7f9SLeon Alrae #define CP0PG_RIE 31 2597207c7f9SLeon Alrae #define CP0PG_XIE 30 260e117f526SLeon Alrae #define CP0PG_ELPA 29 26192ceb440SLeon Alrae #define CP0PG_IEC 27 262cec56a73SJames Hogan target_ulong CP0_SegCtl0; 263cec56a73SJames Hogan target_ulong CP0_SegCtl1; 264cec56a73SJames Hogan target_ulong CP0_SegCtl2; 265cec56a73SJames Hogan #define CP0SC_PA 9 266cec56a73SJames Hogan #define CP0SC_PA_MASK (0x7FULL << CP0SC_PA) 267cec56a73SJames Hogan #define CP0SC_PA_1GMASK (0x7EULL << CP0SC_PA) 268cec56a73SJames Hogan #define CP0SC_AM 4 269cec56a73SJames Hogan #define CP0SC_AM_MASK (0x7ULL << CP0SC_AM) 270cec56a73SJames Hogan #define CP0SC_AM_UK 0ULL 271cec56a73SJames Hogan #define CP0SC_AM_MK 1ULL 272cec56a73SJames Hogan #define CP0SC_AM_MSK 2ULL 273cec56a73SJames Hogan #define CP0SC_AM_MUSK 3ULL 274cec56a73SJames Hogan #define CP0SC_AM_MUSUK 4ULL 275cec56a73SJames Hogan #define CP0SC_AM_USK 5ULL 276cec56a73SJames Hogan #define CP0SC_AM_UUSK 7ULL 277cec56a73SJames Hogan #define CP0SC_EU 3 278cec56a73SJames Hogan #define CP0SC_EU_MASK (1ULL << CP0SC_EU) 279cec56a73SJames Hogan #define CP0SC_C 0 280cec56a73SJames Hogan #define CP0SC_C_MASK (0x7ULL << CP0SC_C) 281cec56a73SJames Hogan #define CP0SC_MASK (CP0SC_C_MASK | CP0SC_EU_MASK | CP0SC_AM_MASK | \ 282cec56a73SJames Hogan CP0SC_PA_MASK) 283cec56a73SJames Hogan #define CP0SC_1GMASK (CP0SC_C_MASK | CP0SC_EU_MASK | CP0SC_AM_MASK | \ 284cec56a73SJames Hogan CP0SC_PA_1GMASK) 285cec56a73SJames Hogan #define CP0SC0_MASK (CP0SC_MASK | (CP0SC_MASK << 16)) 286cec56a73SJames Hogan #define CP0SC1_XAM 59 287cec56a73SJames Hogan #define CP0SC1_XAM_MASK (0x7ULL << CP0SC1_XAM) 288cec56a73SJames Hogan #define CP0SC1_MASK (CP0SC_MASK | (CP0SC_MASK << 16) | CP0SC1_XAM_MASK) 289cec56a73SJames Hogan #define CP0SC2_XR 56 290cec56a73SJames Hogan #define CP0SC2_XR_MASK (0xFFULL << CP0SC2_XR) 291cec56a73SJames Hogan #define CP0SC2_MASK (CP0SC_1GMASK | (CP0SC_1GMASK << 16) | CP0SC2_XR_MASK) 2929c2149c8Sths int32_t CP0_Wired; 293ead9360eSths int32_t CP0_SRSConf0_rw_bitmask; 294ead9360eSths int32_t CP0_SRSConf0; 295ead9360eSths #define CP0SRSC0_M 31 296ead9360eSths #define CP0SRSC0_SRS3 20 297ead9360eSths #define CP0SRSC0_SRS2 10 298ead9360eSths #define CP0SRSC0_SRS1 0 299ead9360eSths int32_t CP0_SRSConf1_rw_bitmask; 300ead9360eSths int32_t CP0_SRSConf1; 301ead9360eSths #define CP0SRSC1_M 31 302ead9360eSths #define CP0SRSC1_SRS6 20 303ead9360eSths #define CP0SRSC1_SRS5 10 304ead9360eSths #define CP0SRSC1_SRS4 0 305ead9360eSths int32_t CP0_SRSConf2_rw_bitmask; 306ead9360eSths int32_t CP0_SRSConf2; 307ead9360eSths #define CP0SRSC2_M 31 308ead9360eSths #define CP0SRSC2_SRS9 20 309ead9360eSths #define CP0SRSC2_SRS8 10 310ead9360eSths #define CP0SRSC2_SRS7 0 311ead9360eSths int32_t CP0_SRSConf3_rw_bitmask; 312ead9360eSths int32_t CP0_SRSConf3; 313ead9360eSths #define CP0SRSC3_M 31 314ead9360eSths #define CP0SRSC3_SRS12 20 315ead9360eSths #define CP0SRSC3_SRS11 10 316ead9360eSths #define CP0SRSC3_SRS10 0 317ead9360eSths int32_t CP0_SRSConf4_rw_bitmask; 318ead9360eSths int32_t CP0_SRSConf4; 319ead9360eSths #define CP0SRSC4_SRS15 20 320ead9360eSths #define CP0SRSC4_SRS14 10 321ead9360eSths #define CP0SRSC4_SRS13 0 3229c2149c8Sths int32_t CP0_HWREna; 323c570fd16Sths target_ulong CP0_BadVAddr; 324aea14095SLeon Alrae uint32_t CP0_BadInstr; 325aea14095SLeon Alrae uint32_t CP0_BadInstrP; 3269c2149c8Sths int32_t CP0_Count; 3279c2149c8Sths target_ulong CP0_EntryHi; 3289456c2fbSLeon Alrae #define CP0EnHi_EHINV 10 3296ec98bd7SPaul Burton target_ulong CP0_EntryHi_ASID_mask; 3309c2149c8Sths int32_t CP0_Compare; 3319c2149c8Sths int32_t CP0_Status; 3326af0bf9cSbellard #define CP0St_CU3 31 3336af0bf9cSbellard #define CP0St_CU2 30 3346af0bf9cSbellard #define CP0St_CU1 29 3356af0bf9cSbellard #define CP0St_CU0 28 3366af0bf9cSbellard #define CP0St_RP 27 3376ea83fedSbellard #define CP0St_FR 26 3386af0bf9cSbellard #define CP0St_RE 25 3397a387fffSths #define CP0St_MX 24 3407a387fffSths #define CP0St_PX 23 3416af0bf9cSbellard #define CP0St_BEV 22 3426af0bf9cSbellard #define CP0St_TS 21 3436af0bf9cSbellard #define CP0St_SR 20 3446af0bf9cSbellard #define CP0St_NMI 19 3456af0bf9cSbellard #define CP0St_IM 8 3467a387fffSths #define CP0St_KX 7 3477a387fffSths #define CP0St_SX 6 3487a387fffSths #define CP0St_UX 5 349623a930eSths #define CP0St_KSU 3 3506af0bf9cSbellard #define CP0St_ERL 2 3516af0bf9cSbellard #define CP0St_EXL 1 3526af0bf9cSbellard #define CP0St_IE 0 3539c2149c8Sths int32_t CP0_IntCtl; 354ead9360eSths #define CP0IntCtl_IPTI 29 35588991299SDongxue Zhang #define CP0IntCtl_IPPCI 26 356ead9360eSths #define CP0IntCtl_VS 5 3579c2149c8Sths int32_t CP0_SRSCtl; 358ead9360eSths #define CP0SRSCtl_HSS 26 359ead9360eSths #define CP0SRSCtl_EICSS 18 360ead9360eSths #define CP0SRSCtl_ESS 12 361ead9360eSths #define CP0SRSCtl_PSS 6 362ead9360eSths #define CP0SRSCtl_CSS 0 3639c2149c8Sths int32_t CP0_SRSMap; 364ead9360eSths #define CP0SRSMap_SSV7 28 365ead9360eSths #define CP0SRSMap_SSV6 24 366ead9360eSths #define CP0SRSMap_SSV5 20 367ead9360eSths #define CP0SRSMap_SSV4 16 368ead9360eSths #define CP0SRSMap_SSV3 12 369ead9360eSths #define CP0SRSMap_SSV2 8 370ead9360eSths #define CP0SRSMap_SSV1 4 371ead9360eSths #define CP0SRSMap_SSV0 0 3729c2149c8Sths int32_t CP0_Cause; 3737a387fffSths #define CP0Ca_BD 31 3747a387fffSths #define CP0Ca_TI 30 3757a387fffSths #define CP0Ca_CE 28 3767a387fffSths #define CP0Ca_DC 27 3777a387fffSths #define CP0Ca_PCI 26 3786af0bf9cSbellard #define CP0Ca_IV 23 3797a387fffSths #define CP0Ca_WP 22 3807a387fffSths #define CP0Ca_IP 8 3814de9b249Sths #define CP0Ca_IP_mask 0x0000FF00 3827a387fffSths #define CP0Ca_EC 2 383c570fd16Sths target_ulong CP0_EPC; 3849c2149c8Sths int32_t CP0_PRid; 38574dbf824SJames Hogan target_ulong CP0_EBase; 38674dbf824SJames Hogan target_ulong CP0_EBaseWG_rw_bitmask; 38774dbf824SJames Hogan #define CP0EBase_WG 11 388c870e3f5SYongbok Kim target_ulong CP0_CMGCRBase; 3899c2149c8Sths int32_t CP0_Config0; 3906af0bf9cSbellard #define CP0C0_M 31 3916af0bf9cSbellard #define CP0C0_K23 28 3926af0bf9cSbellard #define CP0C0_KU 25 3936af0bf9cSbellard #define CP0C0_MDU 20 394aff2bc6dSYongbok Kim #define CP0C0_MM 18 3956af0bf9cSbellard #define CP0C0_BM 16 3966af0bf9cSbellard #define CP0C0_BE 15 3976af0bf9cSbellard #define CP0C0_AT 13 3986af0bf9cSbellard #define CP0C0_AR 10 3996af0bf9cSbellard #define CP0C0_MT 7 4007a387fffSths #define CP0C0_VI 3 4016af0bf9cSbellard #define CP0C0_K0 0 4029c2149c8Sths int32_t CP0_Config1; 4037a387fffSths #define CP0C1_M 31 4046af0bf9cSbellard #define CP0C1_MMU 25 4056af0bf9cSbellard #define CP0C1_IS 22 4066af0bf9cSbellard #define CP0C1_IL 19 4076af0bf9cSbellard #define CP0C1_IA 16 4086af0bf9cSbellard #define CP0C1_DS 13 4096af0bf9cSbellard #define CP0C1_DL 10 4106af0bf9cSbellard #define CP0C1_DA 7 4117a387fffSths #define CP0C1_C2 6 4127a387fffSths #define CP0C1_MD 5 4136af0bf9cSbellard #define CP0C1_PC 4 4146af0bf9cSbellard #define CP0C1_WR 3 4156af0bf9cSbellard #define CP0C1_CA 2 4166af0bf9cSbellard #define CP0C1_EP 1 4176af0bf9cSbellard #define CP0C1_FP 0 4189c2149c8Sths int32_t CP0_Config2; 4197a387fffSths #define CP0C2_M 31 4207a387fffSths #define CP0C2_TU 28 4217a387fffSths #define CP0C2_TS 24 4227a387fffSths #define CP0C2_TL 20 4237a387fffSths #define CP0C2_TA 16 4247a387fffSths #define CP0C2_SU 12 4257a387fffSths #define CP0C2_SS 8 4267a387fffSths #define CP0C2_SL 4 4277a387fffSths #define CP0C2_SA 0 4289c2149c8Sths int32_t CP0_Config3; 4297a387fffSths #define CP0C3_M 31 43070409e67SMaciej W. Rozycki #define CP0C3_BPG 30 431c870e3f5SYongbok Kim #define CP0C3_CMGCR 29 432e97a391dSYongbok Kim #define CP0C3_MSAP 28 433aea14095SLeon Alrae #define CP0C3_BP 27 434aea14095SLeon Alrae #define CP0C3_BI 26 43574dbf824SJames Hogan #define CP0C3_SC 25 43670409e67SMaciej W. Rozycki #define CP0C3_IPLW 21 43770409e67SMaciej W. Rozycki #define CP0C3_MMAR 18 43870409e67SMaciej W. Rozycki #define CP0C3_MCU 17 439bbfa8f72SNathan Froyd #define CP0C3_ISA_ON_EXC 16 44070409e67SMaciej W. Rozycki #define CP0C3_ISA 14 441d279279eSPetar Jovanovic #define CP0C3_ULRI 13 4427207c7f9SLeon Alrae #define CP0C3_RXI 12 44370409e67SMaciej W. Rozycki #define CP0C3_DSP2P 11 4447a387fffSths #define CP0C3_DSPP 10 4457a387fffSths #define CP0C3_LPA 7 4467a387fffSths #define CP0C3_VEIC 6 4477a387fffSths #define CP0C3_VInt 5 4487a387fffSths #define CP0C3_SP 4 44970409e67SMaciej W. Rozycki #define CP0C3_CDMM 3 4507a387fffSths #define CP0C3_MT 2 4517a387fffSths #define CP0C3_SM 1 4527a387fffSths #define CP0C3_TL 0 4538280b12cSMaciej W. Rozycki int32_t CP0_Config4; 4548280b12cSMaciej W. Rozycki int32_t CP0_Config4_rw_bitmask; 455b4160af1SPetar Jovanovic #define CP0C4_M 31 4569456c2fbSLeon Alrae #define CP0C4_IE 29 457a0c80608SPaul Burton #define CP0C4_AE 28 458e98c0d17SLeon Alrae #define CP0C4_KScrExist 16 45970409e67SMaciej W. Rozycki #define CP0C4_MMUExtDef 14 46070409e67SMaciej W. Rozycki #define CP0C4_FTLBPageSize 8 46170409e67SMaciej W. Rozycki #define CP0C4_FTLBWays 4 46270409e67SMaciej W. Rozycki #define CP0C4_FTLBSets 0 46370409e67SMaciej W. Rozycki #define CP0C4_MMUSizeExt 0 4648280b12cSMaciej W. Rozycki int32_t CP0_Config5; 4658280b12cSMaciej W. Rozycki int32_t CP0_Config5_rw_bitmask; 466b4dd99a3SPetar Jovanovic #define CP0C5_M 31 467b4dd99a3SPetar Jovanovic #define CP0C5_K 30 468b4dd99a3SPetar Jovanovic #define CP0C5_CV 29 469b4dd99a3SPetar Jovanovic #define CP0C5_EVA 28 470b4dd99a3SPetar Jovanovic #define CP0C5_MSAEn 27 471b00c7218SYongbok Kim #define CP0C5_XNP 13 4727c979afdSLeon Alrae #define CP0C5_UFE 9 4737c979afdSLeon Alrae #define CP0C5_FRE 8 47401bc435bSYongbok Kim #define CP0C5_VP 7 475faf1f68bSLeon Alrae #define CP0C5_SBRI 6 4765204ea79SLeon Alrae #define CP0C5_MVH 5 477ce9782f4SLeon Alrae #define CP0C5_LLB 4 478f6d4dd81SYongbok Kim #define CP0C5_MRP 3 479b4dd99a3SPetar Jovanovic #define CP0C5_UFR 2 480b4dd99a3SPetar Jovanovic #define CP0C5_NFExists 0 481e397ee33Sths int32_t CP0_Config6; 482e397ee33Sths int32_t CP0_Config7; 483f6d4dd81SYongbok Kim uint64_t CP0_MAAR[MIPS_MAAR_MAX]; 484f6d4dd81SYongbok Kim int32_t CP0_MAARI; 485ead9360eSths /* XXX: Maybe make LLAddr per-TC? */ 486284b731aSLeon Alrae uint64_t lladdr; 487590bc601SPaul Brook target_ulong llval; 488590bc601SPaul Brook target_ulong llnewval; 489590bc601SPaul Brook target_ulong llreg; 490284b731aSLeon Alrae uint64_t CP0_LLAddr_rw_bitmask; 4912a6e32ddSAurelien Jarno int CP0_LLAddr_shift; 492fd88b6abSths target_ulong CP0_WatchLo[8]; 493fd88b6abSths int32_t CP0_WatchHi[8]; 4946ec98bd7SPaul Burton #define CP0WH_ASID 16 4959c2149c8Sths target_ulong CP0_XContext; 4969c2149c8Sths int32_t CP0_Framemask; 4979c2149c8Sths int32_t CP0_Debug; 498ead9360eSths #define CP0DB_DBD 31 4996af0bf9cSbellard #define CP0DB_DM 30 5006af0bf9cSbellard #define CP0DB_LSNM 28 5016af0bf9cSbellard #define CP0DB_Doze 27 5026af0bf9cSbellard #define CP0DB_Halt 26 5036af0bf9cSbellard #define CP0DB_CNT 25 5046af0bf9cSbellard #define CP0DB_IBEP 24 5056af0bf9cSbellard #define CP0DB_DBEP 21 5066af0bf9cSbellard #define CP0DB_IEXI 20 5076af0bf9cSbellard #define CP0DB_VER 15 5086af0bf9cSbellard #define CP0DB_DEC 10 5096af0bf9cSbellard #define CP0DB_SSt 8 5106af0bf9cSbellard #define CP0DB_DINT 5 5116af0bf9cSbellard #define CP0DB_DIB 4 5126af0bf9cSbellard #define CP0DB_DDBS 3 5136af0bf9cSbellard #define CP0DB_DDBL 2 5146af0bf9cSbellard #define CP0DB_DBp 1 5156af0bf9cSbellard #define CP0DB_DSS 0 516c570fd16Sths target_ulong CP0_DEPC; 5179c2149c8Sths int32_t CP0_Performance0; 5180d74a222SLeon Alrae int32_t CP0_ErrCtl; 5190d74a222SLeon Alrae #define CP0EC_WST 29 5200d74a222SLeon Alrae #define CP0EC_SPR 28 5210d74a222SLeon Alrae #define CP0EC_ITC 26 522284b731aSLeon Alrae uint64_t CP0_TagLo; 5239c2149c8Sths int32_t CP0_DataLo; 5249c2149c8Sths int32_t CP0_TagHi; 5259c2149c8Sths int32_t CP0_DataHi; 526c570fd16Sths target_ulong CP0_ErrorEPC; 5279c2149c8Sths int32_t CP0_DESAVE; 528b5dc7732Sths /* We waste some space so we can handle shadow registers like TCs. */ 529b5dc7732Sths TCState tcs[MIPS_SHADOW_SET_MAX]; 530f01be154Sths CPUMIPSFPUContext fpus[MIPS_FPU_MAX]; 5315cbdb3a3SStefan Weil /* QEMU */ 5326af0bf9cSbellard int error_code; 533aea14095SLeon Alrae #define EXCP_TLB_NOMATCH 0x1 534aea14095SLeon Alrae #define EXCP_INST_NOTAVAIL 0x2 /* No valid instruction word for BadInstr */ 5356af0bf9cSbellard uint32_t hflags; /* CPU State */ 5366af0bf9cSbellard /* TMASK defines different execution modes */ 53742c86612SJames Hogan #define MIPS_HFLAG_TMASK 0x1F5807FF 53879ef2c4cSNathan Froyd #define MIPS_HFLAG_MODE 0x00007 /* execution modes */ 539623a930eSths /* The KSU flags must be the lowest bits in hflags. The flag order 540623a930eSths must be the same as defined for CP0 Status. This allows to use 541623a930eSths the bits as the value of mmu_idx. */ 54279ef2c4cSNathan Froyd #define MIPS_HFLAG_KSU 0x00003 /* kernel/supervisor/user mode mask */ 54379ef2c4cSNathan Froyd #define MIPS_HFLAG_UM 0x00002 /* user mode flag */ 54479ef2c4cSNathan Froyd #define MIPS_HFLAG_SM 0x00001 /* supervisor mode flag */ 54579ef2c4cSNathan Froyd #define MIPS_HFLAG_KM 0x00000 /* kernel mode flag */ 54679ef2c4cSNathan Froyd #define MIPS_HFLAG_DM 0x00004 /* Debug mode */ 54779ef2c4cSNathan Froyd #define MIPS_HFLAG_64 0x00008 /* 64-bit instructions enabled */ 54879ef2c4cSNathan Froyd #define MIPS_HFLAG_CP0 0x00010 /* CP0 enabled */ 54979ef2c4cSNathan Froyd #define MIPS_HFLAG_FPU 0x00020 /* FPU enabled */ 55079ef2c4cSNathan Froyd #define MIPS_HFLAG_F64 0x00040 /* 64-bit FPU enabled */ 551b8aa4598Sths /* True if the MIPS IV COP1X instructions can be used. This also 552b8aa4598Sths controls the non-COP1X instructions RECIP.S, RECIP.D, RSQRT.S 553b8aa4598Sths and RSQRT.D. */ 55479ef2c4cSNathan Froyd #define MIPS_HFLAG_COP1X 0x00080 /* COP1X instructions enabled */ 55579ef2c4cSNathan Froyd #define MIPS_HFLAG_RE 0x00100 /* Reversed endianness */ 55601f72885SLeon Alrae #define MIPS_HFLAG_AWRAP 0x00200 /* 32-bit compatibility address wrapping */ 55779ef2c4cSNathan Froyd #define MIPS_HFLAG_M16 0x00400 /* MIPS16 mode flag */ 55879ef2c4cSNathan Froyd #define MIPS_HFLAG_M16_SHIFT 10 5594ad40f36Sbellard /* If translation is interrupted between the branch instruction and 5604ad40f36Sbellard * the delay slot, record what type of branch it is so that we can 5614ad40f36Sbellard * resume translation properly. It might be possible to reduce 5624ad40f36Sbellard * this from three bits to two. */ 563339cd2a8SLeon Alrae #define MIPS_HFLAG_BMASK_BASE 0x803800 56479ef2c4cSNathan Froyd #define MIPS_HFLAG_B 0x00800 /* Unconditional branch */ 56579ef2c4cSNathan Froyd #define MIPS_HFLAG_BC 0x01000 /* Conditional branch */ 56679ef2c4cSNathan Froyd #define MIPS_HFLAG_BL 0x01800 /* Likely branch */ 56779ef2c4cSNathan Froyd #define MIPS_HFLAG_BR 0x02000 /* branch to register (can't link TB) */ 56879ef2c4cSNathan Froyd /* Extra flags about the current pending branch. */ 569b231c103SYongbok Kim #define MIPS_HFLAG_BMASK_EXT 0x7C000 57079ef2c4cSNathan Froyd #define MIPS_HFLAG_B16 0x04000 /* branch instruction was 16 bits */ 57179ef2c4cSNathan Froyd #define MIPS_HFLAG_BDS16 0x08000 /* branch requires 16-bit delay slot */ 57279ef2c4cSNathan Froyd #define MIPS_HFLAG_BDS32 0x10000 /* branch requires 32-bit delay slot */ 573b231c103SYongbok Kim #define MIPS_HFLAG_BDS_STRICT 0x20000 /* Strict delay slot size */ 574b231c103SYongbok Kim #define MIPS_HFLAG_BX 0x40000 /* branch exchanges execution mode */ 57579ef2c4cSNathan Froyd #define MIPS_HFLAG_BMASK (MIPS_HFLAG_BMASK_BASE | MIPS_HFLAG_BMASK_EXT) 576853c3240SJia Liu /* MIPS DSP resources access. */ 577b231c103SYongbok Kim #define MIPS_HFLAG_DSP 0x080000 /* Enable access to MIPS DSP resources. */ 578b231c103SYongbok Kim #define MIPS_HFLAG_DSPR2 0x100000 /* Enable access to MIPS DSPR2 resources. */ 579d279279eSPetar Jovanovic /* Extra flag about HWREna register. */ 580b231c103SYongbok Kim #define MIPS_HFLAG_HWRENA_ULR 0x200000 /* ULR bit from HWREna is set. */ 581faf1f68bSLeon Alrae #define MIPS_HFLAG_SBRI 0x400000 /* R6 SDBBP causes RI excpt. in user mode */ 582339cd2a8SLeon Alrae #define MIPS_HFLAG_FBNSLOT 0x800000 /* Forbidden slot */ 583e97a391dSYongbok Kim #define MIPS_HFLAG_MSA 0x1000000 5847c979afdSLeon Alrae #define MIPS_HFLAG_FRE 0x2000000 /* FRE enabled */ 585e117f526SLeon Alrae #define MIPS_HFLAG_ELPA 0x4000000 5860d74a222SLeon Alrae #define MIPS_HFLAG_ITC_CACHE 0x8000000 /* CACHE instr. operates on ITC tag */ 58742c86612SJames Hogan #define MIPS_HFLAG_ERL 0x10000000 /* error level flag */ 5886af0bf9cSbellard target_ulong btarget; /* Jump / branch target */ 5891ba74fb8Saurel32 target_ulong bcond; /* Branch condition (if needed) */ 590a316d335Sbellard 5917a387fffSths int SYNCI_Step; /* Address step size for SYNCI */ 5927a387fffSths int CCRes; /* Cycle count resolution/divisor */ 593ead9360eSths uint32_t CP0_Status_rw_bitmask; /* Read/write bits in CP0_Status */ 594ead9360eSths uint32_t CP0_TCStatus_rw_bitmask; /* Read/write bits in CP0_TCStatus */ 595e189e748Sths int insn_flags; /* Supported instruction set */ 5967a387fffSths 5971f5c00cfSAlex Bennée /* Fields up to this point are cleared by a CPU reset */ 5981f5c00cfSAlex Bennée struct {} end_reset_fields; 5991f5c00cfSAlex Bennée 600a316d335Sbellard CPU_COMMON 6016ae81775Sths 602f0c3c505SAndreas Färber /* Fields from here on are preserved across CPU reset. */ 60351cc2e78SBlue Swirl CPUMIPSMVPContext *mvp; 6043c7b48b7SPaul Brook #if !defined(CONFIG_USER_ONLY) 60551cc2e78SBlue Swirl CPUMIPSTLBContext *tlb; 6063c7b48b7SPaul Brook #endif 60751cc2e78SBlue Swirl 608c227f099SAnthony Liguori const mips_def_t *cpu_model; 60933ac7f16Sths void *irq[8]; 6101246b259SStefan Weil QEMUTimer *timer; /* Internal timer */ 61134fa7e83SLeon Alrae MemoryRegion *itc_tag; /* ITC Configuration Tags */ 61289777fd1SLeon Alrae target_ulong exception_base; /* ExceptionBase input to the core */ 6136af0bf9cSbellard }; 6146af0bf9cSbellard 615416bf936SPaolo Bonzini /** 616416bf936SPaolo Bonzini * MIPSCPU: 617416bf936SPaolo Bonzini * @env: #CPUMIPSState 618416bf936SPaolo Bonzini * 619416bf936SPaolo Bonzini * A MIPS CPU. 620416bf936SPaolo Bonzini */ 621416bf936SPaolo Bonzini struct MIPSCPU { 622416bf936SPaolo Bonzini /*< private >*/ 623416bf936SPaolo Bonzini CPUState parent_obj; 624416bf936SPaolo Bonzini /*< public >*/ 625416bf936SPaolo Bonzini 626416bf936SPaolo Bonzini CPUMIPSState env; 627416bf936SPaolo Bonzini }; 628416bf936SPaolo Bonzini 629416bf936SPaolo Bonzini static inline MIPSCPU *mips_env_get_cpu(CPUMIPSState *env) 630416bf936SPaolo Bonzini { 631416bf936SPaolo Bonzini return container_of(env, MIPSCPU, env); 632416bf936SPaolo Bonzini } 633416bf936SPaolo Bonzini 634416bf936SPaolo Bonzini #define ENV_GET_CPU(e) CPU(mips_env_get_cpu(e)) 635416bf936SPaolo Bonzini 636416bf936SPaolo Bonzini #define ENV_OFFSET offsetof(MIPSCPU, env) 637416bf936SPaolo Bonzini 6389a78eeadSStefan Weil void mips_cpu_list (FILE *f, fprintf_function cpu_fprintf); 639647de6caSths 6409467d44cSths #define cpu_signal_handler cpu_mips_signal_handler 641c732abe2Sj_mayer #define cpu_list mips_cpu_list 6429467d44cSths 643084d0497SRichard Henderson extern void cpu_wrdsp(uint32_t rs, uint32_t mask_num, CPUMIPSState *env); 644084d0497SRichard Henderson extern uint32_t cpu_rddsp(uint32_t mask_num, CPUMIPSState *env); 645084d0497SRichard Henderson 646623a930eSths /* MMU modes definitions. We carefully match the indices with our 647623a930eSths hflags layout. */ 6486ebbf390Sj_mayer #define MMU_MODE0_SUFFIX _kernel 649623a930eSths #define MMU_MODE1_SUFFIX _super 650623a930eSths #define MMU_MODE2_SUFFIX _user 65142c86612SJames Hogan #define MMU_MODE3_SUFFIX _error 652623a930eSths #define MMU_USER_IDX 2 653b0fc6003SJames Hogan 654b0fc6003SJames Hogan static inline int hflags_mmu_index(uint32_t hflags) 655b0fc6003SJames Hogan { 65642c86612SJames Hogan if (hflags & MIPS_HFLAG_ERL) { 65742c86612SJames Hogan return 3; /* ERL */ 65842c86612SJames Hogan } else { 659b0fc6003SJames Hogan return hflags & MIPS_HFLAG_KSU; 660b0fc6003SJames Hogan } 66142c86612SJames Hogan } 662b0fc6003SJames Hogan 66397ed5ccdSBenjamin Herrenschmidt static inline int cpu_mmu_index (CPUMIPSState *env, bool ifetch) 6646ebbf390Sj_mayer { 665b0fc6003SJames Hogan return hflags_mmu_index(env->hflags); 6666ebbf390Sj_mayer } 6676ebbf390Sj_mayer 668022c62cbSPaolo Bonzini #include "exec/cpu-all.h" 6696af0bf9cSbellard 6706af0bf9cSbellard /* Memory access type : 6716af0bf9cSbellard * may be needed for precise access rights control and precise exceptions. 6726af0bf9cSbellard */ 6736af0bf9cSbellard enum { 6746af0bf9cSbellard /* 1 bit to define user level / supervisor access */ 6756af0bf9cSbellard ACCESS_USER = 0x00, 6766af0bf9cSbellard ACCESS_SUPER = 0x01, 6776af0bf9cSbellard /* 1 bit to indicate direction */ 6786af0bf9cSbellard ACCESS_STORE = 0x02, 6796af0bf9cSbellard /* Type of instruction that generated the access */ 6806af0bf9cSbellard ACCESS_CODE = 0x10, /* Code fetch access */ 6816af0bf9cSbellard ACCESS_INT = 0x20, /* Integer load/store access */ 6826af0bf9cSbellard ACCESS_FLOAT = 0x30, /* floating point load/store access */ 6836af0bf9cSbellard }; 6846af0bf9cSbellard 6856af0bf9cSbellard /* Exceptions */ 6866af0bf9cSbellard enum { 6876af0bf9cSbellard EXCP_NONE = -1, 6886af0bf9cSbellard EXCP_RESET = 0, 6896af0bf9cSbellard EXCP_SRESET, 6906af0bf9cSbellard EXCP_DSS, 6916af0bf9cSbellard EXCP_DINT, 69214e51cc7Sths EXCP_DDBL, 69314e51cc7Sths EXCP_DDBS, 6946af0bf9cSbellard EXCP_NMI, 6956af0bf9cSbellard EXCP_MCHECK, 69614e51cc7Sths EXCP_EXT_INTERRUPT, /* 8 */ 6976af0bf9cSbellard EXCP_DFWATCH, 69814e51cc7Sths EXCP_DIB, 6996af0bf9cSbellard EXCP_IWATCH, 7006af0bf9cSbellard EXCP_AdEL, 7016af0bf9cSbellard EXCP_AdES, 7026af0bf9cSbellard EXCP_TLBF, 7036af0bf9cSbellard EXCP_IBE, 70414e51cc7Sths EXCP_DBp, /* 16 */ 7056af0bf9cSbellard EXCP_SYSCALL, 70614e51cc7Sths EXCP_BREAK, 7074ad40f36Sbellard EXCP_CpU, 7086af0bf9cSbellard EXCP_RI, 7096af0bf9cSbellard EXCP_OVERFLOW, 7106af0bf9cSbellard EXCP_TRAP, 7115a5012ecSths EXCP_FPE, 71214e51cc7Sths EXCP_DWATCH, /* 24 */ 7136af0bf9cSbellard EXCP_LTLBL, 7146af0bf9cSbellard EXCP_TLBL, 7156af0bf9cSbellard EXCP_TLBS, 7166af0bf9cSbellard EXCP_DBE, 717ead9360eSths EXCP_THREAD, 71814e51cc7Sths EXCP_MDMX, 71914e51cc7Sths EXCP_C2E, 72014e51cc7Sths EXCP_CACHE, /* 32 */ 721853c3240SJia Liu EXCP_DSPDIS, 722e97a391dSYongbok Kim EXCP_MSADIS, 723e97a391dSYongbok Kim EXCP_MSAFPE, 72492ceb440SLeon Alrae EXCP_TLBXI, 72592ceb440SLeon Alrae EXCP_TLBRI, 72614e51cc7Sths 72792ceb440SLeon Alrae EXCP_LAST = EXCP_TLBRI, 7286af0bf9cSbellard }; 729590bc601SPaul Brook /* Dummy exception for conditional stores. */ 730590bc601SPaul Brook #define EXCP_SC 0x100 7316af0bf9cSbellard 732f249412cSEdgar E. Iglesias /* 73326aa3d9aSPhilippe Mathieu-Daudé * This is an internally generated WAKE request line. 734f249412cSEdgar E. Iglesias * It is driven by the CPU itself. Raised when the MT 735f249412cSEdgar E. Iglesias * block wants to wake a VPE from an inactive state and 736f249412cSEdgar E. Iglesias * cleared when VPE goes from active to inactive. 737f249412cSEdgar E. Iglesias */ 738f249412cSEdgar E. Iglesias #define CPU_INTERRUPT_WAKE CPU_INTERRUPT_TGT_INT_0 739f249412cSEdgar E. Iglesias 740388bb21aSths int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); 7416af0bf9cSbellard 742c4c8146cSIgor Mammedov #define cpu_init(cpu_model) cpu_generic_init(TYPE_MIPS_CPU, cpu_model) 743a7519f2bSIgor Mammedov 744a7519f2bSIgor Mammedov #define MIPS_CPU_TYPE_SUFFIX "-" TYPE_MIPS_CPU 745a7519f2bSIgor Mammedov #define MIPS_CPU_TYPE_NAME(model) model MIPS_CPU_TYPE_SUFFIX 746*0dacec87SIgor Mammedov #define CPU_RESOLVING_TYPE TYPE_MIPS_CPU 747a7519f2bSIgor Mammedov 748a7519f2bSIgor Mammedov bool cpu_supports_cps_smp(const char *cpu_type); 749a7519f2bSIgor Mammedov bool cpu_supports_isa(const char *cpu_type, unsigned int isa); 75089777fd1SLeon Alrae void cpu_set_exception_base(int vp_index, target_ulong address); 75130bf942dSAndreas Färber 7525dc5d9f0SAurelien Jarno /* mips_int.c */ 7537db13faeSAndreas Färber void cpu_mips_soft_irq(CPUMIPSState *env, int irq, int level); 7545dc5d9f0SAurelien Jarno 755f9480ffcSths /* helper.c */ 7561239b472SKwok Cheung Yeung target_ulong exception_resume_pc (CPUMIPSState *env); 757f9480ffcSths 758599bc5e8SAleksandar Markovic static inline void restore_snan_bit_mode(CPUMIPSState *env) 759599bc5e8SAleksandar Markovic { 760599bc5e8SAleksandar Markovic set_snan_bit_is_one((env->active_fpu.fcr31 & (1 << FCR31_NAN2008)) == 0, 761599bc5e8SAleksandar Markovic &env->active_fpu.fp_status); 762599bc5e8SAleksandar Markovic } 763599bc5e8SAleksandar Markovic 7647db13faeSAndreas Färber static inline void cpu_get_tb_cpu_state(CPUMIPSState *env, target_ulong *pc, 76589fee74aSEmilio G. Cota target_ulong *cs_base, uint32_t *flags) 7666b917547Saliguori { 7676b917547Saliguori *pc = env->active_tc.PC; 7686b917547Saliguori *cs_base = 0; 769d279279eSPetar Jovanovic *flags = env->hflags & (MIPS_HFLAG_TMASK | MIPS_HFLAG_BMASK | 770d279279eSPetar Jovanovic MIPS_HFLAG_HWRENA_ULR); 7716b917547Saliguori } 7726b917547Saliguori 77307f5a258SMarkus Armbruster #endif /* MIPS_CPU_H */ 774