mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
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.
This commit is contained in:
parent
3b3c60dc4c
commit
ed40b43960
@ -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<T>(Memory::mmio_mapping->Read<std::make_unsigned_t<T>>(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<typename std::make_unsigned<T>::type>(em_address);
|
||||
}
|
||||
|
||||
PanicAlertFmt("Unable to resolve read address {:x} PC {:x}", em_address, PC);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user