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
|
|
|
|
{
|
|
|
|
uint32 target;
|
|
|
|
uint32 heldValue;
|
|
|
|
};
|
|
|
|
|
2007-11-02 03:05:08 +00:00
|
|
|
struct MIPSSTATE
|
|
|
|
{
|
|
|
|
uint32 nPC;
|
|
|
|
uint32 nDelayedJumpAddr;
|
2007-11-22 19:49:28 +00:00
|
|
|
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
|
|
|
|
uint128 nGPR[32];
|
|
|
|
|
|
|
|
uint32 nHI[2];
|
|
|
|
uint32 nLO[2];
|
|
|
|
uint32 nHI1[2];
|
|
|
|
uint32 nLO1[2];
|
|
|
|
uint32 nSA;
|
|
|
|
|
|
|
|
//COP0
|
|
|
|
uint32 nCOP0[32];
|
|
|
|
|
|
|
|
//COP1
|
|
|
|
uint32 nCOP10[32];
|
|
|
|
uint32 nCOP11[32];
|
|
|
|
uint32 nCOP1A;
|
|
|
|
uint32 nFCSR;
|
|
|
|
|
|
|
|
//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
|
|
|
|
uint128 nCOP2[32];
|
|
|
|
|
|
|
|
uint128 nCOP2A;
|
|
|
|
|
|
|
|
uint128 nCOP2ZF;
|
|
|
|
uint128 nCOP2SF;
|
|
|
|
|
|
|
|
uint32 nCOP2Q;
|
|
|
|
uint32 nCOP2I;
|
|
|
|
uint32 nCOP2P;
|
|
|
|
uint32 nCOP2R;
|
|
|
|
uint32 nCOP2CF;
|
|
|
|
|
|
|
|
uint32 nCOP2VI[16];
|
2008-05-02 00:55:54 +00:00
|
|
|
|
|
|
|
REGISTER_PIPELINE pipeQ;
|
|
|
|
REGISTER_PIPELINE pipeP;
|
2007-11-02 03:05:08 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#define MIPS_INVALID_PC (0x00000001)
|
|
|
|
|
|
|
|
class CMIPS
|
|
|
|
{
|
|
|
|
public:
|
2007-12-01 04:08:34 +00:00
|
|
|
typedef unsigned int (*TickFunctionType)(unsigned int, CMIPS*);
|
|
|
|
typedef void (*SysCallHandlerType)(CMIPS*);
|
|
|
|
typedef uint32 (*AddressTranslator)(CMIPS*, uint32, uint32);
|
2007-12-06 21:36:12 +00:00
|
|
|
typedef std::set<uint32> BreakpointSet;
|
2007-12-01 04:08:34 +00:00
|
|
|
|
|
|
|
CMIPS(MEMORYMAP_ENDIANESS, uint32, uint32);
|
2007-11-02 03:05:08 +00:00
|
|
|
~CMIPS();
|
|
|
|
void ToggleBreakpoint(uint32);
|
|
|
|
bool MustBreak();
|
|
|
|
bool IsBranch(uint32);
|
|
|
|
static long GetBranch(uint16);
|
|
|
|
static uint32 TranslateAddress64(CMIPS*, uint32, uint32);
|
2007-12-01 04:08:34 +00:00
|
|
|
static void DefaultSysCallHandler(CMIPS*);
|
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;
|
|
|
|
uint32 m_nIllOpcode;
|
|
|
|
|
|
|
|
int m_nQuota;
|
|
|
|
CMIPSArchitecture* m_pArch;
|
|
|
|
CMIPSCoprocessor* m_pCOP[4];
|
|
|
|
CMemoryMap* m_pMemoryMap;
|
2007-12-06 21:36:12 +00:00
|
|
|
BreakpointSet m_breakpoints;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
|
|
|
CMIPSAnalysis* m_pAnalysis;
|
|
|
|
CMIPSTags m_Comments;
|
|
|
|
CMIPSTags m_Functions;
|
|
|
|
|
|
|
|
AddressTranslator m_pAddrTranslator;
|
2007-11-04 20:24:56 +00:00
|
|
|
SysCallHandlerType m_pSysCallHandler;
|
2007-11-06 02:08:51 +00:00
|
|
|
TickFunctionType m_pTickFunction;
|
2007-11-05 01:28:31 +00:00
|
|
|
void* m_handlerParam;
|
2007-11-02 03:05:08 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
{
|
|
|
|
STATUS_INT = 0x01,
|
|
|
|
STATUS_EXL = 0x02,
|
|
|
|
STATUS_ERL = 0x04
|
|
|
|
};
|
|
|
|
|
2007-11-02 03:05:08 +00:00
|
|
|
static const char* m_sGPRName[];
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|