From b6b70304829c16fad7b2e48c42d0110d732404dd Mon Sep 17 00:00:00 2001 From: JosJuice Date: Sat, 7 May 2022 19:37:44 +0200 Subject: [PATCH] PowerPC: Add HW_PAGE_MASK constant --- Source/Core/Core/PowerPC/MMU.cpp | 8 ++++---- Source/Core/Core/PowerPC/MMU.h | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/PowerPC/MMU.cpp b/Source/Core/Core/PowerPC/MMU.cpp index ab460f1674..6c0867deb6 100644 --- a/Source/Core/Core/PowerPC/MMU.cpp +++ b/Source/Core/Core/PowerPC/MMU.cpp @@ -173,8 +173,8 @@ static void GenerateDSIException(u32 effective_address, bool write); template static T ReadFromHardware(u32 em_address) { - const u32 em_address_start_page = em_address & ~(HW_PAGE_SIZE - 1); - const u32 em_address_end_page = (em_address + sizeof(T) - 1) & ~(HW_PAGE_SIZE - 1); + const u32 em_address_start_page = em_address & ~HW_PAGE_MASK; + const u32 em_address_end_page = (em_address + sizeof(T) - 1) & ~HW_PAGE_MASK; if (em_address_start_page != em_address_end_page) { // This could be unaligned down to the byte level... hopefully this is rare, so doing it this @@ -252,8 +252,8 @@ static void WriteToHardware(u32 em_address, const u32 data, const u32 size) { DEBUG_ASSERT(size <= 4); - const u32 em_address_start_page = em_address & ~(HW_PAGE_SIZE - 1); - const u32 em_address_end_page = (em_address + size - 1) & ~(HW_PAGE_SIZE - 1); + const u32 em_address_start_page = em_address & ~HW_PAGE_MASK; + const u32 em_address_end_page = (em_address + size - 1) & ~HW_PAGE_MASK; if (em_address_start_page != em_address_end_page) { // The write crosses a page boundary. Break it up into two writes. diff --git a/Source/Core/Core/PowerPC/MMU.h b/Source/Core/Core/PowerPC/MMU.h index afe36a9875..726e861f62 100644 --- a/Source/Core/Core/PowerPC/MMU.h +++ b/Source/Core/Core/PowerPC/MMU.h @@ -215,6 +215,7 @@ inline bool TranslateBatAddess(const BatTable& bat_table, u32* address, bool* wi } constexpr size_t HW_PAGE_SIZE = 4096; +constexpr size_t HW_PAGE_MASK = HW_PAGE_SIZE - 1; constexpr u32 HW_PAGE_INDEX_SHIFT = 12; constexpr u32 HW_PAGE_INDEX_MASK = 0x3f;