Minor style change

This commit is contained in:
Nekotekina 2015-07-19 14:36:32 +03:00
parent 8175630619
commit 2f7fe35f5c
42 changed files with 329 additions and 381 deletions

View File

@ -825,7 +825,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
case X64OP_LOAD:
{
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;
}
@ -835,7 +835,7 @@ bool handle_access_violation(u32 addr, bool is_writing, x64_context* context)
case X64OP_STORE:
{
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;
}

View File

@ -13,7 +13,7 @@
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
@ -80,7 +80,7 @@ void armv7_free_tls(u32 thread)
}
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({})
{
}
@ -90,23 +90,23 @@ ARMv7Thread::~ARMv7Thread()
cv.notify_one();
join();
CloseStack();
armv7_free_tls(GetId());
close_stack();
armv7_free_tls(m_id);
}
void ARMv7Thread::DumpInformation() const
void ARMv7Thread::dump_info() const
{
if (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));
APSR.APSR = 0;
@ -115,11 +115,11 @@ void ARMv7Thread::InitRegs()
PC = PC & ~1; // and fix PC
ITSTATE.IT = 0;
SP = stack_addr + stack_size;
TLS = armv7_get_tls(GetId());
TLS = armv7_get_tls(m_id);
debug = DF_DISASM | DF_PRINT;
}
void ARMv7Thread::InitStack()
void ARMv7Thread::init_stack()
{
if (!stack_addr)
{
@ -137,7 +137,7 @@ void ARMv7Thread::InitStack()
}
}
void ARMv7Thread::CloseStack()
void ARMv7Thread::close_stack()
{
if (stack_addr)
{
@ -175,7 +175,7 @@ bool ARMv7Thread::WriteRegString(const std::string& reg, std::string value)
return true;
}
void ARMv7Thread::DoRun()
void ARMv7Thread::do_run()
{
m_dec.reset();
@ -186,30 +186,30 @@ void ARMv7Thread::DoRun()
m_dec.reset(new ARMv7Decoder(*this));
break;
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();
}
}
void ARMv7Thread::Task()
void ARMv7Thread::task()
{
if (custom_task)
{
if (m_state.load() && CheckStatus()) return;
if (m_state.load() && check_status()) return;
return custom_task(*this);
}
while (true)
{
if (m_state.load() && CheckStatus()) break;
if (m_state.load() && check_status()) break;
// decode instruction using specified decoder
PC += m_dec->DecodeMemory(PC);
}
}
void ARMv7Thread::FastCall(u32 addr)
void ARMv7Thread::fast_call(u32 addr)
{
if (!is_current())
{
@ -219,15 +219,15 @@ void ARMv7Thread::FastCall(u32 addr)
auto old_PC = PC;
auto old_stack = SP;
auto old_LR = LR;
auto old_task = decltype(custom_task)();
auto old_task = std::move(custom_task);
PC = addr;
LR = Emu.GetCPUThreadStop();
custom_task.swap(old_task);
custom_task = nullptr;
try
{
Task();
task();
}
catch (CPUThreadReturn)
{
@ -243,10 +243,10 @@ void ARMv7Thread::FastCall(u32 addr)
}
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;
}
@ -301,7 +301,7 @@ cpu_thread& armv7_thread::run()
{
auto& armv7 = static_cast<ARMv7Thread&>(*thread);
armv7.Run();
armv7.run();
// set arguments
armv7.GPR[0] = argc;

View File

@ -5,24 +5,24 @@
class ARMv7Thread final : public CPUThread, public ARMv7Context
{
public:
std::function<void(ARMv7Thread& CPU)> custom_task;
std::function<void(ARMv7Thread&)> custom_task;
public:
ARMv7Thread(const std::string& name);
virtual ~ARMv7Thread() override;
virtual void DumpInformation() const override;
virtual u32 GetPC() const override { return PC; }
virtual u32 GetOffset() const override { return 0; }
virtual void DoRun() override;
virtual void Task() override;
virtual void dump_info() const override;
virtual u32 get_pc() const override { return PC; }
virtual u32 get_offset() const override { return 0; }
virtual void do_run() override;
virtual void task() override;
virtual void InitRegs() override;
virtual void InitStack() override;
virtual void CloseStack() override;
u32 GetStackArg(u32 pos);
void FastCall(u32 addr);
void FastStop();
virtual void init_regs() override;
virtual void init_stack() override;
virtual void close_stack() override;
u32 get_stack_arg(u32 pos);
void fast_call(u32 addr);
void fast_stop();
virtual std::string RegsToString() const override;
virtual std::string ReadRegString(const std::string& reg) const override;

View File

@ -50,9 +50,9 @@ s32 sceKernelCreateThread(
armv7->PC = entry.addr();
armv7->prio = initPriority;
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)
@ -81,7 +81,7 @@ s32 sceKernelStartThread(s32 threadId, u32 argSize, vm::cptr<void> pArgBlock)
thread->GPR[0] = argSize;
thread->GPR[1] = pos;
thread->Exec();
thread->exec();
return SCE_OK;
}
@ -90,7 +90,7 @@ s32 sceKernelExitThread(ARMv7Context& context, s32 exitStatus)
sceLibKernel.Warning("sceKernelExitThread(exitStatus=0x%x)", exitStatus);
// exit status is stored in r0
static_cast<ARMv7Thread&>(context).Exit();
static_cast<ARMv7Thread&>(context).exit();
return SCE_OK;
}
@ -122,10 +122,10 @@ s32 sceKernelExitDeleteThread(ARMv7Context& context, s32 exitStatus)
sceLibKernel.Warning("sceKernelExitDeleteThread(exitStatus=0x%x)", exitStatus);
// exit status is stored in r0
static_cast<ARMv7Thread&>(context).Stop();
static_cast<ARMv7Thread&>(context).stop();
// current thread should be deleted
const u32 id = static_cast<ARMv7Thread&>(context).GetId();
const u32 id = static_cast<ARMv7Thread&>(context).get_id();
CallAfter([id]()
{
@ -167,7 +167,7 @@ u32 sceKernelGetThreadId(ARMv7Context& context)
{
sceLibKernel.Log("sceKernelGetThreadId()");
return static_cast<ARMv7Thread&>(context).GetId();
return static_cast<ARMv7Thread&>(context).get_id();
}
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;

View File

@ -231,7 +231,7 @@ void initialize_psv_modules()
hle_return.name = "HLE_RETURN";
hle_return.func = [](ARMv7Context& context)
{
static_cast<ARMv7Thread&>(context).FastStop();
static_cast<ARMv7Thread&>(context).fast_stop();
};
// load functions

View File

@ -22,18 +22,18 @@ CPUThread::CPUThread(CPUThreadType type, const std::string& name, std::function<
std::unique_lock<std::mutex> lock(mutex);
// check thread status
while (joinable() && IsActive())
while (joinable() && is_alive())
{
CHECK_EMU_STATUS;
// check stop status
if (!IsStopped())
if (!is_stopped())
{
if (lock) lock.unlock();
try
{
Task();
task();
}
catch (CPUThreadReturn)
{
@ -50,7 +50,7 @@ CPUThread::CPUThread(CPUThreadType type, const std::string& name, std::function<
}
catch (const fmt::exception&)
{
DumpInformation();
dump_info();
throw;
}
@ -79,12 +79,12 @@ CPUThread::~CPUThread()
SendDbgCommand(DID_REMOVE_THREAD, this);
}
bool CPUThread::IsPaused() const
bool CPUThread::is_paused() const
{
return (m_state.load() & CPU_STATE_PAUSED) != 0 || Emu.IsPaused();
}
void CPUThread::DumpInformation() const
void CPUThread::dump_info() const
{
if (!Emu.IsStopped())
{
@ -92,18 +92,18 @@ void CPUThread::DumpInformation() const
}
}
void CPUThread::Run()
void CPUThread::run()
{
SendDbgCommand(DID_START_THREAD, this);
InitStack();
InitRegs();
DoRun();
init_stack();
init_regs();
do_run();
SendDbgCommand(DID_STARTED_THREAD, this);
}
void CPUThread::Pause()
void CPUThread::pause()
{
SendDbgCommand(DID_PAUSE_THREAD, this);
@ -112,7 +112,7 @@ void CPUThread::Pause()
SendDbgCommand(DID_PAUSED_THREAD, this);
}
void CPUThread::Resume()
void CPUThread::resume()
{
SendDbgCommand(DID_RESUME_THREAD, this);
@ -128,7 +128,7 @@ void CPUThread::Resume()
SendDbgCommand(DID_RESUMED_THREAD, this);
}
void CPUThread::Stop()
void CPUThread::stop()
{
SendDbgCommand(DID_STOP_THREAD, this);
@ -149,7 +149,7 @@ void CPUThread::Stop()
SendDbgCommand(DID_STOPED_THREAD, this);
}
void CPUThread::Exec()
void CPUThread::exec()
{
SendDbgCommand(DID_EXEC_THREAD, this);
@ -163,7 +163,7 @@ void CPUThread::Exec()
}
}
void CPUThread::Exit()
void CPUThread::exit()
{
if (is_current())
{
@ -175,7 +175,7 @@ void CPUThread::Exit()
}
}
void CPUThread::Step()
void CPUThread::step()
{
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_SLEEP;
}
void CPUThread::Awake()
void CPUThread::awake()
{
// 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
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
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);
@ -263,7 +263,7 @@ bool CPUThread::CheckStatus()
{
CHECK_EMU_STATUS; // check at least once
if (!IsPaused()) break;
if (!is_paused()) break;
if (!lock)
{
@ -274,7 +274,7 @@ bool CPUThread::CheckStatus()
cv.wait(lock);
}
if (m_state.load() & CPU_STATE_RETURN || IsStopped())
if (m_state.load() & CPU_STATE_RETURN || is_stopped())
{
return true;
}

View File

@ -59,59 +59,59 @@ protected:
public:
virtual ~CPUThread() override;
u32 GetId() const { return m_id; }
CPUThreadType GetType() const { return m_type; }
std::string GetName() const { return m_name; }
u32 get_id() const { return m_id; }
CPUThreadType get_type() const { return m_type; }
std::string get_name() const { return m_name; }
bool IsActive() const { return (m_state.load() & CPU_STATE_DEAD) == 0; }
bool IsStopped() const { return (m_state.load() & CPU_STATE_STOPPED) != 0; }
virtual bool IsPaused() const;
bool is_alive() const { return (m_state.load() & CPU_STATE_DEAD) == 0; }
bool is_stopped() const { return (m_state.load() & CPU_STATE_STOPPED) != 0; }
virtual bool is_paused() const;
virtual void DumpInformation() const;
virtual u32 GetPC() const = 0;
virtual u32 GetOffset() const = 0;
virtual void DoRun() = 0;
virtual void Task() = 0;
virtual void dump_info() const;
virtual u32 get_pc() const = 0;
virtual u32 get_offset() const = 0;
virtual void do_run() = 0;
virtual void task() = 0;
virtual void InitRegs() = 0;
virtual void InitStack() = 0;
virtual void CloseStack() = 0;
virtual void init_regs() = 0;
virtual void init_stack() = 0;
virtual void close_stack() = 0;
// initialize thread
void Run();
void run();
// called by the debugger, don't use
void Pause();
void pause();
// called by the debugger, don't use
void Resume();
void resume();
// stop thread execution
void Stop();
void stop();
// start thread execution (removing STOP status)
void Exec();
void exec();
// exit thread execution
void Exit();
void exit();
// called by the debugger, don't use
void Step();
void step();
// trigger thread status check
void Sleep();
void sleep();
// untrigger thread status check
void Awake();
void awake();
// set SIGNAL and notify (returns true if set)
bool Signal();
bool signal();
// test SIGNAL and reset
bool Unsignal();
bool unsignal();
// process m_state flags, returns true if the checker must return
bool CheckStatus();
bool check_status();
std::string GetFName() const
{
@ -162,54 +162,6 @@ public:
virtual std::string RegsToString() const = 0;
virtual std::string ReadRegString(const std::string& reg) const = 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
@ -245,8 +197,8 @@ public:
// return thread->IsJoinable();
//}
u32 get_id() const
{
return thread->GetId();
}
//u32 get_id() const
//{
// return thread->GetId();
//}
};

View File

@ -59,12 +59,12 @@ void CPUThreadManager::Exec()
{
for (auto& t : Emu.GetIdManager().get_all<PPUThread>())
{
t->Exec();
t->exec();
}
for (auto& t : Emu.GetIdManager().get_all<ARMv7Thread>())
{
t->Exec();
t->exec();
}
}

View File

@ -1476,7 +1476,7 @@ void ppu_interpreter::SC(PPUThread& CPU, ppu_opcode_t op)
switch (op.lev)
{
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
case 0x3: CPU.FastStop(); break;
case 0x3: CPU.fast_stop(); break;
default: throw EXCEPTION("");
}
}

View File

@ -2240,7 +2240,7 @@ private:
{
case 0x0: SysCalls::DoSyscall(CPU, CPU.GPR[11]); break;
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);
}
}

View File

@ -2026,7 +2026,7 @@ void Compiler::SC(u32 lev) {
Call<void>("SysCalls.DoSyscall", SysCalls::DoSyscall, m_state.args[CompileTaskState::Args::State], GetGpr(11));
break;
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;
default:
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) {
return ppu_state->CheckStatus();
return ppu_state->check_status();
}
BranchType ppu_recompiler_llvm::GetBranchTypeFromInstruction(u32 instruction) {

View File

@ -490,7 +490,7 @@ void fill_ppu_exec_map(u32 addr, u32 size)
}
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();
}
@ -506,11 +506,11 @@ PPUThread::~PPUThread()
join();
}
CloseStack();
close_stack();
ppu_free_tls(m_id);
}
void PPUThread::DumpInformation() const
void PPUThread::dump_info() const
{
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);
}
CPUThread::DumpInformation();
CPUThread::dump_info();
}
void PPUThread::InitRegs()
void PPUThread::init_regs()
{
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
@ -536,7 +536,7 @@ void PPUThread::InitRegs()
TB = 0;
}
void PPUThread::InitStack()
void PPUThread::init_stack()
{
if (!stack_addr)
{
@ -554,7 +554,7 @@ void PPUThread::InitStack()
}
}
void PPUThread::CloseStack()
void PPUThread::close_stack()
{
if (stack_addr)
{
@ -563,7 +563,7 @@ void PPUThread::CloseStack()
}
}
void PPUThread::DoRun()
void PPUThread::do_run()
{
m_dec.reset();
@ -636,12 +636,12 @@ int FPRdouble::Cmp(PPCdouble a, PPCdouble b)
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)));
}
void PPUThread::FastCall2(u32 addr, u32 rtoc)
void PPUThread::fast_call(u32 addr, u32 rtoc)
{
if (!is_current())
{
@ -652,16 +652,18 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc)
auto old_stack = GPR[1];
auto old_rtoc = GPR[2];
auto old_LR = LR;
auto old_task = decltype(custom_task)();
auto old_task = std::move(custom_task);
assert(!old_task || !custom_task);
PC = addr;
GPR[2] = rtoc;
LR = Emu.GetCPUThreadStop();
custom_task.swap(old_task);
custom_task = nullptr;
try
{
Task();
task();
}
catch (CPUThreadReturn)
{
@ -678,21 +680,21 @@ void PPUThread::FastCall2(u32 addr, u32 rtoc)
GPR[2] = old_rtoc;
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;
}
void PPUThread::Task()
void PPUThread::task()
{
SetHostRoundingMode(FPSCR_RN_NEAR);
if (custom_task)
{
if (CheckStatus()) return;
if (check_status()) return;
return custom_task(*this);
}
@ -701,7 +703,7 @@ void PPUThread::Task()
{
while (true)
{
if (m_state.load() && CheckStatus()) break;
if (m_state.load() && check_status()) break;
// decode instruction using specified decoder
m_dec->DecodeMemory(PC);
@ -714,7 +716,7 @@ void PPUThread::Task()
{
while (true)
{
if (m_state.load() && CheckStatus()) break;
if (m_state.load() && check_status()) break;
// get interpreter function
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()
{
thread->Run();
thread->run();
gpr(3, argc);
gpr(4, argv.addr());

View File

@ -540,15 +540,15 @@ public:
PPUThread(const std::string& name);
virtual ~PPUThread() override;
virtual void DumpInformation() const override;
virtual u32 GetPC() const override { return PC; }
virtual u32 GetOffset() const override { return 0; }
virtual void DoRun() override;
virtual void Task() override;
virtual void dump_info() const override;
virtual u32 get_pc() const override { return PC; }
virtual u32 get_offset() const override { return 0; }
virtual void do_run() override;
virtual void task() override;
virtual void InitRegs() override;
virtual void InitStack() override;
virtual void CloseStack() override;
virtual void init_regs() override;
virtual void init_stack() override;
virtual void close_stack() override;
inline u8 GetCR(const u8 n) const
{
@ -810,14 +810,14 @@ public:
}
else
{
return GetStackArg(++g_count);
return get_stack_arg(++g_count);
}
}
public:
u64 GetStackArg(s32 i);
void FastCall2(u32 addr, u32 rtoc);
void FastStop();
u64 get_stack_arg(s32 i);
void fast_call(u32 addr, u32 rtoc);
void fast_stop();
};
class ppu_thread : cpu_thread

View File

@ -9,7 +9,7 @@
thread_local spu_mfc_arg_t raw_spu_mfc[8] = {};
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))
{
@ -27,28 +27,7 @@ RawSPUThread::~RawSPUThread()
}
}
void RawSPUThread::start()
{
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)
bool RawSPUThread::read_reg(const u32 addr, u32& value)
{
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;
}
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;
switch (offset)
@ -147,7 +145,7 @@ bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
if (value & MFC_START_MASK)
{
start();
try_start();
}
return true;
@ -195,12 +193,12 @@ bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
{
if (value == SPU_RUNCNTL_RUN_REQUEST)
{
start();
try_start();
}
else if (value == SPU_RUNCNTL_STOP_REQUEST)
{
status &= ~SPU_STATUS_RUNNING;
Stop();
stop();
}
else
{
@ -239,7 +237,7 @@ bool RawSPUThread::WriteReg(const u32 addr, const u32 value)
return false;
}
void RawSPUThread::Task()
void RawSPUThread::task()
{
// get next PC and SPU Interrupt status
PC = npc.exchange(0);
@ -248,7 +246,7 @@ void RawSPUThread::Task()
PC &= 0x3FFFC;
SPUThread::Task();
SPUThread::task();
// save next PC and current SPU Interrupt status
npc.store(PC | ((ch_event_stat.load() & SPU_EVENT_INTR_ENABLED) != 0));

View File

@ -20,11 +20,9 @@ public:
RawSPUThread(const std::string& name, u32 index);
virtual ~RawSPUThread();
void start();
bool ReadReg(const u32 addr, u32& value);
bool WriteReg(const u32 addr, const u32 value);
bool read_reg(const u32 addr, u32& value);
bool write_reg(const u32 addr, const u32 value);
private:
virtual void Task();
virtual void task() override;
};

View File

@ -90,7 +90,7 @@ SPUThread::SPUThread(CPUThreadType type, const std::string& name, std::function<
}
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)
, 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;
}
@ -135,27 +135,27 @@ bool SPUThread::IsPaused() const
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);
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)
{
while (true)
{
if (m_state.load() && CheckStatus()) break;
if (m_state.load() && check_status()) break;
// decode instruction using specified decoder
m_dec->DecodeMemory(PC + offset);
@ -168,7 +168,7 @@ void SPUThread::Task()
{
while (true)
{
if (m_state.load() && CheckStatus()) break;
if (m_state.load() && check_status()) break;
// read opcode
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));
FPSCR.Reset();
@ -224,17 +224,17 @@ void SPUThread::InitRegs()
GPR[1]._u32[3] = 0x3FFF0; // initial stack frame pointer
}
void SPUThread::InitStack()
void SPUThread::init_stack()
{
// nothing to do
}
void SPUThread::CloseStack()
void SPUThread::close_stack()
{
// nothing to do here
}
void SPUThread::DoRun()
void SPUThread::do_run()
{
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())
{
@ -278,15 +278,15 @@ void SPUThread::FastCall(u32 ls_addr)
auto old_PC = PC;
auto old_LR = GPR[0]._u32[3];
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;
GPR[0]._u32[3] = 0x0;
m_custom_task.swap(old_task);
custom_task = nullptr;
try
{
Task();
task();
}
catch (CPUThreadReturn)
{
@ -297,7 +297,7 @@ void SPUThread::FastCall(u32 ls_addr)
PC = old_PC;
GPR[0]._u32[3] = old_LR;
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)
@ -657,7 +657,7 @@ u32 SPUThread::get_ch_value(u32 ch)
CHECK_EMU_STATUS;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
if (!lock)
{
@ -698,7 +698,7 @@ u32 SPUThread::get_ch_value(u32 ch)
CHECK_EMU_STATUS;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
if (!lock)
{
@ -763,14 +763,14 @@ u32 SPUThread::get_ch_value(u32 ch)
if (ch_event_mask.load() & SPU_EVENT_LR)
{
// 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
{
lock.lock();
// simple waiting loop otherwise
while (!get_events(true) && !IsStopped())
while (!get_events(true) && !is_stopped())
{
CHECK_EMU_STATUS;
@ -780,7 +780,7 @@ u32 SPUThread::get_ch_value(u32 ch)
ch_event_stat &= ~SPU_EVENT_WAITING;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
return get_events();
}
@ -818,7 +818,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
{
CHECK_EMU_STATUS;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
if (!lock)
{
@ -875,7 +875,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
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);
}
@ -916,7 +916,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
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;
}
else if (code == 128)
@ -1042,7 +1042,7 @@ void SPUThread::set_ch_value(u32 ch, u32 value)
{
CHECK_EMU_STATUS;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
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);
return Stop();
return stop();
}
switch (code)
@ -1306,7 +1306,7 @@ void SPUThread::stop_and_signal(u32 code)
{
CHECK_EMU_STATUS;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
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)
{
if (t) t->Sleep(); // trigger status check
if (t) t->sleep(); // trigger status check
}
}
else
@ -1334,7 +1334,7 @@ void SPUThread::stop_and_signal(u32 code)
{
CHECK_EMU_STATUS;
if (IsStopped()) throw CPUThreadStop{};
if (is_stopped()) throw CPUThreadStop{};
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)
{
if (t) t->Awake(); // untrigger status check
if (t) t->awake(); // untrigger status check
}
group->cv.notify_all();
@ -1412,7 +1412,7 @@ void SPUThread::stop_and_signal(u32 code)
{
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->cv.notify_one();
return Stop();
return stop();
}
case 0x102:
@ -1450,7 +1450,7 @@ void SPUThread::stop_and_signal(u32 code)
status |= SPU_STATUS_STOPPED_BY_STOP;
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);
return Stop();
return stop();
}
status |= SPU_STATUS_STOPPED_BY_HALT;

View File

@ -682,7 +682,7 @@ public:
}
}
std::function<void(SPUThread& SPU)> m_custom_task;
std::function<void(SPUThread&)> custom_task;
protected:
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);
virtual ~SPUThread() override;
virtual bool IsPaused() const override;
virtual bool is_paused() const override;
virtual void DumpInformation() const override;
virtual u32 GetPC() const override { return PC; }
virtual u32 GetOffset() const override { return offset; }
virtual void DoRun() override;
virtual void Task() override;
virtual void dump_info() const override;
virtual u32 get_pc() const override { return PC; }
virtual u32 get_offset() const override { return offset; }
virtual void do_run() override;
virtual void task() override;
virtual void InitRegs() override;
virtual void InitStack() override;
virtual void CloseStack() override;
virtual void init_regs() override;
virtual void init_stack() override;
virtual void close_stack() override;
void FastCall(u32 ls_addr);
void fast_call(u32 ls_addr);
virtual std::string RegsToString() const
{
@ -770,7 +770,7 @@ public:
{
auto& spu = static_cast<SPUThread&>(*thread);
spu.Run();
spu.run();
return *this;
}

View File

@ -243,7 +243,7 @@ namespace vm
mask = ~0;
// signal thread (must not be signaled yet)
if (!thread->Signal())
if (!thread->signal())
{
throw EXCEPTION("Thread already signaled");
}
@ -259,7 +259,7 @@ namespace vm
void waiter_lock_t::wait()
{
while (!m_waiter->thread->Unsignal())
while (!m_waiter->thread->unsignal())
{
if (m_waiter->pred())
{
@ -1048,7 +1048,7 @@ namespace vm
u32 stack_push(CPUThread& cpu, u32 size, u32 align_v, u32& old_pos)
{
switch (cpu.GetType())
switch (cpu.get_type())
{
case CPU_THREAD_PPU:
{
@ -1107,14 +1107,14 @@ namespace vm
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)
{
switch (cpu.GetType())
switch (cpu.get_type())
{
case CPU_THREAD_PPU:
{
@ -1158,7 +1158,7 @@ namespace vm
default:
{
throw EXCEPTION("Invalid thread type (%d)", cpu.GetType());
throw EXCEPTION("Invalid thread type (%d)", cpu.get_type());
}
}
}

View File

@ -171,7 +171,7 @@ namespace cb_detail
const bool stack = _bind_func_args<0, 0, 0, T...>(CPU, args...);
if (stack) CPU.GPR[1] -= FIXED_STACK_FRAME_SIZE;
CPU.GPR[1] -= 0x70; // create reserved area
CPU.FastCall2(pc, rtoc);
CPU.fast_call(pc, rtoc);
CPU.GPR[1] += 0x70;
if (stack) CPU.GPR[1] += FIXED_STACK_FRAME_SIZE;
}

View File

@ -87,7 +87,7 @@ void CallbackManager::Init()
thread->prio = 1001;
thread->stack_size = 0x10000;
thread->custom_task = task;
thread->Run();
thread->run();
m_cb_thread = thread;
}
@ -98,7 +98,7 @@ void CallbackManager::Init()
thread->prio = 1001;
thread->stack_size = 0x10000;
thread->custom_task = task;
thread->Run();
thread->run();
m_cb_thread = thread;
}

View File

@ -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));
}
CPU.FastCall2(pc, rtoc);
CPU.fast_call(pc, rtoc);
if (Ini.HLELogging.GetValue())
{

View File

@ -469,8 +469,8 @@ void adecOpen(u32 adec_id) // TODO: call from the constructor
};
adec.adecCb->Run();
adec.adecCb->Exec();
adec.adecCb->run();
adec.adecCb->exec();
}
bool adecCheckType(s32 type)
@ -572,7 +572,7 @@ s32 cellAdecClose(u32 handle)
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);
return CELL_OK;
}

