- Renamed ARM9 to ARMv7.

- Improved ELF32 loader.
This commit is contained in:
DH 2013-11-05 21:22:58 +02:00
parent 6b22e7d90a
commit b263c3ebaf
22 changed files with 149 additions and 144 deletions

View File

@ -1,83 +0,0 @@
#include "stdafx.h"
#include "ARM9Thread.h"
#include "ARM9Decoder.h"
#include "ARM9DisAsm.h"
#include "ARM9Interpreter.h"
ARM9Thread::ARM9Thread() : CPUThread(CPU_THREAD_ARM9)
{
}
void ARM9Thread::InitRegs()
{
}
void ARM9Thread::InitStack()
{
}
u64 ARM9Thread::GetFreeStackSize() const
{
return GetStackSize() - m_stack_point;
}
void ARM9Thread::SetArg(const uint pos, const u64 arg)
{
assert(0);
}
void ARM9Thread::SetPc(const u64 pc)
{
PC = pc;
nPC = pc + 2;
}
wxString ARM9Thread::RegsToString()
{
return wxEmptyString;
}
wxString ARM9Thread::ReadRegString(wxString reg)
{
return wxEmptyString;
}
bool ARM9Thread::WriteRegString(wxString reg, wxString value)
{
return true;
}
void ARM9Thread::DoReset()
{
}
void ARM9Thread::DoRun()
{
switch(Ini.CPUDecoderMode.GetValue())
{
case 0:
//m_dec = new PPUDecoder(*new PPUDisAsm());
break;
case 1:
case 2:
m_dec = new ARM9Decoder(*new ARM9Interpreter(*this));
break;
}
}
void ARM9Thread::DoPause()
{
}
void ARM9Thread::DoResume()
{
}
void ARM9Thread::DoStop()
{
}
void ARM9Thread::DoCode()
{
}

View File

@ -1,18 +1,19 @@
#pragma once
#include "Emu/CPU/CPUDecoder.h"
#include "ARM9Opcodes.h"
#include "ARMv7Opcodes.h"
class ARM9Decoder : public CPUDecoder
class ARMv7Decoder : public CPUDecoder
{
ARM9Opcodes& m_op;
ARMv7Opcodes& m_op;
u8 m_last_instr_size;
public:
ARM9Decoder(ARM9Opcodes& op) : m_op(op)
ARMv7Decoder(ARMv7Opcodes& op) : m_op(op)
{
}
virtual void DecodeMemory(const u64 address)
virtual u8 DecodeMemory(const u64 address)
{
const u16 code0 = Memory.Read16(address);
const u16 code1 = Memory.Read16(address + 2);
@ -28,5 +29,7 @@ public:
m_op.UNK(opcode, code0, code1);
break;
}
return 2;
}
};

View File

