From 803c110e3031cda094de41ff477579482d5a7ae3 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 23 Feb 2014 08:32:52 +0100 Subject: [PATCH 1/3] MMIO: Show the read/write size in invalid handlers. --- Source/Core/Core/HW/MMIO.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp index 2f8788b21425..667165b8b774 100644 --- a/Source/Core/Core/HW/MMIO.cpp +++ b/Source/Core/Core/HW/MMIO.cpp @@ -194,8 +194,8 @@ template ReadHandlingMethod* InvalidRead() { return ComplexRead([](u32 addr) { - ERROR_LOG(MEMMAP, "Trying to read from an invalid MMIO (addr=%08x)", - addr); + ERROR_LOG(MEMMAP, "Trying to read%d from an invalid MMIO (addr=%08x)", + 8 * (int)(sizeof (T)), addr); return -1; }); } @@ -203,8 +203,8 @@ template WriteHandlingMethod* InvalidWrite() { return ComplexWrite([](u32 addr, T val) { - ERROR_LOG(MEMMAP, "Trying to write to an invalid MMIO (addr=%08x, val=%08x)", - addr, (u32)val); + ERROR_LOG(MEMMAP, "Trying to write%d to an invalid MMIO (addr=%08x, val=%08x)", + 8 * (int)(sizeof (T)), addr, (u32)val); }); } From b8582b00a9821a86b84611a797167cd9c9cd1f4b Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 23 Feb 2014 08:33:27 +0100 Subject: [PATCH 2/3] MMIO: Pass the provided high part/low part addrs to handlers in {Read,Write}ToSmaller. --- Source/Core/Core/HW/MMIO.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp index 667165b8b774..39ae3187c3ff 100644 --- a/Source/Core/Core/HW/MMIO.cpp +++ b/Source/Core/Core/HW/MMIO.cpp @@ -230,8 +230,9 @@ ReadHandlingMethod* ReadToSmaller(Mapping* mmio, u32 high_part_addr, u32 low_ mmio->GetHandlerForRead(low_part_addr, &low_part); // TODO(delroth): optimize - return ComplexRead([high_part, low_part](u32 addr) { - return ((T)high_part->Read(addr) << (8 * sizeof (ST))) | low_part->Read(addr); + return ComplexRead([=](u32 addr) { + return ((T)high_part->Read(high_part_addr) << (8 * sizeof (ST))) + | low_part->Read(low_part_addr); }); } @@ -246,9 +247,9 @@ WriteHandlingMethod* WriteToSmaller(Mapping* mmio, u32 high_part_addr, u32 lo mmio->GetHandlerForWrite(low_part_addr, &low_part); // TODO(delroth): optimize - return ComplexWrite([high_part, low_part](u32 addr, T val) { - high_part->Write(addr, val >> (8 * sizeof (ST))); - low_part->Write(addr, (ST)val); + return ComplexWrite([=](u32 addr, T val) { + high_part->Write(high_part_addr, val >> (8 * sizeof (ST))); + low_part->Write(low_part_addr, (ST)val); }); } From c06c8f0ec82891345b4fa2c309d57d3d8d360745 Mon Sep 17 00:00:00 2001 From: Pierre Bourdon Date: Sun, 23 Feb 2014 08:34:05 +0100 Subject: [PATCH 3/3] MMIO: Fix a megaderp in the UniqueID function causing handlers to be overwritten by other handlers. --- Source/Core/Core/HW/MMIO.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core/HW/MMIO.h b/Source/Core/Core/HW/MMIO.h index 541d75b271c6..447ae5285dc1 100644 --- a/Source/Core/Core/HW/MMIO.h +++ b/Source/Core/Core/HW/MMIO.h @@ -32,7 +32,7 @@ const u32 BLOCK_SIZE = 0x10000; const u32 NUM_MMIOS = NUM_BLOCKS * BLOCK_SIZE; // Compute the internal unique ID for a given MMIO address. This ID is computed -// from a very simple formula: (1 + block_id) * lower_16_bits(address). +// from a very simple formula: (block_id << 16) | lower_16_bits(address). // // The block ID can easily be computed by simply checking bit 24 (CC vs. CD). inline u32 UniqueID(u32 address) @@ -42,7 +42,7 @@ inline u32 UniqueID(u32 address) ((address & 0xFFFF0000) == 0xCD800000), "Trying to get the ID of a non-existing MMIO address."); - return (1 + ((address >> 24) & 1)) * (address & 0xFFFF); + return (((address >> 24) & 1) << 16) | (address & 0xFFFF); } // Some utilities functions to define MMIO mappings.