Skip to content

Commit

Permalink
Merge pull request #95 from delroth/mmio-fixes
Browse files Browse the repository at this point in the history
MMIO Interface fixes
  • Loading branch information
delroth committed Feb 23, 2014
2 parents 70f3a06 + c06c8f0 commit 14f2fcc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
19 changes: 10 additions & 9 deletions Source/Core/Core/HW/MMIO.cpp
Expand Up @@ -194,17 +194,17 @@ 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;
});
}
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);
});
}

Expand All @@ -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);
});
}

Expand All @@ -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);
});
}

Expand Down
4 changes: 2 additions & 2 deletions Source/Core/Core/HW/MMIO.h
Expand Up @@ -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)
Expand All @@ -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.
Expand Down

0 comments on commit 14f2fcc

Please sign in to comment.