@ -1,15 +1,15 @@
#pragma once
#include "Emu/ARM9/ARM9Opcodes.h"
#include "Emu/ARMv7/ARMv7Opcodes.h"
#include "Emu/CPU/CPUDisAsm.h"
#include "Gui/DisAsmFrame.h"
#include "Emu/Memory/Memory.h"
class ARM9DisAsm
class ARMv7DisAsm
: public CPUDisAsm
, public ARM9Opcodes
, public ARMv7Opcodes
{
public:
ARM9DisAsm(CPUDisAsmMode mode) : CPUDisAsm(mode)
ARMv7DisAsm(CPUDisAsmMode mode) : CPUDisAsm(mode)
{
}

View File

@ -1,12 +1,12 @@
#pragma once
#include "Emu/ARM9/ARM9Opcodes.h"
#include "Emu/ARMv7/ARMv7Opcodes.h"
class ARM9Interpreter : public ARM9Opcodes
class ARMv7Interpreter : public ARMv7Opcodes
{
ARM9Thread& CPU;
ARMv7Thread& CPU;
public:
ARM9Interpreter(ARM9Thread& cpu) : CPU(cpu)
ARMv7Interpreter(ARMv7Thread& cpu) : CPU(cpu)
{
}

View File

@ -1,14 +1,14 @@
#pragma once
namespace ARM9_opcodes
namespace ARMv7_opcodes
{
enum ARM9_MainOpcodes
enum ARMv7_MainOpcodes
{
};
}
class ARM9Opcodes
class ARMv7Opcodes
{
public:
virtual void NULL_OP() = 0;

View File

@ -0,0 +1,77 @@
#include "stdafx.h"
#include "ARMv7Thread.h"
#include "ARMv7Decoder.h"
#include "ARMv7DisAsm.h"
#include "ARMv7Interpreter.h"
ARMv7Thread::ARMv7Thread() : CPUThread(CPU_THREAD_ARMv7)
{
}
void ARMv7Thread::InitRegs()
{
}
void ARMv7Thread::InitStack()
{
}
u64 ARMv7Thread::GetFreeStackSize() const
{
return GetStackSize() - (m_stack_point - GetStackAddr());
}
void ARMv7Thread::SetArg(const uint pos, const u64 arg)
{
assert(0);
}
wxString ARMv7Thread::RegsToString()
{
return wxEmptyString;
}
wxString ARMv7Thread::ReadRegString(wxString reg)
{
return wxEmptyString;
}
bool ARMv7Thread::WriteRegString(wxString reg, wxString value)
{
return true;
}
void ARMv7Thread::DoReset()
{
}
void ARMv7Thread::DoRun()
{
switch(Ini.CPUDecoderMode.GetValue())
{
case 0:
//m_dec = new ARMv7Decoder(*new ARMv7DisAsm());
break;
case 1:
case 2:
m_dec = new ARMv7Decoder(*new ARMv7Interpreter(*this));
break;
}
}
void ARMv7Thread::DoPause()
{
}
void ARMv7Thread::DoResume()
{
}
void ARMv7Thread::DoStop()
{
}
void ARMv7Thread::DoCode()
{
}

View File

@ -1,10 +1,10 @@
#pragma once
#include "Emu\CPU\CPUThread.h"
class ARM9Thread : public CPUThread
class ARMv7Thread : public CPUThread
{
public:
ARM9Thread();
ARMv7Thread();
public:
virtual void InitRegs();
@ -13,8 +13,6 @@ public:
virtual void SetArg(const uint pos, const u64 arg);
public:
virtual void SetPc(const u64 pc);
virtual wxString RegsToString();
virtual wxString ReadRegString(wxString reg);
virtual bool WriteRegString(wxString reg, wxString value);

View File

@ -5,7 +5,7 @@
class CPUDecoder
{
public:
virtual void DecodeMemory(const u64 address)=0;
virtual u8 DecodeMemory(const u64 address)=0;
};
template<typename TO>

View File

@ -18,6 +18,7 @@ CPUThread::CPUThread(CPUThreadType type)
, m_free_data(false)
, m_dec(nullptr)
, m_is_step(false)
, m_is_branch(false)
{
}
@ -45,6 +46,7 @@ void CPUThread::Reset()
SetPc(0);
cycle = 0;
m_is_branch = false;
m_status = Stopped;
m_error = 0;
@ -124,9 +126,18 @@ void CPUThread::SetEntry(const u64 pc)
entry = pc;
}
void CPUThread::NextPc()
void CPUThread::NextPc(u8 instr_size)
{
SetPc(nPC);
if(m_is_branch)
{
m_is_branch = false;
SetPc(nPC);
}
else
{
PC += instr_size;
}
}
void CPUThread::SetBranch(const u64 pc)
@ -137,9 +148,15 @@ void CPUThread::SetBranch(const u64 pc)
Emu.Pause();
}
m_is_branch = true;
nPC = pc;
}
void CPUThread::SetPc(const u64 pc)
{
PC = pc;
}
void CPUThread::SetError(const u32 error)
{
if(error == 0)
@ -279,8 +296,7 @@ void CPUThread::Task()
continue;
}
m_dec->DecodeMemory(PC + m_offset);
NextPc();
NextPc(m_dec->DecodeMemory(PC + m_offset));
if(status == CPUThread_Step)
{

View File

@ -7,7 +7,7 @@ enum CPUThreadType
CPU_THREAD_PPU,
CPU_THREAD_SPU,
CPU_THREAD_RAW_SPU,
CPU_THREAD_ARM9,
CPU_THREAD_ARMv7,
};
enum CPUThreadStatus
@ -86,7 +86,7 @@ public:
case CPU_THREAD_PPU: return "PPU";
case CPU_THREAD_SPU: return "SPU";
case CPU_THREAD_RAW_SPU: return "RawSPU";
case CPU_THREAD_ARM9: return "ARM9";
case CPU_THREAD_ARMv7: return "ARMv7";
}
return "Unknown";
@ -104,6 +104,7 @@ public:
u64 PC;
u64 nPC;
u64 cycle;
bool m_is_branch;
protected:
CPUThread(CPUThreadType type);
@ -130,10 +131,10 @@ public:
int ThreadStatus();
virtual void NextPc();
virtual void SetBranch(const u64 pc);
virtual void SetPc(const u64 pc) = 0;
virtual void SetEntry(const u64 entry);
void NextPc(u8 instr_size);
void SetBranch(const u64 pc);
void SetPc(const u64 pc);
void SetEntry(const u64 entry);
void SetError(const u32 error);

