IOS/ES: Split ESDevice into ESCore and ESDevice.

ESCore implements the core functionality that can also be used outside of emulation. ESDevice implements the IOS device and is only available during emulation.
This commit is contained in:
Admiral H. Curtiss
2023-05-13 05:01:29 +02:00
parent 361a8b2c8e
commit 6a339cbdb3
24 changed files with 454 additions and 397 deletions

View File

@ -300,7 +300,11 @@ Kernel::Kernel(IOSC::ConsoleType console_type) : m_iosc(console_type)
if (m_is_responsible_for_nand_root)
Core::InitializeWiiRoot(false);
AddCoreDevices();
m_fs = FS::MakeFileSystem(IOS::HLE::FS::Location::Session, Core::GetActiveNandRedirects());
ASSERT(m_fs);
AddDevice(std::make_unique<FSDevice>(*this, "/dev/fs"));
m_es_core = std::make_unique<ESCore>(*this);
}
Kernel::~Kernel()
@ -333,7 +337,13 @@ EmulationKernel::EmulationKernel(Core::System& system, u64 title_id)
return;
}
AddCoreDevices();
m_fs = FS::MakeFileSystem(IOS::HLE::FS::Location::Session, Core::GetActiveNandRedirects());
ASSERT(m_fs);
AddDevice(std::make_unique<FSDevice>(*this, "/dev/fs"));
m_es_core = std::make_unique<ESCore>(*this);
AddDevice(std::make_unique<ESDevice>(*this, *m_es_core, "/dev/es"));
AddStaticDevices();
}
@ -360,7 +370,12 @@ std::shared_ptr<FSDevice> Kernel::GetFSDevice()
return std::static_pointer_cast<FSDevice>(m_device_map.at("/dev/fs"));
}
std::shared_ptr<ESDevice> Kernel::GetES()
ESCore& Kernel::GetESCore()
{
return *m_es_core;
}
std::shared_ptr<ESDevice> EmulationKernel::GetESDevice()
{
return std::static_pointer_cast<ESDevice>(m_device_map.at("/dev/es"));
}
@ -537,16 +552,6 @@ void Kernel::AddDevice(std::unique_ptr<Device> device)
m_device_map.insert_or_assign(device->GetDeviceName(), std::move(device));
}
void Kernel::AddCoreDevices()
{
m_fs = FS::MakeFileSystem(IOS::HLE::FS::Location::Session, Core::GetActiveNandRedirects());
ASSERT(m_fs);
std::lock_guard lock(m_device_map_mutex);
AddDevice(std::make_unique<FSDevice>(*this, "/dev/fs"));
AddDevice(std::make_unique<ESDevice>(*this, "/dev/es"));
}
void EmulationKernel::AddStaticDevices()
{
std::lock_guard lock(m_device_map_mutex);