summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2014-02-23 08:39:56 +0100
committerPierre Bourdon <delroth@gmail.com>2014-02-23 08:39:56 +0100
commit14f2fcc96fa88f876ab7bfc23d9b43c7f5487ae2 (patch)
treec03ccf9fc97c1d2955ed68f58b2dc3defdb59e5e /Source
parent70f3a069f2b760b2add51046781be625bef758db (diff)
parentc06c8f0ec82891345b4fa2c309d57d3d8d360745 (diff)
Merge pull request #95 from delroth/mmio-fixes
MMIO Interface fixes
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/MMIO.cpp19
-rw-r--r--Source/Core/Core/HW/MMIO.h4
2 files changed, 12 insertions, 11 deletions
diff --git a/Source/Core/Core/HW/MMIO.cpp b/Source/Core/Core/HW/MMIO.cpp
index 2f8788b214..39ae3187c3 100644
--- a/Source/Core/Core/HW/MMIO.cpp
+++ b/Source/Core/Core/HW/MMIO.cpp
@@ -194,8 +194,8 @@ template <typename T>
ReadHandlingMethod<T>* InvalidRead()
{
return ComplexRead<T>([](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 <typename T>
WriteHandlingMethod<T>* InvalidWrite()
{
return ComplexWrite<T>([](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);
});
}
@@ -230,8 +230,9 @@ ReadHandlingMethod<T>* ReadToSmaller(Mapping* mmio, u32 high_part_addr, u32 low_
mmio->GetHandlerForRead(low_part_addr, &low_part);
// TODO(delroth): optimize
- return ComplexRead<T>([high_part, low_part](u32 addr) {
- return ((T)high_part->Read(addr) << (8 * sizeof (ST))) | low_part->Read(addr);
+ return ComplexRead<T>([=](u32 addr) {
+ return ((T)high_part->Read(high_part_addr) << (8 * sizeof (ST)))
+ | low_part->Read(low_part_addr);
});
}
@@ -246,9 +247,9 @@ WriteHandlingMethod<T>* WriteToSmaller(Mapping* mmio, u32 high_part_addr, u32 lo
mmio->GetHandlerForWrite(low_part_addr, &low_part);
// TODO(delroth): optimize
- return ComplexWrite<T>([high_part, low_part](u32 addr, T val) {
- high_part->Write(addr, val >> (8 * sizeof (ST)));
- low_part->Write(addr, (ST)val);
+ return ComplexWrite<T>([=](u32 addr, T val) {
+ high_part->Write(high_part_addr, val >> (8 * sizeof (ST)));
+ low_part->Write(low_part_addr, (ST)val);
});
}
diff --git a/Source/Core/Core/HW/MMIO.h b/Source/Core/Core/HW/MMIO.h
index 541d75b271..447ae5285d 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.