mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
PowerPC: Refactor to class, move to System.
This commit is contained in:
@@ -126,16 +126,18 @@ InstructionAttributes CodeTrace::GetInstructionAttributes(const TraceOutput& ins
|
||||
TraceOutput CodeTrace::SaveCurrentInstruction(const Core::CPUThreadGuard& guard) const
|
||||
{
|
||||
auto& system = guard.GetSystem();
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
auto& debug_interface = power_pc.GetDebugInterface();
|
||||
|
||||
// Quickly save instruction and memory target for fast logging.
|
||||
TraceOutput output;
|
||||
const std::string instr = PowerPC::debug_interface.Disassemble(&guard, ppc_state.pc);
|
||||
const std::string instr = debug_interface.Disassemble(&guard, ppc_state.pc);
|
||||
output.instruction = instr;
|
||||
output.address = ppc_state.pc;
|
||||
|
||||
if (IsInstructionLoadStore(output.instruction))
|
||||
output.memory_target = PowerPC::debug_interface.GetMemoryAddressFromInstruction(instr);
|
||||
output.memory_target = debug_interface.GetMemoryAddressFromInstruction(instr);
|
||||
|
||||
return output;
|
||||
}
|
||||
@@ -189,16 +191,17 @@ AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool
|
||||
else if (stop_on == AutoStop::Changed)
|
||||
stop_condition = HitType::ACTIVE;
|
||||
|
||||
PowerPC::breakpoints.ClearAllTemporary();
|
||||
auto& power_pc = guard.GetSystem().GetPowerPC();
|
||||
power_pc.GetBreakPoints().ClearAllTemporary();
|
||||
using clock = std::chrono::steady_clock;
|
||||
clock::time_point timeout = clock::now() + std::chrono::seconds(4);
|
||||
|
||||
PowerPC::CoreMode old_mode = PowerPC::GetMode();
|
||||
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
|
||||
PowerPC::CoreMode old_mode = power_pc.GetMode();
|
||||
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
|
||||
|
||||
do
|
||||
{
|
||||
PowerPC::SingleStep();
|
||||
power_pc.SingleStep();
|
||||
|
||||
pc_instr = SaveCurrentInstruction(guard);
|
||||
hit = TraceLogic(pc_instr);
|
||||
@@ -210,7 +213,7 @@ AutoStepResults CodeTrace::AutoStepping(const Core::CPUThreadGuard& guard, bool
|
||||
if (clock::now() >= timeout)
|
||||
results.timed_out = true;
|
||||
|
||||
PowerPC::SetMode(old_mode);
|
||||
power_pc.SetMode(old_mode);
|
||||
m_recording = false;
|
||||
|
||||
results.reg_tracked = m_reg_autotrack;
|
||||
|
||||
@@ -57,13 +57,14 @@ void PresetTimeBaseTicks(Core::System& system, const Core::CPUThreadGuard& guard
|
||||
|
||||
void CBoot::RunFunction(Core::System& system, u32 address)
|
||||
{
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
|
||||
ppc_state.pc = address;
|
||||
LR(ppc_state) = 0x00;
|
||||
|
||||
while (ppc_state.pc != 0x00)
|
||||
PowerPC::SingleStep();
|
||||
power_pc.SingleStep();
|
||||
}
|
||||
|
||||
void CBoot::SetupMSR(PowerPC::PowerPCState& ppc_state)
|
||||
|
||||
@@ -435,7 +435,8 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path,
|
||||
{
|
||||
DeclareAsCPUThread();
|
||||
|
||||
if (Core::System::GetInstance().IsDualCoreMode())
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (system.IsDualCoreMode())
|
||||
Common::SetCurrentThreadName("FIFO player thread");
|
||||
else
|
||||
Common::SetCurrentThreadName("FIFO-GPU thread");
|
||||
@@ -443,15 +444,14 @@ static void FifoPlayerThread(const std::optional<std::string>& savestate_path,
|
||||
// Enter CPU run loop. When we leave it - we are done.
|
||||
if (auto cpu_core = FifoPlayer::GetInstance().GetCPUCore())
|
||||
{
|
||||
PowerPC::InjectExternalCPUCore(cpu_core.get());
|
||||
system.GetPowerPC().InjectExternalCPUCore(cpu_core.get());
|
||||
s_is_started = true;
|
||||
|
||||
CPUSetInitialExecutionState();
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetCPU().Run();
|
||||
|
||||
s_is_started = false;
|
||||
PowerPC::InjectExternalCPUCore(nullptr);
|
||||
system.GetPowerPC().InjectExternalCPUCore(nullptr);
|
||||
FifoPlayer::GetInstance().Close();
|
||||
}
|
||||
else
|
||||
@@ -552,7 +552,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||
HLE::Clear();
|
||||
|
||||
CPUThreadGuard guard(system);
|
||||
PowerPC::debug_interface.Clear(guard);
|
||||
system.GetPowerPC().GetDebugInterface().Clear(guard);
|
||||
}};
|
||||
|
||||
VideoBackendBase::PopulateBackendInfo();
|
||||
@@ -590,7 +590,7 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||
system.GetCPU().Break();
|
||||
|
||||
// Load GCM/DOL/ELF whatever ... we boot with the interpreter core
|
||||
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
|
||||
system.GetPowerPC().SetMode(PowerPC::CoreMode::Interpreter);
|
||||
|
||||
// Determine the CPU thread function
|
||||
void (*cpuThreadFunc)(const std::optional<std::string>& savestate_path, bool delete_savestate);
|
||||
@@ -628,11 +628,11 @@ static void EmuThread(std::unique_ptr<BootParameters> boot, WindowSystemInfo wsi
|
||||
// Setup our core
|
||||
if (Config::Get(Config::MAIN_CPU_CORE) != PowerPC::CPUCore::Interpreter)
|
||||
{
|
||||
PowerPC::SetMode(PowerPC::CoreMode::JIT);
|
||||
system.GetPowerPC().SetMode(PowerPC::CoreMode::JIT);
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
|
||||
system.GetPowerPC().SetMode(PowerPC::CoreMode::Interpreter);
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
@@ -901,7 +901,7 @@ void UpdateTitle()
|
||||
{
|
||||
// Settings are shown the same for both extended and summary info
|
||||
const std::string SSettings = fmt::format(
|
||||
"{} {} | {} | {}", PowerPC::GetCPUName(),
|
||||
"{} {} | {} | {}", Core::System::GetInstance().GetPowerPC().GetCPUName(),
|
||||
Core::System::GetInstance().IsDualCoreMode() ? "DC" : "SC", g_video_backend->GetDisplayName(),
|
||||
Config::Get(Config::MAIN_DSP_HLE) ? "HLE" : "LLE");
|
||||
|
||||
|
||||
@@ -303,8 +303,8 @@ void CoreTimingManager::MoveEvents()
|
||||
|
||||
void CoreTimingManager::Advance()
|
||||
{
|
||||
auto& system = m_system;
|
||||
auto& ppc_state = m_system.GetPPCState();
|
||||
auto& power_pc = m_system.GetPowerPC();
|
||||
auto& ppc_state = power_pc.GetPPCState();
|
||||
|
||||
MoveEvents();
|
||||
|
||||
@@ -323,7 +323,7 @@ void CoreTimingManager::Advance()
|
||||
m_event_queue.pop_back();
|
||||
|
||||
Throttle(evt.time);
|
||||
evt.type->callback(system, evt.userdata, m_globals.global_timer - evt.time);
|
||||
evt.type->callback(m_system, evt.userdata, m_globals.global_timer - evt.time);
|
||||
}
|
||||
|
||||
m_is_global_timer_sane = false;
|
||||
@@ -341,7 +341,7 @@ void CoreTimingManager::Advance()
|
||||
// It's important to do this after processing events otherwise any exceptions will be delayed
|
||||
// until the next slice:
|
||||
// Pokemon Box refuses to boot if the first exception from the audio DMA is received late
|
||||
PowerPC::CheckExternalExceptions();
|
||||
power_pc.CheckExternalExceptions();
|
||||
}
|
||||
|
||||
void CoreTimingManager::Throttle(const s64 target_cycle)
|
||||
|
||||
@@ -32,7 +32,7 @@ void AddAutoBreakpoints()
|
||||
{
|
||||
Common::Symbol* symbol = g_symbolDB.GetSymbolFromName(bp);
|
||||
if (symbol)
|
||||
PowerPC::breakpoints.Add(symbol->address, false);
|
||||
Core::System::GetInstance().GetPowerPC().GetBreakPoints().Add(symbol->address, false);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -36,6 +36,7 @@ void ApplyMemoryPatch(const Core::CPUThreadGuard& guard, Common::Debug::MemoryPa
|
||||
if (!PowerPC::MMU::HostIsRAMAddress(guard, address))
|
||||
return;
|
||||
|
||||
auto& power_pc = guard.GetSystem().GetPowerPC();
|
||||
for (u32 offset = 0; offset < size; ++offset)
|
||||
{
|
||||
if (store_existing_value)
|
||||
@@ -50,11 +51,11 @@ void ApplyMemoryPatch(const Core::CPUThreadGuard& guard, Common::Debug::MemoryPa
|
||||
}
|
||||
|
||||
if (((address + offset) % 4) == 3)
|
||||
PowerPC::ScheduleInvalidateCacheThreadSafe(Common::AlignDown(address + offset, 4));
|
||||
power_pc.ScheduleInvalidateCacheThreadSafe(Common::AlignDown(address + offset, 4));
|
||||
}
|
||||
if (((address + size) % 4) != 0)
|
||||
{
|
||||
PowerPC::ScheduleInvalidateCacheThreadSafe(
|
||||
power_pc.ScheduleInvalidateCacheThreadSafe(
|
||||
Common::AlignDown(address + static_cast<u32>(size), 4));
|
||||
}
|
||||
}
|
||||
@@ -347,40 +348,41 @@ bool PPCDebugInterface::IsAlive() const
|
||||
|
||||
bool PPCDebugInterface::IsBreakpoint(u32 address) const
|
||||
{
|
||||
return PowerPC::breakpoints.IsAddressBreakPoint(address);
|
||||
return m_system.GetPowerPC().GetBreakPoints().IsAddressBreakPoint(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::SetBreakpoint(u32 address)
|
||||
{
|
||||
PowerPC::breakpoints.Add(address);
|
||||
m_system.GetPowerPC().GetBreakPoints().Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearBreakpoint(u32 address)
|
||||
{
|
||||
PowerPC::breakpoints.Remove(address);
|
||||
m_system.GetPowerPC().GetBreakPoints().Remove(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearAllBreakpoints()
|
||||
{
|
||||
PowerPC::breakpoints.Clear();
|
||||
m_system.GetPowerPC().GetBreakPoints().Clear();
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ToggleBreakpoint(u32 address)
|
||||
{
|
||||
if (PowerPC::breakpoints.IsAddressBreakPoint(address))
|
||||
PowerPC::breakpoints.Remove(address);
|
||||
auto& breakpoints = m_system.GetPowerPC().GetBreakPoints();
|
||||
if (breakpoints.IsAddressBreakPoint(address))
|
||||
breakpoints.Remove(address);
|
||||
else
|
||||
PowerPC::breakpoints.Add(address);
|
||||
breakpoints.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearAllMemChecks()
|
||||
{
|
||||
PowerPC::memchecks.Clear();
|
||||
m_system.GetPowerPC().GetMemChecks().Clear();
|
||||
}
|
||||
|
||||
bool PPCDebugInterface::IsMemCheck(u32 address, size_t size) const
|
||||
{
|
||||
return PowerPC::memchecks.GetMemCheck(address, size) != nullptr;
|
||||
return m_system.GetPowerPC().GetMemChecks().GetMemCheck(address, size) != nullptr;
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool log)
|
||||
@@ -397,11 +399,11 @@ void PPCDebugInterface::ToggleMemCheck(u32 address, bool read, bool write, bool
|
||||
MemCheck.log_on_hit = log;
|
||||
MemCheck.break_on_hit = true;
|
||||
|
||||
PowerPC::memchecks.Add(std::move(MemCheck));
|
||||
m_system.GetPowerPC().GetMemChecks().Add(std::move(MemCheck));
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerPC::memchecks.Remove(address);
|
||||
m_system.GetPowerPC().GetMemChecks().Remove(address);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ HookFlag GetHookFlagsByIndex(u32 index)
|
||||
bool IsEnabled(HookFlag flag)
|
||||
{
|
||||
return flag != HLE::HookFlag::Debug || Config::Get(Config::MAIN_ENABLE_DEBUGGING) ||
|
||||
PowerPC::GetMode() == PowerPC::CoreMode::Interpreter;
|
||||
Core::System::GetInstance().GetPowerPC().GetMode() == PowerPC::CoreMode::Interpreter;
|
||||
}
|
||||
|
||||
u32 UnPatch(Core::System& system, std::string_view patch_name)
|
||||
|
||||
+16
-14
@@ -19,19 +19,21 @@
|
||||
|
||||
namespace CPU
|
||||
{
|
||||
CPUManager::CPUManager() = default;
|
||||
CPUManager::CPUManager(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
CPUManager::~CPUManager() = default;
|
||||
|
||||
void CPUManager::Init(PowerPC::CPUCore cpu_core)
|
||||
{
|
||||
PowerPC::Init(cpu_core);
|
||||
m_system.GetPowerPC().Init(cpu_core);
|
||||
m_state = State::Stepping;
|
||||
}
|
||||
|
||||
void CPUManager::Shutdown()
|
||||
{
|
||||
Stop();
|
||||
PowerPC::Shutdown();
|
||||
m_system.GetPowerPC().Shutdown();
|
||||
}
|
||||
|
||||
// Requires holding m_state_change_lock
|
||||
@@ -62,11 +64,11 @@ void CPUManager::ExecutePendingJobs(std::unique_lock<std::mutex>& state_lock)
|
||||
|
||||
void CPUManager::Run()
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& power_pc = m_system.GetPowerPC();
|
||||
|
||||
// Updating the host CPU's rounding mode must be done on the CPU thread.
|
||||
// We can't rely on PowerPC::Init doing it, since it's called from EmuThread.
|
||||
PowerPC::RoundingModeUpdated();
|
||||
PowerPC::RoundingModeUpdated(power_pc.GetPPCState());
|
||||
|
||||
std::unique_lock state_lock(m_state_change_lock);
|
||||
while (m_state != State::PowerDown)
|
||||
@@ -85,22 +87,22 @@ void CPUManager::Run()
|
||||
// SingleStep so that the "continue", "step over" and "step out" debugger functions
|
||||
// work when the PC is at a breakpoint at the beginning of the block
|
||||
// If watchpoints are enabled, any instruction could be a breakpoint.
|
||||
if (PowerPC::GetMode() != PowerPC::CoreMode::Interpreter)
|
||||
if (power_pc.GetMode() != PowerPC::CoreMode::Interpreter)
|
||||
{
|
||||
if (PowerPC::breakpoints.IsAddressBreakPoint(system.GetPPCState().pc) ||
|
||||
PowerPC::memchecks.HasAny())
|
||||
if (power_pc.GetBreakPoints().IsAddressBreakPoint(power_pc.GetPPCState().pc) ||
|
||||
power_pc.GetMemChecks().HasAny())
|
||||
{
|
||||
m_state = State::Stepping;
|
||||
PowerPC::CoreMode old_mode = PowerPC::GetMode();
|
||||
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
|
||||
PowerPC::SingleStep();
|
||||
PowerPC::SetMode(old_mode);
|
||||
PowerPC::CoreMode old_mode = power_pc.GetMode();
|
||||
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
|
||||
power_pc.SingleStep();
|
||||
power_pc.SetMode(old_mode);
|
||||
m_state = State::Running;
|
||||
}
|
||||
}
|
||||
|
||||
// Enter a fast runloop
|
||||
PowerPC::RunLoop();
|
||||
power_pc.RunLoop();
|
||||
|
||||
state_lock.lock();
|
||||
m_state_cpu_thread_active = false;
|
||||
@@ -147,7 +149,7 @@ void CPUManager::Run()
|
||||
m_state_cpu_thread_active = true;
|
||||
state_lock.unlock();
|
||||
|
||||
PowerPC::SingleStep();
|
||||
power_pc.SingleStep();
|
||||
|
||||
state_lock.lock();
|
||||
m_state_cpu_thread_active = false;
|
||||
|
||||
@@ -12,7 +12,10 @@ namespace Common
|
||||
{
|
||||
class Event;
|
||||
}
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
namespace PowerPC
|
||||
{
|
||||
enum class CPUCore;
|
||||
@@ -30,7 +33,7 @@ enum class State
|
||||
class CPUManager
|
||||
{
|
||||
public:
|
||||
CPUManager();
|
||||
explicit CPUManager(Core::System& system);
|
||||
CPUManager(const CPUManager& other) = delete;
|
||||
CPUManager(CPUManager&& other) = delete;
|
||||
CPUManager& operator=(const CPUManager& other) = delete;
|
||||
@@ -130,5 +133,7 @@ private:
|
||||
bool m_state_cpu_step_instruction = false;
|
||||
Common::Event* m_state_cpu_step_instruction_sync = nullptr;
|
||||
std::queue<std::function<void()>> m_pending_jobs;
|
||||
|
||||
Core::System& m_system;
|
||||
};
|
||||
} // namespace CPU
|
||||
|
||||
@@ -448,7 +448,7 @@ void CEXIETHERNET::SendFromDirectFIFO()
|
||||
const u8* frame = tx_fifo.get();
|
||||
const u16 size = Common::BitCastPtr<u16>(&mBbaMem[BBA_TXFIFOCNT]);
|
||||
if (m_network_interface->SendFrame(frame, size))
|
||||
PowerPC::debug_interface.NetworkLogger()->LogBBA(frame, size);
|
||||
m_system.GetPowerPC().GetDebugInterface().NetworkLogger()->LogBBA(frame, size);
|
||||
}
|
||||
|
||||
void CEXIETHERNET::SendFromPacketBuffer()
|
||||
@@ -561,7 +561,8 @@ bool CEXIETHERNET::RecvHandlePacket()
|
||||
INFO_LOG_FMT(SP1, "{:x} {:x} {:x} {:x}", page_ptr(BBA_BP), page_ptr(BBA_RRP), page_ptr(BBA_RWP),
|
||||
page_ptr(BBA_RHBP));
|
||||
#endif
|
||||
PowerPC::debug_interface.NetworkLogger()->LogBBA(mRecvBuffer.get(), mRecvBufferLength);
|
||||
m_system.GetPowerPC().GetDebugInterface().NetworkLogger()->LogBBA(mRecvBuffer.get(),
|
||||
mRecvBufferLength);
|
||||
write_ptr = &mBbaMem[page_ptr(BBA_RWP) << 8];
|
||||
|
||||
descriptor = (Descriptor*)write_ptr;
|
||||
|
||||
@@ -223,7 +223,7 @@ void TimeBaseSet()
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& core_timing = system.GetCoreTiming();
|
||||
core_timing.SetFakeTBStartTicks(core_timing.GetTicks());
|
||||
core_timing.SetFakeTBStartValue(PowerPC::ReadFullTimeBaseValue());
|
||||
core_timing.SetFakeTBStartValue(system.GetPowerPC().ReadFullTimeBaseValue());
|
||||
}
|
||||
|
||||
u64 GetFakeTimeBase()
|
||||
|
||||
@@ -200,8 +200,9 @@ static void ResetAndPausePPC()
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& memory = system.GetMemory();
|
||||
memory.Write_U32(0x48000000, 0x00000000); // b 0x0
|
||||
PowerPC::Reset();
|
||||
system.GetPPCState().pc = 0;
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
power_pc.Reset();
|
||||
power_pc.GetPPCState().pc = 0;
|
||||
}
|
||||
|
||||
static void ReleasePPC()
|
||||
|
||||
@@ -43,7 +43,7 @@ static void ReinitHardware()
|
||||
// (and not by MIOS), causing games that use DTK to break. Perhaps MIOS doesn't actually
|
||||
// reset DI fully, in such a way that the DTK config isn't cleared?
|
||||
// system.GetDVDInterface().ResetDrive(true);
|
||||
PowerPC::Reset();
|
||||
system.GetPowerPC().Reset();
|
||||
Wiimote::ResetAllWiimotes();
|
||||
// Note: this is specific to Dolphin and is required because we initialised it in Wii mode.
|
||||
auto& dsp = system.GetDSP();
|
||||
@@ -83,18 +83,18 @@ bool Load()
|
||||
Host_NotifyMapLoaded();
|
||||
}
|
||||
|
||||
auto& ppc_state = system.GetPPCState();
|
||||
const PowerPC::CoreMode core_mode = PowerPC::GetMode();
|
||||
PowerPC::SetMode(PowerPC::CoreMode::Interpreter);
|
||||
ppc_state.msr.Hex = 0;
|
||||
ppc_state.pc = 0x3400;
|
||||
auto& power_pc = system.GetPowerPC();
|
||||
const PowerPC::CoreMode core_mode = power_pc.GetMode();
|
||||
power_pc.SetMode(PowerPC::CoreMode::Interpreter);
|
||||
power_pc.GetPPCState().msr.Hex = 0;
|
||||
power_pc.GetPPCState().pc = 0x3400;
|
||||
NOTICE_LOG_FMT(IOS, "Loaded MIOS and bootstrapped PPC.");
|
||||
|
||||
// IOS writes 0 to 0x30f8 before bootstrapping the PPC. Once started, the IPL eventually writes
|
||||
// 0xdeadbeef there, then waits for it to be cleared by IOS before continuing.
|
||||
while (memory.Read_U32(ADDRESS_INIT_SEMAPHORE) != 0xdeadbeef)
|
||||
PowerPC::SingleStep();
|
||||
PowerPC::SetMode(core_mode);
|
||||
power_pc.SingleStep();
|
||||
power_pc.SetMode(core_mode);
|
||||
|
||||
memory.Write_U32(0x00000000, ADDRESS_INIT_SEMAPHORE);
|
||||
NOTICE_LOG_FMT(IOS, "IPL ready.");
|
||||
|
||||
@@ -63,7 +63,10 @@ int SSLSendWithoutSNI(void* ctx, const unsigned char* buf, size_t len)
|
||||
|
||||
// Log raw SSL packets if we don't dump unencrypted SSL writes
|
||||
if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_WRITE) && ret > 0)
|
||||
PowerPC::debug_interface.NetworkLogger()->LogWrite(buf, ret, *fd, nullptr);
|
||||
{
|
||||
Core::System::GetInstance().GetPowerPC().GetDebugInterface().NetworkLogger()->LogWrite(
|
||||
buf, ret, *fd, nullptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
@@ -76,7 +79,10 @@ int SSLRecv(void* ctx, unsigned char* buf, size_t len)
|
||||
|
||||
// Log raw SSL packets if we don't dump unencrypted SSL reads
|
||||
if (!Config::Get(Config::MAIN_NETWORK_SSL_DUMP_READ) && ret > 0)
|
||||
PowerPC::debug_interface.NetworkLogger()->LogRead(buf, ret, *fd, nullptr);
|
||||
{
|
||||
Core::System::GetInstance().GetPowerPC().GetDebugInterface().NetworkLogger()->LogRead(
|
||||
buf, ret, *fd, nullptr);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -487,8 +487,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
PowerPC::debug_interface.NetworkLogger()->LogSSLWrite(memory.GetPointer(BufferOut2),
|
||||
ret, ssl->hostfd);
|
||||
system.GetPowerPC().GetDebugInterface().NetworkLogger()->LogSSLWrite(
|
||||
memory.GetPointer(BufferOut2), ret, ssl->hostfd);
|
||||
// Return bytes written or SSL_ERR_ZERO if none
|
||||
WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn);
|
||||
}
|
||||
@@ -521,8 +521,8 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
PowerPC::debug_interface.NetworkLogger()->LogSSLRead(memory.GetPointer(BufferIn2),
|
||||
ret, ssl->hostfd);
|
||||
system.GetPowerPC().GetDebugInterface().NetworkLogger()->LogSSLRead(
|
||||
memory.GetPointer(BufferIn2), ret, ssl->hostfd);
|
||||
// Return bytes read or SSL_ERR_ZERO if none
|
||||
WriteReturnValue((ret == 0) ? SSL_ERR_ZERO : ret, BufferIn);
|
||||
}
|
||||
@@ -595,7 +595,7 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
const int ret = sendto(fd, data, BufferInSize, flags, to, tolen);
|
||||
ReturnValue = WiiSockMan::GetNetErrorCode(ret, "SO_SENDTO", true);
|
||||
if (ret > 0)
|
||||
PowerPC::debug_interface.NetworkLogger()->LogWrite(data, ret, fd, to);
|
||||
system.GetPowerPC().GetDebugInterface().NetworkLogger()->LogWrite(data, ret, fd, to);
|
||||
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"{} = {} Socket: {:08x}, BufferIn: ({:08x}, {}), BufferIn2: ({:08x}, {}), "
|
||||
@@ -654,7 +654,7 @@ void WiiSocket::Update(bool read, bool write, bool except)
|
||||
ReturnValue =
|
||||
WiiSockMan::GetNetErrorCode(ret, BufferOutSize2 ? "SO_RECVFROM" : "SO_RECV", true);
|
||||
if (ret > 0)
|
||||
PowerPC::debug_interface.NetworkLogger()->LogRead(data, ret, fd, from);
|
||||
system.GetPowerPC().GetDebugInterface().NetworkLogger()->LogRead(data, ret, fd, from);
|
||||
|
||||
INFO_LOG_FMT(IOS_NET,
|
||||
"{}({}, {}) Socket: {:08X}, Flags: {:08X}, "
|
||||
@@ -865,7 +865,7 @@ s32 WiiSockMan::AddSocket(s32 fd, bool is_rw)
|
||||
WiiSocket& sock = WiiSockets[wii_fd];
|
||||
sock.SetFd(fd);
|
||||
sock.SetWiiFd(wii_fd);
|
||||
PowerPC::debug_interface.NetworkLogger()->OnNewSocket(fd);
|
||||
Core::System::GetInstance().GetPowerPC().GetDebugInterface().NetworkLogger()->OnNewSocket(fd);
|
||||
|
||||
#ifdef __APPLE__
|
||||
int opt_no_sigpipe = 1;
|
||||
|
||||
@@ -277,7 +277,7 @@ static void ApplyMemoryPatches(const Core::CPUThreadGuard& guard,
|
||||
std::lock_guard lock(s_on_frame_memory_mutex);
|
||||
for (std::size_t index : memory_patch_indices)
|
||||
{
|
||||
PowerPC::debug_interface.ApplyExistingPatch(guard, index);
|
||||
guard.GetSystem().GetPowerPC().GetDebugInterface().ApplyExistingPatch(guard, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,12 @@
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "Core/System.h"
|
||||
|
||||
BreakPoints::BreakPoints(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
BreakPoints::~BreakPoints() = default;
|
||||
|
||||
bool BreakPoints::IsAddressBreakPoint(u32 address) const
|
||||
{
|
||||
return std::any_of(m_breakpoints.begin(), m_breakpoints.end(),
|
||||
@@ -107,7 +113,7 @@ void BreakPoints::Add(TBreakPoint bp)
|
||||
if (IsAddressBreakPoint(bp.address))
|
||||
return;
|
||||
|
||||
Core::System::GetInstance().GetJitInterface().InvalidateICache(bp.address, 4, true);
|
||||
m_system.GetJitInterface().InvalidateICache(bp.address, 4, true);
|
||||
|
||||
m_breakpoints.emplace_back(std::move(bp));
|
||||
}
|
||||
@@ -143,7 +149,7 @@ void BreakPoints::Add(u32 address, bool temp, bool break_on_hit, bool log_on_hit
|
||||
m_breakpoints.emplace_back(std::move(bp));
|
||||
}
|
||||
|
||||
Core::System::GetInstance().GetJitInterface().InvalidateICache(address, 4, true);
|
||||
m_system.GetJitInterface().InvalidateICache(address, 4, true);
|
||||
}
|
||||
|
||||
bool BreakPoints::ToggleBreakPoint(u32 address)
|
||||
@@ -167,14 +173,14 @@ void BreakPoints::Remove(u32 address)
|
||||
return;
|
||||
|
||||
m_breakpoints.erase(iter);
|
||||
Core::System::GetInstance().GetJitInterface().InvalidateICache(address, 4, true);
|
||||
m_system.GetJitInterface().InvalidateICache(address, 4, true);
|
||||
}
|
||||
|
||||
void BreakPoints::Clear()
|
||||
{
|
||||
for (const TBreakPoint& bp : m_breakpoints)
|
||||
{
|
||||
Core::System::GetInstance().GetJitInterface().InvalidateICache(bp.address, 4, true);
|
||||
m_system.GetJitInterface().InvalidateICache(bp.address, 4, true);
|
||||
}
|
||||
|
||||
m_breakpoints.clear();
|
||||
@@ -187,7 +193,7 @@ void BreakPoints::ClearAllTemporary()
|
||||
{
|
||||
if (bp->is_temporary)
|
||||
{
|
||||
Core::System::GetInstance().GetJitInterface().InvalidateICache(bp->address, 4, true);
|
||||
m_system.GetJitInterface().InvalidateICache(bp->address, 4, true);
|
||||
bp = m_breakpoints.erase(bp);
|
||||
}
|
||||
else
|
||||
@@ -197,6 +203,12 @@ void BreakPoints::ClearAllTemporary()
|
||||
}
|
||||
}
|
||||
|
||||
MemChecks::MemChecks(Core::System& system) : m_system(system)
|
||||
{
|
||||
}
|
||||
|
||||
MemChecks::~MemChecks() = default;
|
||||
|
||||
MemChecks::TMemChecksStr MemChecks::GetStrings() const
|
||||
{
|
||||
TMemChecksStr mc_strings;
|
||||
@@ -280,8 +292,8 @@ void MemChecks::Add(TMemCheck memory_check)
|
||||
// If this is the first one, clear the JIT cache so it can switch to
|
||||
// watchpoint-compatible code.
|
||||
if (!had_any)
|
||||
Core::System::GetInstance().GetJitInterface().ClearCache();
|
||||
Core::System::GetInstance().GetMMU().DBATUpdated();
|
||||
m_system.GetJitInterface().ClearCache();
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -309,8 +321,8 @@ void MemChecks::Remove(u32 address)
|
||||
Core::RunAsCPUThread([&] {
|
||||
m_mem_checks.erase(iter);
|
||||
if (!HasAny())
|
||||
Core::System::GetInstance().GetJitInterface().ClearCache();
|
||||
Core::System::GetInstance().GetMMU().DBATUpdated();
|
||||
m_system.GetJitInterface().ClearCache();
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -318,8 +330,8 @@ void MemChecks::Clear()
|
||||
{
|
||||
Core::RunAsCPUThread([&] {
|
||||
m_mem_checks.clear();
|
||||
Core::System::GetInstance().GetJitInterface().ClearCache();
|
||||
Core::System::GetInstance().GetMMU().DBATUpdated();
|
||||
m_system.GetJitInterface().ClearCache();
|
||||
m_system.GetMMU().DBATUpdated();
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,10 @@ namespace Common
|
||||
{
|
||||
class DebugInterface;
|
||||
}
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
struct TBreakPoint
|
||||
{
|
||||
@@ -53,6 +57,13 @@ struct TMemCheck
|
||||
class BreakPoints
|
||||
{
|
||||
public:
|
||||
explicit BreakPoints(Core::System& system);
|
||||
BreakPoints(const BreakPoints& other) = delete;
|
||||
BreakPoints(BreakPoints&& other) = delete;
|
||||
BreakPoints& operator=(const BreakPoints& other) = delete;
|
||||
BreakPoints& operator=(BreakPoints&& other) = delete;
|
||||
~BreakPoints();
|
||||
|
||||
using TBreakPoints = std::vector<TBreakPoint>;
|
||||
using TBreakPointsStr = std::vector<std::string>;
|
||||
|
||||
@@ -82,12 +93,20 @@ public:
|
||||
|
||||
private:
|
||||
TBreakPoints m_breakpoints;
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
||||
// Memory breakpoints
|
||||
class MemChecks
|
||||
{
|
||||
public:
|
||||
explicit MemChecks(Core::System& system);
|
||||
MemChecks(const MemChecks& other) = delete;
|
||||
MemChecks(MemChecks&& other) = delete;
|
||||
MemChecks& operator=(const MemChecks& other) = delete;
|
||||
MemChecks& operator=(MemChecks&& other) = delete;
|
||||
~MemChecks();
|
||||
|
||||
using TMemChecks = std::vector<TMemCheck>;
|
||||
using TMemChecksStr = std::vector<std::string>;
|
||||
|
||||
@@ -109,4 +128,5 @@ public:
|
||||
|
||||
private:
|
||||
TMemChecks m_mem_checks;
|
||||
Core::System& m_system;
|
||||
};
|
||||
|
||||
@@ -214,7 +214,7 @@ bool CachedInterpreter::CheckFPU(CachedInterpreter& cached_interpreter, u32 data
|
||||
if (!ppc_state.msr.FP)
|
||||
{
|
||||
ppc_state.Exceptions |= EXCEPTION_FPU_UNAVAILABLE;
|
||||
PowerPC::CheckExceptions();
|
||||
cached_interpreter.m_system.GetPowerPC().CheckExceptions();
|
||||
ppc_state.downcount -= data;
|
||||
return true;
|
||||
}
|
||||
@@ -226,7 +226,7 @@ bool CachedInterpreter::CheckDSI(CachedInterpreter& cached_interpreter, u32 data
|
||||
auto& ppc_state = cached_interpreter.m_ppc_state;
|
||||
if (ppc_state.Exceptions & EXCEPTION_DSI)
|
||||
{
|
||||
PowerPC::CheckExceptions();
|
||||
cached_interpreter.m_system.GetPowerPC().CheckExceptions();
|
||||
ppc_state.downcount -= data;
|
||||
return true;
|
||||
}
|
||||
@@ -238,7 +238,7 @@ bool CachedInterpreter::CheckProgramException(CachedInterpreter& cached_interpre
|
||||
auto& ppc_state = cached_interpreter.m_ppc_state;
|
||||
if (ppc_state.Exceptions & EXCEPTION_PROGRAM)
|
||||
{
|
||||
PowerPC::CheckExceptions();
|
||||
cached_interpreter.m_system.GetPowerPC().CheckExceptions();
|
||||
ppc_state.downcount -= data;
|
||||
return true;
|
||||
}
|
||||
@@ -247,7 +247,7 @@ bool CachedInterpreter::CheckProgramException(CachedInterpreter& cached_interpre
|
||||
|
||||
bool CachedInterpreter::CheckBreakpoint(CachedInterpreter& cached_interpreter, u32 data)
|
||||
{
|
||||
PowerPC::CheckBreakPoints();
|
||||
cached_interpreter.m_system.GetPowerPC().CheckBreakPoints();
|
||||
if (cached_interpreter.m_system.GetCPU().GetState() != CPU::State::Running)
|
||||
{
|
||||
cached_interpreter.m_ppc_state.downcount -= data;
|
||||
@@ -295,7 +295,7 @@ void CachedInterpreter::Jit(u32 address)
|
||||
// Address of instruction could not be translated
|
||||
m_ppc_state.npc = nextPC;
|
||||
m_ppc_state.Exceptions |= EXCEPTION_ISI;
|
||||
PowerPC::CheckExceptions();
|
||||
m_system.GetPowerPC().CheckExceptions();
|
||||
WARN_LOG_FMT(POWERPC, "ISI exception at {:#010x}", nextPC);
|
||||
return;
|
||||
}
|
||||
@@ -329,7 +329,8 @@ void CachedInterpreter::Jit(u32 address)
|
||||
if (!op.skip)
|
||||
{
|
||||
const bool breakpoint =
|
||||
m_enable_debugging && PowerPC::breakpoints.IsAddressBreakPoint(op.address);
|
||||
m_enable_debugging &&
|
||||
m_system.GetPowerPC().GetBreakPoints().IsAddressBreakPoint(op.address);
|
||||
const bool check_fpu = (op.opinfo->flags & FL_USE_FPU) && !js.firstFPInstructionFound;
|
||||
const bool endblock = (op.opinfo->flags & FL_ENDBLOCK) != 0;
|
||||
const bool memcheck = (op.opinfo->flags & FL_LOADSTORE) && jo.memcheck;
|
||||
|
||||
@@ -163,17 +163,19 @@ static void RemoveBreakpoint(BreakpointType type, u32 addr, u32 len)
|
||||
{
|
||||
if (type == BreakpointType::ExecuteHard || type == BreakpointType::ExecuteSoft)
|
||||
{
|
||||
while (PowerPC::breakpoints.IsAddressBreakPoint(addr))
|
||||
auto& breakpoints = Core::System::GetInstance().GetPowerPC().GetBreakPoints();
|
||||
while (breakpoints.IsAddressBreakPoint(addr))
|
||||
{
|
||||
PowerPC::breakpoints.Remove(addr);
|
||||
breakpoints.Remove(addr);
|
||||
INFO_LOG_FMT(GDB_STUB, "gdb: removed a breakpoint: {:08x} bytes at {:08x}", len, addr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
while (PowerPC::memchecks.GetMemCheck(addr, len) != nullptr)
|
||||
auto& memchecks = Core::System::GetInstance().GetPowerPC().GetMemChecks();
|
||||
while (memchecks.GetMemCheck(addr, len) != nullptr)
|
||||
{
|
||||
PowerPC::memchecks.Remove(addr);
|
||||
memchecks.Remove(addr);
|
||||
INFO_LOG_FMT(GDB_STUB, "gdb: removed a memcheck: {:08x} bytes at {:08x}", len, addr);
|
||||
}
|
||||
}
|
||||
@@ -869,7 +871,8 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
|
||||
{
|
||||
if (type == BreakpointType::ExecuteHard || type == BreakpointType::ExecuteSoft)
|
||||
{
|
||||
PowerPC::breakpoints.Add(addr);
|
||||
auto& breakpoints = Core::System::GetInstance().GetPowerPC().GetBreakPoints();
|
||||
breakpoints.Add(addr);
|
||||
INFO_LOG_FMT(GDB_STUB, "gdb: added {} breakpoint: {:08x} bytes at {:08x}",
|
||||
static_cast<int>(type), len, addr);
|
||||
}
|
||||
@@ -886,7 +889,8 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
|
||||
new_memcheck.break_on_hit = true;
|
||||
new_memcheck.log_on_hit = false;
|
||||
new_memcheck.is_enabled = true;
|
||||
PowerPC::memchecks.Add(std::move(new_memcheck));
|
||||
auto& memchecks = Core::System::GetInstance().GetPowerPC().GetMemChecks();
|
||||
memchecks.Add(std::move(new_memcheck));
|
||||
INFO_LOG_FMT(GDB_STUB, "gdb: added {} memcheck: {:08x} bytes at {:08x}", static_cast<int>(type),
|
||||
len, addr);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user