Core: Don't call InitMMIO from MemoryManager::Init

In the unit test I'm adding in the next commit, I want to call
MemoryManager::Init, but initializing all the hardware that
MemoryManager::InitMMIO calls into would be cumbersome.

Calling MemoryManager::InitMMIO from MemoryManager::Init was a bit
strange anyway. Because MemoryManager::Init is called about halfway
through HW::Init, some of the hardware that MemoryManager::InitMMIO
calls into isn't initialized yet.
This commit is contained in:
JosJuice
2026-02-04 21:35:22 +01:00
parent b0e2a28e14
commit 94283c9639
3 changed files with 20 additions and 21 deletions
+2
View File
@@ -57,6 +57,8 @@ void Init(Core::System& system, const Sram* override_sram)
system.GetWiiIPC().Init(); system.GetWiiIPC().Init();
IOS::HLE::Init(system); // Depends on Memory IOS::HLE::Init(system); // Depends on Memory
} }
system.GetMemory().InitMMIO(system);
} }
void Shutdown(Core::System& system) void Shutdown(Core::System& system)
+17 -19
View File
@@ -61,27 +61,27 @@ MemoryManager::HostPageType MemoryManager::GetHostPageTypeForPageSize(u32 page_s
return page_size > PowerPC::HW_PAGE_SIZE ? HostPageType::LargePages : HostPageType::SmallPages; return page_size > PowerPC::HW_PAGE_SIZE ? HostPageType::LargePages : HostPageType::SmallPages;
} }
void MemoryManager::InitMMIO(bool is_wii) void MemoryManager::InitMMIO(Core::System& system)
{ {
m_mmio_mapping = std::make_unique<MMIO::Mapping>(); m_mmio_mapping = std::make_unique<MMIO::Mapping>();
m_system.GetCommandProcessor().RegisterMMIO(m_mmio_mapping.get(), 0x0C000000); system.GetCommandProcessor().RegisterMMIO(m_mmio_mapping.get(), 0x0C000000);
m_system.GetPixelEngine().RegisterMMIO(m_mmio_mapping.get(), 0x0C001000); system.GetPixelEngine().RegisterMMIO(m_mmio_mapping.get(), 0x0C001000);
m_system.GetVideoInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C002000); system.GetVideoInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C002000);
m_system.GetProcessorInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C003000); system.GetProcessorInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C003000);
m_system.GetMemoryInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C004000); system.GetMemoryInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C004000);
m_system.GetDSP().RegisterMMIO(m_mmio_mapping.get(), 0x0C005000); system.GetDSP().RegisterMMIO(m_mmio_mapping.get(), 0x0C005000);
m_system.GetDVDInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006000, false); system.GetDVDInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006000, false);
m_system.GetSerialInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006400); system.GetSerialInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006400);
m_system.GetExpansionInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006800); system.GetExpansionInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006800);
m_system.GetAudioInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006C00); system.GetAudioInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0C006C00);
if (is_wii) if (system.IsWii())
{ {
m_system.GetWiiIPC().RegisterMMIO(m_mmio_mapping.get(), 0x0D000000); system.GetWiiIPC().RegisterMMIO(m_mmio_mapping.get(), 0x0D000000);
m_system.GetDVDInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006000, true); system.GetDVDInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006000, true);
m_system.GetSerialInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006400); system.GetSerialInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006400);
m_system.GetExpansionInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006800); system.GetExpansionInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006800);
m_system.GetAudioInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006C00); system.GetAudioInterface().RegisterMMIO(m_mmio_mapping.get(), 0x0D006C00);
} }
} }
@@ -165,8 +165,6 @@ void MemoryManager::Init()
m_physical_page_mappings_base = reinterpret_cast<u8*>(m_physical_page_mappings.data()); m_physical_page_mappings_base = reinterpret_cast<u8*>(m_physical_page_mappings.data());
m_logical_page_mappings_base = reinterpret_cast<u8*>(m_logical_page_mappings.data()); m_logical_page_mappings_base = reinterpret_cast<u8*>(m_logical_page_mappings.data());
InitMMIO(wii);
Clear(); Clear();
INFO_LOG_FMT(MEMMAP, "Memory system initialized. RAM at {}", fmt::ptr(m_ram)); INFO_LOG_FMT(MEMMAP, "Memory system initialized. RAM at {}", fmt::ptr(m_ram));
+1 -2
View File
@@ -95,6 +95,7 @@ public:
// Init and Shutdown // Init and Shutdown
bool IsInitialized() const { return m_is_initialized; } bool IsInitialized() const { return m_is_initialized; }
void InitMMIO(Core::System& system);
void Init(); void Init();
void Shutdown(); void Shutdown();
bool InitFastmemArena(); bool InitFastmemArena();
@@ -284,8 +285,6 @@ private:
static HostPageType GetHostPageTypeForPageSize(u32 page_size); static HostPageType GetHostPageTypeForPageSize(u32 page_size);
void InitMMIO(bool is_wii);
void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable); void TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool writeable);
bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address, bool TryAddLargePageTableMapping(u32 logical_address, u32 translated_address,
std::map<u32, std::vector<u32>>& map); std::map<u32, std::vector<u32>>& map);