View File

@ -764,8 +764,8 @@ void dmuxOpen(u32 dmux_id) // TODO: call from the constructor
dmux.is_finished = true;
};
dmux.dmuxCb->Run();
dmux.dmuxCb->Exec();
dmux.dmuxCb->run();
dmux.dmuxCb->exec();
}
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
}
Emu.GetIdManager().remove<PPUThread>(dmux->dmuxCb->GetId());
Emu.GetIdManager().remove<PPUThread>(dmux->dmuxCb->get_id());
Emu.GetIdManager().remove<Demuxer>(handle);
return CELL_OK;
}

View File

@ -1156,10 +1156,10 @@ s32 spursInit(
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()
spuThread->m_custom_task = [spurs](SPUThread& SPU)
spuThread->custom_task = [spurs](SPUThread& spu)
{
SPU.RegisterHleFunction(spurs->spuImg.entry_point, spursKernelEntry);
SPU.FastCall(spurs->spuImg.entry_point);
spu.RegisterHleFunction(spurs->spuImg.entry_point, spursKernelEntry);
spu.fast_call(spurs->spuImg.entry_point);
};
}

View File

@ -1386,7 +1386,7 @@ void spursTasksetOnTaskExit(SPUThread & spu, u64 addr, u32 taskId, s32 exitCode,
spu.GPR[4]._u32[3] = taskId;
spu.GPR[5]._u32[3] = exitCode;
spu.GPR[6]._u64[1] = args;
spu.FastCall(0x10000);
spu.fast_call(0x10000);
}
/// Save the context of a task
@ -1505,7 +1505,7 @@ void spursTasksetDispatch(SPUThread & spu) {
if (elfAddr & 2) { // TODO: Figure this out
spu.status |= SPU_STATUS_STOPPED_BY_STOP;
spu.Stop();
spu.stop();
return;
}
@ -1551,7 +1551,7 @@ void spursTasksetDispatch(SPUThread & spu) {
if (elfAddr & 2) { // TODO: Figure this out
spu.status |= SPU_STATUS_STOPPED_BY_STOP;
spu.Stop();
spu.stop();
return;
}

View File

@ -540,8 +540,8 @@ void vdecOpen(u32 vdec_id) // TODO: call from the constructor
vdec.is_finished = true;
};
vdec.vdecCb->Run();
vdec.vdecCb->Exec();
vdec.vdecCb->run();
vdec.vdecCb->exec();
}
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
}
Emu.GetIdManager().remove<PPUThread>(vdec->vdecCb->GetId());
Emu.GetIdManager().remove<PPUThread>(vdec->vdecCb->get_id());
Emu.GetIdManager().remove<VideoDecoder>(handle);
return CELL_OK;
}