View File

@ -3,7 +3,7 @@
#include "Emu\Cell\PPUThread.h"
#include "Emu\Cell\SPUThread.h"
#include "Emu\Cell\RawSPUThread.h"
#include "Emu\ARM9\ARM9Thread.h"
#include "Emu\ARMv7\ARMv7Thread.h"
CPUThreadManager::CPUThreadManager()
: m_raw_spu_num(0)
@ -32,7 +32,7 @@ CPUThread& CPUThreadManager::AddThread(CPUThreadType type)
case CPU_THREAD_PPU: new_thread = new PPUThread(); break;
case CPU_THREAD_SPU: new_thread = new SPUThread(); break;
case CPU_THREAD_RAW_SPU: new_thread = new RawSPUThread(m_raw_spu_num++); break;
case CPU_THREAD_ARM9: new_thread = new ARM9Thread(); break;
case CPU_THREAD_ARMv7: new_thread = new ARMv7Thread(); break;
default: assert(0);
}

View File

@ -1,7 +1,9 @@
#include "stdafx.h"
#include "PPCDecoder.h"
void PPCDecoder::DecodeMemory(const u64 address)
u8 PPCDecoder::DecodeMemory(const u64 address)
{
Decode(Memory.Read32(address));
return 4;
}

View File

@ -7,7 +7,7 @@ class PPCDecoder : public CPUDecoder
public:
virtual void Decode(const u32 code)=0;
virtual void DecodeMemory(const u64 address);
virtual u8 DecodeMemory(const u64 address);
};

View File

@ -44,9 +44,3 @@ void PPCThread::InitStack()
*/
}
void PPCThread::SetPc(const u64 pc)
{
PC = pc;
nPC = PC + 4;
}

View File

@ -26,10 +26,6 @@ protected:
public:
~PPCThread();
virtual void SetPc(const u64 pc) override;
void SetError(const u32 error);
protected:
virtual void DoReset() override;
};

View File

