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/TitleManagement.cpp
IOS/ES/Views.cpp
IOS/FS/FileSystem.cpp
IOS/FS/HostBackend/File.cpp
IOS/FS/HostBackend/FS.cpp
IOS/FS/FileIO.cpp

View File

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

View File

@ -735,6 +735,9 @@
<ClCompile Include="IOS\FS\FileIO.cpp">
<Filter>IOS\FS</Filter>
</ClCompile>
<ClCompile Include="IOS\FS\FileSystem.cpp">
<Filter>IOS\FS</Filter>
</ClCompile>
<ClCompile Include="IOS\FS\HostBackend\FS.cpp">
<Filter>IOS\FS</Filter>
</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
#include <memory>
#include <string>
#include <vector>
@ -170,4 +171,6 @@ public:
virtual Result<DirectoryStats> GetDirectoryStats(const std::string& path) = 0;
};
std::unique_ptr<FileSystem> MakeFileSystem();
} // namespace IOS::HLE::FS

View File

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

View File

@ -23,11 +23,15 @@ namespace IOS
{
namespace HLE
{
namespace FS
{
class FileSystem;
}
namespace Device
{
class Device;
class ES;
class FS;
}
struct Request;
@ -94,7 +98,7 @@ public:
// These are *always* part of the IOS kernel and always available.
// 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();
void SDIO_EventNotify();
@ -146,6 +150,7 @@ protected:
u64 m_last_reply_time = 0;
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.