IOS: Change GetFS() to return a FileSystem

Now that we have a proper filesystem interface, it makes more sense
to return it instead of the emulated IOS device (which isn't
really usable for any purpose other than emulated IPC).
This commit is contained in:
Léo Lam 2018-03-03 18:25:51 +01:00
parent 1eec459e30
commit fcfe4e2a26
7 changed files with 37 additions and 4 deletions

View file

@ -165,6 +165,7 @@ add_library(core
IOS/ES/TitleInformation.cpp IOS/ES/TitleInformation.cpp
IOS/ES/TitleManagement.cpp IOS/ES/TitleManagement.cpp
IOS/ES/Views.cpp IOS/ES/Views.cpp
IOS/FS/FileSystem.cpp
IOS/FS/HostBackend/File.cpp IOS/FS/HostBackend/File.cpp
IOS/FS/HostBackend/FS.cpp IOS/FS/HostBackend/FS.cpp
IOS/FS/FileIO.cpp IOS/FS/FileIO.cpp

View file

@ -197,6 +197,7 @@
<ClCompile Include="IOS\ES\Views.cpp" /> <ClCompile Include="IOS\ES\Views.cpp" />
<ClCompile Include="IOS\FS\FileIO.cpp" /> <ClCompile Include="IOS\FS\FileIO.cpp" />
<ClCompile Include="IOS\FS\FS.cpp" /> <ClCompile Include="IOS\FS\FS.cpp" />
<ClCompile Include="IOS\FS\FileSystem.cpp" />
<ClCompile Include="IOS\FS\HostBackend\FS.cpp" /> <ClCompile Include="IOS\FS\HostBackend\FS.cpp" />
<ClCompile Include="IOS\FS\HostBackend\File.cpp" /> <ClCompile Include="IOS\FS\HostBackend\File.cpp" />
<ClCompile Include="IOS\Network\ICMPLin.cpp" /> <ClCompile Include="IOS\Network\ICMPLin.cpp" />

View file

@ -735,6 +735,9 @@
<ClCompile Include="IOS\FS\FileIO.cpp"> <ClCompile Include="IOS\FS\FileIO.cpp">
<Filter>IOS\FS</Filter> <Filter>IOS\FS</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="IOS\FS\FileSystem.cpp">
<Filter>IOS\FS</Filter>
</ClCompile>
<ClCompile Include="IOS\FS\HostBackend\FS.cpp"> <ClCompile Include="IOS\FS\HostBackend\FS.cpp">
<Filter>IOS\FS</Filter> <Filter>IOS\FS</Filter>
</ClCompile> </ClCompile>

View file

@ -0,0 +1,15 @@
// Copyright 2018 Dolphin Emulator Project
// Licensed under GPLv2+
// Refer to the license.txt file included.
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/FS/HostBackend/FS.h"
namespace IOS::HLE::FS
{
std::unique_ptr<FileSystem> MakeFileSystem()
{
return std::make_unique<HostFileSystem>();
}
} // namespace IOS::HLE::FS

View file

@ -4,6 +4,7 @@
#pragma once #pragma once
#include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
@ -170,4 +171,6 @@ public:
virtual Result<DirectoryStats> GetDirectoryStats(const std::string& path) = 0; virtual Result<DirectoryStats> GetDirectoryStats(const std::string& path) = 0;
}; };
std::unique_ptr<FileSystem> MakeFileSystem();
} // namespace IOS::HLE::FS } // namespace IOS::HLE::FS

View file

@ -33,6 +33,7 @@
#include "Core/IOS/ES/ES.h" #include "Core/IOS/ES/ES.h"
#include "Core/IOS/FS/FS.h" #include "Core/IOS/FS/FS.h"
#include "Core/IOS/FS/FileIO.h" #include "Core/IOS/FS/FileIO.h"
#include "Core/IOS/FS/FileSystem.h"
#include "Core/IOS/MIOS.h" #include "Core/IOS/MIOS.h"
#include "Core/IOS/Network/IP/Top.h" #include "Core/IOS/Network/IP/Top.h"
#include "Core/IOS/Network/KD/NetKDRequest.h" #include "Core/IOS/Network/KD/NetKDRequest.h"
@ -242,9 +243,9 @@ u32 Kernel::GetVersion() const
return static_cast<u32>(m_title_id); return static_cast<u32>(m_title_id);
} }
std::shared_ptr<Device::FS> Kernel::GetFS() std::shared_ptr<FS::FileSystem> Kernel::GetFS()
{ {
return std::static_pointer_cast<Device::FS>(m_device_map.at("/dev/fs")); return m_fs;
} }
std::shared_ptr<Device::ES> Kernel::GetES() std::shared_ptr<Device::ES> Kernel::GetES()
@ -368,6 +369,9 @@ void Kernel::AddDevice(std::unique_ptr<Device::Device> device)
void Kernel::AddCoreDevices() void Kernel::AddCoreDevices()
{ {
m_fs = FS::MakeFileSystem();
ASSERT(m_fs);
std::lock_guard<std::mutex> lock(m_device_map_mutex); std::lock_guard<std::mutex> lock(m_device_map_mutex);
AddDevice(std::make_unique<Device::FS>(*this, "/dev/fs")); AddDevice(std::make_unique<Device::FS>(*this, "/dev/fs"));
AddDevice(std::make_unique<Device::ES>(*this, "/dev/es")); AddDevice(std::make_unique<Device::ES>(*this, "/dev/es"));
@ -691,6 +695,7 @@ void Kernel::DoState(PointerWrap& p)
p.Do(m_ppc_gid); p.Do(m_ppc_gid);
m_iosc.DoState(p); m_iosc.DoState(p);
m_fs->DoState(p);
if (m_title_id == Titles::MIOS) if (m_title_id == Titles::MIOS)
return; return;

View file

@ -23,11 +23,15 @@ namespace IOS
{ {
namespace HLE namespace HLE
{ {
namespace FS
{
class FileSystem;
}
namespace Device namespace Device
{ {
class Device; class Device;
class ES; class ES;
class FS;
} }
struct Request; struct Request;
@ -94,7 +98,7 @@ public:
// These are *always* part of the IOS kernel and always available. // These are *always* part of the IOS kernel and always available.
// They are also the only available resource managers even before loading any module. // They are also the only available resource managers even before loading any module.
std::shared_ptr<Device::FS> GetFS(); std::shared_ptr<FS::FileSystem> GetFS();
std::shared_ptr<Device::ES> GetES(); std::shared_ptr<Device::ES> GetES();
void SDIO_EventNotify(); void SDIO_EventNotify();
@ -146,6 +150,7 @@ protected:
u64 m_last_reply_time = 0; u64 m_last_reply_time = 0;
IOSC m_iosc; IOSC m_iosc;
std::shared_ptr<FS::FileSystem> m_fs;
}; };
// HLE for an IOS tied to emulation: base kernel which may have additional modules loaded. // HLE for an IOS tied to emulation: base kernel which may have additional modules loaded.