View File

@ -455,11 +455,11 @@ s32 cellSurMixerCreate(vm::cptr<CellSurMixerConfig> config)
surMixerCb.set(0);
Emu.GetIdManager().remove<PPUThread>(ppu.GetId());
Emu.GetIdManager().remove<PPUThread>(ppu.get_id());
};
ppu->Run();
ppu->Exec();
ppu->run();
ppu->exec();
return CELL_OK;
}

View File

@ -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);
// 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;
}
@ -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);
const be_t<u32> tid = ppu.GetId();
const be_t<u32> tid = ppu.get_id();
// try to lock lightweight mutex
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);
const be_t<u32> tid = ppu.GetId();
const be_t<u32> tid = ppu.get_id();
// try to lock lightweight mutex
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);
const be_t<u32> tid = ppu.GetId();
const be_t<u32> tid = ppu.get_id();
// check owner
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);
}
if (lwmutex->vars.owner.load() == ppu.GetId())
if (lwmutex->vars.owner.load() == ppu.get_id())
{
// if owns the mutex
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);
}
if (lwmutex->vars.owner.load() == ppu.GetId())
if (lwmutex->vars.owner.load() == ppu.get_id())
{
// if owns the mutex, call the syscall
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);
}
if (lwmutex->vars.owner.load() == ppu.GetId())
if (lwmutex->vars.owner.load() == ppu.get_id())
{
// if owns the mutex
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);
const be_t<u32> tid = ppu.GetId();
const be_t<u32> tid = ppu.get_id();
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);
*thread_id = ppu.GetId();
*thread_id = ppu.get_id();
return CELL_OK;
}

