Play-/tools/VuTest/TestVm.cpp

46 lines
1.2 KiB
C++
Raw Permalink Normal View History

2014-12-06 16:42:11 -05:00
#include "TestVm.h"
#include "Ps2Const.h"
CTestVm::CTestVm()
2018-04-30 21:01:23 +01:00
: m_cpu(MEMORYMAP_ENDIAN_LSBF)
, m_executor(m_cpu, PS2::MICROMEM1SIZE)
, m_vuMem(reinterpret_cast<uint8*>(framework_aligned_alloc(PS2::VUMEM1SIZE, 0x10)))
, m_microMem(reinterpret_cast<uint8*>(framework_aligned_alloc(PS2::MICROMEM1SIZE, 0x10)))
2018-04-30 21:01:23 +01:00
, m_maVu(PS2::VUMEM1SIZE - 1)
2014-12-06 16:42:11 -05:00
{
2018-04-30 21:01:23 +01:00
m_cpu.m_pMemoryMap->InsertReadMap(0x00000000, 0x00003FFF, m_vuMem, 0x00);
m_cpu.m_pMemoryMap->InsertWriteMap(0x00000000, 0x00003FFF, m_vuMem, 0x00);
2014-12-06 16:42:11 -05:00
m_cpu.m_pMemoryMap->InsertInstructionMap(0x00000000, 0x00003FFF, m_microMem, 0x01);
2018-04-30 21:01:23 +01:00
m_cpu.m_pArch = &m_maVu;
m_cpu.m_pAddrTranslator = CMIPS::TranslateAddress64;
2014-12-06 16:42:11 -05:00
m_cpu.m_vuMem = m_vuMem;
}
CTestVm::~CTestVm()
{
framework_aligned_free(m_vuMem);
framework_aligned_free(m_microMem);
2014-12-06 16:42:11 -05:00
}
void CTestVm::Reset()
{
m_cpu.Reset();
m_executor.Reset();
2014-12-06 16:42:11 -05:00
memset(m_vuMem, 0, PS2::VUMEM1SIZE);
memset(m_microMem, 0, PS2::MICROMEM1SIZE);
}
void CTestVm::ExecuteTest(uint32 startAddress)
{
m_cpu.m_State.nPC = startAddress;
2020-05-25 12:51:34 -04:00
assert(m_cpu.m_State.nHasException == 0);
2014-12-06 16:42:11 -05:00
while(!m_cpu.m_State.nHasException)
{
m_executor.Execute(100);
}
2020-05-25 12:51:34 -04:00
m_cpu.m_State.nHasException = 0;
2014-12-06 16:42:11 -05:00
}