2007-11-02 03:05:08 +00:00
|
|
|
#ifndef _MIPS_H_
|
|
|
|
#define _MIPS_H_
|
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
#include "MemoryMap.h"
|
|
|
|
#include "MIPSArchitecture.h"
|
|
|
|
#include "MIPSCoprocessor.h"
|
|
|
|
#include "MIPSAnalysis.h"
|
|
|
|
#include "MIPSTags.h"
|
|
|
|
#include "uint128.h"
|
2007-11-06 02:08:51 +00:00
|
|
|
#include <set>
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2008-05-02 00:55:54 +00:00
|
|
|
struct REGISTER_PIPELINE
|
|
|
|
{
|
2012-03-13 06:16:33 +00:00
|
|
|
uint32 counter;
|
|
|
|
uint32 heldValue;
|
2008-05-02 00:55:54 +00:00
|
|
|
};
|
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
enum
|
|
|
|
{
|
2015-02-16 01:58:40 -05:00
|
|
|
//Must be a power of 2
|
|
|
|
MACFLAG_PIPELINE_SLOTS = 8,
|
2011-04-03 05:25:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct MACFLAG_PIPELINE
|
|
|
|
{
|
2012-03-18 01:52:44 +00:00
|
|
|
uint32 index;
|
|
|
|
uint32 values[MACFLAG_PIPELINE_SLOTS];
|
|
|
|
uint32 pipeTimes[MACFLAG_PIPELINE_SLOTS];
|
2011-04-03 05:25:07 +00:00
|
|
|
};
|
|
|
|
|
2011-10-23 20:19:51 +00:00
|
|
|
enum
|
|
|
|
{
|
2014-06-04 23:37:40 -04:00
|
|
|
MIPS_EXCEPTION_NONE = 0,
|
|
|
|
MIPS_EXCEPTION_SYSCALL,
|
|
|
|
MIPS_EXCEPTION_CHECKPENDINGINT,
|
2015-07-09 01:14:02 -04:00
|
|
|
MIPS_EXCEPTION_IDLE,
|
2014-06-04 23:37:40 -04:00
|
|
|
MIPS_EXCEPTION_RETURNFROMEXCEPTION,
|
|
|
|
MIPS_EXCEPTION_CALLMS,
|
2011-10-23 20:19:51 +00:00
|
|
|
};
|
|
|
|
|
2007-11-02 03:05:08 +00:00
|
|
|
struct MIPSSTATE
|
|
|
|
{
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nPC;
|
|
|
|
uint32 nDelayedJumpAddr;
|
|
|
|
uint32 nHasException;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
__declspec(align(16))
|
2008-01-24 20:02:39 +00:00
|
|
|
#else
|
|
|
|
__attribute__((aligned(16)))
|
2007-11-02 03:05:08 +00:00
|
|
|
#endif
|
2011-04-03 05:25:07 +00:00
|
|
|
uint128 nGPR[32];
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nHI[2];
|
|
|
|
uint32 nLO[2];
|
|
|
|
uint32 nHI1[2];
|
|
|
|
uint32 nLO1[2];
|
|
|
|
uint32 nSA;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
|
|
|
//COP0
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nCOP0[32];
|
2007-11-02 03:05:08 +00:00
|
|
|
|
|
|
|
//COP1
|
2014-09-28 03:09:17 -04:00
|
|
|
uint32 nCOP1[32];
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nCOP1A;
|
|
|
|
uint32 nFCSR;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
|
|
|
//COP2
|
|
|
|
#ifdef WIN32
|
|
|
|
__declspec(align(16))
|
2008-02-29 02:43:49 +00:00
|
|
|
#else
|
|
|
|
__attribute__((aligned(16)))
|
2007-11-02 03:05:08 +00:00
|
|
|
#endif
|
2011-04-03 05:25:07 +00:00
|
|
|
uint128 nCOP2[33];
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
uint128 nCOP2A;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
uint128 nCOP2VF_PreUp;
|
|
|
|
uint128 nCOP2VF_UpRes;
|
2009-06-06 15:38:03 +00:00
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nCOP2Q;
|
|
|
|
uint32 nCOP2I;
|
|
|
|
uint32 nCOP2P;
|
|
|
|
uint32 nCOP2R;
|
|
|
|
uint32 nCOP2CF;
|
|
|
|
uint32 nCOP2MF;
|
2015-03-20 01:41:09 -04:00
|
|
|
uint32 nCOP2SF;
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nCOP2T;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
uint32 nCOP2VI[16];
|
2008-05-02 00:55:54 +00:00
|
|
|
|
2011-04-03 05:25:07 +00:00
|
|
|
REGISTER_PIPELINE pipeQ;
|
|
|
|
REGISTER_PIPELINE pipeP;
|
|
|
|
MACFLAG_PIPELINE pipeMac;
|
2011-10-23 20:19:51 +00:00
|
|
|
|
2012-03-18 01:52:44 +00:00
|
|
|
uint32 pipeTime;
|
|
|
|
|
2012-10-09 01:56:38 +00:00
|
|
|
uint32 cmsar0;
|
2011-10-23 20:19:51 +00:00
|
|
|
uint32 callMsEnabled;
|
|
|
|
uint32 callMsAddr;
|
2007-11-02 03:05:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MIPS_INVALID_PC (0x00000001)
|
|
|
|
|
|
|
|
class CMIPS
|
|
|
|
{
|
|
|
|
public:
|
2012-04-16 02:34:36 +00:00
|
|
|
typedef uint32 (*AddressTranslator)(CMIPS*, uint32);
|
2012-03-13 06:16:33 +00:00
|
|
|
typedef std::set<uint32> BreakpointSet;
|
2007-12-01 04:08:34 +00:00
|
|
|
|
2012-03-13 06:16:33 +00:00
|
|
|
CMIPS(MEMORYMAP_ENDIANESS);
|
2007-11-02 03:05:08 +00:00
|
|
|
~CMIPS();
|
|
|
|
void ToggleBreakpoint(uint32);
|
|
|
|
bool IsBranch(uint32);
|
|
|
|
static long GetBranch(uint16);
|
2012-04-16 02:34:36 +00:00
|
|
|
static uint32 TranslateAddress64(CMIPS*, uint32);
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2008-05-02 15:00:27 +00:00
|
|
|
void Reset();
|
|
|
|
|
2007-11-02 03:05:08 +00:00
|
|
|
bool GenerateInterrupt(uint32);
|
|
|
|
bool GenerateException(uint32);
|
|
|
|
|
|
|
|
MIPSSTATE m_State;
|
|
|
|
|
2014-10-18 18:22:03 -04:00
|
|
|
void* m_vuMem = nullptr;
|
|
|
|
|
2007-11-02 03:05:08 +00:00
|
|
|
CMIPSArchitecture* m_pArch;
|
|
|
|
CMIPSCoprocessor* m_pCOP[4];
|
|
|
|
CMemoryMap* m_pMemoryMap;
|
2012-03-13 06:16:33 +00:00
|
|
|
BreakpointSet m_breakpoints;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
2014-08-16 21:42:19 -04:00
|
|
|
CMIPSAnalysis* m_analysis;
|
2007-11-02 03:05:08 +00:00
|
|
|
CMIPSTags m_Comments;
|
|
|
|
CMIPSTags m_Functions;
|
|
|
|
|
|
|
|
AddressTranslator m_pAddrTranslator;
|
|
|
|
|
|
|
|
enum REGISTER
|
|
|
|
{
|
|
|
|
R0 = 0, AT, V0, V1, A0, A1, A2, A3,
|
|
|
|
T0, T1, T2, T3, T4, T5, T6, T7,
|
|
|
|
S0, S1, S2, S3, S4, S5, S6, S7,
|
|
|
|
T8, T9, K0, K1, GP, SP, FP, RA
|
|
|
|
};
|
|
|
|
|
2008-05-13 21:43:29 +00:00
|
|
|
enum
|
|
|
|
{
|
2015-04-13 00:24:35 -04:00
|
|
|
STATUS_IE = (1 << 0),
|
|
|
|
STATUS_EXL = (1 << 1),
|
2015-04-13 00:51:25 -04:00
|
|
|
STATUS_ERL = (1 << 2),
|
|
|
|
STATUS_EIE = (1 << 16), //PS2 EE specific
|
2008-05-13 21:43:29 +00:00
|
|
|
};
|
|
|
|
|
2007-11-02 03:05:08 +00:00
|
|
|
static const char* m_sGPRName[];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|