View File

@ -71,7 +71,7 @@ namespace ppu_func_detail
static force_inline T get_arg(PPUThread& CPU)
{
// 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);
}
};

View File

@ -41,18 +41,18 @@ sleep_queue_entry_t::sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue)
, m_queue(queue)
{
add_entry();
cpu.Sleep();
cpu.sleep();
}
sleep_queue_entry_t::sleep_queue_entry_t(CPUThread& cpu, sleep_queue_t& queue, const defer_sleep_t&)
: m_thread(cpu)
, m_queue(queue)
{
cpu.Sleep();
cpu.sleep();
}
sleep_queue_entry_t::~sleep_queue_entry_t() noexcept(false)
{
remove_entry();
m_thread.Awake();
m_thread.awake();
}

View File

@ -27,7 +27,7 @@ void lv2_cond_t::notify(lv2_lock_t& lv2_lock, sleep_queue_t::iterator it)
{
mutex->owner = thread;
if (!thread->Signal())
if (!thread->signal())
{
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)
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->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)
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
if (timeout && waiter)
{
@ -228,8 +230,6 @@ s32 sys_cond_wait(PPUThread& ppu, u32 cond_id, u64 timeout)
{
ppu.cv.wait(lv2_lock);
}
CHECK_EMU_STATUS;
}
// mutex owner is restored after notification or unlocking

