summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2014-09-11 21:02:45 +1200
committerScott Mansell <phiren@gmail.com>2015-01-24 17:24:40 +1300
commitfe28d1476a671145697dd056b2d7b03257e45d8c (patch)
tree518af70c0346830cdc1919a9385ff89231c3b483 /Source
parentf1a4b98d36bedc4c56c409a93c94ba81a1bbefaa (diff)
Make the IsMMIOAddress function easier to read, add tests.
This also makes IsMMIOAddress more restrictive.
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/HW/MMIO.h15
-rw-r--r--Source/UnitTests/Core/MMIOTest.cpp13
2 files changed, 26 insertions, 2 deletions
diff --git a/Source/Core/Core/HW/MMIO.h b/Source/Core/Core/HW/MMIO.h
index 10bba4a6c8..0a4a1a5d04 100644
--- a/Source/Core/Core/HW/MMIO.h
+++ b/Source/Core/Core/HW/MMIO.h
@@ -9,6 +9,7 @@
#include <type_traits>
#include "Common/Common.h"
+#include "Core/ConfigManager.h"
#include "Core/HW/MMIOHandlers.h"
namespace MMIO
@@ -40,8 +41,18 @@ const u32 NUM_MMIOS = NUM_BLOCKS * BLOCK_SIZE;
// interface.
inline bool IsMMIOAddress(u32 address)
{
- return ((address & 0xFE7F0000) == 0xCC000000) &&
- ((address & 0x0000FFFF) != 0x00008000);
+ if (address == 0xCC008000)
+ return false; // WG Pipe
+ if ((address & 0xFFFF0000) == 0xCC000000)
+ return true; // GameCube MMIOs
+
+ if(SConfig::GetInstance().m_LocalCoreStartupParameter.bWii)
+ {
+ return ((address & 0xFFFF0000) == 0xCD000000) || // Wii MMIOs
+ ((address & 0xFFFF0000) == 0xCD800000); // Mirror of Wii MMIOs
+ }
+
+ return false;
}
// Compute the internal unique ID for a given MMIO address. This ID is computed
diff --git a/Source/UnitTests/Core/MMIOTest.cpp b/Source/UnitTests/Core/MMIOTest.cpp
index f9173ce0c4..bb7f1c4714 100644
--- a/Source/UnitTests/Core/MMIOTest.cpp
+++ b/Source/UnitTests/Core/MMIOTest.cpp
@@ -25,11 +25,24 @@ TEST(UniqueID, UniqueEnough)
TEST(IsMMIOAddress, SpecialAddresses)
{
+ SConfig::Init();
+ SConfig::GetInstance().m_LocalCoreStartupParameter.bWii = true;
+
// WG Pipe address, should not be handled by MMIO.
EXPECT_FALSE(MMIO::IsMMIOAddress(0xCC008000));
// Memory zone used by games using the "MMU Speedhack".
EXPECT_FALSE(MMIO::IsMMIOAddress(0xE0000000));
+
+ // Uncached mirror of MEM1, shouldn't be handled by MMIO
+ EXPECT_FALSE(MMIO::IsMMIOAddress(0xC0000000));
+
+ // And lets check some valid addresses too
+ EXPECT_TRUE(MMIO::IsMMIOAddress(0xCC0000E0)); // Gamecube MMIOs
+ EXPECT_TRUE(MMIO::IsMMIOAddress(0xCD00008C)); // Wii MMIOs
+ EXPECT_TRUE(MMIO::IsMMIOAddress(0xCD800F10)); // Mirror of Wii MMIOs
+
+ SConfig::Shutdown();
}
class MappingTest : public testing::Test