mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-02-28 22:13:24 +00:00
Minor style change
This commit is contained in:
parent
8175630619
commit
2f7fe35f5c
@ -825,7 +825,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
|
|||||||
case X64OP_LOAD:
|
case X64OP_LOAD:
|
||||||
{
|
{
|
||||||
u32 value;
|
u32 value;
|
||||||
if (is_writing || !thread->ReadReg(addr, value) || !put_x64_reg_value(context, reg, d_size, _byteswap_ulong(value)))
|
if (is_writing || !thread->read_reg(addr, value) || !put_x64_reg_value(context, reg, d_size, _byteswap_ulong(value)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -835,7 +835,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
|
|||||||
case X64OP_STORE:
|
case X64OP_STORE:
|
||||||
{
|
{
|
||||||
u64 reg_value;
|
u64 reg_value;
|
||||||
if (!is_writing || !get_x64_reg_value(context, reg, d_size, i_size, reg_value) || !thread->WriteReg(addr, _byteswap_ulong((u32)reg_value)))
|
if (!is_writing || !get_x64_reg_value(context, reg, d_size, i_size, reg_value) || !thread->write_reg(addr, _byteswap_ulong((u32)reg_value)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
void ARMv7Context::fast_call(u32 addr)
|
void ARMv7Context::fast_call(u32 addr)
|
||||||
{
|
{
|
||||||
return static_cast<ARMv7Thread*>(this)->FastCall(addr);
|
return static_cast<ARMv7Thread*>(this)->fast_call(addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define TLS_MAX 128
|
#define TLS_MAX 128
|
||||||
@ -80,7 +80,7 @@ void armv7_free_tls(u32 thread)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ARMv7Thread::ARMv7Thread(const std::string& name)
|
ARMv7Thread::ARMv7Thread(const std::string& name)
|
||||||
: CPUThread(CPU_THREAD_ARMv7, name, WRAP_EXPR(fmt::format("ARMv7[0x%x] Thread (%s)[0x%08x]", GetId(), GetName(), PC)))
|
: CPUThread(CPU_THREAD_ARMv7, name, WRAP_EXPR(fmt::format("ARMv7[0x%x] Thread (%s)[0x%08x]", m_id, m_name.c_str(), PC)))
|
||||||
, ARMv7Context({})
|
, ARMv7Context({})
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -90,23 +90,23 @@ ARMv7Thread::~ARMv7Thread()
|
|||||||
cv.notify_one();
|
cv.notify_one();
|
||||||
join();
|
join();
|
||||||
|
|
||||||
CloseStack();
|
close_stack();
|
||||||
armv7_free_tls(GetId());
|
armv7_free_tls(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::DumpInformation() const
|
void ARMv7Thread::dump_info() const
|
||||||
{
|
{
|
||||||
if (hle_func)
|
if (hle_func)
|
||||||
{
|
{
|
||||||
const auto func = get_psv_func_by_nid(hle_func);
|
const auto func = get_psv_func_by_nid(hle_func);
|
||||||
|
|
||||||
LOG_SUCCESS(HLE, "Information: function 0x%x (%s)", hle_func, func ? func->name : "?????????");
|
LOG_SUCCESS(HLE, "Last function: %s (0x%x)", func ? func->name : "?????????", hle_func);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUThread::DumpInformation();
|
CPUThread::dump_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::InitRegs()
|
void ARMv7Thread::init_regs()
|
||||||
{
|
{
|
||||||
memset(GPR, 0, sizeof(GPR));
|
memset(GPR, 0, sizeof(GPR));
|
||||||
APSR.APSR = 0;
|
APSR.APSR = 0;
|
||||||
@ -115,11 +115,11 @@ void ARMv7Thread::InitRegs()
|
|||||||
PC = PC & ~1; // and fix PC
|
PC = PC & ~1; // and fix PC
|
||||||
ITSTATE.IT = 0;
|
ITSTATE.IT = 0;
|
||||||
SP = stack_addr + stack_size;
|
SP = stack_addr + stack_size;
|
||||||
TLS = armv7_get_tls(GetId());
|
TLS = armv7_get_tls(m_id);
|
||||||
debug = DF_DISASM | DF_PRINT;
|
debug = DF_DISASM | DF_PRINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::InitStack()
|
void ARMv7Thread::init_stack()
|
||||||
{
|
{
|
||||||
if (!stack_addr)
|
if (!stack_addr)
|
||||||
{
|
{
|
||||||
@ -137,7 +137,7 @@ void ARMv7Thread::InitStack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::CloseStack()
|
void ARMv7Thread::close_stack()
|
||||||
{
|
{
|
||||||
if (stack_addr)
|
if (stack_addr)
|
||||||
{
|
{
|
||||||
@ -175,7 +175,7 @@ bool ARMv7Thread::WriteRegString(const std::string& reg, std::string value)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::DoRun()
|
void ARMv7Thread::do_run()
|
||||||
{
|
{
|
||||||
m_dec.reset();
|
m_dec.reset();
|
||||||
|
|
||||||
@ -186,30 +186,30 @@ void ARMv7Thread::DoRun()
|
|||||||
m_dec.reset(new ARMv7Decoder(*this));
|
m_dec.reset(new ARMv7Decoder(*this));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOG_ERROR(PPU, "Invalid CPU decoder mode: %d", Ini.CPUDecoderMode.GetValue());
|
LOG_ERROR(ARMv7, "Invalid CPU decoder mode: %d", Ini.CPUDecoderMode.GetValue());
|
||||||
Emu.Pause();
|
Emu.Pause();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::Task()
|
void ARMv7Thread::task()
|
||||||
{
|
{
|
||||||
if (custom_task)
|
if (custom_task)
|
||||||
{
|
{
|
||||||
if (m_state.load() && CheckStatus()) return;
|
if (m_state.load() && check_status()) return;
|
||||||
|
|
||||||
return custom_task(*this);
|
return custom_task(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (m_state.load() && CheckStatus()) break;
|
if (m_state.load() && check_status()) break;
|
||||||
|
|
||||||
// decode instruction using specified decoder
|
// decode instruction using specified decoder
|
||||||
PC += m_dec->DecodeMemory(PC);
|
PC += m_dec->DecodeMemory(PC);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::FastCall(u32 addr)
|
void ARMv7Thread::fast_call(u32 addr)
|
||||||
{
|
{
|
||||||
if (!is_current())
|
if (!is_current())
|
||||||
{
|
{
|
||||||
@ -219,15 +219,15 @@ void ARMv7Thread::FastCall(u32 addr)
|
|||||||
auto old_PC = PC;
|
auto old_PC = PC;
|
||||||
auto old_stack = SP;
|
auto old_stack = SP;
|
||||||
auto old_LR = LR;
|
auto old_LR = LR;
|
||||||
auto old_task = decltype(custom_task)();
|
auto old_task = std::move(custom_task);
|
||||||
|
|
||||||
PC = addr;
|
PC = addr;
|
||||||
LR = Emu.GetCPUThreadStop();
|
LR = Emu.GetCPUThreadStop();
|
||||||
custom_task.swap(old_task);
|
custom_task = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task();
|
task();
|
||||||
}
|
}
|
||||||
catch (CPUThreadReturn)
|
catch (CPUThreadReturn)
|
||||||
{
|
{
|
||||||
@ -243,10 +243,10 @@ void ARMv7Thread::FastCall(u32 addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
LR = old_LR;
|
LR = old_LR;
|
||||||
custom_task.swap(old_task);
|
custom_task = std::move(old_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ARMv7Thread::FastStop()
|
void ARMv7Thread::fast_stop()
|
||||||
{
|
{
|
||||||
m_state |= CPU_STATE_RETURN;
|
m_state |= CPU_STATE_RETURN;
|
||||||
}
|
}
|
||||||
@ -301,7 +301,7 @@ cpu_thread& armv7_thread::run()
|
|||||||
{
|
{
|
||||||
auto& armv7 = static_cast<ARMv7Thread&>(*thread);
|
auto& armv7 = static_cast<ARMv7Thread&>(*thread);
|
||||||
|
|
||||||
armv7.Run();
|
armv7.run();
|
||||||
|
|
||||||
// set arguments
|
// set arguments
|
||||||
armv7.GPR[0] = argc;
|
armv7.GPR[0] = argc;
|
||||||
|
@ -5,24 +5,24 @@
|
|||||||
class ARMv7Thread final : public CPUThread, public ARMv7Context
|
class ARMv7Thread final : public CPUThread, public ARMv7Context
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
std::function<void(ARMv7Thread& CPU)> custom_task;
|
std::function<void(ARMv7Thread&)> custom_task;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ARMv7Thread(const std::string& name);
|
ARMv7Thread(const std::string& name);
|
||||||
virtual ~ARMv7Thread() override;
|
virtual ~ARMv7Thread() override;
|
||||||
|
|
||||||
virtual void DumpInformation() const override;
|
virtual void dump_info() const override;
|
||||||
virtual u32 GetPC() const override { return PC; }
|
virtual u32 get_pc() const override { return PC; }
|
||||||
virtual u32 GetOffset() const override { return 0; }
|
virtual u32 get_offset() const override { return 0; }
|
||||||
virtual void DoRun() override;
|
virtual void do_run() override;
|
||||||
virtual void Task() override;
|
virtual void task() override;
|
||||||
|
|
||||||
virtual void InitRegs() override;
|
virtual void init_regs() override;
|
||||||
virtual void InitStack() override;
|
virtual void init_stack() override;
|
||||||
virtual void CloseStack() override;
|
virtual void close_stack() override;
|
||||||
u32 GetStackArg(u32 pos);
|
u32 get_stack_arg(u32 pos);
|
||||||
void FastCall(u32 addr);
|
void fast_call(u32 addr);
|
||||||
void FastStop();
|
void fast_stop();
|
||||||
|
|
||||||
virtual std::string RegsToString() const override;
|
virtual std::string RegsToString() const override;
|
||||||
virtual std::string ReadRegString(const std::string& reg) const override;
|
virtual std::string ReadRegString(const std::string& reg) const override;
|
||||||
|
@ -50,9 +50,9 @@ s32 sceKernelCreateThread(
|
|||||||
armv7->PC = entry.addr();
|
armv7->PC = entry.addr();
|
||||||
armv7->prio = initPriority;
|
armv7->prio = initPriority;
|
||||||
armv7->stack_size = stackSize;
|
armv7->stack_size = stackSize;
|
||||||
armv7->Run();
|
armv7->run();
|
||||||
|
|
||||||
return armv7->GetId();
|
return armv7->get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr<void> pArgBlock)
|
s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr<void> pArgBlock)
|
||||||
@ -81,7 +81,7 @@ s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr<void> pArgBlock)
|
|||||||
thread->GPR[0] = argSize;
|
thread->GPR[0] = argSize;
|
||||||
thread->GPR[1] = pos;
|
thread->GPR[1] = pos;
|
||||||
|
|
||||||
thread->Exec();
|
thread->exec();
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +90,7 @@ s32 sceKernelExitThread(ARMv7Context& context, s32 exitStatus)
|
|||||||
sceLibKernel.Warning("sceKernelExitThread(exitStatus=0x%x)", exitStatus);
|
sceLibKernel.Warning("sceKernelExitThread(exitStatus=0x%x)", exitStatus);
|
||||||
|
|
||||||
// exit status is stored in r0
|
// exit status is stored in r0
|
||||||
static_cast<ARMv7Thread&>(context).Exit();
|
static_cast<ARMv7Thread&>(context).exit();
|
||||||
|
|
||||||
return SCE_OK;
|
return SCE_OK;
|
||||||
}
|
}
|
||||||
@ -122,10 +122,10 @@ s32 sceKernelExitDeleteThread(ARMv7Context& context, s32 exitStatus)
|
|||||||
sceLibKernel.Warning("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus);
|
sceLibKernel.Warning("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus);
|
||||||
|
|
||||||
// exit status is stored in r0
|
// exit status is stored in r0
|
||||||
static_cast<ARMv7Thread&>(context).Stop();
|
static_cast<ARMv7Thread&>(context).stop();
|
||||||
|
|
||||||
// current thread should be deleted
|
// current thread should be deleted
|
||||||
const u32 id = static_cast<ARMv7Thread&>(context).GetId();
|
const u32 id = static_cast<ARMv7Thread&>(context).get_id();
|
||||||
|
|
||||||
CallAfter([id]()
|
CallAfter([id]()
|
||||||
{
|
{
|
||||||
@ -167,7 +167,7 @@ u32 sceKernelGetThreadId(ARMv7Context& context)
|
|||||||
{
|
{
|
||||||
sceLibKernel.Log("sceKernelGetThreadId()");
|
sceLibKernel.Log("sceKernelGetThreadId()");
|
||||||
|
|
||||||
return static_cast<ARMv7Thread&>(context).GetId();
|
return static_cast<ARMv7Thread&>(context).get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr)
|
s32 sceKernelChangeCurrentThreadAttr(u32 clearAttr, u32 setAttr)
|
||||||
@ -269,7 +269,7 @@ s32 sceKernelWaitThreadEnd(s32 threadId, vm::ptr<s32> pExitStatus, vm::ptr<u32>
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
while (thread->IsActive())
|
while (thread->is_alive())
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
|
@ -231,7 +231,7 @@ void initialize_psv_modules()
|
|||||||
hle_return.name = "HLE_RETURN";
|
hle_return.name = "HLE_RETURN";
|
||||||
hle_return.func = [](ARMv7Context& context)
|
hle_return.func = [](ARMv7Context& context)
|
||||||
{
|
{
|
||||||
static_cast<ARMv7Thread&>(context).FastStop();
|
static_cast<ARMv7Thread&>(context).fast_stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
// load functions
|
// load functions
|
||||||
|
@ -22,18 +22,18 @@ CPUThread::CPUThread(CPUThreadType type, const std::string& name, std::function<
|
|||||||
std::unique_lock<std::mutex> lock(mutex);
|
std::unique_lock<std::mutex> lock(mutex);
|
||||||
|
|
||||||
// check thread status
|
// check thread status
|
||||||
while (joinable() && IsActive())
|
while (joinable() && is_alive())
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
// check stop status
|
// check stop status
|
||||||
if (!IsStopped())
|
if (!is_stopped())
|
||||||
{
|
{
|
||||||
if (lock) lock.unlock();
|
if (lock) lock.unlock();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task();
|
task();
|
||||||
}
|
}
|
||||||
catch (CPUThreadReturn)
|
catch (CPUThreadReturn)
|
||||||
{
|
{
|
||||||
@ -50,7 +50,7 @@ CPUThread::CPUThread(CPUThreadType type, const std::string& name, std::function<
|
|||||||
}
|
}
|
||||||
catch (const fmt::exception&)
|
catch (const fmt::exception&)
|
||||||
{
|
{
|
||||||
DumpInformation();
|
dump_info();
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,12 +79,12 @@ CPUThread::~CPUThread()
|
|||||||
SendDbgCommand(DID_REMOVE_THREAD, this);
|
SendDbgCommand(DID_REMOVE_THREAD, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUThread::IsPaused() const
|
bool CPUThread::is_paused() const
|
||||||
{
|
{
|
||||||
return (m_state.load() & CPU_STATE_PAUSED) != 0 || Emu.IsPaused();
|
return (m_state.load() & CPU_STATE_PAUSED) != 0 || Emu.IsPaused();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::DumpInformation() const
|
void CPUThread::dump_info() const
|
||||||
{
|
{
|
||||||
if (!Emu.IsStopped())
|
if (!Emu.IsStopped())
|
||||||
{
|
{
|
||||||
@ -92,18 +92,18 @@ void CPUThread::DumpInformation() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Run()
|
void CPUThread::run()
|
||||||
{
|
{
|
||||||
SendDbgCommand(DID_START_THREAD, this);
|
SendDbgCommand(DID_START_THREAD, this);
|
||||||
|
|
||||||
InitStack();
|
init_stack();
|
||||||
InitRegs();
|
init_regs();
|
||||||
DoRun();
|
do_run();
|
||||||
|
|
||||||
SendDbgCommand(DID_STARTED_THREAD, this);
|
SendDbgCommand(DID_STARTED_THREAD, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Pause()
|
void CPUThread::pause()
|
||||||
{
|
{
|
||||||
SendDbgCommand(DID_PAUSE_THREAD, this);
|
SendDbgCommand(DID_PAUSE_THREAD, this);
|
||||||
|
|
||||||
@ -112,7 +112,7 @@ void CPUThread::Pause()
|
|||||||
SendDbgCommand(DID_PAUSED_THREAD, this);
|
SendDbgCommand(DID_PAUSED_THREAD, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Resume()
|
void CPUThread::resume()
|
||||||
{
|
{
|
||||||
SendDbgCommand(DID_RESUME_THREAD, this);
|
SendDbgCommand(DID_RESUME_THREAD, this);
|
||||||
|
|
||||||
@ -128,7 +128,7 @@ void CPUThread::Resume()
|
|||||||
SendDbgCommand(DID_RESUMED_THREAD, this);
|
SendDbgCommand(DID_RESUMED_THREAD, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Stop()
|
void CPUThread::stop()
|
||||||
{
|
{
|
||||||
SendDbgCommand(DID_STOP_THREAD, this);
|
SendDbgCommand(DID_STOP_THREAD, this);
|
||||||
|
|
||||||
@ -149,7 +149,7 @@ void CPUThread::Stop()
|
|||||||
SendDbgCommand(DID_STOPED_THREAD, this);
|
SendDbgCommand(DID_STOPED_THREAD, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Exec()
|
void CPUThread::exec()
|
||||||
{
|
{
|
||||||
SendDbgCommand(DID_EXEC_THREAD, this);
|
SendDbgCommand(DID_EXEC_THREAD, this);
|
||||||
|
|
||||||
@ -163,7 +163,7 @@ void CPUThread::Exec()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Exit()
|
void CPUThread::exit()
|
||||||
{
|
{
|
||||||
if (is_current())
|
if (is_current())
|
||||||
{
|
{
|
||||||
@ -175,7 +175,7 @@ void CPUThread::Exit()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Step()
|
void CPUThread::step()
|
||||||
{
|
{
|
||||||
if (m_state.atomic_op([](u64& state) -> bool
|
if (m_state.atomic_op([](u64& state) -> bool
|
||||||
{
|
{
|
||||||
@ -196,13 +196,13 @@ void CPUThread::Step()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Sleep()
|
void CPUThread::sleep()
|
||||||
{
|
{
|
||||||
m_state += CPU_STATE_MAX;
|
m_state += CPU_STATE_MAX;
|
||||||
m_state |= CPU_STATE_SLEEP;
|
m_state |= CPU_STATE_SLEEP;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPUThread::Awake()
|
void CPUThread::awake()
|
||||||
{
|
{
|
||||||
// must be called after the balanced Sleep() call
|
// must be called after the balanced Sleep() call
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ void CPUThread::Awake()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUThread::Signal()
|
bool CPUThread::signal()
|
||||||
{
|
{
|
||||||
// try to set SIGNAL
|
// try to set SIGNAL
|
||||||
if (m_state._or(CPU_STATE_SIGNAL) & CPU_STATE_SIGNAL)
|
if (m_state._or(CPU_STATE_SIGNAL) & CPU_STATE_SIGNAL)
|
||||||
@ -249,13 +249,13 @@ bool CPUThread::Signal()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUThread::Unsignal()
|
bool CPUThread::unsignal()
|
||||||
{
|
{
|
||||||
// remove SIGNAL and return its old value
|
// remove SIGNAL and return its old value
|
||||||
return (m_state._and_not(CPU_STATE_SIGNAL) & CPU_STATE_SIGNAL) != 0;
|
return (m_state._and_not(CPU_STATE_SIGNAL) & CPU_STATE_SIGNAL) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CPUThread::CheckStatus()
|
bool CPUThread::check_status()
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(mutex, std::defer_lock);
|
std::unique_lock<std::mutex> lock(mutex, std::defer_lock);
|
||||||
|
|
||||||
@ -263,7 +263,7 @@ bool CPUThread::CheckStatus()
|
|||||||
{
|
{
|
||||||
CHECK_EMU_STATUS; // check at least once
|
CHECK_EMU_STATUS; // check at least once
|
||||||
|
|
||||||
if (!IsPaused()) break;
|
if (!is_paused()) break;
|
||||||
|
|
||||||
if (!lock)
|
if (!lock)
|
||||||
{
|
{
|
||||||
@ -274,7 +274,7 @@ bool CPUThread::CheckStatus()
|
|||||||
cv.wait(lock);
|
cv.wait(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_state.load() & CPU_STATE_RETURN || IsStopped())
|
if (m_state.load() & CPU_STATE_RETURN || is_stopped())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -59,59 +59,59 @@ protected:
|
|||||||
public:
|
public:
|
||||||
virtual ~CPUThread() override;
|
virtual ~CPUThread() override;
|
||||||
|
|
||||||
u32 GetId() const { return m_id; }
|
u32 get_id() const { return m_id; }
|
||||||
CPUThreadType GetType() const { return m_type; }
|
CPUThreadType get_type() const { return m_type; }
|
||||||
std::string GetName() const { return m_name; }
|
std::string get_name() const { return m_name; }
|
||||||
|
|
||||||
bool IsActive() const { return (m_state.load() & CPU_STATE_DEAD) == 0; }
|
bool is_alive() const { return (m_state.load() & CPU_STATE_DEAD) == 0; }
|
||||||
bool IsStopped() const { return (m_state.load() & CPU_STATE_STOPPED) != 0; }
|
bool is_stopped() const { return (m_state.load() & CPU_STATE_STOPPED) != 0; }
|
||||||
virtual bool IsPaused() const;
|
virtual bool is_paused() const;
|
||||||
|
|
||||||
virtual void DumpInformation() const;
|
virtual void dump_info() const;
|
||||||
virtual u32 GetPC() const = 0;
|
virtual u32 get_pc() const = 0;
|
||||||
virtual u32 GetOffset() const = 0;
|
virtual u32 get_offset() const = 0;
|
||||||
virtual void DoRun() = 0;
|
virtual void do_run() = 0;
|
||||||
virtual void Task() = 0;
|
virtual void task() = 0;
|
||||||
|
|
||||||
virtual void InitRegs() = 0;
|
virtual void init_regs() = 0;
|
||||||
virtual void InitStack() = 0;
|
virtual void init_stack() = 0;
|
||||||
virtual void CloseStack() = 0;
|
virtual void close_stack() = 0;
|
||||||
|
|
||||||
// initialize thread
|
// initialize thread
|
||||||
void Run();
|
void run();
|
||||||
|
|
||||||
// called by the debugger, don't use
|
// called by the debugger, don't use
|
||||||
void Pause();
|
void pause();
|
||||||
|
|
||||||
// called by the debugger, don't use
|
// called by the debugger, don't use
|
||||||
void Resume();
|
void resume();
|
||||||
|
|
||||||
// stop thread execution
|
// stop thread execution
|
||||||
void Stop();
|
void stop();
|
||||||
|
|
||||||
// start thread execution (removing STOP status)
|
// start thread execution (removing STOP status)
|
||||||
void Exec();
|
void exec();
|
||||||
|
|
||||||
// exit thread execution
|
// exit thread execution
|
||||||
void Exit();
|
void exit();
|
||||||
|
|
||||||
// called by the debugger, don't use
|
// called by the debugger, don't use
|
||||||
void Step();
|
void step();
|
||||||
|
|
||||||
// trigger thread status check
|
// trigger thread status check
|
||||||
void Sleep();
|
void sleep();
|
||||||
|
|
||||||
// untrigger thread status check
|
// untrigger thread status check
|
||||||
void Awake();
|
void awake();
|
||||||
|
|
||||||
// set SIGNAL and notify (returns true if set)
|
// set SIGNAL and notify (returns true if set)
|
||||||
bool Signal();
|
bool signal();
|
||||||
|
|
||||||
// test SIGNAL and reset
|
// test SIGNAL and reset
|
||||||
bool Unsignal();
|
bool unsignal();
|
||||||
|
|
||||||
// process m_state flags, returns true if the checker must return
|
// process m_state flags, returns true if the checker must return
|
||||||
bool CheckStatus();
|
bool check_status();
|
||||||
|
|
||||||
std::string GetFName() const
|
std::string GetFName() const
|
||||||
{
|
{
|
||||||
@ -162,54 +162,6 @@ public:
|
|||||||
virtual std::string RegsToString() const = 0;
|
virtual std::string RegsToString() const = 0;
|
||||||
virtual std::string ReadRegString(const std::string& reg) const = 0;
|
virtual std::string ReadRegString(const std::string& reg) const = 0;
|
||||||
virtual bool WriteRegString(const std::string& reg, std::string value) = 0;
|
virtual bool WriteRegString(const std::string& reg, std::string value) = 0;
|
||||||
|
|
||||||
struct CallStackItem
|
|
||||||
{
|
|
||||||
u32 pc;
|
|
||||||
u32 branch_pc;
|
|
||||||
};
|
|
||||||
|
|
||||||
std::vector<CallStackItem> m_call_stack;
|
|
||||||
|
|
||||||
std::string CallStackToString()
|
|
||||||
{
|
|
||||||
std::string ret = "Call Stack:\n==========\n";
|
|
||||||
|
|
||||||
for(uint i=0; i<m_call_stack.size(); ++i)
|
|
||||||
{
|
|
||||||
ret += fmt::Format("0x%x -> 0x%x\n", m_call_stack[i].pc, m_call_stack[i].branch_pc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
void CallStackBranch(u32 pc)
|
|
||||||
{
|
|
||||||
//look if we're jumping back and if so pop the stack back to that position
|
|
||||||
auto res = std::find_if(m_call_stack.rbegin(), m_call_stack.rend(),
|
|
||||||
[&pc, this](CallStackItem &it)
|
|
||||||
{
|
|
||||||
return CallStackGetNextPC(it.pc) == pc;
|
|
||||||
});
|
|
||||||
if (res != m_call_stack.rend())
|
|
||||||
{
|
|
||||||
m_call_stack.erase((res + 1).base(), m_call_stack.end());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//add a new entry otherwise
|
|
||||||
CallStackItem new_item;
|
|
||||||
|
|
||||||
new_item.branch_pc = pc;
|
|
||||||
new_item.pc = GetPC();
|
|
||||||
|
|
||||||
m_call_stack.push_back(new_item);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual u32 CallStackGetNextPC(u32 pc)
|
|
||||||
{
|
|
||||||
return pc + 4;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class cpu_thread
|
class cpu_thread
|
||||||
@ -245,8 +197,8 @@ public:
|
|||||||
// return thread->IsJoinable();
|
// return thread->IsJoinable();
|
||||||
//}
|
//}
|
||||||
|
|
||||||
u32 get_id() const
|
//u32 get_id() const
|
||||||
{
|
//{
|
||||||
return thread->GetId();
|
// return thread->GetId();
|
||||||
}
|
//}
|
||||||
};
|
};
|
||||||
|
@ -59,12 +59,12 @@ void CPUThreadManager::Exec()
|
|||||||
{
|
{
|
||||||
for (auto& t : Emu.GetIdManager().get_all<PPUThread>())
|
for (auto& t : Emu.GetIdManager().get_all<PPUThread>())
|
||||||
{
|
{
|
||||||
t->Exec();
|
t->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto& t : Emu.GetIdManager().get_all<ARMv7Thread>())
|
for (auto& t : Emu.GetIdManager().get_all<ARMv7Thread>())
|
||||||
{
|
{
|
||||||
t->Exec();
|
t->exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1476,7 +1476,7 @@ void ppu_interpreter::SC(PPUThread& CPU, ppu_opcode_t op)
|
|||||||
switch (op.lev)
|
switch (op.lev)
|
||||||
{
|
{
|
||||||
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
|
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
|
||||||
case 0x3: CPU.FastStop(); break;
|
case 0x3: CPU.fast_stop(); break;
|
||||||
default: throw EXCEPTION("");
|
default: throw EXCEPTION("");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2240,7 +2240,7 @@ private:
|
|||||||
{
|
{
|
||||||
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
|
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
|
||||||
case 0x1: throw EXCEPTION("HyperCall LV1");
|
case 0x1: throw EXCEPTION("HyperCall LV1");
|
||||||
case 0x3: CPU.FastStop(); break;
|
case 0x3: CPU.fast_stop(); break;
|
||||||
default: throw EXCEPTION("Unknown level (0x%x)", lev);
|
default: throw EXCEPTION("Unknown level (0x%x)", lev);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2026,7 +2026,7 @@ void Compiler::SC(u32 lev) {
|
|||||||
Call<void>("SysCalls.DoSyscall", SysCalls::DoSyscall, m_state.args[CompileTaskState::Args::State], GetGpr(11));
|
Call<void>("SysCalls.DoSyscall", SysCalls::DoSyscall, m_state.args[CompileTaskState::Args::State], GetGpr(11));
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
Call<void>("PPUThread.FastStop", &PPUThread::FastStop, m_state.args[CompileTaskState::Args::State]);
|
Call<void>("PPUThread.FastStop", &PPUThread::fast_stop, m_state.args[CompileTaskState::Args::State]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
CompilationError(fmt::Format("SC %u", lev));
|
CompilationError(fmt::Format("SC %u", lev));
|
||||||
@ -6055,7 +6055,7 @@ u32 ppu_recompiler_llvm::ExecutionEngine::ExecuteTillReturn(PPUThread * ppu_stat
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ppu_recompiler_llvm::ExecutionEngine::PollStatus(PPUThread * ppu_state) {
|
bool ppu_recompiler_llvm::ExecutionEngine::PollStatus(PPUThread * ppu_state) {
|
||||||
return ppu_state->CheckStatus();
|
return ppu_state->check_status();
|
||||||
}
|
}
|
||||||
|
|
||||||
BranchType ppu_recompiler_llvm::GetBranchTypeFromInstruction(u32 instruction) {
|
BranchType ppu_recompiler_llvm::GetBranchTypeFromInstruction(u32 instruction) {
|
||||||
|
@ -490,7 +490,7 @@ void fill_ppu_exec_map(u32 addr, u32 size)
|
|||||||
}
|
}
|
||||||
|
|
||||||
PPUThread::PPUThread(const std::string& name)
|
PPUThread::PPUThread(const std::string& name)
|
||||||
: CPUThread(CPU_THREAD_PPU, name, WRAP_EXPR(fmt::format("PPU[0x%x] Thread (%s)[0x%08x]", GetId(), GetName(), PC)))
|
: CPUThread(CPU_THREAD_PPU, name, WRAP_EXPR(fmt::format("PPU[0x%x] Thread (%s)[0x%08x]", m_id, m_name.c_str(), PC)))
|
||||||
{
|
{
|
||||||
InitRotateMask();
|
InitRotateMask();
|
||||||
}
|
}
|
||||||
@ -506,11 +506,11 @@ PPUThread::~PPUThread()
|
|||||||
join();
|
join();
|
||||||
}
|
}
|
||||||
|
|
||||||
CloseStack();
|
close_stack();
|
||||||
ppu_free_tls(m_id);
|
ppu_free_tls(m_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::DumpInformation() const
|
void PPUThread::dump_info() const
|
||||||
{
|
{
|
||||||
if (~hle_code < 1024)
|
if (~hle_code < 1024)
|
||||||
{
|
{
|
||||||
@ -521,10 +521,10 @@ void PPUThread::DumpInformation() const
|
|||||||
LOG_SUCCESS(HLE, "Last function: %s (0x%llx)", SysCalls::GetFuncName(hle_code), hle_code);
|
LOG_SUCCESS(HLE, "Last function: %s (0x%llx)", SysCalls::GetFuncName(hle_code), hle_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
CPUThread::DumpInformation();
|
CPUThread::dump_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::InitRegs()
|
void PPUThread::init_regs()
|
||||||
{
|
{
|
||||||
GPR[1] = align(stack_addr + stack_size, 0x200) - 0x200;
|
GPR[1] = align(stack_addr + stack_size, 0x200) - 0x200;
|
||||||
GPR[13] = ppu_get_tls(m_id) + 0x7000; // 0x7000 is subtracted from r13 to access first TLS element
|
GPR[13] = ppu_get_tls(m_id) + 0x7000; // 0x7000 is subtracted from r13 to access first TLS element
|
||||||
@ -536,7 +536,7 @@ void PPUThread::InitRegs()
|
|||||||
TB = 0;
|
TB = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::InitStack()
|
void PPUThread::init_stack()
|
||||||
{
|
{
|
||||||
if (!stack_addr)
|
if (!stack_addr)
|
||||||
{
|
{
|
||||||
@ -554,7 +554,7 @@ void PPUThread::InitStack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::CloseStack()
|
void PPUThread::close_stack()
|
||||||
{
|
{
|
||||||
if (stack_addr)
|
if (stack_addr)
|
||||||
{
|
{
|
||||||
@ -563,7 +563,7 @@ void PPUThread::CloseStack()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::DoRun()
|
void PPUThread::do_run()
|
||||||
{
|
{
|
||||||
m_dec.reset();
|
m_dec.reset();
|
||||||
|
|
||||||
@ -636,12 +636,12 @@ int FPRdouble::Cmp(PPCdouble a, PPCdouble b)
|
|||||||
return CR_SO;
|
return CR_SO;
|
||||||
}
|
}
|
||||||
|
|
||||||
u64 PPUThread::GetStackArg(s32 i)
|
u64 PPUThread::get_stack_arg(s32 i)
|
||||||
{
|
{
|
||||||
return vm::read64(VM_CAST(GPR[1] + 0x70 + 0x8 * (i - 9)));
|
return vm::read64(VM_CAST(GPR[1] + 0x70 + 0x8 * (i - 9)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::FastCall2(u32 addr, u32 rtoc)
|
void PPUThread::fast_call(u32 addr, u32 rtoc)
|
||||||
{
|
{
|
||||||
if (!is_current())
|
if (!is_current())
|
||||||
{
|
{
|
||||||
@ -652,16 +652,18 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc)
|
|||||||
auto old_stack = GPR[1];
|
auto old_stack = GPR[1];
|
||||||
auto old_rtoc = GPR[2];
|
auto old_rtoc = GPR[2];
|
||||||
auto old_LR = LR;
|
auto old_LR = LR;
|
||||||
auto old_task = decltype(custom_task)();
|
auto old_task = std::move(custom_task);
|
||||||
|
|
||||||
|
assert(!old_task || !custom_task);
|
||||||
|
|
||||||
PC = addr;
|
PC = addr;
|
||||||
GPR[2] = rtoc;
|
GPR[2] = rtoc;
|
||||||
LR = Emu.GetCPUThreadStop();
|
LR = Emu.GetCPUThreadStop();
|
||||||
custom_task.swap(old_task);
|
custom_task = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task();
|
task();
|
||||||
}
|
}
|
||||||
catch (CPUThreadReturn)
|
catch (CPUThreadReturn)
|
||||||
{
|
{
|
||||||
@ -678,21 +680,21 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc)
|
|||||||
|
|
||||||
GPR[2] = old_rtoc;
|
GPR[2] = old_rtoc;
|
||||||
LR = old_LR;
|
LR = old_LR;
|
||||||
custom_task.swap(old_task);
|
custom_task = std::move(old_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::FastStop()
|
void PPUThread::fast_stop()
|
||||||
{
|
{
|
||||||
m_state |= CPU_STATE_RETURN;
|
m_state |= CPU_STATE_RETURN;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPUThread::Task()
|
void PPUThread::task()
|
||||||
{
|
{
|
||||||
SetHostRoundingMode(FPSCR_RN_NEAR);
|
SetHostRoundingMode(FPSCR_RN_NEAR);
|
||||||
|
|
||||||
if (custom_task)
|
if (custom_task)
|
||||||
{
|
{
|
||||||
if (CheckStatus()) return;
|
if (check_status()) return;
|
||||||
|
|
||||||
return custom_task(*this);
|
return custom_task(*this);
|
||||||
}
|
}
|
||||||
@ -701,7 +703,7 @@ void PPUThread::Task()
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (m_state.load() && CheckStatus()) break;
|
if (m_state.load() && check_status()) break;
|
||||||
|
|
||||||
// decode instruction using specified decoder
|
// decode instruction using specified decoder
|
||||||
m_dec->DecodeMemory(PC);
|
m_dec->DecodeMemory(PC);
|
||||||
@ -714,7 +716,7 @@ void PPUThread::Task()
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (m_state.load() && CheckStatus()) break;
|
if (m_state.load() && check_status()) break;
|
||||||
|
|
||||||
// get interpreter function
|
// get interpreter function
|
||||||
const auto func = g_ppu_inter_func_list[*(u32*)((u8*)g_ppu_exec_map + PC)];
|
const auto func = g_ppu_inter_func_list[*(u32*)((u8*)g_ppu_exec_map + PC)];
|
||||||
@ -775,7 +777,7 @@ cpu_thread& ppu_thread::args(std::initializer_list<std::string> values)
|
|||||||
|
|
||||||
cpu_thread& ppu_thread::run()
|
cpu_thread& ppu_thread::run()
|
||||||
{
|
{
|
||||||
thread->Run();
|
thread->run();
|
||||||
|
|
||||||
gpr(3, argc);
|
gpr(3, argc);
|
||||||
gpr(4, argv.addr());
|
gpr(4, argv.addr());
|
||||||
|
@ -540,15 +540,15 @@ public:
|
|||||||
PPUThread(const std::string& name);
|
PPUThread(const std::string& name);
|
||||||
virtual ~PPUThread() override;
|
virtual ~PPUThread() override;
|
||||||
|
|
||||||
virtual void DumpInformation() const override;
|
virtual void dump_info() const override;
|
||||||
virtual u32 GetPC() const override { return PC; }
|
virtual u32 get_pc() const override { return PC; }
|
||||||
virtual u32 GetOffset() const override { return 0; }
|
virtual u32 get_offset() const override { return 0; }
|
||||||
virtual void DoRun() override;
|
virtual void do_run() override;
|
||||||
virtual void Task() override;
|
virtual void task() override;
|
||||||
|
|
||||||
virtual void InitRegs() override;
|
virtual void init_regs() override;
|
||||||
virtual void InitStack() override;
|
virtual void init_stack() override;
|
||||||
virtual void CloseStack() override;
|
virtual void close_stack() override;
|
||||||
|
|
||||||
inline u8 GetCR(const u8 n) const
|
inline u8 GetCR(const u8 n) const
|
||||||
{
|
{
|
||||||
@ -810,14 +810,14 @@ public:
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return GetStackArg(++g_count);
|
return get_stack_arg(++g_count);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
u64 GetStackArg(s32 i);
|
u64 get_stack_arg(s32 i);
|
||||||
void FastCall2(u32 addr, u32 rtoc);
|
void fast_call(u32 addr, u32 rtoc);
|
||||||
void FastStop();
|
void fast_stop();
|
||||||
};
|
};
|
||||||
|
|
||||||
class ppu_thread : cpu_thread
|
class ppu_thread : cpu_thread
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
thread_local spu_mfc_arg_t raw_spu_mfc[8] = {};
|
thread_local spu_mfc_arg_t raw_spu_mfc[8] = {};
|
||||||
|
|
||||||
RawSPUThread::RawSPUThread(const std::string& name, u32 index)
|
RawSPUThread::RawSPUThread(const std::string& name, u32 index)
|
||||||
: SPUThread(CPU_THREAD_RAW_SPU, name, COPY_EXPR(fmt::format("RawSPU_%d[0x%x] Thread (%s)[0x%08x]", index, GetId(), GetName(), PC)), index, RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * index)
|
: SPUThread(CPU_THREAD_RAW_SPU, name, COPY_EXPR(fmt::format("RawSPU%d[0x%x] Thread (%s)[0x%08x]", index, m_id, m_name.c_str(), PC)), index, RAW_SPU_BASE_ADDR + RAW_SPU_OFFSET * index)
|
||||||
{
|
{
|
||||||
if (!vm::falloc(offset, 0x40000))
|
if (!vm::falloc(offset, 0x40000))
|
||||||
{
|
{
|
||||||
@ -27,28 +27,7 @@ RawSPUThread::~RawSPUThread()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawSPUThread::start()
|
bool RawSPUThread::read_reg(const u32 addr, u32& value)
|
||||||
{
|
|
||||||
const bool do_start = status.atomic_op([](u32& status) -> bool
|
|
||||||
{
|
|
||||||
if (status & SPU_STATUS_RUNNING)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
status = SPU_STATUS_RUNNING;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (do_start)
|
|
||||||
{
|
|
||||||
Exec();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool RawSPUThread::ReadReg(const u32 addr, u32& value)
|
|
||||||
{
|
{
|
||||||
const u32 offset = addr - RAW_SPU_BASE_ADDR - index * RAW_SPU_OFFSET - RAW_SPU_PROB_OFFSET;
|
const u32 offset = addr - RAW_SPU_BASE_ADDR - index * RAW_SPU_OFFSET - RAW_SPU_PROB_OFFSET;
|
||||||
|
|
||||||
@ -100,8 +79,27 @@ bool RawSPUThread::ReadReg(const u32 addr, u32& value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
|
bool RawSPUThread::write_reg(const u32 addr, const u32 value)
|
||||||
{
|
{
|
||||||
|
auto try_start = [this]()
|
||||||
|
{
|
||||||
|
if (status.atomic_op([](u32& status) -> bool
|
||||||
|
{
|
||||||
|
if (status & SPU_STATUS_RUNNING)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
status = SPU_STATUS_RUNNING;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}))
|
||||||
|
{
|
||||||
|
exec();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const u32 offset = addr - RAW_SPU_BASE_ADDR - index * RAW_SPU_OFFSET - RAW_SPU_PROB_OFFSET;
|
const u32 offset = addr - RAW_SPU_BASE_ADDR - index * RAW_SPU_OFFSET - RAW_SPU_PROB_OFFSET;
|
||||||
|
|
||||||
switch (offset)
|
switch (offset)
|
||||||
@ -147,7 +145,7 @@ bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
|
|||||||
|
|
||||||
if (value & MFC_START_MASK)
|
if (value & MFC_START_MASK)
|
||||||
{
|
{
|
||||||
start();
|
try_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -195,12 +193,12 @@ bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
|
|||||||
{
|
{
|
||||||
if (value == SPU_RUNCNTL_RUN_REQUEST)
|
if (value == SPU_RUNCNTL_RUN_REQUEST)
|
||||||
{
|
{
|
||||||
start();
|
try_start();
|
||||||
}
|
}
|
||||||
else if (value == SPU_RUNCNTL_STOP_REQUEST)
|
else if (value == SPU_RUNCNTL_STOP_REQUEST)
|
||||||
{
|
{
|
||||||
status &= ~SPU_STATUS_RUNNING;
|
status &= ~SPU_STATUS_RUNNING;
|
||||||
Stop();
|
stop();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -239,7 +237,7 @@ bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RawSPUThread::Task()
|
void RawSPUThread::task()
|
||||||
{
|
{
|
||||||
// get next PC and SPU Interrupt status
|
// get next PC and SPU Interrupt status
|
||||||
PC = npc.exchange(0);
|
PC = npc.exchange(0);
|
||||||
@ -248,7 +246,7 @@ void RawSPUThread::Task()
|
|||||||
|
|
||||||
PC &= 0x3FFFC;
|
PC &= 0x3FFFC;
|
||||||
|
|
||||||
SPUThread::Task();
|
SPUThread::task();
|
||||||
|
|
||||||
// save next PC and current SPU Interrupt status
|
// save next PC and current SPU Interrupt status
|
||||||
npc.store(PC | ((ch_event_stat.load() & SPU_EVENT_INTR_ENABLED) != 0));
|
npc.store(PC | ((ch_event_stat.load() & SPU_EVENT_INTR_ENABLED) != 0));
|
||||||
|
@ -20,11 +20,9 @@ public:
|
|||||||
RawSPUThread(const std::string& name, u32 index);
|
RawSPUThread(const std::string& name, u32 index);
|
||||||
virtual ~RawSPUThread();
|
virtual ~RawSPUThread();
|
||||||
|
|
||||||
void start();
|
bool read_reg(const u32 addr, u32& value);
|
||||||
|
bool write_reg(const u32 addr, const u32 value);
|
||||||
bool ReadReg(const u32 addr, u32& value);
|
|
||||||
bool WriteReg(const u32 addr, const u32 value);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void Task();
|
virtual void task() override;
|
||||||
};
|
};
|
||||||
|
@ -90,7 +90,7 @@ SPUThread::SPUThread(CPUThreadType type, const std::string& name, std::function<
|
|||||||
}
|
}
|
||||||
|
|
||||||
SPUThread::SPUThread(const std::string& name, u32 index)
|
SPUThread::SPUThread(const std::string& name, u32 index)
|
||||||
: CPUThread(CPU_THREAD_SPU, name, WRAP_EXPR(fmt::format("SPU[0x%x] Thread (%s)[0x%08x]", GetId(), GetName(), PC)))
|
: CPUThread(CPU_THREAD_SPU, name, WRAP_EXPR(fmt::format("SPU[0x%x] Thread (%s)[0x%08x]", m_id, m_name.c_str(), PC)))
|
||||||
, index(index)
|
, index(index)
|
||||||
, offset(vm::alloc(0x40000, vm::main))
|
, offset(vm::alloc(0x40000, vm::main))
|
||||||
{
|
{
|
||||||
@ -117,9 +117,9 @@ SPUThread::~SPUThread()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SPUThread::IsPaused() const
|
bool SPUThread::is_paused() const
|
||||||
{
|
{
|
||||||
if (CPUThread::IsPaused())
|
if (CPUThread::is_paused())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -135,27 +135,27 @@ bool SPUThread::IsPaused() const
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::DumpInformation() const
|
void SPUThread::dump_info() const
|
||||||
{
|
{
|
||||||
CPUThread::DumpInformation();
|
CPUThread::dump_info();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::Task()
|
void SPUThread::task()
|
||||||
{
|
{
|
||||||
std::fesetround(FE_TOWARDZERO);
|
std::fesetround(FE_TOWARDZERO);
|
||||||
|
|
||||||
if (m_custom_task)
|
if (custom_task)
|
||||||
{
|
{
|
||||||
if (CheckStatus()) return;
|
if (check_status()) return;
|
||||||
|
|
||||||
return m_custom_task(*this);
|
return custom_task(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_dec)
|
if (m_dec)
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (m_state.load() && CheckStatus()) break;
|
if (m_state.load() && check_status()) break;
|
||||||
|
|
||||||
// decode instruction using specified decoder
|
// decode instruction using specified decoder
|
||||||
m_dec->DecodeMemory(PC + offset);
|
m_dec->DecodeMemory(PC + offset);
|
||||||
@ -168,7 +168,7 @@ void SPUThread::Task()
|
|||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
if (m_state.load() && CheckStatus()) break;
|
if (m_state.load() && check_status()) break;
|
||||||
|
|
||||||
// read opcode
|
// read opcode
|
||||||
const spu_opcode_t opcode = { vm::read32(PC + offset) };
|
const spu_opcode_t opcode = { vm::read32(PC + offset) };
|
||||||
@ -185,7 +185,7 @@ void SPUThread::Task()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::InitRegs()
|
void SPUThread::init_regs()
|
||||||
{
|
{
|
||||||
memset(GPR, 0, sizeof(GPR));
|
memset(GPR, 0, sizeof(GPR));
|
||||||
FPSCR.Reset();
|
FPSCR.Reset();
|
||||||
@ -224,17 +224,17 @@ void SPUThread::InitRegs()
|
|||||||
GPR[1]._u32[3] = 0x3FFF0; // initial stack frame pointer
|
GPR[1]._u32[3] = 0x3FFF0; // initial stack frame pointer
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::InitStack()
|
void SPUThread::init_stack()
|
||||||
{
|
{
|
||||||
// nothing to do
|
// nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::CloseStack()
|
void SPUThread::close_stack()
|
||||||
{
|
{
|
||||||
// nothing to do here
|
// nothing to do here
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::DoRun()
|
void SPUThread::do_run()
|
||||||
{
|
{
|
||||||
m_dec = nullptr;
|
m_dec = nullptr;
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ void SPUThread::DoRun()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::FastCall(u32 ls_addr)
|
void SPUThread::fast_call(u32 ls_addr)
|
||||||
{
|
{
|
||||||
if (!is_current())
|
if (!is_current())
|
||||||
{
|
{
|
||||||
@ -278,15 +278,15 @@ void SPUThread::FastCall(u32 ls_addr)
|
|||||||
auto old_PC = PC;
|
auto old_PC = PC;
|
||||||
auto old_LR = GPR[0]._u32[3];
|
auto old_LR = GPR[0]._u32[3];
|
||||||
auto old_stack = GPR[1]._u32[3]; // only saved and restored (may be wrong)
|
auto old_stack = GPR[1]._u32[3]; // only saved and restored (may be wrong)
|
||||||
auto old_task = decltype(m_custom_task)();
|
auto old_task = std::move(custom_task);
|
||||||
|
|
||||||
PC = ls_addr;
|
PC = ls_addr;
|
||||||
GPR[0]._u32[3] = 0x0;
|
GPR[0]._u32[3] = 0x0;
|
||||||
m_custom_task.swap(old_task);
|
custom_task = nullptr;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Task();
|
task();
|
||||||
}
|
}
|
||||||
catch (CPUThreadReturn)
|
catch (CPUThreadReturn)
|
||||||
{
|
{
|
||||||
@ -297,7 +297,7 @@ void SPUThread::FastCall(u32 ls_addr)
|
|||||||
PC = old_PC;
|
PC = old_PC;
|
||||||
GPR[0]._u32[3] = old_LR;
|
GPR[0]._u32[3] = old_LR;
|
||||||
GPR[1]._u32[3] = old_stack;
|
GPR[1]._u32[3] = old_stack;
|
||||||
m_custom_task.swap(old_task);
|
custom_task = std::move(old_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SPUThread::do_dma_transfer(u32 cmd, spu_mfc_arg_t args)
|
void SPUThread::do_dma_transfer(u32 cmd, spu_mfc_arg_t args)
|
||||||
@ -657,7 +657,7 @@ u32 SPUThread::get_ch_value(u32 ch)
|
|||||||
|
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
if (!lock)
|
if (!lock)
|
||||||
{
|
{
|
||||||
@ -698,7 +698,7 @@ u32 SPUThread::get_ch_value(u32 ch)
|
|||||||
|
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
if (!lock)
|
if (!lock)
|
||||||
{
|
{
|
||||||
@ -763,14 +763,14 @@ u32 SPUThread::get_ch_value(u32 ch)
|
|||||||
if (ch_event_mask.load() & SPU_EVENT_LR)
|
if (ch_event_mask.load() & SPU_EVENT_LR)
|
||||||
{
|
{
|
||||||
// register waiter if polling reservation status is required
|
// register waiter if polling reservation status is required
|
||||||
vm::wait_op(*this, last_raddr, 128, WRAP_EXPR(get_events(true) || IsStopped()));
|
vm::wait_op(*this, last_raddr, 128, WRAP_EXPR(get_events(true) || is_stopped()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
|
|
||||||
// simple waiting loop otherwise
|
// simple waiting loop otherwise
|
||||||
while (!get_events(true) && !IsStopped())
|
while (!get_events(true) && !is_stopped())
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
@ -780,7 +780,7 @@ u32 SPUThread::get_ch_value(u32 ch)
|
|||||||
|
|
||||||
ch_event_stat &= ~SPU_EVENT_WAITING;
|
ch_event_stat &= ~SPU_EVENT_WAITING;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
return get_events();
|
return get_events();
|
||||||
}
|
}
|
||||||
@ -818,7 +818,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
|
|||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
if (!lock)
|
if (!lock)
|
||||||
{
|
{
|
||||||
@ -875,7 +875,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
|
|||||||
return ch_in_mbox.set_values(1, CELL_EBUSY);
|
return ch_in_mbox.set_values(1, CELL_EBUSY);
|
||||||
}
|
}
|
||||||
|
|
||||||
queue->push(lv2_lock, SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data);
|
queue->push(lv2_lock, SYS_SPU_THREAD_EVENT_USER_KEY, m_id, ((u64)spup << 32) | (value & 0x00ffffff), data);
|
||||||
|
|
||||||
return ch_in_mbox.set_values(1, CELL_OK);
|
return ch_in_mbox.set_values(1, CELL_OK);
|
||||||
}
|
}
|
||||||
@ -916,7 +916,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
queue->push(lv2_lock, SYS_SPU_THREAD_EVENT_USER_KEY, GetId(), ((u64)spup << 32) | (value & 0x00ffffff), data);
|
queue->push(lv2_lock, SYS_SPU_THREAD_EVENT_USER_KEY, m_id, ((u64)spup << 32) | (value & 0x00ffffff), data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (code == 128)
|
else if (code == 128)
|
||||||
@ -1042,7 +1042,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
|
|||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
if (!lock)
|
if (!lock)
|
||||||
{
|
{
|
||||||
@ -1213,7 +1213,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
|
|
||||||
int_ctrl[2].set(SPU_INT2_STAT_SPU_STOP_AND_SIGNAL_INT);
|
int_ctrl[2].set(SPU_INT2_STAT_SPU_STOP_AND_SIGNAL_INT);
|
||||||
|
|
||||||
return Stop();
|
return stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (code)
|
switch (code)
|
||||||
@ -1306,7 +1306,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
group->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
|
group->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
|
||||||
}
|
}
|
||||||
@ -1318,7 +1318,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
|
|
||||||
for (auto& t : group->threads)
|
for (auto& t : group->threads)
|
||||||
{
|
{
|
||||||
if (t) t->Sleep(); // trigger status check
|
if (t) t->sleep(); // trigger status check
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1334,7 +1334,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
if (IsStopped()) throw CPUThreadStop{};
|
if (is_stopped()) throw CPUThreadStop{};
|
||||||
|
|
||||||
queue->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
|
queue->cv.wait_for(lv2_lock, std::chrono::milliseconds(1));
|
||||||
}
|
}
|
||||||
@ -1373,7 +1373,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
|
|
||||||
for (auto& t : group->threads)
|
for (auto& t : group->threads)
|
||||||
{
|
{
|
||||||
if (t) t->Awake(); // untrigger status check
|
if (t) t->awake(); // untrigger status check
|
||||||
}
|
}
|
||||||
|
|
||||||
group->cv.notify_all();
|
group->cv.notify_all();
|
||||||
@ -1412,7 +1412,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
{
|
{
|
||||||
if (t && t.get() != this)
|
if (t && t.get() != this)
|
||||||
{
|
{
|
||||||
t->Stop();
|
t->stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1421,7 +1421,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
group->join_state |= SPU_TGJSF_GROUP_EXIT;
|
group->join_state |= SPU_TGJSF_GROUP_EXIT;
|
||||||
group->cv.notify_one();
|
group->cv.notify_one();
|
||||||
|
|
||||||
return Stop();
|
return stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x102:
|
case 0x102:
|
||||||
@ -1450,7 +1450,7 @@ void SPUThread::stop_and_signal(u32 code)
|
|||||||
status |= SPU_STATUS_STOPPED_BY_STOP;
|
status |= SPU_STATUS_STOPPED_BY_STOP;
|
||||||
group->cv.notify_one();
|
group->cv.notify_one();
|
||||||
|
|
||||||
return Stop();
|
return stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1481,7 +1481,7 @@ void SPUThread::halt()
|
|||||||
|
|
||||||
int_ctrl[2].set(SPU_INT2_STAT_SPU_HALT_OR_STEP_INT);
|
int_ctrl[2].set(SPU_INT2_STAT_SPU_HALT_OR_STEP_INT);
|
||||||
|
|
||||||
return Stop();
|
return stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
status |= SPU_STATUS_STOPPED_BY_HALT;
|
status |= SPU_STATUS_STOPPED_BY_HALT;
|
||||||
|
@ -682,7 +682,7 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<void(SPUThread& SPU)> m_custom_task;
|
std::function<void(SPUThread&)> custom_task;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
SPUThread(CPUThreadType type, const std::string& name, std::function<std::string()> thread_name, u32 index, u32 offset);
|
SPUThread(CPUThreadType type, const std::string& name, std::function<std::string()> thread_name, u32 index, u32 offset);
|
||||||
@ -691,19 +691,19 @@ public:
|
|||||||
SPUThread(const std::string& name, u32 index);
|
SPUThread(const std::string& name, u32 index);
|
||||||
virtual ~SPUThread() override;
|
virtual ~SPUThread() override;
|
||||||
|
|
||||||
virtual bool IsPaused() const override;
|
virtual bool is_paused() const override;
|
||||||
|
|
||||||
virtual void DumpInformation() const override;
|
virtual void dump_info() const override;
|
||||||
virtual u32 GetPC() const override { return PC; }
|
virtual u32 get_pc() const override { return PC; }
|
||||||
virtual u32 GetOffset() const override { return offset; }
|
virtual u32 get_offset() const override { return offset; }
|
||||||
virtual void DoRun() override;
|
virtual void do_run() override;
|
||||||
virtual void Task() override;
|
virtual void task() override;
|
||||||
|
|
||||||
virtual void InitRegs() override;
|
virtual void init_regs() override;
|
||||||
virtual void InitStack() override;
|
virtual void init_stack() override;
|
||||||
virtual void CloseStack() override;
|
virtual void close_stack() override;
|
||||||
|
|
||||||
void FastCall(u32 ls_addr);
|
void fast_call(u32 ls_addr);
|
||||||
|
|
||||||
virtual std::string RegsToString() const
|
virtual std::string RegsToString() const
|
||||||
{
|
{
|
||||||
@ -770,7 +770,7 @@ public:
|
|||||||
{
|
{
|
||||||
auto& spu = static_cast<SPUThread&>(*thread);
|
auto& spu = static_cast<SPUThread&>(*thread);
|
||||||
|
|
||||||
spu.Run();
|
spu.run();
|
||||||
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +243,7 @@ namespace vm
|
|||||||
mask = ~0;
|
mask = ~0;
|
||||||
|
|
||||||
// signal thread (must not be signaled yet)
|
// signal thread (must not be signaled yet)
|
||||||
if (!thread->Signal())
|
if (!thread->signal())
|
||||||
{
|
{
|
||||||
throw EXCEPTION("Thread already signaled");
|
throw EXCEPTION("Thread already signaled");
|
||||||
}
|
}
|
||||||
@ -259,7 +259,7 @@ namespace vm
|
|||||||
|
|
||||||
void waiter_lock_t::wait()
|
void waiter_lock_t::wait()
|
||||||
{
|
{
|
||||||
while (!m_waiter->thread->Unsignal())
|
while (!m_waiter->thread->unsignal())
|
||||||
{
|
{
|
||||||
if (m_waiter->pred())
|
if (m_waiter->pred())
|
||||||
{
|
{
|
||||||
@ -1048,7 +1048,7 @@ namespace vm
|
|||||||
|
|
||||||
u32 stack_push(CPUThread& cpu, u32 size, u32 align_v, u32& old_pos)
|
u32 stack_push(CPUThread& cpu, u32 size, u32 align_v, u32& old_pos)
|
||||||
{
|
{
|
||||||
switch (cpu.GetType())
|
switch (cpu.get_type())
|
||||||
{
|
{
|
||||||
case CPU_THREAD_PPU:
|
case CPU_THREAD_PPU:
|
||||||
{
|
{
|
||||||
@ -1107,14 +1107,14 @@ namespace vm
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw EXCEPTION("Invalid thread type (%d)", cpu.GetId());
|
throw EXCEPTION("Invalid thread type (%d)", cpu.get_id());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void stack_pop(CPUThread& cpu, u32 addr, u32 old_pos)
|
void stack_pop(CPUThread& cpu, u32 addr, u32 old_pos)
|
||||||
{
|
{
|
||||||
switch (cpu.GetType())
|
switch (cpu.get_type())
|
||||||
{
|
{
|
||||||
case CPU_THREAD_PPU:
|
case CPU_THREAD_PPU:
|
||||||
{
|
{
|
||||||
@ -1158,7 +1158,7 @@ namespace vm
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
throw EXCEPTION("Invalid thread type (%d)", cpu.GetType());
|
throw EXCEPTION("Invalid thread type (%d)", cpu.get_type());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ namespace cb_detail
|
|||||||
const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...);
|
const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...);
|
||||||
if (stack) CPU.GPR[1] -= FIXED_STACK_FRAME_SIZE;
|
if (stack) CPU.GPR[1] -= FIXED_STACK_FRAME_SIZE;
|
||||||
CPU.GPR[1] -= 0x70; // create reserved area
|
CPU.GPR[1] -= 0x70; // create reserved area
|
||||||
CPU.FastCall2(pc, rtoc);
|
CPU.fast_call(pc, rtoc);
|
||||||
CPU.GPR[1] += 0x70;
|
CPU.GPR[1] += 0x70;
|
||||||
if (stack) CPU.GPR[1] += FIXED_STACK_FRAME_SIZE;
|
if (stack) CPU.GPR[1] += FIXED_STACK_FRAME_SIZE;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ void CallbackManager::Init()
|
|||||||
thread->prio = 1001;
|
thread->prio = 1001;
|
||||||
thread->stack_size = 0x10000;
|
thread->stack_size = 0x10000;
|
||||||
thread->custom_task = task;
|
thread->custom_task = task;
|
||||||
thread->Run();
|
thread->run();
|
||||||
|
|
||||||
m_cb_thread = thread;
|
m_cb_thread = thread;
|
||||||
}
|
}
|
||||||
@ -98,7 +98,7 @@ void CallbackManager::Init()
|
|||||||
thread->prio = 1001;
|
thread->prio = 1001;
|
||||||
thread->stack_size = 0x10000;
|
thread->stack_size = 0x10000;
|
||||||
thread->custom_task = task;
|
thread->custom_task = task;
|
||||||
thread->Run();
|
thread->run();
|
||||||
|
|
||||||
m_cb_thread = thread;
|
m_cb_thread = thread;
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ void execute_ppu_func_by_index(PPUThread& CPU, u32 index)
|
|||||||
LOG_NOTICE(HLE, "LLE function called: %s", SysCalls::GetFuncName(func->id));
|
LOG_NOTICE(HLE, "LLE function called: %s", SysCalls::GetFuncName(func->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
CPU.FastCall2(pc, rtoc);
|
CPU.fast_call(pc, rtoc);
|
||||||
|
|
||||||
if (Ini.HLELogging.GetValue())
|
if (Ini.HLELogging.GetValue())
|
||||||
{
|
{
|
||||||
|
@ -469,8 +469,8 @@ void adecOpen(u32 adec_id) // TODO: call from the constructor
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
adec.adecCb->Run();
|
adec.adecCb->run();
|
||||||
adec.adecCb->Exec();
|
adec.adecCb->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool adecCheckType(s32 type)
|
bool adecCheckType(s32 type)
|
||||||
@ -572,7 +572,7 @@ s32 cellAdecClose(u32 handle)
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu.GetIdManager().remove<PPUThread>(adec->adecCb->GetId());
|
Emu.GetIdManager().remove<PPUThread>(adec->adecCb->get_id());
|
||||||
Emu.GetIdManager().remove<AudioDecoder>(handle);
|
Emu.GetIdManager().remove<AudioDecoder>(handle);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -764,8 +764,8 @@ void dmuxOpen(u32 dmux_id) // TODO: call from the constructor
|
|||||||
dmux.is_finished = true;
|
dmux.is_finished = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
dmux.dmuxCb->Run();
|
dmux.dmuxCb->run();
|
||||||
dmux.dmuxCb->Exec();
|
dmux.dmuxCb->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cellDmuxQueryAttr(vm::cptr<CellDmuxType> type, vm::ptr<CellDmuxAttr> attr)
|
s32 cellDmuxQueryAttr(vm::cptr<CellDmuxType> type, vm::ptr<CellDmuxAttr> attr)
|
||||||
@ -872,7 +872,7 @@ s32 cellDmuxClose(u32 handle)
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu.GetIdManager().remove<PPUThread>(dmux->dmuxCb->GetId());
|
Emu.GetIdManager().remove<PPUThread>(dmux->dmuxCb->get_id());
|
||||||
Emu.GetIdManager().remove<Demuxer>(handle);
|
Emu.GetIdManager().remove<Demuxer>(handle);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -1156,10 +1156,10 @@ s32 spursInit(
|
|||||||
const auto spuThread = Emu.GetIdManager().get<SPUThread>(spurs->spus[num] = spuThreadId.value());
|
const auto spuThread = Emu.GetIdManager().get<SPUThread>(spurs->spus[num] = spuThreadId.value());
|
||||||
|
|
||||||
// entry point cannot be initialized immediately because SPU LS will be rewritten by sys_spu_thread_group_start()
|
// entry point cannot be initialized immediately because SPU LS will be rewritten by sys_spu_thread_group_start()
|
||||||
spuThread->m_custom_task = [spurs](SPUThread& SPU)
|
spuThread->custom_task = [spurs](SPUThread& spu)
|
||||||
{
|
{
|
||||||
SPU.RegisterHleFunction(spurs->spuImg.entry_point, spursKernelEntry);
|
spu.RegisterHleFunction(spurs->spuImg.entry_point, spursKernelEntry);
|
||||||
SPU.FastCall(spurs->spuImg.entry_point);
|
spu.fast_call(spurs->spuImg.entry_point);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1386,7 +1386,7 @@ void spursTasksetOnTaskExit(SPUThread & spu, u64 addr, u32 taskId, s32 exitCode,
|
|||||||
spu.GPR[4]._u32[3] = taskId;
|
spu.GPR[4]._u32[3] = taskId;
|
||||||
spu.GPR[5]._u32[3] = exitCode;
|
spu.GPR[5]._u32[3] = exitCode;
|
||||||
spu.GPR[6]._u64[1] = args;
|
spu.GPR[6]._u64[1] = args;
|
||||||
spu.FastCall(0x10000);
|
spu.fast_call(0x10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Save the context of a task
|
/// Save the context of a task
|
||||||
@ -1505,7 +1505,7 @@ void spursTasksetDispatch(SPUThread & spu) {
|
|||||||
|
|
||||||
if (elfAddr & 2) { // TODO: Figure this out
|
if (elfAddr & 2) { // TODO: Figure this out
|
||||||
spu.status |= SPU_STATUS_STOPPED_BY_STOP;
|
spu.status |= SPU_STATUS_STOPPED_BY_STOP;
|
||||||
spu.Stop();
|
spu.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1551,7 +1551,7 @@ void spursTasksetDispatch(SPUThread & spu) {
|
|||||||
|
|
||||||
if (elfAddr & 2) { // TODO: Figure this out
|
if (elfAddr & 2) { // TODO: Figure this out
|
||||||
spu.status |= SPU_STATUS_STOPPED_BY_STOP;
|
spu.status |= SPU_STATUS_STOPPED_BY_STOP;
|
||||||
spu.Stop();
|
spu.stop();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -540,8 +540,8 @@ void vdecOpen(u32 vdec_id) // TODO: call from the constructor
|
|||||||
vdec.is_finished = true;
|
vdec.is_finished = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
vdec.vdecCb->Run();
|
vdec.vdecCb->run();
|
||||||
vdec.vdecCb->Exec();
|
vdec.vdecCb->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 cellVdecQueryAttr(vm::cptr<CellVdecType> type, vm::ptr<CellVdecAttr> attr)
|
s32 cellVdecQueryAttr(vm::cptr<CellVdecType> type, vm::ptr<CellVdecAttr> attr)
|
||||||
@ -597,7 +597,7 @@ s32 cellVdecClose(u32 handle)
|
|||||||
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
std::this_thread::sleep_for(std::chrono::milliseconds(1)); // hack
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu.GetIdManager().remove<PPUThread>(vdec->vdecCb->GetId());
|
Emu.GetIdManager().remove<PPUThread>(vdec->vdecCb->get_id());
|
||||||
Emu.GetIdManager().remove<VideoDecoder>(handle);
|
Emu.GetIdManager().remove<VideoDecoder>(handle);
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -455,11 +455,11 @@ s32 cellSurMixerCreate(vm::cptr<CellSurMixerConfig> config)
|
|||||||
|
|
||||||
surMixerCb.set(0);
|
surMixerCb.set(0);
|
||||||
|
|
||||||
Emu.GetIdManager().remove<PPUThread>(ppu.GetId());
|
Emu.GetIdManager().remove<PPUThread>(ppu.get_id());
|
||||||
};
|
};
|
||||||
|
|
||||||
ppu->Run();
|
ppu->run();
|
||||||
ppu->Exec();
|
ppu->exec();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -123,7 +123,7 @@ s32 sys_lwmutex_destroy(PPUThread& ppu, vm::ptr<sys_lwmutex_t> lwmutex)
|
|||||||
sysPrxForUser.Log("sys_lwmutex_destroy(lwmutex=*0x%x)", lwmutex);
|
sysPrxForUser.Log("sys_lwmutex_destroy(lwmutex=*0x%x)", lwmutex);
|
||||||
|
|
||||||
// check to prevent recursive locking in the next call
|
// check to prevent recursive locking in the next call
|
||||||
if (lwmutex->vars.owner.load() == ppu.GetId())
|
if (lwmutex->vars.owner.load() == ppu.get_id())
|
||||||
{
|
{
|
||||||
return CELL_EBUSY;
|
return CELL_EBUSY;
|
||||||
}
|
}
|
||||||
@ -153,7 +153,7 @@ s32 sys_lwmutex_lock(PPUThread& ppu, vm::ptr<sys_lwmutex_t> lwmutex, u64 timeout
|
|||||||
{
|
{
|
||||||
sysPrxForUser.Log("sys_lwmutex_lock(lwmutex=*0x%x, timeout=0x%llx)", lwmutex, timeout);
|
sysPrxForUser.Log("sys_lwmutex_lock(lwmutex=*0x%x, timeout=0x%llx)", lwmutex, timeout);
|
||||||
|
|
||||||
const be_t<u32> tid = ppu.GetId();
|
const be_t<u32> tid = ppu.get_id();
|
||||||
|
|
||||||
// try to lock lightweight mutex
|
// try to lock lightweight mutex
|
||||||
const be_t<u32> old_owner = lwmutex->vars.owner.compare_and_swap(lwmutex_free, tid);
|
const be_t<u32> old_owner = lwmutex->vars.owner.compare_and_swap(lwmutex_free, tid);
|
||||||
@ -247,7 +247,7 @@ s32 sys_lwmutex_trylock(PPUThread& ppu, vm::ptr<sys_lwmutex_t> lwmutex)
|
|||||||
{
|
{
|
||||||
sysPrxForUser.Log("sys_lwmutex_trylock(lwmutex=*0x%x)", lwmutex);
|
sysPrxForUser.Log("sys_lwmutex_trylock(lwmutex=*0x%x)", lwmutex);
|
||||||
|
|
||||||
const be_t<u32> tid = ppu.GetId();
|
const be_t<u32> tid = ppu.get_id();
|
||||||
|
|
||||||
// try to lock lightweight mutex
|
// try to lock lightweight mutex
|
||||||
const be_t<u32> old_owner = lwmutex->vars.owner.compare_and_swap(lwmutex_free, tid);
|
const be_t<u32> old_owner = lwmutex->vars.owner.compare_and_swap(lwmutex_free, tid);
|
||||||
@ -314,7 +314,7 @@ s32 sys_lwmutex_unlock(PPUThread& ppu, vm::ptr<sys_lwmutex_t> lwmutex)
|
|||||||
{
|
{
|
||||||
sysPrxForUser.Log("sys_lwmutex_unlock(lwmutex=*0x%x)", lwmutex);
|
sysPrxForUser.Log("sys_lwmutex_unlock(lwmutex=*0x%x)", lwmutex);
|
||||||
|
|
||||||
const be_t<u32> tid = ppu.GetId();
|
const be_t<u32> tid = ppu.get_id();
|
||||||
|
|
||||||
// check owner
|
// check owner
|
||||||
if (lwmutex->vars.owner.load() != tid)
|
if (lwmutex->vars.owner.load() != tid)
|
||||||
@ -390,7 +390,7 @@ s32 sys_lwcond_signal(PPUThread& ppu, vm::ptr<sys_lwcond_t> lwcond)
|
|||||||
//return _sys_lwcond_signal(lwcond->lwcond_queue, 0, -1, 2);
|
//return _sys_lwcond_signal(lwcond->lwcond_queue, 0, -1, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lwmutex->vars.owner.load() == ppu.GetId())
|
if (lwmutex->vars.owner.load() == ppu.get_id())
|
||||||
{
|
{
|
||||||
// if owns the mutex
|
// if owns the mutex
|
||||||
lwmutex->all_info++;
|
lwmutex->all_info++;
|
||||||
@ -448,7 +448,7 @@ s32 sys_lwcond_signal_all(PPUThread& ppu, vm::ptr<sys_lwcond_t> lwcond)
|
|||||||
//return _sys_lwcond_signal_all(lwcond->lwcond_queue, lwmutex->sleep_queue, 2);
|
//return _sys_lwcond_signal_all(lwcond->lwcond_queue, lwmutex->sleep_queue, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lwmutex->vars.owner.load() == ppu.GetId())
|
if (lwmutex->vars.owner.load() == ppu.get_id())
|
||||||
{
|
{
|
||||||
// if owns the mutex, call the syscall
|
// if owns the mutex, call the syscall
|
||||||
const s32 res = _sys_lwcond_signal_all(lwcond->lwcond_queue, lwmutex->sleep_queue, 1);
|
const s32 res = _sys_lwcond_signal_all(lwcond->lwcond_queue, lwmutex->sleep_queue, 1);
|
||||||
@ -505,7 +505,7 @@ s32 sys_lwcond_signal_to(PPUThread& ppu, vm::ptr<sys_lwcond_t> lwcond, u32 ppu_t
|
|||||||
//return _sys_lwcond_signal(lwcond->lwcond_queue, 0, ppu_thread_id, 2);
|
//return _sys_lwcond_signal(lwcond->lwcond_queue, 0, ppu_thread_id, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lwmutex->vars.owner.load() == ppu.GetId())
|
if (lwmutex->vars.owner.load() == ppu.get_id())
|
||||||
{
|
{
|
||||||
// if owns the mutex
|
// if owns the mutex
|
||||||
lwmutex->all_info++;
|
lwmutex->all_info++;
|
||||||
@ -555,7 +555,7 @@ s32 sys_lwcond_wait(PPUThread& ppu, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
|
|||||||
{
|
{
|
||||||
sysPrxForUser.Log("sys_lwcond_wait(lwcond=*0x%x, timeout=0x%llx)", lwcond, timeout);
|
sysPrxForUser.Log("sys_lwcond_wait(lwcond=*0x%x, timeout=0x%llx)", lwcond, timeout);
|
||||||
|
|
||||||
const be_t<u32> tid = ppu.GetId();
|
const be_t<u32> tid = ppu.get_id();
|
||||||
|
|
||||||
const vm::ptr<sys_lwmutex_t> lwmutex = lwcond->lwmutex;
|
const vm::ptr<sys_lwmutex_t> lwmutex = lwcond->lwmutex;
|
||||||
|
|
||||||
@ -1247,7 +1247,7 @@ s32 sys_ppu_thread_get_id(PPUThread& ppu, vm::ptr<u64> thread_id)
|
|||||||
{
|
{
|
||||||
sysPrxForUser.Log("sys_ppu_thread_get_id(thread_id=*0x%x)", thread_id);
|
sysPrxForUser.Log("sys_ppu_thread_get_id(thread_id=*0x%x)", thread_id);
|
||||||
|
|
||||||
*thread_id = ppu.GetId();
|
*thread_id = ppu.get_id();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ namespace ppu_func_detail
|
|||||||
static force_inline T get_arg(PPUThread& CPU)
|
static force_inline T get_arg(PPUThread& CPU)
|
||||||
{
|
{
|
||||||
// TODO: check stack argument displacement
|
// TODO: check stack argument displacement
|
||||||
const u64 res = CPU.GetStackArg(8 + std::max<s32>(g_count - 8, 0) + std::max<s32>(f_count - 13, 0) + std::max<s32>(v_count - 12, 0));
|
const u64 res = CPU.get_stack_arg(8 + std::max<s32>(g_count - 8, 0) + std::max<s32>(f_count - 13, 0) + std::max<s32>(v_count - 12, 0));
|
||||||
return cast_from_ppu_gpr<T>(res);
|
return cast_from_ppu_gpr<T>(res);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -41,18 +41,18 @@ sleep_queue_entry_t::sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue)
|
|||||||
, m_queue(queue)
|
, m_queue(queue)
|
||||||
{
|
{
|
||||||
add_entry();
|
add_entry();
|
||||||
cpu.Sleep();
|
cpu.sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep_queue_entry_t::sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue, const defer_sleep_t&)
|
sleep_queue_entry_t::sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue, const defer_sleep_t&)
|
||||||
: m_thread(cpu)
|
: m_thread(cpu)
|
||||||
, m_queue(queue)
|
, m_queue(queue)
|
||||||
{
|
{
|
||||||
cpu.Sleep();
|
cpu.sleep();
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep_queue_entry_t::~sleep_queue_entry_t() noexcept(false)
|
sleep_queue_entry_t::~sleep_queue_entry_t() noexcept(false)
|
||||||
{
|
{
|
||||||
remove_entry();
|
remove_entry();
|
||||||
m_thread.Awake();
|
m_thread.awake();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ void lv2_cond_t::notify(lv2_lock_t& lv2_lock, sleep_queue_t::iterator it)
|
|||||||
{
|
{
|
||||||
mutex->owner = thread;
|
mutex->owner = thread;
|
||||||
|
|
||||||
if (!thread->Signal())
|
if (!thread->signal())
|
||||||
{
|
{
|
||||||
throw EXCEPTION("Thread already signaled");
|
throw EXCEPTION("Thread already signaled");
|
||||||
}
|
}
|
||||||
@ -156,7 +156,7 @@ s32 sys_cond_signal_to(u32 cond_id, u32 thread_id)
|
|||||||
// signal specified thread (protocol is not required)
|
// signal specified thread (protocol is not required)
|
||||||
for (auto it = cond->sq.begin(); it != cond->sq.end(); it++)
|
for (auto it = cond->sq.begin(); it != cond->sq.end(); it++)
|
||||||
{
|
{
|
||||||
if ((*it)->GetId() == thread_id)
|
if ((*it)->get_id() == thread_id)
|
||||||
{
|
{
|
||||||
cond->notify(lv2_lock, it);
|
cond->notify(lv2_lock, it);
|
||||||
cond->sq.erase(it);
|
cond->sq.erase(it);
|
||||||
@ -200,8 +200,10 @@ s32 sys_cond_wait(PPUThread& ppu, u32 cond_id, u64 timeout)
|
|||||||
// add empty mutex waiter (may be actually set later)
|
// add empty mutex waiter (may be actually set later)
|
||||||
sleep_queue_entry_t mutex_waiter(ppu, cond->mutex->sq, defer_sleep);
|
sleep_queue_entry_t mutex_waiter(ppu, cond->mutex->sq, defer_sleep);
|
||||||
|
|
||||||
while (!ppu.Unsignal())
|
while (!ppu.unsignal())
|
||||||
{
|
{
|
||||||
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
// timeout is ignored if waiting on the cond var is already dropped
|
// timeout is ignored if waiting on the cond var is already dropped
|
||||||
if (timeout && waiter)
|
if (timeout && waiter)
|
||||||
{
|
{
|
||||||
@ -228,8 +230,6 @@ s32 sys_cond_wait(PPUThread& ppu, u32 cond_id, u64 timeout)
|
|||||||
{
|
{
|
||||||
ppu.cv.wait(lv2_lock);
|
ppu.cv.wait(lv2_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
CHECK_EMU_STATUS;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// mutex owner is restored after notification or unlocking
|
// mutex owner is restored after notification or unlocking
|
||||||
|
@ -30,7 +30,7 @@ void lv2_int_serv_t::join(PPUThread& ppu, lv2_lock_t& lv2_lock)
|
|||||||
thread->cv.notify_one();
|
thread->cv.notify_one();
|
||||||
|
|
||||||
// Start joining
|
// Start joining
|
||||||
while (thread->IsActive())
|
while (thread->is_alive())
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
@ -39,7 +39,7 @@ void lv2_int_serv_t::join(PPUThread& ppu, lv2_lock_t& lv2_lock)
|
|||||||
|
|
||||||
// Cleanup
|
// Cleanup
|
||||||
Emu.GetIdManager().remove<lv2_int_serv_t>(id);
|
Emu.GetIdManager().remove<lv2_int_serv_t>(id);
|
||||||
Emu.GetIdManager().remove<PPUThread>(thread->GetId());
|
Emu.GetIdManager().remove<PPUThread>(thread->get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 sys_interrupt_tag_destroy(u32 intrtag)
|
s32 sys_interrupt_tag_destroy(u32 intrtag)
|
||||||
@ -88,7 +88,7 @@ s32 _sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u32 intrthread
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If interrupt thread is running, it's already established on another interrupt tag
|
// If interrupt thread is running, it's already established on another interrupt tag
|
||||||
if (!it->IsStopped())
|
if (!it->is_stopped())
|
||||||
{
|
{
|
||||||
return CELL_EAGAIN;
|
return CELL_EAGAIN;
|
||||||
}
|
}
|
||||||
@ -122,7 +122,7 @@ s32 _sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u32 intrthread
|
|||||||
|
|
||||||
ppu.GPR[3] = arg1;
|
ppu.GPR[3] = arg1;
|
||||||
ppu.GPR[4] = arg2;
|
ppu.GPR[4] = arg2;
|
||||||
ppu.FastCall2(pc, rtoc);
|
ppu.fast_call(pc, rtoc);
|
||||||
|
|
||||||
handler->signal--;
|
handler->signal--;
|
||||||
continue;
|
continue;
|
||||||
@ -137,10 +137,10 @@ s32 _sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u32 intrthread
|
|||||||
ppu.cv.wait(lv2_lock);
|
ppu.cv.wait(lv2_lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
ppu.Exit();
|
ppu.exit();
|
||||||
};
|
};
|
||||||
|
|
||||||
it->Exec();
|
it->exec();
|
||||||
|
|
||||||
*ih = handler->id;
|
*ih = handler->id;
|
||||||
|
|
||||||
@ -177,5 +177,5 @@ void sys_interrupt_thread_eoi(PPUThread& ppu)
|
|||||||
|
|
||||||
ppu.GPR[1] = align(ppu.stack_addr + ppu.stack_size, 0x200) - 0x200; // supercrutch to bypass stack check
|
ppu.GPR[1] = align(ppu.stack_addr + ppu.stack_size, 0x200) - 0x200; // supercrutch to bypass stack check
|
||||||
|
|
||||||
ppu.FastStop();
|
ppu.fast_stop();
|
||||||
}
|
}
|
||||||
|
@ -177,9 +177,9 @@ s32 _sys_lwcond_queue_wait(PPUThread& CPU, u32 lwcond_id, u32 lwmutex_id, u64 ti
|
|||||||
}
|
}
|
||||||
|
|
||||||
// add waiter; protocol is ignored in current implementation
|
// add waiter; protocol is ignored in current implementation
|
||||||
cond->waiters.emplace(CPU.GetId());
|
cond->waiters.emplace(CPU.get_id());
|
||||||
|
|
||||||
while ((!(cond->signaled1 && mutex->signaled) && !cond->signaled2) || cond->waiters.count(CPU.GetId()))
|
while ((!(cond->signaled1 && mutex->signaled) && !cond->signaled2) || cond->waiters.count(CPU.get_id()))
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
@ -189,7 +189,7 @@ s32 _sys_lwcond_queue_wait(PPUThread& CPU, u32 lwcond_id, u32 lwmutex_id, u64 ti
|
|||||||
if (is_timedout)
|
if (is_timedout)
|
||||||
{
|
{
|
||||||
// cancel waiting
|
// cancel waiting
|
||||||
if (!cond->waiters.erase(CPU.GetId()))
|
if (!cond->waiters.erase(CPU.get_id()))
|
||||||
{
|
{
|
||||||
if (cond->signaled1 && !mutex->signaled)
|
if (cond->signaled1 && !mutex->signaled)
|
||||||
{
|
{
|
||||||
|
@ -22,7 +22,7 @@ void lv2_mutex_t::unlock(lv2_lock_t& lv2_lock)
|
|||||||
// pick new owner; protocol is ignored in current implementation
|
// pick new owner; protocol is ignored in current implementation
|
||||||
owner = sq.front();
|
owner = sq.front();
|
||||||
|
|
||||||
if (!owner->Signal())
|
if (!owner->signal())
|
||||||
{
|
{
|
||||||
throw EXCEPTION("Mutex owner already signaled");
|
throw EXCEPTION("Mutex owner already signaled");
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ s32 sys_mutex_lock(PPUThread& ppu, u32 mutex_id, u64 timeout)
|
|||||||
// add waiter; protocol is ignored in current implementation
|
// add waiter; protocol is ignored in current implementation
|
||||||
sleep_queue_entry_t waiter(ppu, mutex->sq);
|
sleep_queue_entry_t waiter(ppu, mutex->sq);
|
||||||
|
|
||||||
while (!ppu.Unsignal())
|
while (!ppu.unsignal())
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
|
@ -31,10 +31,10 @@ void _sys_ppu_thread_exit(PPUThread& ppu, u64 errorcode)
|
|||||||
|
|
||||||
if (!ppu.is_joinable)
|
if (!ppu.is_joinable)
|
||||||
{
|
{
|
||||||
Emu.GetIdManager().remove<PPUThread>(ppu.GetId());
|
Emu.GetIdManager().remove<PPUThread>(ppu.get_id());
|
||||||
}
|
}
|
||||||
|
|
||||||
ppu.Exit();
|
ppu.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void sys_ppu_thread_yield()
|
void sys_ppu_thread_yield()
|
||||||
@ -71,7 +71,7 @@ s32 sys_ppu_thread_join(PPUThread& ppu, u32 thread_id, vm::ptr<u64> vptr)
|
|||||||
thread->is_joining = true;
|
thread->is_joining = true;
|
||||||
|
|
||||||
// join thread
|
// join thread
|
||||||
while (thread->IsActive())
|
while (thread->is_alive())
|
||||||
{
|
{
|
||||||
CHECK_EMU_STATUS;
|
CHECK_EMU_STATUS;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@ s32 sys_ppu_thread_join(PPUThread& ppu, u32 thread_id, vm::ptr<u64> vptr)
|
|||||||
*vptr = thread->GPR[3];
|
*vptr = thread->GPR[3];
|
||||||
|
|
||||||
// cleanup
|
// cleanup
|
||||||
Emu.GetIdManager().remove<PPUThread>(thread->GetId());
|
Emu.GetIdManager().remove<PPUThread>(thread->get_id());
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ u32 ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool is_joina
|
|||||||
ppu->prio = prio;
|
ppu->prio = prio;
|
||||||
ppu->stack_size = stacksize < 0x4000 ? 0x4000 : stacksize; // (hack) adjust minimal stack size
|
ppu->stack_size = stacksize < 0x4000 ? 0x4000 : stacksize; // (hack) adjust minimal stack size
|
||||||
ppu->custom_task = task;
|
ppu->custom_task = task;
|
||||||
ppu->Run();
|
ppu->run();
|
||||||
|
|
||||||
if (entry)
|
if (entry)
|
||||||
{
|
{
|
||||||
@ -231,10 +231,10 @@ u32 ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool is_joina
|
|||||||
if (!is_interrupt)
|
if (!is_interrupt)
|
||||||
{
|
{
|
||||||
ppu->GPR[3] = arg;
|
ppu->GPR[3] = arg;
|
||||||
ppu->Exec();
|
ppu->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
return ppu->GetId();
|
return ppu->get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_param_t> param, u64 arg, u64 unk, s32 prio, u32 stacksize, u64 flags, vm::cptr<char> threadname)
|
s32 _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_param_t> param, u64 arg, u64 unk, s32 prio, u32 stacksize, u64 flags, vm::cptr<char> threadname)
|
||||||
@ -261,7 +261,7 @@ s32 _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_param_t> p
|
|||||||
|
|
||||||
ppu->prio = prio;
|
ppu->prio = prio;
|
||||||
ppu->stack_size = stacksize < 0x4000 ? 0x4000 : stacksize; // (hack) adjust minimal stack size
|
ppu->stack_size = stacksize < 0x4000 ? 0x4000 : stacksize; // (hack) adjust minimal stack size
|
||||||
ppu->Run();
|
ppu->run();
|
||||||
|
|
||||||
ppu->PC = vm::read32(param->entry);
|
ppu->PC = vm::read32(param->entry);
|
||||||
ppu->GPR[2] = vm::read32(param->entry + 4); // rtoc
|
ppu->GPR[2] = vm::read32(param->entry + 4); // rtoc
|
||||||
@ -275,7 +275,7 @@ s32 _sys_ppu_thread_create(vm::ptr<u64> thread_id, vm::ptr<ppu_thread_param_t> p
|
|||||||
ppu->GPR[13] = tls;
|
ppu->GPR[13] = tls;
|
||||||
}
|
}
|
||||||
|
|
||||||
*thread_id = ppu->GetId();
|
*thread_id = ppu->get_id();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
@ -293,7 +293,7 @@ s32 sys_ppu_thread_start(u32 thread_id)
|
|||||||
return CELL_ESRCH;
|
return CELL_ESRCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->Exec();
|
thread->exec();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ s32 sys_rwlock_wlock(PPUThread& CPU, u32 rw_lock_id, u64 timeout)
|
|||||||
return CELL_ESRCH;
|
return CELL_ESRCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rwlock->writer == CPU.GetId())
|
if (rwlock->writer == CPU.get_id())
|
||||||
{
|
{
|
||||||
return CELL_EDEADLK;
|
return CELL_EDEADLK;
|
||||||
}
|
}
|
||||||
@ -187,7 +187,7 @@ s32 sys_rwlock_wlock(PPUThread& CPU, u32 rw_lock_id, u64 timeout)
|
|||||||
rwlock->wcv.wait_for(lv2_lock, std::chrono::milliseconds(1));
|
rwlock->wcv.wait_for(lv2_lock, std::chrono::milliseconds(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
rwlock->writer = CPU.GetId();
|
rwlock->writer = CPU.get_id();
|
||||||
rwlock->wwaiters--;
|
rwlock->wwaiters--;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
@ -206,7 +206,7 @@ s32 sys_rwlock_trywlock(PPUThread& CPU, u32 rw_lock_id)
|
|||||||
return CELL_ESRCH;
|
return CELL_ESRCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rwlock->writer == CPU.GetId())
|
if (rwlock->writer == CPU.get_id())
|
||||||
{
|
{
|
||||||
return CELL_EDEADLK;
|
return CELL_EDEADLK;
|
||||||
}
|
}
|
||||||
@ -216,7 +216,7 @@ s32 sys_rwlock_trywlock(PPUThread& CPU, u32 rw_lock_id)
|
|||||||
return CELL_EBUSY;
|
return CELL_EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
rwlock->writer = CPU.GetId();
|
rwlock->writer = CPU.get_id();
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ s32 sys_rwlock_wunlock(PPUThread& CPU, u32 rw_lock_id)
|
|||||||
return CELL_ESRCH;
|
return CELL_ESRCH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rwlock->writer != CPU.GetId())
|
if (rwlock->writer != CPU.get_id())
|
||||||
{
|
{
|
||||||
return CELL_EPERM;
|
return CELL_EPERM;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ u32 spu_thread_initialize(u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img,
|
|||||||
|
|
||||||
const auto spu = Emu.GetIdManager().make_ptr<SPUThread>(name, spu_num);
|
const auto spu = Emu.GetIdManager().make_ptr<SPUThread>(name, spu_num);
|
||||||
|
|
||||||
spu->m_custom_task = task;
|
spu->custom_task = task;
|
||||||
|
|
||||||
const auto group = Emu.GetIdManager().get<spu_group_t>(group_id);
|
const auto group = Emu.GetIdManager().get<spu_group_t>(group_id);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ u32 spu_thread_initialize(u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img,
|
|||||||
group->state = SPU_THREAD_GROUP_STATUS_INITIALIZED;
|
group->state = SPU_THREAD_GROUP_STATUS_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return spu->GetId();
|
return spu->get_id();
|
||||||
}
|
}
|
||||||
|
|
||||||
s32 sys_spu_thread_initialize(vm::ptr<u32> thread, u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_thread_attribute> attr, vm::ptr<sys_spu_thread_argument> arg)
|
s32 sys_spu_thread_initialize(vm::ptr<u32> thread, u32 group_id, u32 spu_num, vm::ptr<sys_spu_image> img, vm::ptr<sys_spu_thread_attribute> attr, vm::ptr<sys_spu_thread_argument> arg)
|
||||||
@ -265,7 +265,7 @@ s32 sys_spu_thread_group_destroy(u32 id)
|
|||||||
{
|
{
|
||||||
if (t)
|
if (t)
|
||||||
{
|
{
|
||||||
Emu.GetIdManager().remove<SPUThread>(t->GetId());
|
Emu.GetIdManager().remove<SPUThread>(t->get_id());
|
||||||
|
|
||||||
t.reset();
|
t.reset();
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ s32 sys_spu_thread_group_start(u32 id)
|
|||||||
std::memcpy(vm::get_ptr<void>(t->offset), vm::get_ptr<void>(image->addr), 256 * 1024);
|
std::memcpy(vm::get_ptr<void>(t->offset), vm::get_ptr<void>(image->addr), 256 * 1024);
|
||||||
|
|
||||||
t->PC = image->entry_point;
|
t->PC = image->entry_point;
|
||||||
t->Run();
|
t->run();
|
||||||
t->GPR[3] = u128::from64(0, args.arg1);
|
t->GPR[3] = u128::from64(0, args.arg1);
|
||||||
t->GPR[4] = u128::from64(0, args.arg2);
|
t->GPR[4] = u128::from64(0, args.arg2);
|
||||||
t->GPR[5] = u128::from64(0, args.arg3);
|
t->GPR[5] = u128::from64(0, args.arg3);
|
||||||
@ -333,7 +333,7 @@ s32 sys_spu_thread_group_start(u32 id)
|
|||||||
|
|
||||||
for (auto& t : group->threads)
|
for (auto& t : group->threads)
|
||||||
{
|
{
|
||||||
if (t) t->Exec();
|
if (t) t->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
@ -383,7 +383,7 @@ s32 sys_spu_thread_group_suspend(u32 id)
|
|||||||
|
|
||||||
for (auto& t : group->threads)
|
for (auto& t : group->threads)
|
||||||
{
|
{
|
||||||
if (t) t->Sleep(); // trigger status check
|
if (t) t->sleep(); // trigger status check
|
||||||
}
|
}
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
@ -424,7 +424,7 @@ s32 sys_spu_thread_group_resume(u32 id)
|
|||||||
|
|
||||||
for (auto& t : group->threads)
|
for (auto& t : group->threads)
|
||||||
{
|
{
|
||||||
if (t) t->Awake(); // untrigger status check
|
if (t) t->awake(); // untrigger status check
|
||||||
}
|
}
|
||||||
|
|
||||||
group->cv.notify_all();
|
group->cv.notify_all();
|
||||||
@ -498,7 +498,7 @@ s32 sys_spu_thread_group_terminate(u32 id, s32 value)
|
|||||||
|
|
||||||
for (auto& t : group->threads)
|
for (auto& t : group->threads)
|
||||||
{
|
{
|
||||||
if (t) t->Stop();
|
if (t) t->stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
group->state = SPU_THREAD_GROUP_STATUS_INITIALIZED;
|
group->state = SPU_THREAD_GROUP_STATUS_INITIALIZED;
|
||||||
@ -1147,7 +1147,7 @@ s32 sys_raw_spu_create(vm::ptr<u32> id, vm::ptr<void> attr)
|
|||||||
return CELL_EAGAIN;
|
return CELL_EAGAIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
thread->Run();
|
thread->run();
|
||||||
|
|
||||||
*id = thread->index;
|
*id = thread->index;
|
||||||
|
|
||||||
@ -1170,7 +1170,7 @@ s32 sys_raw_spu_destroy(PPUThread& ppu, u32 id)
|
|||||||
// TODO: CELL_EBUSY is not returned
|
// TODO: CELL_EBUSY is not returned
|
||||||
|
|
||||||
// Stop thread
|
// Stop thread
|
||||||
thread->Stop();
|
thread->stop();
|
||||||
|
|
||||||
// Clear interrupt handlers
|
// Clear interrupt handlers
|
||||||
for (auto& intr : thread->int_ctrl)
|
for (auto& intr : thread->int_ctrl)
|
||||||
@ -1186,7 +1186,7 @@ s32 sys_raw_spu_destroy(PPUThread& ppu, u32 id)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Emu.GetIdManager().remove<RawSPUThread>(thread->GetId());
|
Emu.GetIdManager().remove<RawSPUThread>(thread->get_id());
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
@ -300,7 +300,7 @@ void Emulator::Pause()
|
|||||||
|
|
||||||
for (auto& t : GetCPU().GetAllThreads())
|
for (auto& t : GetCPU().GetAllThreads())
|
||||||
{
|
{
|
||||||
t->Sleep(); // trigger status check
|
t->sleep(); // trigger status check
|
||||||
}
|
}
|
||||||
|
|
||||||
SendDbgCommand(DID_PAUSED_EMU);
|
SendDbgCommand(DID_PAUSED_EMU);
|
||||||
@ -332,7 +332,7 @@ void Emulator::Resume()
|
|||||||
|
|
||||||
for (auto& t : GetCPU().GetAllThreads())
|
for (auto& t : GetCPU().GetAllThreads())
|
||||||
{
|
{
|
||||||
t->Awake(); // untrigger status check and signal
|
t->awake(); // untrigger status check and signal
|
||||||
}
|
}
|
||||||
|
|
||||||
SendDbgCommand(DID_RESUMED_EMU);
|
SendDbgCommand(DID_RESUMED_EMU);
|
||||||
@ -359,7 +359,7 @@ void Emulator::Stop()
|
|||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(t->mutex);
|
std::lock_guard<std::mutex> lock(t->mutex);
|
||||||
|
|
||||||
t->Sleep(); // trigger status check
|
t->sleep(); // trigger status check
|
||||||
|
|
||||||
t->cv.notify_one(); // signal
|
t->cv.notify_one(); // signal
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u64 _pc, CPUTh
|
|||||||
s_panel_margin_x->AddSpacer(12);
|
s_panel_margin_x->AddSpacer(12);
|
||||||
|
|
||||||
this->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(InstructionEditorDialog::updatePreview));
|
this->Connect(wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler(InstructionEditorDialog::updatePreview));
|
||||||
t2_instr->SetValue(wxString::Format("%08x", vm::ps3::read32(CPU->GetOffset() + pc).value()));
|
t2_instr->SetValue(wxString::Format("%08x", vm::ps3::read32(CPU->get_offset() + pc).value()));
|
||||||
|
|
||||||
this->SetSizerAndFit(s_panel_margin_x);
|
this->SetSizerAndFit(s_panel_margin_x);
|
||||||
|
|
||||||
@ -83,7 +83,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u64 _pc, CPUTh
|
|||||||
if (!t2_instr->GetValue().ToULong(&opcode, 16))
|
if (!t2_instr->GetValue().ToULong(&opcode, 16))
|
||||||
wxMessageBox("This instruction could not be parsed.\nNo changes were made.","Error");
|
wxMessageBox("This instruction could not be parsed.\nNo changes were made.","Error");
|
||||||
else
|
else
|
||||||
vm::ps3::write32(CPU->GetOffset() + pc, (u32)opcode);
|
vm::ps3::write32(CPU->get_offset() + pc, (u32)opcode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,7 +92,7 @@ void InstructionEditorDialog::updatePreview(wxCommandEvent& event)
|
|||||||
unsigned long opcode;
|
unsigned long opcode;
|
||||||
if (t2_instr->GetValue().ToULong(&opcode, 16))
|
if (t2_instr->GetValue().ToULong(&opcode, 16))
|
||||||
{
|
{
|
||||||
if(CPU->GetType() == CPU_THREAD_ARMv7)
|
if(CPU->get_type() == CPU_THREAD_ARMv7)
|
||||||
{
|
{
|
||||||
t3_preview->SetLabel("Preview for ARMv7Thread not implemented yet.");
|
t3_preview->SetLabel("Preview for ARMv7Thread not implemented yet.");
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event)
|
|||||||
|
|
||||||
if(CPU)
|
if(CPU)
|
||||||
{
|
{
|
||||||
switch(CPU->GetType())
|
switch(CPU->get_type())
|
||||||
{
|
{
|
||||||
case CPU_THREAD_PPU:
|
case CPU_THREAD_PPU:
|
||||||
{
|
{
|
||||||
@ -247,10 +247,10 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
disasm->offset = vm::get_ptr<u8>(CPU->GetOffset());
|
disasm->offset = vm::get_ptr<u8>(CPU->get_offset());
|
||||||
for(uint i=0, count = 4; i<m_item_count; ++i, PC += count)
|
for(uint i=0, count = 4; i<m_item_count; ++i, PC += count)
|
||||||
{
|
{
|
||||||
if(!vm::check_addr(CPU->GetOffset() + PC, 4))
|
if(!vm::check_addr(CPU->get_offset() + PC, 4))
|
||||||
{
|
{
|
||||||
m_list->SetItem(i, 0, wxString(IsBreakPoint(PC) ? ">>> " : " ") + wxString::Format("[%08llx] illegal address", PC));
|
m_list->SetItem(i, 0, wxString(IsBreakPoint(PC) ? ">>> " : " ") + wxString::Format("[%08llx] illegal address", PC));
|
||||||
count = 4;
|
count = 4;
|
||||||
@ -258,7 +258,7 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
disasm->dump_pc = PC;
|
disasm->dump_pc = PC;
|
||||||
count = decoder->DecodeMemory(CPU->GetOffset() + PC);
|
count = decoder->DecodeMemory(CPU->get_offset() + PC);
|
||||||
|
|
||||||
if(IsBreakPoint(PC))
|
if(IsBreakPoint(PC))
|
||||||
{
|
{
|
||||||
@ -271,7 +271,7 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
|
|||||||
|
|
||||||
wxColour colour;
|
wxColour colour;
|
||||||
|
|
||||||
if(CPU->IsPaused() && PC == CPU->GetPC())
|
if(CPU->is_paused() && PC == CPU->get_pc())
|
||||||
{
|
{
|
||||||
colour = wxColour("Green");
|
colour = wxColour("Green");
|
||||||
}
|
}
|
||||||
@ -339,11 +339,9 @@ void InterpreterDisAsmFrame::WriteCallStack()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string data = CPU->CallStackToString();
|
|
||||||
|
|
||||||
m_calls->Freeze();
|
m_calls->Freeze();
|
||||||
m_calls->Clear();
|
m_calls->Clear();
|
||||||
m_calls->WriteText(fmt::FromUTF8(data));
|
//m_calls->WriteText(fmt::FromUTF8(data));
|
||||||
m_calls->Thaw();
|
m_calls->Thaw();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +363,7 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if(CPU && thr->GetId() == CPU->GetId())
|
else if(CPU && thr->get_id() == CPU->get_id())
|
||||||
{
|
{
|
||||||
switch(event.GetId())
|
switch(event.GetId())
|
||||||
{
|
{
|
||||||
@ -455,11 +453,11 @@ void InterpreterDisAsmFrame::Show_Val(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
diag->SetSizerAndFit( s_panel );
|
diag->SetSizerAndFit( s_panel );
|
||||||
|
|
||||||
if(CPU) p_pc->SetValue(wxString::Format("%x", CPU->GetPC()));
|
if(CPU) p_pc->SetValue(wxString::Format("%x", CPU->get_pc()));
|
||||||
|
|
||||||
if(diag->ShowModal() == wxID_OK)
|
if(diag->ShowModal() == wxID_OK)
|
||||||
{
|
{
|
||||||
unsigned long pc = CPU ? CPU->GetPC() : 0x0;
|
unsigned long pc = CPU ? CPU->get_pc() : 0x0;
|
||||||
p_pc->GetValue().ToULong(&pc, 16);
|
p_pc->GetValue().ToULong(&pc, 16);
|
||||||
Emu.GetMarkedPoints().push_back(pc);
|
Emu.GetMarkedPoints().push_back(pc);
|
||||||
remove_markedPC.push_back(Emu.GetMarkedPoints().size()-1);
|
remove_markedPC.push_back(Emu.GetMarkedPoints().size()-1);
|
||||||
@ -469,18 +467,18 @@ void InterpreterDisAsmFrame::Show_Val(wxCommandEvent& WXUNUSED(event))
|
|||||||
|
|
||||||
void InterpreterDisAsmFrame::Show_PC(wxCommandEvent& WXUNUSED(event))
|
void InterpreterDisAsmFrame::Show_PC(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if(CPU) ShowAddr(CentrePc(CPU->GetPC()));
|
if(CPU) ShowAddr(CentrePc(CPU->get_pc()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
|
void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if(!CPU) return;
|
if(!CPU) return;
|
||||||
|
|
||||||
if(CPU->IsPaused()) CPU->Resume();
|
if(CPU->is_paused()) CPU->resume();
|
||||||
|
|
||||||
if(!Emu.IsPaused())
|
if(!Emu.IsPaused())
|
||||||
{
|
{
|
||||||
CPU->Exec();
|
CPU->exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ThreadBase::Start();
|
//ThreadBase::Start();
|
||||||
@ -489,12 +487,12 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
|
|||||||
void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event))
|
void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
//DoUpdate();
|
//DoUpdate();
|
||||||
if(CPU) CPU->Pause();
|
if(CPU) CPU->pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event))
|
void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event))
|
||||||
{
|
{
|
||||||
if(CPU) CPU->Step();
|
if(CPU) CPU->step();
|
||||||
}
|
}
|
||||||
|
|
||||||
void InterpreterDisAsmFrame::InstrKey(wxListEvent& event)
|
void InterpreterDisAsmFrame::InstrKey(wxListEvent& event)
|
||||||
|
@ -224,7 +224,7 @@ void KernelExplorer::Update()
|
|||||||
|
|
||||||
for (const auto& thread : Emu.GetIdManager().get_all<PPUThread>())
|
for (const auto& thread : Emu.GetIdManager().get_all<PPUThread>())
|
||||||
{
|
{
|
||||||
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString());
|
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->get_id(), thread->get_name().c_str(), thread->ThreadStatusToString());
|
||||||
m_tree->AppendItem(node, name);
|
m_tree->AppendItem(node, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,9 +236,9 @@ void KernelExplorer::Update()
|
|||||||
|
|
||||||
for (const auto& thread : Emu.GetIdManager().get_all<SPUThread>())
|
for (const auto& thread : Emu.GetIdManager().get_all<SPUThread>())
|
||||||
{
|
{
|
||||||
if (thread->GetType() == CPU_THREAD_SPU)
|
if (thread->get_type() == CPU_THREAD_SPU)
|
||||||
{
|
{
|
||||||
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString());
|
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->get_id(), thread->get_name().c_str(), thread->ThreadStatusToString());
|
||||||
m_tree->AppendItem(node, name);
|
m_tree->AppendItem(node, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,9 +251,9 @@ void KernelExplorer::Update()
|
|||||||
|
|
||||||
for (const auto& thread : Emu.GetIdManager().get_all<RawSPUThread>())
|
for (const auto& thread : Emu.GetIdManager().get_all<RawSPUThread>())
|
||||||
{
|
{
|
||||||
if (thread->GetType() == CPU_THREAD_RAW_SPU)
|
if (thread->get_type() == CPU_THREAD_RAW_SPU)
|
||||||
{
|
{
|
||||||
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->GetId(), thread->GetName().c_str(), thread->ThreadStatusToString());
|
sprintf(name, "Thread: ID = 0x%08x '%s', - %s", thread->get_id(), thread->get_name().c_str(), thread->ThreadStatusToString());
|
||||||
m_tree->AppendItem(node, name);
|
m_tree->AppendItem(node, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u64 _pc, CPUThread*
|
|||||||
|
|
||||||
Bind(wxEVT_COMBOBOX, &RegisterEditorDialog::updateRegister, this);
|
Bind(wxEVT_COMBOBOX, &RegisterEditorDialog::updateRegister, this);
|
||||||
|
|
||||||
switch(CPU->GetType())
|
switch(CPU->get_type())
|
||||||
{
|
{
|
||||||
case CPU_THREAD_PPU:
|
case CPU_THREAD_PPU:
|
||||||
for (int i=0; i<32; i++) t1_register->Append(wxString::Format("GPR[%d]",i));
|
for (int i=0; i<32; i++) t1_register->Append(wxString::Format("GPR[%d]",i));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user