View File

@ -30,7 +30,7 @@ void lv2_int_serv_t::join(PPUThread& ppu, lv2_lock_t& lv2_lock)
thread->cv.notify_one();
// Start joining
while (thread->IsActive())
while (thread->is_alive())
{
CHECK_EMU_STATUS;
@ -39,7 +39,7 @@ void lv2_int_serv_t::join(PPUThread& ppu, lv2_lock_t& lv2_lock)
// Cleanup
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)
@ -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 (!it->IsStopped())
if (!it->is_stopped())
{
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[4] = arg2;
ppu.FastCall2(pc, rtoc);
ppu.fast_call(pc, rtoc);
handler->signal--;
continue;
@ -137,10 +137,10 @@ s32 _sys_interrupt_thread_establish(vm::ptr<u32> ih, u32 intrtag, u32 intrthread
ppu.cv.wait(lv2_lock);
}
ppu.Exit();
ppu.exit();
};
it->Exec();
it->exec();
*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.FastStop();
ppu.fast_stop();
}

View File

@ -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
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;
@ -189,7 +189,7 @@ s32 _sys_lwcond_queue_wait(PPUThread& CPU, u32 lwcond_id, u32 lwmutex_id, u64 ti
if (is_timedout)
{
// cancel waiting
if (!cond->waiters.erase(CPU.GetId()))
if (!cond->waiters.erase(CPU.get_id()))
{
if (cond->signaled1 && !mutex->signaled)
{

View File

@ -22,7 +22,7 @@ void lv2_mutex_t::unlock(lv2_lock_t& lv2_lock)
// pick new owner; protocol is ignored in current implementation
owner = sq.front();
if (!owner->Signal())
if (!owner->signal())
{
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
sleep_queue_entry_t waiter(ppu, mutex->sq);
while (!ppu.Unsignal())
while (!ppu.unsignal())
{
CHECK_EMU_STATUS;

View File

@ -31,10 +31,10 @@ void _sys_ppu_thread_exit(PPUThread& ppu, u64 errorcode)
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()
@ -71,7 +71,7 @@ s32 sys_ppu_thread_join(PPUThread& ppu, u32 thread_id, vm::ptr<u64> vptr)
thread->is_joining = true;
// join thread
while (thread->IsActive())
while (thread->is_alive())
{
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];
// cleanup
Emu.GetIdManager().remove<PPUThread>(thread->GetId());
Emu.GetIdManager().remove<PPUThread>(thread->get_id());
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->stack_size = stacksize < 0x4000 ? 0x4000 : stacksize; // (hack) adjust minimal stack size
ppu->custom_task = task;
ppu->Run();
ppu->run();
if (entry)
{
@ -231,10 +231,10 @@ u32 ppu_thread_create(u32 entry, u64 arg, s32 prio, u32 stacksize, bool is_joina
if (!is_interrupt)
{
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)
@ -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->stack_size = stacksize < 0x4000 ? 0x4000 : stacksize; // (hack) adjust minimal stack size
ppu->Run();
ppu->run();
ppu->PC = vm::read32(param->entry);
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;
}
*thread_id = ppu->GetId();
*thread_id = ppu->get_id();
return CELL_OK;
}
@ -293,7 +293,7 @@ s32 sys_ppu_thread_start(u32 thread_id)
return CELL_ESRCH;
}
thread->Exec();
thread->exec();
return CELL_OK;
}

View File

@ -166,7 +166,7 @@ s32 sys_rwlock_wlock(PPUThread& CPU, u32 rw_lock_id, u64 timeout)
return CELL_ESRCH;
}
if (rwlock->writer == CPU.GetId())
if (rwlock->writer == CPU.get_id())
{
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->writer = CPU.GetId();
rwlock->writer = CPU.get_id();
rwlock->wwaiters--;
return CELL_OK;
@ -206,7 +206,7 @@ s32 sys_rwlock_trywlock(PPUThread& CPU, u32 rw_lock_id)
return CELL_ESRCH;
}
if (rwlock->writer == CPU.GetId())
if (rwlock->writer == CPU.get_id())
{
return CELL_EDEADLK;
}
@ -216,7 +216,7 @@ s32 sys_rwlock_trywlock(PPUThread& CPU, u32 rw_lock_id)
return CELL_EBUSY;
}
rwlock->writer = CPU.GetId();
rwlock->writer = CPU.get_id();
return CELL_OK;
}
@ -234,7 +234,7 @@ s32 sys_rwlock_wunlock(PPUThread& CPU, u32 rw_lock_id)
return CELL_ESRCH;
}
if (rwlock->writer != CPU.GetId())
if (rwlock->writer != CPU.get_id())
{
return CELL_EPERM;
}

