From c1ff466e163e3465d279c2f407bc156a202c25ab Mon Sep 17 00:00:00 2001 From: "Dr. Dystopia" Date: Tue, 16 Jul 2024 12:10:48 +0200 Subject: [PATCH] Split 'IsRAMAddress' method into 'IsEffectiveRAMAddress' and 'IsPhysicalRAMAddress' methods --- Source/Core/Core/PowerPC/MMU.cpp | 29 +++++++++++++++-------------- Source/Core/Core/PowerPC/MMU.h | 3 ++- 2 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index 8af5247aba..06e4504e9b 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -938,16 +938,14 @@ bool MMU::IsOptimizableRAMAddress(const u32 address, const u32 access_size) cons } template -bool MMU::IsRAMAddress(u32 address, bool translate) +bool MMU::IsEffectiveRAMAddress(u32 address) { - if (translate) - { - auto translate_address = TranslateAddress(address); - if (!translate_address.Success()) - return false; - address = translate_address.address; - } + auto translate_address = TranslateAddress(address); + return translate_address.Success() && IsPhysicalRAMAddress(translate_address.address); +} +bool MMU::IsPhysicalRAMAddress(const u32 address) const +{ u32 segment = address >> 28; if (m_memory.GetRAM() && segment == 0x0 && (address & 0x0FFFFFFF) < m_memory.GetRamSizeReal()) { @@ -977,13 +975,14 @@ bool MMU::HostIsRAMAddress(const Core::CPUThreadGuard& guard, u32 address, switch (space) { case RequestedAddressSpace::Effective: - return mmu.IsRAMAddress(address, mmu.m_ppc_state.msr.DR); + return mmu.m_ppc_state.msr.DR ? mmu.IsEffectiveRAMAddress(address) : + mmu.IsPhysicalRAMAddress(address); case RequestedAddressSpace::Physical: - return mmu.IsRAMAddress(address, false); + return mmu.IsPhysicalRAMAddress(address); case RequestedAddressSpace::Virtual: if (!mmu.m_ppc_state.msr.DR) return false; - return mmu.IsRAMAddress(address, true); + return mmu.IsEffectiveRAMAddress(address); } ASSERT(false); @@ -1001,13 +1000,15 @@ bool MMU::HostIsInstructionRAMAddress(const Core::CPUThreadGuard& guard, u32 add switch (space) { case RequestedAddressSpace::Effective: - return mmu.IsRAMAddress(address, mmu.m_ppc_state.msr.IR); + return mmu.m_ppc_state.msr.IR ? + mmu.IsEffectiveRAMAddress(address) : + mmu.IsPhysicalRAMAddress(address); case RequestedAddressSpace::Physical: - return mmu.IsRAMAddress(address, false); + return mmu.IsPhysicalRAMAddress(address); case RequestedAddressSpace::Virtual: if (!mmu.m_ppc_state.msr.IR) return false; - return mmu.IsRAMAddress(address, true); + return mmu.IsEffectiveRAMAddress(address); } ASSERT(false); diff --git a/Source/Core/Core/PowerPC/MMU.h b/Source/Core/Core/PowerPC/MMU.h index faf6776389..d839b829f2 100644 --- a/Source/Core/Core/PowerPC/MMU.h +++ b/Source/Core/Core/PowerPC/MMU.h @@ -310,7 +310,8 @@ private: template void WriteToHardware(u32 em_address, const u32 data, const u32 size); template - bool IsRAMAddress(u32 address, bool translate); + bool IsEffectiveRAMAddress(u32 address); + bool IsPhysicalRAMAddress(u32 address) const; template static std::optional> HostTryReadUX(const Core::CPUThreadGuard& guard,