diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp index 32f213c8f066..45740b1f6cdc 100644 --- a/Source/Core/Core/Core.cpp +++ b/Source/Core/Core/Core.cpp @@ -263,7 +263,7 @@ void Stop() // - Hammertime! PowerPC::Stop(); // Kick it if it's waiting (code stepping wait loop) - CCPU::StepOpcode(); + CPU::StepOpcode(); if (_CoreParameter.bCPUThread) { @@ -344,7 +344,7 @@ static void CpuThread() #endif // Enter CPU run loop. When we leave it - we are done. - CCPU::Run(); + CPU::Run(); s_is_started = false; @@ -606,11 +606,11 @@ void SetState(EState _State) switch (_State) { case CORE_PAUSE: - CCPU::EnableStepping(true); // Break + CPU::EnableStepping(true); // Break Wiimote::Pause(); break; case CORE_RUN: - CCPU::EnableStepping(false); + CPU::EnableStepping(false); Wiimote::Resume(); break; default: @@ -626,10 +626,10 @@ EState GetState() if (s_hardware_initialized) { - if (CCPU::IsStepping()) + if (CPU::IsStepping()) return CORE_PAUSE; - else - return CORE_RUN; + + return CORE_RUN; } return CORE_UNINITIALIZED; @@ -707,7 +707,7 @@ bool PauseAndLock(bool doLock, bool unpauseOnUnlock) return true; // first pause or unpause the CPU - bool wasUnpaused = CCPU::PauseAndLock(doLock, unpauseOnUnlock); + bool wasUnpaused = CPU::PauseAndLock(doLock, unpauseOnUnlock); ExpansionInterface::PauseAndLock(doLock, unpauseOnUnlock); // audio has to come after CPU, because CPU thread can wait for audio thread (m_throttle). diff --git a/Source/Core/Core/HW/CPU.cpp b/Source/Core/Core/HW/CPU.cpp index b09e071d9803..96eb93705442 100644 --- a/Source/Core/Core/HW/CPU.cpp +++ b/Source/Core/Core/HW/CPU.cpp @@ -24,19 +24,22 @@ namespace static std::mutex m_csCpuOccupied; } -void CCPU::Init(int cpu_core) +namespace CPU +{ + +void Init(int cpu_core) { PowerPC::Init(cpu_core); m_SyncEvent = nullptr; } -void CCPU::Shutdown() +void Shutdown() { PowerPC::Shutdown(); m_SyncEvent = nullptr; } -void CCPU::Run() +void Run() { std::lock_guard lk(m_csCpuOccupied); Host_UpdateDisasmDialog(); @@ -81,22 +84,22 @@ void CCPU::Run() } } -void CCPU::Stop() +void Stop() { PowerPC::Stop(); m_StepEvent.Set(); } -bool CCPU::IsStepping() +bool IsStepping() { return PowerPC::GetState() == PowerPC::CPU_STEPPING; } -void CCPU::Reset() +void Reset() { } -void CCPU::StepOpcode(Common::Event *event) +void StepOpcode(Common::Event* event) { m_StepEvent.Set(); if (PowerPC::GetState() == PowerPC::CPU_STEPPING) @@ -105,9 +108,9 @@ void CCPU::StepOpcode(Common::Event *event) } } -void CCPU::EnableStepping(const bool _bStepping) +void EnableStepping(const bool stepping) { - if (_bStepping) + if (stepping) { PowerPC::Pause(); m_StepEvent.Reset(); @@ -139,15 +142,15 @@ void CCPU::EnableStepping(const bool _bStepping) } } -void CCPU::Break() +void Break() { EnableStepping(true); } -bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock) +bool PauseAndLock(bool do_lock, bool unpause_on_unlock) { bool wasUnpaused = !IsStepping(); - if (doLock) + if (do_lock) { // we can't use EnableStepping, that would causes deadlocks with both audio and video PowerPC::Pause(); @@ -156,7 +159,7 @@ bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock) } else { - if (unpauseOnUnlock) + if (unpause_on_unlock) { PowerPC::Start(); m_StepEvent.Set(); @@ -167,3 +170,5 @@ bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock) } return wasUnpaused; } + +} diff --git a/Source/Core/Core/HW/CPU.h b/Source/Core/Core/HW/CPU.h index 52d9cd0df90f..41b2630f2ebb 100644 --- a/Source/Core/Core/HW/CPU.h +++ b/Source/Core/Core/HW/CPU.h @@ -4,46 +4,46 @@ #pragma once -#include "Common/CommonTypes.h" - namespace Common { class Event; } -class CCPU +namespace CPU { -public: - // init - static void Init(int cpu_core); - // shutdown - static void Shutdown(); +// Init +void Init(int cpu_core); + +// Shutdown +void Shutdown(); + +// Starts the CPU +void Run(); - // starts the CPU - static void Run(); +// Causes shutdown +void Stop(); - // causes shutdown - static void Stop(); - // Reset - static void Reset(); +// Reset +void Reset(); - // StepOpcode (Steps one Opcode) - static void StepOpcode(Common::Event *event = nullptr); +// StepOpcode (Steps one Opcode) +void StepOpcode(Common::Event* event = nullptr); - // Enable or Disable Stepping - static void EnableStepping(const bool _bStepping); +// Enable or Disable Stepping +void EnableStepping(bool stepping); - // break, same as EnableStepping(true). - static void Break(); +// Break, same as EnableStepping(true). +void Break(); - // is stepping ? - static bool IsStepping(); +// Is stepping ? +bool IsStepping(); - // waits until is stepping and is ready for a command (paused and fully idle), and acquires a lock on that state. - // or, if doLock is false, releases a lock on that state and optionally re-disables stepping. - // calls must be balanced and non-recursive (once with doLock true, then once with doLock false). - // intended (but not required) to be called from another thread, - // e.g. when the GUI thread wants to make sure everything is paused so that it can create a savestate. - // the return value is whether the CPU was unpaused before the call. - static bool PauseAndLock(bool doLock, bool unpauseOnUnlock=true); -}; +// Waits until is stepping and is ready for a command (paused and fully idle), and acquires a lock on that state. +// or, if doLock is false, releases a lock on that state and optionally re-disables stepping. +// calls must be balanced and non-recursive (once with doLock true, then once with doLock false). +// intended (but not required) to be called from another thread, +// e.g. when the GUI thread wants to make sure everything is paused so that it can create a savestate. +// the return value is whether the CPU was unpaused before the call. +bool PauseAndLock(bool do_lock, bool unpause_on_unlock = true); + +} diff --git a/Source/Core/Core/HW/HW.cpp b/Source/Core/Core/HW/HW.cpp index ae89b677e148..b9ae3c60689f 100644 --- a/Source/Core/Core/HW/HW.cpp +++ b/Source/Core/Core/HW/HW.cpp @@ -47,7 +47,7 @@ namespace HW DSP::Init(SConfig::GetInstance().bDSPHLE); DVDInterface::Init(); GPFifo::Init(); - CCPU::Init(SConfig::GetInstance().iCPUCore); + CPU::Init(SConfig::GetInstance().iCPUCore); SystemTimers::Init(); if (SConfig::GetInstance().bWii) @@ -63,7 +63,7 @@ namespace HW void Shutdown() { SystemTimers::Shutdown(); - CCPU::Shutdown(); + CPU::Shutdown(); ExpansionInterface::Shutdown(); DVDInterface::Shutdown(); DSP::Shutdown(); diff --git a/Source/Core/Core/PowerPC/GDBStub.cpp b/Source/Core/Core/PowerPC/GDBStub.cpp index 1b930f81e8f8..3ad2715d18c8 100644 --- a/Source/Core/Core/PowerPC/GDBStub.cpp +++ b/Source/Core/Core/PowerPC/GDBStub.cpp @@ -247,7 +247,7 @@ static void gdb_read_command() } else if (c == 0x03) { - CCPU::Break(); + CPU::Break(); gdb_signal(SIGTRAP); return; } diff --git a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp index 76e4c2b59a40..0c72effafd19 100644 --- a/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp +++ b/Source/Core/Core/PowerPC/Interpreter/Interpreter.cpp @@ -244,7 +244,7 @@ void Interpreter::Run() } #endif INFO_LOG(POWERPC, "Hit Breakpoint - %08x", PC); - CCPU::Break(); + CPU::Break(); if (PowerPC::breakpoints.IsTempBreakPoint(PC)) PowerPC::breakpoints.Remove(PC); diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 9a06058bb105..f44ac3b46831 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -453,7 +453,7 @@ static __forceinline void Memcheck(u32 address, u32 var, bool write, int size) TMemCheck *mc = PowerPC::memchecks.GetMemCheck(address); if (mc) { - if (CCPU::IsStepping()) + if (CPU::IsStepping()) { // Disable when stepping so that resume works. return; @@ -462,7 +462,7 @@ static __forceinline void Memcheck(u32 address, u32 var, bool write, int size) bool pause = mc->Action(&PowerPC::debug_interface, var, address, write, size, PC); if (pause) { - CCPU::Break(); + CPU::Break(); // Fake a DSI so that all the code that tests for it in order to skip // the rest of the instruction will apply. (This means that // watchpoints will stop the emulator before the offending load/store, diff --git a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp index 3760ebd1c299..f21b56054bc3 100644 --- a/Source/Core/DolphinWX/Debugger/CodeWindow.cpp +++ b/Source/Core/DolphinWX/Debugger/CodeWindow.cpp @@ -283,11 +283,11 @@ void CCodeWindow::OnCallsListChange(wxCommandEvent& event) void CCodeWindow::SingleStep() { - if (CCPU::IsStepping()) + if (CPU::IsStepping()) { PowerPC::breakpoints.ClearAllTemporary(); JitInterface::InvalidateICache(PC, 4, true); - CCPU::StepOpcode(&sync_event); + CPU::StepOpcode(&sync_event); wxThread::Sleep(20); // need a short wait here JumpToAddress(PC); @@ -297,14 +297,14 @@ void CCodeWindow::SingleStep() void CCodeWindow::StepOver() { - if (CCPU::IsStepping()) + if (CPU::IsStepping()) { UGeckoInstruction inst = PowerPC::HostRead_Instruction(PC); if (inst.LK) { PowerPC::breakpoints.ClearAllTemporary(); PowerPC::breakpoints.Add(PC + 4, true); - CCPU::EnableStepping(false); + CPU::EnableStepping(false); JumpToAddress(PC); Update(); } @@ -321,7 +321,7 @@ void CCodeWindow::StepOver() void CCodeWindow::StepOut() { - if (CCPU::IsStepping()) + if (CPU::IsStepping()) { PowerPC::breakpoints.ClearAllTemporary(); @@ -365,7 +365,7 @@ void CCodeWindow::StepOut() void CCodeWindow::ToggleBreakpoint() { - if (CCPU::IsStepping()) + if (CPU::IsStepping()) { if (codeview) codeview->ToggleBreakpoint(codeview->GetSelection()); Update(); @@ -700,7 +700,7 @@ void CCodeWindow::UpdateButtonStates() { bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED); bool Pause = (Core::GetState() == Core::CORE_PAUSE); - bool Stepping = CCPU::IsStepping(); + bool Stepping = CPU::IsStepping(); wxToolBar* ToolBar = GetToolBar(); // Toolbar diff --git a/Source/Core/DolphinWX/FrameTools.cpp b/Source/Core/DolphinWX/FrameTools.cpp index 294819928665..d79981b56a27 100644 --- a/Source/Core/DolphinWX/FrameTools.cpp +++ b/Source/Core/DolphinWX/FrameTools.cpp @@ -845,10 +845,7 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event)) // Core is initialized and emulator is running if (UseDebugger) { - if (CCPU::IsStepping()) - CCPU::EnableStepping(false); - else - CCPU::EnableStepping(true); // Break + CPU::EnableStepping(!CPU::IsStepping()); wxThread::Sleep(20); g_pCodeWindow->JumpToAddress(PC);