View File

@ -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);
spu->m_custom_task = task;
spu->custom_task = task;
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;
}
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)
@ -265,7 +265,7 @@ s32 sys_spu_thread_group_destroy(u32 id)
{
if (t)
{
Emu.GetIdManager().remove<SPUThread>(t->GetId());
Emu.GetIdManager().remove<SPUThread>(t->get_id());
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);
t->PC = image->entry_point;
t->Run();
t->run();
t->GPR[3] = u128::from64(0, args.arg1);
t->GPR[4] = u128::from64(0, args.arg2);
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)
{
if (t) t->Exec();
if (t) t->exec();
}
return CELL_OK;
@ -383,7 +383,7 @@ s32 sys_spu_thread_group_suspend(u32 id)
for (auto& t : group->threads)
{
if (t) t->Sleep(); // trigger status check
if (t) t->sleep(); // trigger status check
}
return CELL_OK;
@ -424,7 +424,7 @@ s32 sys_spu_thread_group_resume(u32 id)
for (auto& t : group->threads)
{
if (t) t->Awake(); // untrigger status check
if (t) t->awake(); // untrigger status check
}
group->cv.notify_all();
@ -498,7 +498,7 @@ s32 sys_spu_thread_group_terminate(u32 id, s32 value)
for (auto& t : group->threads)
{
if (t) t->Stop();
if (t) t->stop();
}
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;
}
thread->Run();
thread->run();
*id = thread->index;
@ -1170,7 +1170,7 @@ s32 sys_raw_spu_destroy(PPUThread& ppu, u32 id)
// TODO: CELL_EBUSY is not returned
// Stop thread
thread->Stop();
thread->stop();
// Clear interrupt handlers
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;
}

