Merge pull request #12423 from lioncash/mios

IOS/MIOS: Eliminate global system accessors
This commit is contained in:
Tilka 2023-12-14 22:19:11 +00:00 committed by GitHub
commit f777a584c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 7 deletions

View File

@ -329,7 +329,7 @@ EmulationKernel::EmulationKernel(Core::System& system, u64 title_id)
if (title_id == Titles::MIOS) if (title_id == Titles::MIOS)
{ {
MIOS::Load(); MIOS::Load(m_system);
return; return;
} }

View File

@ -30,12 +30,11 @@
namespace IOS::HLE::MIOS namespace IOS::HLE::MIOS
{ {
static void ReinitHardware() static void ReinitHardware(Core::System& system)
{ {
SConfig::GetInstance().bWii = false; SConfig::GetInstance().bWii = false;
// IOS clears mem2 and overwrites it with pseudo-random data (for security). // IOS clears mem2 and overwrites it with pseudo-random data (for security).
auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory(); auto& memory = system.GetMemory();
std::memset(memory.GetEXRAM(), 0, memory.GetExRamSizeReal()); std::memset(memory.GetEXRAM(), 0, memory.GetExRamSizeReal());
// MIOS appears to only reset the DI and the PPC. // MIOS appears to only reset the DI and the PPC.
@ -56,9 +55,8 @@ static void ReinitHardware()
constexpr u32 ADDRESS_INIT_SEMAPHORE = 0x30f8; constexpr u32 ADDRESS_INIT_SEMAPHORE = 0x30f8;
bool Load() bool Load(Core::System& system)
{ {
auto& system = Core::System::GetInstance();
auto& memory = system.GetMemory(); auto& memory = system.GetMemory();
ASSERT(Core::IsCPUThread()); ASSERT(Core::IsCPUThread());
@ -67,7 +65,7 @@ bool Load()
memory.Write_U32(0x00000000, ADDRESS_INIT_SEMAPHORE); memory.Write_U32(0x00000000, ADDRESS_INIT_SEMAPHORE);
memory.Write_U32(0x09142001, 0x3180); memory.Write_U32(0x09142001, 0x3180);
ReinitHardware(); ReinitHardware(system);
NOTICE_LOG_FMT(IOS, "Reinitialised hardware."); NOTICE_LOG_FMT(IOS, "Reinitialised hardware.");
// Load symbols for the IPL if they exist. // Load symbols for the IPL if they exist.

View File

@ -3,7 +3,12 @@
#pragma once #pragma once
namespace Core
{
class System;
}
namespace IOS::HLE::MIOS namespace IOS::HLE::MIOS
{ {
bool Load(); bool Load(Core::System& system);
} // namespace IOS::HLE::MIOS } // namespace IOS::HLE::MIOS