@ -311,8 +311,7 @@ void RawSPUThread::Task()
SPU.Status.SetValue(SPU_STATUS_RUNNING);
}
m_dec->DecodeMemory(PC + m_offset);
NextPc();
NextPc(m_dec->DecodeMemory(PC + m_offset));
for(uint i=0; i<bp.GetCount(); ++i)
{

View File

@ -156,9 +156,10 @@ void Emulator::Load()
{
case MACHINE_PPC64: thread_type = CPU_THREAD_PPU; break;
case MACHINE_SPU: thread_type = CPU_THREAD_SPU; break;
case MACHINE_ARM: thread_type = CPU_THREAD_ARM9; break;
case MACHINE_ARM: thread_type = CPU_THREAD_ARMv7; break;
default:
ConLog.Error("Unimplemented thread type for machine.");
is_error = true;
break;
}

View File

@ -90,9 +90,9 @@ void InstructionEditorDialog::updatePreview(wxCommandEvent& event)
unsigned long opcode;
if (t2_instr->GetValue().ToULong(&opcode, 16))
{
if(CPU->GetType() == CPU_THREAD_ARM9)
if(CPU->GetType() == CPU_THREAD_ARMv7)
{
t3_preview->SetLabel("Preview for ARM9Thread not implemented yet.");
t3_preview->SetLabel("Preview for ARMv7Thread not implemented yet.");
}
else
{

View File

@ -4,8 +4,8 @@
#include "Emu/Cell/PPUDisAsm.h"
#include "Emu/Cell/SPUDecoder.h"
#include "Emu/Cell/SPUDisAsm.h"
#include "Emu/ARM9/ARM9DisAsm.h"
#include "Emu/ARM9/ARM9Decoder.h"
#include "Emu/ARMv7/ARMv7DisAsm.h"
#include "Emu/ARMv7/ARMv7Decoder.h"
#include "InstructionEditor.cpp"
#include "RegisterEditor.cpp"
@ -135,10 +135,10 @@ void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event)
}
break;
case CPU_THREAD_ARM9:
case CPU_THREAD_ARMv7:
{
ARM9DisAsm& dis_asm = *new ARM9DisAsm(CPUDisAsm_InterpreterMode);
decoder = new ARM9Decoder(dis_asm);
ARMv7DisAsm& dis_asm = *new ARMv7DisAsm(CPUDisAsm_InterpreterMode);
decoder = new ARMv7Decoder(dis_asm);
disasm = &dis_asm;
}
break;

View File

@ -59,7 +59,7 @@ bool ELF32Loader::LoadEhdrInfo()
return false;
}
entry = ehdr.GetEntry();
entry = ehdr.GetEntry() & ~0x3;
if(entry == 0)
{
ConLog.Error("elf32 error: entry is null!");
@ -100,6 +100,7 @@ bool ELF32Loader::LoadPhdrInfo()
}
}
}
return true;
}

View File

@ -201,7 +201,7 @@
<ItemGroup>
<ClCompile Include="..\Utilities\Thread.cpp" />
<ClCompile Include="AppConnector.cpp" />
<ClCompile Include="Emu\ARM9\ARM9Thread.cpp" />
<ClCompile Include="Emu\ARMv7\ARMv7Thread.cpp" />
<ClCompile Include="Emu\Cell\MFC.cpp" />
<ClCompile Include="Emu\Cell\PPCDecoder.cpp" />
<ClCompile Include="Emu\Cell\PPCThread.cpp" />

View File

@ -50,7 +50,7 @@
<Filter Include="Emu\CPU">
<UniqueIdentifier>{041a844e-9f8b-4b4b-a4c5-6c72ecbde475}</UniqueIdentifier>
</Filter>
<Filter Include="Emu\ARM9">
<Filter Include="Emu\ARMv7">
<UniqueIdentifier>{bee6a4b4-6371-4c1b-8558-fc7888b1574e}</UniqueIdentifier>
</Filter>
</ItemGroup>
@ -319,12 +319,12 @@
<ClCompile Include="Emu\CPU\CPUThreadManager.cpp">
<Filter>Emu\CPU</Filter>
</ClCompile>
<ClCompile Include="Emu\ARM9\ARM9Thread.cpp">
<Filter>Emu\ARM9</Filter>
</ClCompile>
<ClCompile Include="Emu\Cell\PPCDecoder.cpp">
<Filter>Emu\Cell</Filter>
</ClCompile>
<ClCompile Include="Emu\ARMv7\ARMv7Thread.cpp">
<Filter>Emu\ARMv7</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="rpcs3.rc" />