View File

@ -300,7 +300,7 @@ void Emulator::Pause()
for (auto& t : GetCPU().GetAllThreads())
{
t->Sleep(); // trigger status check
t->sleep(); // trigger status check
}
SendDbgCommand(DID_PAUSED_EMU);
@ -332,7 +332,7 @@ void Emulator::Resume()
for (auto& t : GetCPU().GetAllThreads())
{
t->Awake(); // untrigger status check and signal
t->awake(); // untrigger status check and signal
}
SendDbgCommand(DID_RESUMED_EMU);
@ -359,7 +359,7 @@ void Emulator::Stop()
{
std::lock_guard<std::mutex> lock(t->mutex);
t->Sleep(); // trigger status check
t->sleep(); // trigger status check
t->cv.notify_one(); // signal
}

View File

@ -73,7 +73,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u64 _pc, CPUTh
s_panel_margin_x->AddSpacer(12);
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);
@ -83,7 +83,7 @@ InstructionEditorDialog::InstructionEditorDialog(wxPanel *parent, u64 _pc, CPUTh
if (!t2_instr->GetValue().ToULong(&opcode, 16))
wxMessageBox("This instruction could not be parsed.\nNo changes were made.","Error");
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;
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.");
}

View File

@ -128,7 +128,7 @@ void InterpreterDisAsmFrame::OnSelectUnit(wxCommandEvent& event)
if(CPU)
{
switch(CPU->GetType())
switch(CPU->get_type())
{
case CPU_THREAD_PPU:
{
@ -247,10 +247,10 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
}
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)
{
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));
count = 4;
@ -258,7 +258,7 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
}
disasm->dump_pc = PC;
count = decoder->DecodeMemory(CPU->GetOffset() + PC);
count = decoder->DecodeMemory(CPU->get_offset() + PC);
if(IsBreakPoint(PC))
{
@ -271,7 +271,7 @@ void InterpreterDisAsmFrame::ShowAddr(const u64 addr)
wxColour colour;
if(CPU->IsPaused() && PC == CPU->GetPC())
if(CPU->is_paused() && PC == CPU->get_pc())
{
colour = wxColour("Green");
}
@ -339,11 +339,9 @@ void InterpreterDisAsmFrame::WriteCallStack()
return;
}
const std::string data = CPU->CallStackToString();
m_calls->Freeze();
m_calls->Clear();
m_calls->WriteText(fmt::FromUTF8(data));
//m_calls->WriteText(fmt::FromUTF8(data));
m_calls->Thaw();
}
@ -365,7 +363,7 @@ void InterpreterDisAsmFrame::HandleCommand(wxCommandEvent& event)
break;
}
}
else if(CPU && thr->GetId() == CPU->GetId())
else if(CPU && thr->get_id() == CPU->get_id())
{
switch(event.GetId())
{
@ -455,11 +453,11 @@ void InterpreterDisAsmFrame::Show_Val(wxCommandEvent& WXUNUSED(event))
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)
{
unsigned long pc = CPU ? CPU->GetPC() : 0x0;
unsigned long pc = CPU ? CPU->get_pc() : 0x0;
p_pc->GetValue().ToULong(&pc, 16);
Emu.GetMarkedPoints().push_back(pc);
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))
{
if(CPU) ShowAddr(CentrePc(CPU->GetPC()));
if(CPU) ShowAddr(CentrePc(CPU->get_pc()));
}
void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
{
if(!CPU) return;
if(CPU->IsPaused()) CPU->Resume();
if(CPU->is_paused()) CPU->resume();
if(!Emu.IsPaused())
{
CPU->Exec();
CPU->exec();
}
//ThreadBase::Start();
@ -489,12 +487,12 @@ void InterpreterDisAsmFrame::DoRun(wxCommandEvent& WXUNUSED(event))
void InterpreterDisAsmFrame::DoPause(wxCommandEvent& WXUNUSED(event))
{
//DoUpdate();
if(CPU) CPU->Pause();
if(CPU) CPU->pause();
}
void InterpreterDisAsmFrame::DoStep(wxCommandEvent& WXUNUSED(event))
{
if(CPU) CPU->Step();
if(CPU) CPU->step();
}
void InterpreterDisAsmFrame::InstrKey(wxListEvent& event)

View File

@ -224,7 +224,7 @@ void KernelExplorer::Update()
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);
}
}
@ -236,9 +236,9 @@ void KernelExplorer::Update()
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);
}
}
@ -251,9 +251,9 @@ void KernelExplorer::Update()
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);
}
}

View File

@ -67,7 +67,7 @@ RegisterEditorDialog::RegisterEditorDialog(wxPanel *parent, u64 _pc, CPUThread*
Bind(wxEVT_COMBOBOX, &RegisterEditorDialog::updateRegister, this);
switch(CPU->GetType())
switch(CPU->get_type())
{
case CPU_THREAD_PPU:
for (int i=0; i<32; i++) t1_register->Append(wxString::Format("GPR[%d]",i));