diff --git a/Source/Core/Core/HW/Memmap.cpp b/Source/Core/Core/HW/Memmap.cpp index b0d8baad24..22c7708bd6 100644 --- a/Source/Core/Core/HW/Memmap.cpp +++ b/Source/Core/Core/HW/Memmap.cpp @@ -209,8 +209,6 @@ void Init() PanicAlert("MemoryMap_Setup: Failed finding a memory base."); exit(0); } - - mem_size += region.size; } #ifndef _ARCH_32 @@ -252,15 +250,8 @@ void UpdateLogicalMemory(u32* dbat_table) if (intersection_start < intersection_end) { // Found an overlapping region; map it. - // We only worry about one overlapping region; in theory, a logical - // region could translate to more than one physical region, but in - // practice, that doesn't happen. - u32 position = physical_region.shm_position; - if (intersection_start > mapping_address) - position += intersection_start - mapping_address; - u8* base = logical_base + logical_address; - if (intersection_start > translated_address) - base += intersection_start - translated_address; + u32 position = physical_region.shm_position + intersection_start - mapping_address; + u8* base = logical_base + logical_address + intersection_start - translated_address; u32 mapped_size = intersection_end - intersection_start; void* mapped_pointer = g_arena.CreateView(position, mapped_size, base); @@ -270,7 +261,6 @@ void UpdateLogicalMemory(u32* dbat_table) exit(0); } logical_mapped_entries.push_back({mapped_pointer, mapped_size}); - break; } } } diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index e6430dabd4..e5462efae7 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -179,20 +179,20 @@ __forceinline static T ReadFromHardware(u32 em_address) // TODO: floats on non-word-aligned boundaries should technically cause alignment exceptions. // Note that "word" means 32-bit, so paired singles or doubles might still be 32-bit aligned! u32 em_address_next_page = (em_address + sizeof(T) - 1) & ~(HW_PAGE_SIZE - 1); - auto tlb_addr_next_page = TranslateAddress(em_address_next_page); - if (!tlb_addr_next_page.Success()) + auto addr_next_page = TranslateAddress(em_address_next_page); + if (!addr_next_page.Success()) { if (flag == FLAG_READ) GenerateDSIException(em_address_next_page, false); return 0; } T var = 0; - u32 tlb_addr = translated_addr.address; - for (u32 addr = em_address; addr < em_address + sizeof(T); addr++, tlb_addr++) + u32 addr_translated = translated_addr.address; + for (u32 addr = em_address; addr < em_address + sizeof(T); addr++, addr_translated++) { if (addr == em_address_next_page) - tlb_addr = tlb_addr_next_page.address; - var = (var << 8) | ReadFromHardware(tlb_addr); + addr_translated = addr_next_page.address; + var = (var << 8) | ReadFromHardware(addr_translated); } return var; } @@ -260,20 +260,21 @@ __forceinline static void WriteToHardware(u32 em_address, const T data) // TODO: floats on non-word-aligned boundaries should technically cause alignment exceptions. // Note that "word" means 32-bit, so paired singles or doubles might still be 32-bit aligned! u32 em_address_next_page = (em_address + sizeof(T) - 1) & ~(HW_PAGE_SIZE - 1); - auto tlb_addr_next_page = TranslateAddress(em_address_next_page); - if (!tlb_addr_next_page.Success()) + auto addr_next_page = TranslateAddress(em_address_next_page); + if (!addr_next_page.Success()) { if (flag == FLAG_WRITE) GenerateDSIException(em_address_next_page, true); return; } T val = bswap(data); - u32 tlb_addr = translated_addr.address; - for (u32 addr = em_address; addr < em_address + sizeof(T); addr++, tlb_addr++, val >>= 8) + u32 addr_translated = translated_addr.address; + for (u32 addr = em_address; addr < em_address + sizeof(T); + addr++, addr_translated++, val >>= 8) { if (addr == em_address_next_page) - tlb_addr = tlb_addr_next_page.address; - WriteToHardware(tlb_addr, (u8)val); + addr_translated = addr_next_page.address; + WriteToHardware(addr_translated, (u8)val); } return; } @@ -1151,7 +1152,7 @@ static void UpdateBATs(u32* bat_table, u32 base_spr) // invalid BATs as well. WARN_LOG(POWERPC, "Bad BAT setup: invalid mask in BL"); } - for (u32 j = 0; j < (1 << 11); ++j) + for (u32 j = 0; j <= batu.BL; ++j) { // Enumerate all bit-patterns which fit within the given mask. if ((j & batu.BL) == j)