29 changes: 15 additions & 14 deletions Source/Core/Core/PowerPC/MMU.cpp
Expand Up @@ -15,6 +15,7 @@
#include "Common/Logging/Log.h"

#include "Core/ConfigManager.h"
#include "Core/Core.h"
#include "Core/HW/CPU.h"
#include "Core/HW/GPFifo.h"
#include "Core/HW/MMIO.h"
Expand Down Expand Up @@ -524,7 +525,7 @@ TryReadInstResult TryReadInstruction(u32 address)

u32 HostRead_Instruction(const Core::CPUThreadGuard& guard, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
return ReadFromHardware<XCheckTLBFlag::OpcodeNoException, u32>(system, memory, address);
}
Expand All @@ -536,7 +537,7 @@ std::optional<ReadResult<u32>> HostTryReadInstruction(const Core::CPUThreadGuard
if (!HostIsInstructionRAMAddress(guard, address, space))
return std::nullopt;

auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();

switch (space)
Expand Down Expand Up @@ -660,7 +661,7 @@ static std::optional<ReadResult<T>> HostTryReadUX(const Core::CPUThreadGuard& gu
if (!HostIsRAMAddress(guard, address, space))
return std::nullopt;

auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();

switch (space)
Expand Down Expand Up @@ -795,28 +796,28 @@ void Write_F64(const double var, const u32 address)

u8 HostRead_U8(const Core::CPUThreadGuard& guard, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
return ReadFromHardware<XCheckTLBFlag::NoException, u8>(system, memory, address);
}

u16 HostRead_U16(const Core::CPUThreadGuard& guard, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
return ReadFromHardware<XCheckTLBFlag::NoException, u16>(system, memory, address);
}

u32 HostRead_U32(const Core::CPUThreadGuard& guard, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
return ReadFromHardware<XCheckTLBFlag::NoException, u32>(system, memory, address);
}

u64 HostRead_U64(const Core::CPUThreadGuard& guard, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
return ReadFromHardware<XCheckTLBFlag::NoException, u64>(system, memory, address);
}
Expand All @@ -837,28 +838,28 @@ double HostRead_F64(const Core::CPUThreadGuard& guard, const u32 address)

void HostWrite_U8(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 1);
}

void HostWrite_U16(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 2);
}

void HostWrite_U32(const Core::CPUThreadGuard& guard, const u32 var, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, var, 4);
}

void HostWrite_U64(const Core::CPUThreadGuard& guard, const u64 var, const u32 address)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();
WriteToHardware<XCheckTLBFlag::NoException>(system, memory, address, static_cast<u32>(var >> 32),
4);
Expand Down Expand Up @@ -887,7 +888,7 @@ static std::optional<WriteResult> HostTryWriteUX(const Core::CPUThreadGuard& gua
if (!HostIsRAMAddress(guard, address, space))
return std::nullopt;

auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();

switch (space)
Expand Down Expand Up @@ -1041,7 +1042,7 @@ static bool IsRAMAddress(Memory::MemoryManager& memory, u32 address, bool transl

bool HostIsRAMAddress(const Core::CPUThreadGuard& guard, u32 address, RequestedAddressSpace space)
{
auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();

switch (space)
Expand All @@ -1067,7 +1068,7 @@ bool HostIsInstructionRAMAddress(const Core::CPUThreadGuard& guard, u32 address,
if (address & 3)
return false;

auto& system = Core::System::GetInstance();
auto& system = guard.GetSystem();
auto& memory = system.GetMemory();

switch (space)
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Core/State.cpp
Expand Up @@ -230,7 +230,7 @@ static void DoState(PointerWrap& p)
p.DoMarker("CoreTiming");

// HW needs to be restored before PowerPC because the data cache might need to be flushed.
HW::DoState(p);
HW::DoState(system, p);
p.DoMarker("HW");

PowerPC::DoState(p);
Expand Down
5 changes: 3 additions & 2 deletions Source/Core/Core/System.cpp
Expand Up @@ -37,8 +37,9 @@ struct System::Impl
{
explicit Impl(System& system)
: m_audio_interface(system), m_core_timing(system), m_dsp(system), m_dvd_interface(system),
m_dvd_thread(system), m_expansion_interface(system), m_gp_fifo(system),
m_ppc_state(PowerPC::ppcState), m_serial_interface(system), m_video_interface(system)
m_dvd_thread(system), m_expansion_interface(system), m_gp_fifo(system), m_memory(system),
m_ppc_state(PowerPC::ppcState), m_processor_interface(system), m_serial_interface(system),
m_video_interface(system)
{
}

Expand Down