1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 02:32:36 +01:00

- Fixed sys_ppu_thread_exit.

- Disabled some dbg tools.
This commit is contained in:
DH 2013-08-17 19:23:03 +03:00
parent 0aff049960
commit 2f5fa75bb4
16 changed files with 152 additions and 113 deletions

View File

@ -1,6 +1,6 @@
#pragma once
#include "PPCInstrTable.h"
#pragma warning( disable : 4800 4554 )
#pragma warning( disable : 4800 )
template<typename TO>
class InstrCaller
@ -485,21 +485,21 @@ static InstrList<count2, TO>* connect_list(InstrList<count1, TO>* parent, InstrL
}
template<typename TO, uint from, uint to>
static InstrList<1 << (to - from + 1), TO>* new_list(const CodeField<from, to>& func, InstrCaller<TO>* error_func = nullptr)
static InstrList<1 << CodeField<from, to>::size, TO>* new_list(const CodeField<from, to>& func, InstrCaller<TO>* error_func = nullptr)
{
return new InstrList<1 << (to - from + 1), TO>(func, error_func);
return new InstrList<1 << CodeField<from, to>::size, TO>(func, error_func);
}
template<int count, typename TO, uint from, uint to>
static InstrList<1 << (to - from + 1), TO>* new_list(InstrList<count, TO>* parent, int opcode, const CodeField<from, to>& func, InstrCaller<TO>* error_func = nullptr)
static InstrList<1 << CodeField<from, to>::size, TO>* new_list(InstrList<count, TO>* parent, int opcode, const CodeField<from, to>& func, InstrCaller<TO>* error_func = nullptr)
{
return connect_list(parent, new InstrList<1 << (to - from + 1), TO>(func, error_func), opcode);
return connect_list(parent, new InstrList<1 << CodeField<from, to>::size, TO>(func, error_func), opcode);
}
template<int count, typename TO, uint from, uint to>
static InstrList<1 << (to - from + 1), TO>* new_list(InstrList<count, TO>* parent, const CodeField<from, to>& func, InstrCaller<TO>* error_func = nullptr)
static InstrList<1 << CodeField<from, to>::size, TO>* new_list(InstrList<count, TO>* parent, const CodeField<from, to>& func, InstrCaller<TO>* error_func = nullptr)
{
return connect_list(parent, new InstrList<1 << (to - from + 1), TO>(func, error_func));
return connect_list(parent, new InstrList<1 << CodeField<from, to>::size, TO>(func, error_func));
}
template<typename TO, int opcode, int count>

View File

@ -1,10 +1,12 @@
#pragma once
template<int size, typename T> __forceinline static T sign(const T value)
template<uint size, typename T> __forceinline static T sign(const T value)
{
if(value & (1 << (size - 1)))
static_assert(size > 0 && size < sizeof(T) * 8, "Bad size");
static const T sub_value = T(1) << size;
if(value & (T(1) << (size - 1)))
{
return value - (1 << size);
return value - sub_value;
}
return value;
@ -52,6 +54,7 @@ public:
{
}
static const u32 size = to - from + 1;
static const u32 shift = 31 - to;
static const u32 mask = ((1ULL << ((to - from) + 1)) - 1) << shift;

View File

@ -10,8 +10,8 @@ PPCThread* GetCurrentPPCThread()
PPCThread::PPCThread(PPCThreadType type)
: ThreadBase(true, "PPCThread")
, m_type(type)
, DisAsmFrame(NULL)
, m_dec(NULL)
, DisAsmFrame(nullptr)
, m_dec(nullptr)
, stack_size(0)
, stack_addr(0)
, m_prio(0)
@ -28,12 +28,13 @@ PPCThread::~PPCThread()
void PPCThread::Close()
{
Stop();
if(DisAsmFrame)
{
DisAsmFrame->Close();
DisAsmFrame = nullptr;
}
Stop();
}
void PPCThread::Reset()
@ -260,12 +261,11 @@ void PPCThread::Stop()
wxGetApp().SendDbgCommand(DID_STOP_THREAD, this);
m_status = Stopped;
ThreadBase::Stop();
Reset();
DoStop();
Emu.CheckStatus();
ThreadBase::Stop();
wxGetApp().SendDbgCommand(DID_STOPED_THREAD, this);
}

