2015-03-03 10:47:18 -08:00
|
|
|
#pragma once
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
#include "MIPSCoprocessor.h"
|
2011-12-10 20:49:50 +00:00
|
|
|
#include "MIPSReflection.h"
|
2016-04-29 21:18:49 -04:00
|
|
|
#include "Convertible.h"
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
class CCOP_SCU : public CMIPSCoprocessor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum REGISTER
|
|
|
|
{
|
2018-09-01 09:57:42 -04:00
|
|
|
INDEX = 0x00,
|
|
|
|
ENTRYLO0 = 0x02,
|
|
|
|
ENTRYLO1 = 0x03,
|
|
|
|
PAGEMASK = 0x05,
|
2018-09-13 08:12:40 -04:00
|
|
|
BADVADDR = 0x08,
|
2018-04-30 21:01:23 +01:00
|
|
|
COUNT = 0x09,
|
2018-09-01 09:57:42 -04:00
|
|
|
ENTRYHI = 0x0A,
|
2018-04-30 21:01:23 +01:00
|
|
|
STATUS = 0x0C,
|
2018-09-17 17:38:41 -04:00
|
|
|
CAUSE = 0x0D,
|
2018-04-30 21:01:23 +01:00
|
|
|
EPC = 0x0E,
|
|
|
|
CPCOND0 = 0x15,
|
|
|
|
ERROREPC = 0x1E,
|
2006-06-15 04:19:30 +00:00
|
|
|
};
|
|
|
|
|
2020-08-04 13:29:59 -04:00
|
|
|
enum CAUSE_BITS
|
2019-02-21 18:37:42 -05:00
|
|
|
{
|
2020-08-04 13:29:59 -04:00
|
|
|
CAUSE_EXCCODE_INT = (0x00 << 2), //Interrupt
|
|
|
|
CAUSE_EXCCODE_TLBL = (0x02 << 2), //TLB refill exception (load or instruction fetch)
|
|
|
|
CAUSE_EXCCODE_TLBS = (0x03 << 2), //TLB refill exception (store)
|
2022-03-23 15:43:29 -04:00
|
|
|
CAUSE_EXCCODE_TRAP = (0x0D << 2), //Trap
|
2021-12-03 13:44:24 -05:00
|
|
|
CAUSE_EXCCODE_MASK = (0x1F << 2),
|
|
|
|
|
|
|
|
CAUSE_IP_2 = (1 << 10),
|
|
|
|
CAUSE_IP_3 = (1 << 11)
|
2020-08-04 13:29:59 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ENTRYLO_BITS
|
|
|
|
{
|
|
|
|
ENTRYLO_GLOBAL = (1 << 0),
|
|
|
|
ENTRYLO_VALID = (1 << 1),
|
|
|
|
ENTRYLO_DIRTY = (1 << 2)
|
2019-02-21 18:37:42 -05:00
|
|
|
};
|
|
|
|
|
2016-04-29 21:18:49 -04:00
|
|
|
struct PCCR : public convertible<uint32>
|
|
|
|
{
|
2018-04-30 21:01:23 +01:00
|
|
|
unsigned int reserved0 : 1;
|
|
|
|
unsigned int exl0 : 1;
|
|
|
|
unsigned int k0 : 1;
|
|
|
|
unsigned int s0 : 1;
|
|
|
|
unsigned int u0 : 1;
|
|
|
|
unsigned int event0 : 5;
|
|
|
|
unsigned int reserved1 : 1;
|
|
|
|
unsigned int exl1 : 1;
|
|
|
|
unsigned int k1 : 1;
|
|
|
|
unsigned int s1 : 1;
|
|
|
|
unsigned int u1 : 1;
|
|
|
|
unsigned int event1 : 5;
|
|
|
|
unsigned int reserved2 : 11;
|
|
|
|
unsigned int cte : 1;
|
2016-04-29 21:18:49 -04:00
|
|
|
};
|
|
|
|
static_assert(sizeof(PCCR) == 4, "PCCR must be 4 bytes long.");
|
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
CCOP_SCU(MIPS_REGSIZE);
|
2022-10-18 20:01:20 +01:00
|
|
|
virtual void CompileInstruction(uint32, CMipsJitter*, CMIPS*, uint32) override;
|
2018-04-30 21:01:23 +01:00
|
|
|
virtual void GetInstruction(uint32, char*) override;
|
|
|
|
virtual void GetArguments(uint32, uint32, char*) override;
|
|
|
|
virtual uint32 GetEffectiveAddress(uint32, uint32) override;
|
|
|
|
virtual MIPS_BRANCH_TYPE IsBranch(uint32) override;
|
2011-12-10 20:49:50 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
static const char* m_sRegName[];
|
2011-12-10 20:49:50 +00:00
|
|
|
|
|
|
|
protected:
|
2018-04-30 21:01:23 +01:00
|
|
|
void SetupReflectionTables();
|
|
|
|
|
|
|
|
static void ReflOpRt(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
|
|
|
|
static void ReflOpRtPcr(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
|
|
|
|
static void ReflOpRtRd(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
|
|
|
|
static void ReflOpCcOff(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32, char*, unsigned int);
|
|
|
|
|
|
|
|
static uint32 ReflEaOffset(MIPSReflection::INSTRUCTION*, CMIPS*, uint32, uint32);
|
|
|
|
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflGeneral[64];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflMfc0[32];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflMtc0[32];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflCop0[32];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflBc0[4];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflC0[64];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflMfPerf[2];
|
|
|
|
MIPSReflection::INSTRUCTION m_ReflMtPerf[2];
|
|
|
|
|
|
|
|
MIPSReflection::SUBTABLE m_ReflGeneralTable;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflMfc0Table;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflMtc0Table;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflCop0Table;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflBc0Table;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflC0Table;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflMfPerfTable;
|
|
|
|
MIPSReflection::SUBTABLE m_ReflMtPerfTable;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
private:
|
2020-08-04 17:27:16 -04:00
|
|
|
static void HandleTLBRead(CMIPS*);
|
|
|
|
static void HandleTLBWrite(CMIPS*);
|
|
|
|
|
2009-03-30 04:57:52 +00:00
|
|
|
typedef void (CCOP_SCU::*InstructionFuncConstant)();
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
static InstructionFuncConstant m_pOpGeneral[0x20];
|
|
|
|
static InstructionFuncConstant m_pOpMtc0[0x20];
|
|
|
|
static InstructionFuncConstant m_pOpBC0[0x20];
|
|
|
|
static InstructionFuncConstant m_pOpC0[0x40];
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2018-04-30 21:01:23 +01:00
|
|
|
uint8 m_nRT;
|
|
|
|
uint8 m_nRD;
|
2006-06-15 04:19:30 +00:00
|
|
|
|
|
|
|
//General
|
2018-04-30 21:01:23 +01:00
|
|
|
void MFC0();
|
|
|
|
void MTC0();
|
|
|
|
void BC0();
|
|
|
|
void C0();
|
2006-06-15 04:19:30 +00:00
|
|
|
|
2015-03-03 10:47:18 -08:00
|
|
|
//BC0
|
2018-04-30 21:01:23 +01:00
|
|
|
void BC0F();
|
|
|
|
void BC0T();
|
|
|
|
void BC0FL();
|
2009-04-28 01:20:03 +00:00
|
|
|
|
|
|
|
//C0
|
2020-08-04 17:27:16 -04:00
|
|
|
void TLBR();
|
2018-04-30 21:01:23 +01:00
|
|
|
void TLBWI();
|
2023-08-31 16:34:59 -04:00
|
|
|
void TLBP();
|
2018-04-30 21:01:23 +01:00
|
|
|
void ERET();
|
|
|
|
void EI();
|
|
|
|
void DI();
|
2011-12-10 20:49:50 +00:00
|
|
|
|
|
|
|
//Reflection tables
|
2018-04-30 21:01:23 +01:00
|
|
|
static MIPSReflection::INSTRUCTION m_cReflGeneral[64];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflCop0[32];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflMfc0[32];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflMtc0[32];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflBc0[4];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflC0[64];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflMfPerf[2];
|
|
|
|
static MIPSReflection::INSTRUCTION m_cReflMtPerf[2];
|
2006-06-15 04:19:30 +00:00
|
|
|
};
|