Merge pull request #1057 from phire/IsMMIOAddress2
Further improvements to IsMMIOAddress (Includes tests!)
This commit is contained in:
commit
4e9497cdb8
|
@ -9,6 +9,7 @@
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
#include "Common/Common.h"
|
#include "Common/Common.h"
|
||||||
|
#include "Core/ConfigManager.h"
|
||||||
#include "Core/HW/MMIOHandlers.h"
|
#include "Core/HW/MMIOHandlers.h"
|
||||||
|
|
||||||
namespace MMIO
|
namespace MMIO
|
||||||
|
@ -40,8 +41,18 @@ const u32 NUM_MMIOS = NUM_BLOCKS * BLOCK_SIZE;
|
||||||
// interface.
|
// interface.
|
||||||
inline bool IsMMIOAddress(u32 address)
|
inline bool IsMMIOAddress(u32 address)
|
||||||
{
|
{
|
||||||
return ((address & 0xFE7F0000) == 0xCC000000) &&
|
if (address == 0xCC008000)
|
||||||
((address & 0x0000FFFF) != 0x00008000);
|
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
|
// Compute the internal unique ID for a given MMIO address. This ID is computed
|
||||||
|
|
|
@ -25,11 +25,24 @@ TEST(UniqueID, UniqueEnough)
|
||||||
|
|
||||||
TEST(IsMMIOAddress, SpecialAddresses)
|
TEST(IsMMIOAddress, SpecialAddresses)
|
||||||
{
|
{
|
||||||
|
SConfig::Init();
|
||||||
|
SConfig::GetInstance().m_LocalCoreStartupParameter.bWii = true;
|
||||||
|
|
||||||
// WG Pipe address, should not be handled by MMIO.
|
// WG Pipe address, should not be handled by MMIO.
|
||||||
EXPECT_FALSE(MMIO::IsMMIOAddress(0xCC008000));
|
EXPECT_FALSE(MMIO::IsMMIOAddress(0xCC008000));
|
||||||
|
|
||||||
// Memory zone used by games using the "MMU Speedhack".
|
// Memory zone used by games using the "MMU Speedhack".
|
||||||
EXPECT_FALSE(MMIO::IsMMIOAddress(0xE0000000));
|
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
|
class MappingTest : public testing::Test
|
||||||
|
|
Loading…
Reference in New Issue