View File

@ -50,10 +50,11 @@ void PPCThreadManager::RemoveThread(const u32 id)
if(m_threads[i].GetId() != id) continue;
wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, &m_threads[i]);
m_threads[i].Close();
delete &m_threads[i];
PPCThread* thr = &m_threads[i];
m_threads.RemoveFAt(i);
wxGetApp().SendDbgCommand(DID_REMOVE_THREAD, thr);
thr->Close();
delete thr;
i--;
}

View File

@ -541,7 +541,9 @@ namespace PPU_instr
/*0x33a*/bind_instr(g1f_list, SRADI1, RA, RS, sh, RC);
/*0x33b*/bind_instr(g1f_list, SRADI2, RA, RS, sh, RC);
/*0x356*/bind_instr(g1f_list, EIEIO);
/*0x387*/bind_instr(g1f_list, STVLXL, VS, RA, RB);
/*0x39a*/bind_instr(g1f_list, EXTSH, RA, RS, RC);
/*0x387*/bind_instr(g1f_list, STVRXL, VS, RA, RB);
/*0x3ba*/bind_instr(g1f_list, EXTSB, RA, RS, RC);
/*0x3d7*/bind_instr(g1f_list, STFIWX, FRS, RA, RB);
/*0x3da*/bind_instr(g1f_list, EXTSW, RA, RS, RC);

View File

@ -739,7 +739,7 @@ public:
virtual void SRADI1(u32 ra, u32 rs, u32 sh, bool rc) = 0;
virtual void SRADI2(u32 ra, u32 rs, u32 sh, bool rc) = 0;
virtual void EIEIO() = 0;
virtual void STVLXL(u32 sd, u32 ra, u32 rb) = 0;
virtual void STVLXL(u32 vs, u32 ra, u32 rb) = 0;
virtual void EXTSH(u32 ra, u32 rs, bool rc) = 0;
virtual void STVRXL(u32 sd, u32 ra, u32 rb) = 0;
virtual void EXTSB(u32 ra, u32 rs, bool rc) = 0;

View File

@ -178,6 +178,7 @@ bool dump_enable = false;
void PPUThread::DoCode(const s32 code)
{
#ifdef _DEBUG
static bool is_last_enabled = false;
if(dump_enable)
@ -208,6 +209,7 @@ void PPUThread::DoCode(const s32 code)
cycle = 0;
TB++;
}
#endif
m_dec->Decode(code);
}

View File

@ -3,7 +3,7 @@
#include "Emu/Cell/PPCInstrTable.h"
#define CMD_DEBUG 0
#define DUMP_VERTEX_DATA 1
#define DUMP_VERTEX_DATA 0
#if CMD_DEBUG
#define CMD_LOG ConLog.Write
@ -199,7 +199,6 @@ void GLRSXThread::Task()
{
u32 addr = cmd & ~(CELL_GCM_METHOD_FLAG_JUMP | CELL_GCM_METHOD_FLAG_NON_INCREMENT);
addr &= ~0x1000;
//0x30101000 + 0x80bf000 = 0x80be000
ConLog.Warning("rsx jump(0x%x) #addr=0x%x, cmd=0x%x, get=0x%x, put=0x%x", addr, p.m_ioAddress + get, cmd, get, put);
re(p.m_ctrl->get, addr);
continue;
@ -1337,7 +1336,7 @@ void GLGSRender::ExecCMD()
m_program.SetTex(i);
tex.Init();
checkForGlError("tex.Init");
tex.Save();
//tex.Save();
}
if(m_indexed_array.m_count)

