CPU: Convert CCPU into a namespace
There's not much point to a class with only static member functions.
This commit is contained in:
parent
e076de137b
commit
ef1cc2cec4
|
@ -263,7 +263,7 @@ void Stop() // - Hammertime!
|
||||||
PowerPC::Stop();
|
PowerPC::Stop();
|
||||||
|
|
||||||
// Kick it if it's waiting (code stepping wait loop)
|
// Kick it if it's waiting (code stepping wait loop)
|
||||||
CCPU::StepOpcode();
|
CPU::StepOpcode();
|
||||||
|
|
||||||
if (_CoreParameter.bCPUThread)
|
if (_CoreParameter.bCPUThread)
|
||||||
{
|
{
|
||||||
|
@ -344,7 +344,7 @@ static void CpuThread()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Enter CPU run loop. When we leave it - we are done.
|
// Enter CPU run loop. When we leave it - we are done.
|
||||||
CCPU::Run();
|
CPU::Run();
|
||||||
|
|
||||||
s_is_started = false;
|
s_is_started = false;
|
||||||
|
|
||||||
|
@ -606,11 +606,11 @@ void SetState(EState _State)
|
||||||
switch (_State)
|
switch (_State)
|
||||||
{
|
{
|
||||||
case CORE_PAUSE:
|
case CORE_PAUSE:
|
||||||
CCPU::EnableStepping(true); // Break
|
CPU::EnableStepping(true); // Break
|
||||||
Wiimote::Pause();
|
Wiimote::Pause();
|
||||||
break;
|
break;
|
||||||
case CORE_RUN:
|
case CORE_RUN:
|
||||||
CCPU::EnableStepping(false);
|
CPU::EnableStepping(false);
|
||||||
Wiimote::Resume();
|
Wiimote::Resume();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -626,10 +626,10 @@ EState GetState()
|
||||||
|
|
||||||
if (s_hardware_initialized)
|
if (s_hardware_initialized)
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
if (CPU::IsStepping())
|
||||||
return CORE_PAUSE;
|
return CORE_PAUSE;
|
||||||
else
|
|
||||||
return CORE_RUN;
|
return CORE_RUN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return CORE_UNINITIALIZED;
|
return CORE_UNINITIALIZED;
|
||||||
|
@ -707,7 +707,7 @@ bool PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// first pause or unpause the CPU
|
// first pause or unpause the CPU
|
||||||
bool wasUnpaused = CCPU::PauseAndLock(doLock, unpauseOnUnlock);
|
bool wasUnpaused = CPU::PauseAndLock(doLock, unpauseOnUnlock);
|
||||||
ExpansionInterface::PauseAndLock(doLock, unpauseOnUnlock);
|
ExpansionInterface::PauseAndLock(doLock, unpauseOnUnlock);
|
||||||
|
|
||||||
// audio has to come after CPU, because CPU thread can wait for audio thread (m_throttle).
|
// audio has to come after CPU, because CPU thread can wait for audio thread (m_throttle).
|
||||||
|
|
|
@ -24,19 +24,22 @@ namespace
|
||||||
static std::mutex m_csCpuOccupied;
|
static std::mutex m_csCpuOccupied;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPU::Init(int cpu_core)
|
namespace CPU
|
||||||
|
{
|
||||||
|
|
||||||
|
void Init(int cpu_core)
|
||||||
{
|
{
|
||||||
PowerPC::Init(cpu_core);
|
PowerPC::Init(cpu_core);
|
||||||
m_SyncEvent = nullptr;
|
m_SyncEvent = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPU::Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
PowerPC::Shutdown();
|
PowerPC::Shutdown();
|
||||||
m_SyncEvent = nullptr;
|
m_SyncEvent = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPU::Run()
|
void Run()
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lk(m_csCpuOccupied);
|
std::lock_guard<std::mutex> lk(m_csCpuOccupied);
|
||||||
Host_UpdateDisasmDialog();
|
Host_UpdateDisasmDialog();
|
||||||
|
@ -81,22 +84,22 @@ void CCPU::Run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPU::Stop()
|
void Stop()
|
||||||
{
|
{
|
||||||
PowerPC::Stop();
|
PowerPC::Stop();
|
||||||
m_StepEvent.Set();
|
m_StepEvent.Set();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCPU::IsStepping()
|
bool IsStepping()
|
||||||
{
|
{
|
||||||
return PowerPC::GetState() == PowerPC::CPU_STEPPING;
|
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();
|
m_StepEvent.Set();
|
||||||
if (PowerPC::GetState() == PowerPC::CPU_STEPPING)
|
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();
|
PowerPC::Pause();
|
||||||
m_StepEvent.Reset();
|
m_StepEvent.Reset();
|
||||||
|
@ -139,15 +142,15 @@ void CCPU::EnableStepping(const bool _bStepping)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CCPU::Break()
|
void Break()
|
||||||
{
|
{
|
||||||
EnableStepping(true);
|
EnableStepping(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
bool PauseAndLock(bool do_lock, bool unpause_on_unlock)
|
||||||
{
|
{
|
||||||
bool wasUnpaused = !IsStepping();
|
bool wasUnpaused = !IsStepping();
|
||||||
if (doLock)
|
if (do_lock)
|
||||||
{
|
{
|
||||||
// we can't use EnableStepping, that would causes deadlocks with both audio and video
|
// we can't use EnableStepping, that would causes deadlocks with both audio and video
|
||||||
PowerPC::Pause();
|
PowerPC::Pause();
|
||||||
|
@ -156,7 +159,7 @@ bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (unpauseOnUnlock)
|
if (unpause_on_unlock)
|
||||||
{
|
{
|
||||||
PowerPC::Start();
|
PowerPC::Start();
|
||||||
m_StepEvent.Set();
|
m_StepEvent.Set();
|
||||||
|
@ -167,3 +170,5 @@ bool CCPU::PauseAndLock(bool doLock, bool unpauseOnUnlock)
|
||||||
}
|
}
|
||||||
return wasUnpaused;
|
return wasUnpaused;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,46 +4,46 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Common/CommonTypes.h"
|
|
||||||
|
|
||||||
namespace Common {
|
namespace Common {
|
||||||
class Event;
|
class Event;
|
||||||
}
|
}
|
||||||
|
|
||||||
class CCPU
|
namespace CPU
|
||||||
{
|
{
|
||||||
public:
|
|
||||||
// init
|
|
||||||
static void Init(int cpu_core);
|
|
||||||
|
|
||||||
// shutdown
|
// Init
|
||||||
static void Shutdown();
|
void Init(int cpu_core);
|
||||||
|
|
||||||
// starts the CPU
|
// Shutdown
|
||||||
static void Run();
|
void Shutdown();
|
||||||
|
|
||||||
// causes shutdown
|
// Starts the CPU
|
||||||
static void Stop();
|
void Run();
|
||||||
// Reset
|
|
||||||
static void Reset();
|
|
||||||
|
|
||||||
// StepOpcode (Steps one Opcode)
|
// Causes shutdown
|
||||||
static void StepOpcode(Common::Event *event = nullptr);
|
void Stop();
|
||||||
|
|
||||||
// Enable or Disable Stepping
|
// Reset
|
||||||
static void EnableStepping(const bool _bStepping);
|
void Reset();
|
||||||
|
|
||||||
// break, same as EnableStepping(true).
|
// StepOpcode (Steps one Opcode)
|
||||||
static void Break();
|
void StepOpcode(Common::Event* event = nullptr);
|
||||||
|
|
||||||
// is stepping ?
|
// Enable or Disable Stepping
|
||||||
static bool IsStepping();
|
void EnableStepping(bool stepping);
|
||||||
|
|
||||||
// waits until is stepping and is ready for a command (paused and fully idle), and acquires a lock on that state.
|
// Break, same as EnableStepping(true).
|
||||||
// or, if doLock is false, releases a lock on that state and optionally re-disables stepping.
|
void Break();
|
||||||
// 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,
|
// Is stepping ?
|
||||||
// e.g. when the GUI thread wants to make sure everything is paused so that it can create a savestate.
|
bool IsStepping();
|
||||||
// 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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ namespace HW
|
||||||
DSP::Init(SConfig::GetInstance().bDSPHLE);
|
DSP::Init(SConfig::GetInstance().bDSPHLE);
|
||||||
DVDInterface::Init();
|
DVDInterface::Init();
|
||||||
GPFifo::Init();
|
GPFifo::Init();
|
||||||
CCPU::Init(SConfig::GetInstance().iCPUCore);
|
CPU::Init(SConfig::GetInstance().iCPUCore);
|
||||||
SystemTimers::Init();
|
SystemTimers::Init();
|
||||||
|
|
||||||
if (SConfig::GetInstance().bWii)
|
if (SConfig::GetInstance().bWii)
|
||||||
|
@ -63,7 +63,7 @@ namespace HW
|
||||||
void Shutdown()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
SystemTimers::Shutdown();
|
SystemTimers::Shutdown();
|
||||||
CCPU::Shutdown();
|
CPU::Shutdown();
|
||||||
ExpansionInterface::Shutdown();
|
ExpansionInterface::Shutdown();
|
||||||
DVDInterface::Shutdown();
|
DVDInterface::Shutdown();
|
||||||
DSP::Shutdown();
|
DSP::Shutdown();
|
||||||
|
|
|
@ -247,7 +247,7 @@ static void gdb_read_command()
|
||||||
}
|
}
|
||||||
else if (c == 0x03)
|
else if (c == 0x03)
|
||||||
{
|
{
|
||||||
CCPU::Break();
|
CPU::Break();
|
||||||
gdb_signal(SIGTRAP);
|
gdb_signal(SIGTRAP);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,7 +244,7 @@ void Interpreter::Run()
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
INFO_LOG(POWERPC, "Hit Breakpoint - %08x", PC);
|
INFO_LOG(POWERPC, "Hit Breakpoint - %08x", PC);
|
||||||
CCPU::Break();
|
CPU::Break();
|
||||||
if (PowerPC::breakpoints.IsTempBreakPoint(PC))
|
if (PowerPC::breakpoints.IsTempBreakPoint(PC))
|
||||||
PowerPC::breakpoints.Remove(PC);
|
PowerPC::breakpoints.Remove(PC);
|
||||||
|
|
||||||
|
|
|
@ -453,7 +453,7 @@ static __forceinline void Memcheck(u32 address, u32 var, bool write, int size)
|
||||||
TMemCheck *mc = PowerPC::memchecks.GetMemCheck(address);
|
TMemCheck *mc = PowerPC::memchecks.GetMemCheck(address);
|
||||||
if (mc)
|
if (mc)
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
if (CPU::IsStepping())
|
||||||
{
|
{
|
||||||
// Disable when stepping so that resume works.
|
// Disable when stepping so that resume works.
|
||||||
return;
|
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);
|
bool pause = mc->Action(&PowerPC::debug_interface, var, address, write, size, PC);
|
||||||
if (pause)
|
if (pause)
|
||||||
{
|
{
|
||||||
CCPU::Break();
|
CPU::Break();
|
||||||
// Fake a DSI so that all the code that tests for it in order to skip
|
// 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
|
// the rest of the instruction will apply. (This means that
|
||||||
// watchpoints will stop the emulator before the offending load/store,
|
// watchpoints will stop the emulator before the offending load/store,
|
||||||
|
|
|
@ -283,11 +283,11 @@ void CCodeWindow::OnCallsListChange(wxCommandEvent& event)
|
||||||
|
|
||||||
void CCodeWindow::SingleStep()
|
void CCodeWindow::SingleStep()
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
if (CPU::IsStepping())
|
||||||
{
|
{
|
||||||
PowerPC::breakpoints.ClearAllTemporary();
|
PowerPC::breakpoints.ClearAllTemporary();
|
||||||
JitInterface::InvalidateICache(PC, 4, true);
|
JitInterface::InvalidateICache(PC, 4, true);
|
||||||
CCPU::StepOpcode(&sync_event);
|
CPU::StepOpcode(&sync_event);
|
||||||
wxThread::Sleep(20);
|
wxThread::Sleep(20);
|
||||||
// need a short wait here
|
// need a short wait here
|
||||||
JumpToAddress(PC);
|
JumpToAddress(PC);
|
||||||
|
@ -297,14 +297,14 @@ void CCodeWindow::SingleStep()
|
||||||
|
|
||||||
void CCodeWindow::StepOver()
|
void CCodeWindow::StepOver()
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
if (CPU::IsStepping())
|
||||||
{
|
{
|
||||||
UGeckoInstruction inst = PowerPC::HostRead_Instruction(PC);
|
UGeckoInstruction inst = PowerPC::HostRead_Instruction(PC);
|
||||||
if (inst.LK)
|
if (inst.LK)
|
||||||
{
|
{
|
||||||
PowerPC::breakpoints.ClearAllTemporary();
|
PowerPC::breakpoints.ClearAllTemporary();
|
||||||
PowerPC::breakpoints.Add(PC + 4, true);
|
PowerPC::breakpoints.Add(PC + 4, true);
|
||||||
CCPU::EnableStepping(false);
|
CPU::EnableStepping(false);
|
||||||
JumpToAddress(PC);
|
JumpToAddress(PC);
|
||||||
Update();
|
Update();
|
||||||
}
|
}
|
||||||
|
@ -321,7 +321,7 @@ void CCodeWindow::StepOver()
|
||||||
|
|
||||||
void CCodeWindow::StepOut()
|
void CCodeWindow::StepOut()
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
if (CPU::IsStepping())
|
||||||
{
|
{
|
||||||
PowerPC::breakpoints.ClearAllTemporary();
|
PowerPC::breakpoints.ClearAllTemporary();
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ void CCodeWindow::StepOut()
|
||||||
|
|
||||||
void CCodeWindow::ToggleBreakpoint()
|
void CCodeWindow::ToggleBreakpoint()
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
if (CPU::IsStepping())
|
||||||
{
|
{
|
||||||
if (codeview) codeview->ToggleBreakpoint(codeview->GetSelection());
|
if (codeview) codeview->ToggleBreakpoint(codeview->GetSelection());
|
||||||
Update();
|
Update();
|
||||||
|
@ -700,7 +700,7 @@ void CCodeWindow::UpdateButtonStates()
|
||||||
{
|
{
|
||||||
bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED);
|
bool Initialized = (Core::GetState() != Core::CORE_UNINITIALIZED);
|
||||||
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
|
bool Pause = (Core::GetState() == Core::CORE_PAUSE);
|
||||||
bool Stepping = CCPU::IsStepping();
|
bool Stepping = CPU::IsStepping();
|
||||||
wxToolBar* ToolBar = GetToolBar();
|
wxToolBar* ToolBar = GetToolBar();
|
||||||
|
|
||||||
// Toolbar
|
// Toolbar
|
||||||
|
|
|
@ -845,10 +845,7 @@ void CFrame::OnPlay(wxCommandEvent& WXUNUSED (event))
|
||||||
// Core is initialized and emulator is running
|
// Core is initialized and emulator is running
|
||||||
if (UseDebugger)
|
if (UseDebugger)
|
||||||
{
|
{
|
||||||
if (CCPU::IsStepping())
|
CPU::EnableStepping(!CPU::IsStepping());
|
||||||
CCPU::EnableStepping(false);
|
|
||||||
else
|
|
||||||
CCPU::EnableStepping(true); // Break
|
|
||||||
|
|
||||||
wxThread::Sleep(20);
|
wxThread::Sleep(20);
|
||||||
g_pCodeWindow->JumpToAddress(PC);
|
g_pCodeWindow->JumpToAddress(PC);
|
||||||
|
|
Loading…
Reference in New Issue