From ed40b439605d0fc509f61f89271a70bc233ad96b Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 7 May 2022 14:32:45 +0200 Subject: [PATCH] PowerPC: Reorder code in ReadFromHardware This refactorization is done just to match the order that I made WriteToHardware use in 543ed8a. For WriteToHardware, it's important that things like MMIO and gather pipe are handled before we reach a special piece of code that only should get triggered for writes that hit memory directly, but for ReadFromHardware we don't have any code like that. --- Source/Core/Core/PowerPC/MMU.cpp | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index aac5f35054..ab460f1674 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -199,11 +199,27 @@ static T ReadFromHardware(u32 em_address) em_address = translated_addr.address; } + if (flag == XCheckTLBFlag::Read && (em_address & 0xF8000000) == 0x08000000) + { + if (em_address < 0x0c000000) + return EFB_Read(em_address); + else + return static_cast(Memory::mmio_mapping->Read>(em_address)); + } + + // Locked L1 technically doesn't have a fixed address, but games all use 0xE0000000. + if (Memory::m_pL1Cache && (em_address >> 28) == 0xE && + (em_address < (0xE0000000 + Memory::GetL1CacheSize()))) + { + T value; + std::memcpy(&value, &Memory::m_pL1Cache[em_address & 0x0FFFFFFF], sizeof(T)); + return bswap(value); + } + if (Memory::m_pRAM && (em_address & 0xF8000000) == 0x00000000) { // Handle RAM; the masking intentionally discards bits (essentially creating // mirrors of memory). - // TODO: Only the first GetRamSizeReal() is supposed to be backed by actual memory. T value; std::memcpy(&value, &Memory::m_pRAM[em_address & Memory::GetRamMask()], sizeof(T)); return bswap(value); @@ -217,14 +233,6 @@ static T ReadFromHardware(u32 em_address) return bswap(value); } - // Locked L1 technically doesn't have a fixed address, but games all use 0xE0000000. - if (Memory::m_pL1Cache && (em_address >> 28) == 0xE && - (em_address < (0xE0000000 + Memory::GetL1CacheSize()))) - { - T value; - std::memcpy(&value, &Memory::m_pL1Cache[em_address & 0x0FFFFFFF], sizeof(T)); - return bswap(value); - } // In Fake-VMEM mode, we need to map the memory somewhere into // physical memory for BAT translation to work; we currently use // [0x7E000000, 0x80000000). @@ -235,14 +243,6 @@ static T ReadFromHardware(u32 em_address) return bswap(value); } - if (flag == XCheckTLBFlag::Read && (em_address & 0xF8000000) == 0x08000000) - { - if (em_address < 0x0c000000) - return EFB_Read(em_address); - else - return (T)Memory::mmio_mapping->Read::type>(em_address); - } - PanicAlertFmt("Unable to resolve read address {:x} PC {:x}", em_address, PC); return 0; }