View File

@ -140,19 +140,13 @@ bool IsLoadedFunc(u32 id)
return false;
}
bool CallFunc(u32 id)
bool CallFunc(u32 num)
{
for(u32 i=0; i<g_modules_funcs_list.GetCount(); ++i)
{
if(g_modules_funcs_list[i].id == id)
{
(*g_modules_funcs_list[i].func)();
return true;
}
}
if(num - 1024 >= g_modules_funcs_list.GetCount())
return false;
(*g_modules_funcs_list[num - 1024].func)();
return true;
}
bool UnloadFunc(u32 id)
@ -170,6 +164,19 @@ bool UnloadFunc(u32 id)
return false;
}
u32 GetFuncNumById(u32 id)
{
for(u32 i=0; i<g_modules_funcs_list.GetCount(); ++i)
{
if(g_modules_funcs_list[i].id == id)
{
return 1024 + i;
}
}
return id;
}
void UnloadModules()
{
for(u32 i=0; i<g_max_module_id; ++i)

View File

@ -8,8 +8,6 @@ public:
virtual void operator()() = 0;
};
static func_caller *null_func = nullptr;
//TODO
struct ModuleFunc
{
@ -74,8 +72,9 @@ public:
};
bool IsLoadedFunc(u32 id);
bool CallFunc(u32 id);
bool CallFunc(u32 num);
bool UnloadFunc(u32 id);
void UnloadModules();
u32 GetFuncNumById(u32 id);
Module* GetModuleByName(const wxString& name);
Module* GetModuleById(u16 id);

View File

