2008-03-22 02:37:01 +00:00
|
|
|
#ifndef _VPU_H_
|
|
|
|
#define _VPU_H_
|
|
|
|
|
|
|
|
#include "Types.h"
|
|
|
|
#include "VIF.h"
|
|
|
|
#include "MIPS.h"
|
2008-03-24 01:18:20 +00:00
|
|
|
#include "VuExecutor.h"
|
2008-05-10 02:51:43 +00:00
|
|
|
#include "Convertible.h"
|
2008-03-22 02:37:01 +00:00
|
|
|
#include <boost/thread.hpp>
|
2008-06-30 16:31:28 +00:00
|
|
|
#include <boost/static_assert.hpp>
|
2008-03-22 02:37:01 +00:00
|
|
|
#include "zip/ZipArchiveWriter.h"
|
|
|
|
#include "zip/ZipArchiveReader.h"
|
|
|
|
|
|
|
|
class CVPU
|
|
|
|
{
|
|
|
|
public:
|
2008-07-20 17:26:08 +00:00
|
|
|
typedef CVIF::CFifoStream StreamType;
|
|
|
|
|
2008-03-22 02:37:01 +00:00
|
|
|
CVPU(CVIF&, unsigned int, const CVIF::VPUINIT&);
|
|
|
|
virtual ~CVPU();
|
2008-04-09 03:08:32 +00:00
|
|
|
|
|
|
|
void JoinThread();
|
|
|
|
|
2008-03-22 02:37:01 +00:00
|
|
|
void SingleStep();
|
|
|
|
virtual void Reset();
|
2008-06-15 19:55:28 +00:00
|
|
|
virtual uint32 GetTOP() const;
|
|
|
|
virtual uint32 GetITOP() const;
|
2008-03-22 02:37:01 +00:00
|
|
|
virtual void SaveState(CZipArchiveWriter&);
|
|
|
|
virtual void LoadState(CZipArchiveReader&);
|
2008-07-20 17:26:08 +00:00
|
|
|
virtual void ProcessPacket(StreamType&);
|
2008-03-22 02:37:01 +00:00
|
|
|
|
|
|
|
CMIPS& GetContext() const;
|
|
|
|
uint8* GetVuMemory() const;
|
2008-06-15 19:55:28 +00:00
|
|
|
bool IsRunning() const;
|
2008-03-22 02:37:01 +00:00
|
|
|
|
|
|
|
protected:
|
2008-05-10 02:51:43 +00:00
|
|
|
struct STAT : public convertible<uint32>
|
2008-03-22 02:37:01 +00:00
|
|
|
{
|
|
|
|
unsigned int nVPS : 2;
|
|
|
|
unsigned int nVEW : 1;
|
|
|
|
unsigned int nReserved0 : 3;
|
|
|
|
unsigned int nMRK : 1;
|
|
|
|
unsigned int nDBF : 1;
|
|
|
|
unsigned int nVSS : 1;
|
|
|
|
unsigned int nVFS : 1;
|
|
|
|
unsigned int nVIS : 1;
|
|
|
|
unsigned int nINT : 1;
|
|
|
|
unsigned int nER0 : 1;
|
|
|
|
unsigned int nER1 : 1;
|
|
|
|
unsigned int nReserved2 : 10;
|
|
|
|
unsigned int nFQC : 4;
|
|
|
|
unsigned int nReserved3 : 4;
|
|
|
|
};
|
|
|
|
|
2008-05-10 02:51:43 +00:00
|
|
|
struct CYCLE : public convertible<uint32>
|
2008-03-22 02:37:01 +00:00
|
|
|
{
|
|
|
|
unsigned int nCL : 8;
|
|
|
|
unsigned int nWL : 8;
|
|
|
|
unsigned int reserved : 16;
|
|
|
|
};
|
|
|
|
|
|
|
|
#pragma pack(push, 1)
|
2008-05-10 02:51:43 +00:00
|
|
|
struct CODE : public convertible<uint32>
|
2008-03-22 02:37:01 +00:00
|
|
|
{
|
|
|
|
unsigned int nIMM : 16;
|
|
|
|
unsigned int nNUM : 8;
|
|
|
|
unsigned int nCMD : 7;
|
|
|
|
unsigned int nI : 1;
|
|
|
|
};
|
2008-06-30 16:31:28 +00:00
|
|
|
BOOST_STATIC_ASSERT(sizeof(CODE) == sizeof(uint32));
|
2008-03-22 02:37:01 +00:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2008-06-15 19:55:28 +00:00
|
|
|
enum ADDMODE
|
|
|
|
{
|
|
|
|
MODE_NORMAL = 0,
|
|
|
|
MODE_OFFSET = 1,
|
|
|
|
MODE_DIFFERENCE = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
enum MASKOP
|
|
|
|
{
|
|
|
|
MASK_DATA = 0,
|
|
|
|
MASK_ROW = 1,
|
|
|
|
MASK_COL = 2,
|
|
|
|
MASK_MASK = 3
|
|
|
|
};
|
|
|
|
|
2008-07-20 17:26:08 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
CMDBUFFER_SIZE = 0x10000,
|
|
|
|
};
|
|
|
|
|
2008-03-22 02:37:01 +00:00
|
|
|
void ExecuteThreadProc();
|
2008-07-20 17:26:08 +00:00
|
|
|
void CommandThreadProc();
|
2008-03-30 22:12:52 +00:00
|
|
|
void ExecuteMicro(uint32);
|
2008-06-15 19:55:28 +00:00
|
|
|
virtual void StartMicroProgram(uint32);
|
2008-07-20 17:26:08 +00:00
|
|
|
virtual void ExecuteCommand(StreamType&, CODE);
|
|
|
|
virtual void Cmd_UNPACK(StreamType&, CODE, uint32);
|
|
|
|
|
|
|
|
void Cmd_MPG(StreamType&, CODE);
|
|
|
|
void Cmd_STROW(StreamType&, CODE);
|
|
|
|
void Cmd_STMASK(StreamType&, CODE);
|
|
|
|
|
|
|
|
bool Unpack_S32(StreamType&, uint128&);
|
|
|
|
bool Unpack_S16(StreamType&, uint128&, bool);
|
|
|
|
bool Unpack_V16(StreamType&, uint128&, unsigned int, bool);
|
|
|
|
bool Unpack_V8(StreamType&, uint128&, unsigned int, bool);
|
|
|
|
bool Unpack_V32(StreamType&, uint128&, unsigned int);
|
|
|
|
bool Unpack_V45(StreamType&, uint128&);
|
2008-03-22 02:37:01 +00:00
|
|
|
|
|
|
|
uint32 GetVbs() const;
|
2008-06-15 19:55:28 +00:00
|
|
|
uint32 GetMaskOp(unsigned int, unsigned int) const;
|
2008-03-22 02:37:01 +00:00
|
|
|
|
2008-04-23 00:15:51 +00:00
|
|
|
void DisassembleCommand(CODE);
|
|
|
|
|
2008-03-22 02:37:01 +00:00
|
|
|
STAT m_STAT;
|
|
|
|
CYCLE m_CYCLE;
|
|
|
|
CODE m_CODE;
|
|
|
|
uint8 m_NUM;
|
2008-06-15 19:55:28 +00:00
|
|
|
uint32 m_MODE;
|
|
|
|
uint32 m_R[4];
|
|
|
|
uint32 m_MASK;
|
|
|
|
uint32 m_ITOP;
|
|
|
|
uint32 m_ITOPS;
|
|
|
|
uint32 m_readTick;
|
|
|
|
uint32 m_writeTick;
|
2008-03-22 02:37:01 +00:00
|
|
|
|
2008-03-29 16:38:35 +00:00
|
|
|
uint128 m_buffer;
|
|
|
|
|
2008-03-22 02:37:01 +00:00
|
|
|
uint8* m_pMicroMem;
|
|
|
|
uint8* m_pVUMem;
|
|
|
|
CMIPS* m_pCtx;
|
|
|
|
CVIF& m_vif;
|
|
|
|
|
|
|
|
unsigned int m_vpuNumber;
|
|
|
|
|
|
|
|
bool m_endThread;
|
|
|
|
bool m_paused;
|
|
|
|
boost::thread* m_execThread;
|
|
|
|
boost::condition m_execCondition;
|
2008-03-30 22:12:52 +00:00
|
|
|
#ifdef _DEBUG
|
|
|
|
boost::condition m_execDoneCondition;
|
|
|
|
#endif
|
2008-03-22 02:37:01 +00:00
|
|
|
boost::mutex m_execMutex;
|
2008-03-24 01:18:20 +00:00
|
|
|
CVuExecutor m_executor;
|
2008-03-22 02:37:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|