@ -3,6 +3,9 @@
#include "Modules.h"
#include "SC_FUNC.h"
void default_syscall();
static func_caller *null_func = bind_func(default_syscall);
static func_caller* sc_table[1024] =
{
null_func, bind_func(sys_process_getpid), null_func, bind_func(sys_process_exit), null_func, //4
@ -212,28 +215,16 @@ static func_caller* sc_table[1024] =
null_func, null_func, null_func, bind_func(cellGcmCallback), //1024
};
SysCalls::SysCalls(PPUThread& cpu) : CPU(cpu)
{
}
SysCalls::~SysCalls()
{
}
bool enable_log = false;
void SysCalls::DoSyscall(u32 code)
void default_syscall()
{
if(code < 0x400)
{
if(sc_table[code])
{
(*sc_table[code])();
return;
}
declCPU();
u32 code = CPU.GPR[11];
//TODO: remove this
switch(code)
{
/*
//process
case 2: RESULT(lv2ProcessWaitForChild(CPU)); return;
case 4: RESULT(lv2ProcessGetStatus(CPU)); return;
@ -244,6 +235,7 @@ void SysCalls::DoSyscall(u32 code)
case 19: RESULT(lv2ProcessKill(CPU)); return;
case 23: RESULT(lv2ProcessWaitForChild2(CPU)); return;
case 25: RESULT(lv2ProcessGetSdkVersion(CPU)); return;
*/
//timer
case 141:
case 142:
@ -275,6 +267,22 @@ void SysCalls::DoSyscall(u32 code)
return;
}
SysCalls::SysCalls(PPUThread& cpu) : CPU(cpu)
{
}
SysCalls::~SysCalls()
{
}
void SysCalls::DoSyscall(u32 code)
{
if(code < 1024)
{
(*sc_table[code])();
return;
}
if(CallFunc(code))
{
return;

View File

@ -21,7 +21,9 @@ int sys_ppu_thread_exit(int errorcode)
sysPrxForUser.Warning("sys_ppu_thread_exit(errorcode=%d)", errorcode);
}
Emu.GetCPU().RemoveThread(GetCurrentPPUThread().GetId());
PPUThread& thr = GetCurrentPPUThread();
thr.SetExitStatus(errorcode);
wxGetApp().SendDbgCommand(DID_EXIT_THR_SYSCALL, &thr);
return CELL_OK;
}

View File

@ -74,6 +74,8 @@ public:
void HandleCommand(wxCommandEvent& event)
{
event.Skip();
switch(event.GetId())
{
case DID_STOP_EMU:
@ -88,10 +90,13 @@ public:
case DID_RESUME_EMU:
m_btn_run->SetLabel("Pause");
break;
case DID_EXIT_THR_SYSCALL:
Emu.GetCPU().RemoveThread(((PPCThread*)event.GetClientData())->GetId());
break;
}
UpdateUI();
event.Skip();
}
};

View File

@ -278,9 +278,17 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
void InterpreterDisAsmFrame::WriteRegs()
{
if(!CPU)
{
m_regs->Clear();
return;
}
const wxString data = CPU->RegsToString();
m_regs->Freeze();
m_regs->Clear();
if(CPU) m_regs->WriteText(CPU->RegsToString());
m_regs->WriteText(data);
m_regs->Thaw();
}
@ -293,9 +301,9 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
{
switch(event.GetId())
{
case DID_STOP_EMU:
case DID_PAUSE_EMU:
DoUpdate();
case DID_STOPED_EMU:
case DID_PAUSED_EMU:
//DoUpdate();
break;
}
}
@ -304,12 +312,16 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
switch(event.GetId())
{
case DID_PAUSE_THREAD:
m_btn_run->Disable();
m_btn_step->Disable();
m_btn_pause->Disable();
break;
case DID_PAUSED_THREAD:
m_btn_run->Enable();
m_btn_step->Enable();
m_btn_pause->Disable();
case DID_CREATE_THREAD:
DoUpdate();
//DoUpdate();
break;
case DID_START_THREAD:
@ -318,11 +330,6 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
m_btn_run->Disable();
m_btn_step->Disable();
m_btn_pause->Enable();
if(event.GetId() == DID_START_THREAD)
{
DoUpdate();
}
break;
case DID_REMOVE_THREAD:
@ -333,15 +340,14 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
if(event.GetId() == DID_REMOVE_THREAD)
{
m_choice_units->SetSelection(-1);
wxCommandEvent event;
event.SetInt(-1);
//m_choice_units->SetSelection(-1);
//wxCommandEvent event;
//event.SetInt(-1);
//event.SetClientData(nullptr);
OnSelectUnit(event);
//OnSelectUnit(event);
UpdateUnitList();
//DoUpdate();
}
DoUpdate();
break;
}
}
@ -353,14 +359,17 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
UpdateUnitList();
if(m_choice_units->GetSelection() == -1)
{
m_choice_units->SetSelection(0);
wxCommandEvent event;
event.SetInt(0);
event.SetClientData(&Emu.GetCPU().GetThreads()[0]);
OnSelectUnit(event);
DoUpdate();
//m_choice_units->SetSelection(0);
//wxCommandEvent event;
//event.SetInt(0);
//event.SetClientData(&Emu.GetCPU().GetThreads()[0]);
//OnSelectUnit(event);
}
break;
case DID_REMOVED_THREAD:
UpdateUnitList();
break;
}
}
}
@ -421,6 +430,7 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event))
{
//DoUpdate();
if(CPU) CPU->Pause();
}

View File

@ -382,7 +382,7 @@ bool ELF64Loader::LoadPhdrData(u64 offset)
mem32_t out_tbl(tbl + i*8);
out_tbl += dst + i*section;
out_tbl += nid;
out_tbl += GetFuncNumById(nid);
mem32_t out_dst(dst + i*section);
out_dst += OR(11, 2, 2, 0);

View File

@ -47,6 +47,7 @@ enum DbgCommand
DID_EXEC_THREAD,
DID_REGISTRED_CALLBACK,
DID_UNREGISTRED_CALLBACK,
DID_EXIT_THR_SYSCALL,
DID_LAST_COMMAND,
};