diff options
| author | 2018-08-03 11:51:48 -0400 | |
|---|---|---|
| committer | 2018-08-08 21:18:45 -0400 | |
| commit | 4b471f0554146463f3b82eed14ff3922a5584e9f (patch) | |
| tree | 677b35914dd914343700be24a1e4098db292615c /src/core | |
| parent | vfs: Add unreachable assert to file permissions converter (diff) | |
| download | yuzu-4b471f0554146463f3b82eed14ff3922a5584e9f.tar.gz yuzu-4b471f0554146463f3b82eed14ff3922a5584e9f.tar.xz yuzu-4b471f0554146463f3b82eed14ff3922a5584e9f.zip | |
core: Port core to VfsFilesystem for file access
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/core.cpp | 8 | ||||
| -rw-r--r-- | src/core/core.h | 12 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.cpp | 14 | ||||
| -rw-r--r-- | src/core/hle/service/filesystem/filesystem.h | 2 | ||||
| -rw-r--r-- | src/core/hle/service/service.cpp | 4 | ||||
| -rw-r--r-- | src/core/hle/service/service.h | 7 |
6 files changed, 34 insertions, 13 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index 085ba68d0..69c45c026 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -89,7 +89,7 @@ System::ResultStatus System::SingleStep() { | |||
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& filepath) { | 91 | System::ResultStatus System::Load(EmuWindow& emu_window, const std::string& filepath) { |
| 92 | app_loader = Loader::GetLoader(std::make_shared<FileSys::RealVfsFile>(filepath)); | 92 | app_loader = Loader::GetLoader(virtual_filesystem->OpenFile(filepath, FileSys::Mode::Read)); |
| 93 | 93 | ||
| 94 | if (!app_loader) { | 94 | if (!app_loader) { |
| 95 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); | 95 | LOG_CRITICAL(Core, "Failed to obtain loader for {}!", filepath); |
| @@ -174,6 +174,10 @@ System::ResultStatus System::Init(EmuWindow& emu_window) { | |||
| 174 | 174 | ||
| 175 | CoreTiming::Init(); | 175 | CoreTiming::Init(); |
| 176 | 176 | ||
| 177 | // Create a default fs if one doesn't already exist. | ||
| 178 | if (virtual_filesystem == nullptr) | ||
| 179 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); | ||
| 180 | |||
| 177 | current_process = Kernel::Process::Create("main"); | 181 | current_process = Kernel::Process::Create("main"); |
| 178 | 182 | ||
| 179 | cpu_barrier = std::make_shared<CpuBarrier>(); | 183 | cpu_barrier = std::make_shared<CpuBarrier>(); |
| @@ -186,7 +190,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window) { | |||
| 186 | service_manager = std::make_shared<Service::SM::ServiceManager>(); | 190 | service_manager = std::make_shared<Service::SM::ServiceManager>(); |
| 187 | 191 | ||
| 188 | Kernel::Init(); | 192 | Kernel::Init(); |
| 189 | Service::Init(service_manager); | 193 | Service::Init(service_manager, virtual_filesystem); |
| 190 | GDBStub::Init(); | 194 | GDBStub::Init(); |
| 191 | 195 | ||
| 192 | renderer = VideoCore::CreateRenderer(emu_window); | 196 | renderer = VideoCore::CreateRenderer(emu_window); |
diff --git a/src/core/core.h b/src/core/core.h index c8ca4b247..7cf7ea4e1 100644 --- a/src/core/core.h +++ b/src/core/core.h | |||
| @@ -17,6 +17,8 @@ | |||
| 17 | #include "core/memory.h" | 17 | #include "core/memory.h" |
| 18 | #include "core/perf_stats.h" | 18 | #include "core/perf_stats.h" |
| 19 | #include "core/telemetry_session.h" | 19 | #include "core/telemetry_session.h" |
| 20 | #include "file_sys/vfs_real.h" | ||
| 21 | #include "hle/service/filesystem/filesystem.h" | ||
| 20 | #include "video_core/debug_utils/debug_utils.h" | 22 | #include "video_core/debug_utils/debug_utils.h" |
| 21 | #include "video_core/gpu.h" | 23 | #include "video_core/gpu.h" |
| 22 | 24 | ||
| @@ -211,6 +213,14 @@ public: | |||
| 211 | return debug_context; | 213 | return debug_context; |
| 212 | } | 214 | } |
| 213 | 215 | ||
| 216 | void SetFilesystem(FileSys::VirtualFilesystem vfs) { | ||
| 217 | virtual_filesystem = std::move(vfs); | ||
| 218 | } | ||
| 219 | |||
| 220 | FileSys::VirtualFilesystem GetFilesystem() const { | ||
| 221 | return virtual_filesystem; | ||
| 222 | } | ||
| 223 | |||
| 214 | private: | 224 | private: |
| 215 | System(); | 225 | System(); |
| 216 | 226 | ||
| @@ -225,6 +235,8 @@ private: | |||
| 225 | */ | 235 | */ |
| 226 | ResultStatus Init(EmuWindow& emu_window); | 236 | ResultStatus Init(EmuWindow& emu_window); |
| 227 | 237 | ||
| 238 | /// RealVfsFilesystem instance | ||
| 239 | FileSys::VirtualFilesystem virtual_filesystem; | ||
| 228 | /// AppLoader used to load the current executing application | 240 | /// AppLoader used to load the current executing application |
| 229 | std::unique_ptr<Loader::AppLoader> app_loader; | 241 | std::unique_ptr<Loader::AppLoader> app_loader; |
| 230 | std::unique_ptr<VideoCore::RendererBase> renderer; | 242 | std::unique_ptr<VideoCore::RendererBase> renderer; |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 9b87e3484..5e416cde2 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -281,15 +281,15 @@ ResultVal<FileSys::VirtualDir> OpenSDMC() { | |||
| 281 | return sdmc_factory->Open(); | 281 | return sdmc_factory->Open(); |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | void RegisterFileSystems() { | 284 | void RegisterFileSystems(const FileSys::VirtualFilesystem& vfs) { |
| 285 | romfs_factory = nullptr; | 285 | romfs_factory = nullptr; |
| 286 | save_data_factory = nullptr; | 286 | save_data_factory = nullptr; |
| 287 | sdmc_factory = nullptr; | 287 | sdmc_factory = nullptr; |
| 288 | 288 | ||
| 289 | auto nand_directory = std::make_shared<FileSys::RealVfsDirectory>( | 289 | auto nand_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), |
| 290 | FileUtil::GetUserPath(FileUtil::UserPath::NANDDir), FileSys::Mode::ReadWrite); | 290 | FileSys::Mode::ReadWrite); |
| 291 | auto sd_directory = std::make_shared<FileSys::RealVfsDirectory>( | 291 | auto sd_directory = vfs->OpenDirectory(FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), |
| 292 | FileUtil::GetUserPath(FileUtil::UserPath::SDMCDir), FileSys::Mode::ReadWrite); | 292 | FileSys::Mode::ReadWrite); |
| 293 | 293 | ||
| 294 | auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); | 294 | auto savedata = std::make_unique<FileSys::SaveDataFactory>(std::move(nand_directory)); |
| 295 | save_data_factory = std::move(savedata); | 295 | save_data_factory = std::move(savedata); |
| @@ -298,8 +298,8 @@ void RegisterFileSystems() { | |||
| 298 | sdmc_factory = std::move(sdcard); | 298 | sdmc_factory = std::move(sdcard); |
| 299 | } | 299 | } |
| 300 | 300 | ||
| 301 | void InstallInterfaces(SM::ServiceManager& service_manager) { | 301 | void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs) { |
| 302 | RegisterFileSystems(); | 302 | RegisterFileSystems(vfs); |
| 303 | std::make_shared<FSP_LDR>()->InstallAsService(service_manager); | 303 | std::make_shared<FSP_LDR>()->InstallAsService(service_manager); |
| 304 | std::make_shared<FSP_PR>()->InstallAsService(service_manager); | 304 | std::make_shared<FSP_PR>()->InstallAsService(service_manager); |
| 305 | std::make_shared<FSP_SRV>()->InstallAsService(service_manager); | 305 | std::make_shared<FSP_SRV>()->InstallAsService(service_manager); |
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index d4483daa5..462c13f20 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -36,7 +36,7 @@ ResultVal<FileSys::VirtualDir> OpenSDMC(); | |||
| 36 | // ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenBIS(); | 36 | // ResultVal<std::unique_ptr<FileSys::FileSystemBackend>> OpenBIS(); |
| 37 | 37 | ||
| 38 | /// Registers all Filesystem services with the specified service manager. | 38 | /// Registers all Filesystem services with the specified service manager. |
| 39 | void InstallInterfaces(SM::ServiceManager& service_manager); | 39 | void InstallInterfaces(SM::ServiceManager& service_manager, const FileSys::VirtualFilesystem& vfs); |
| 40 | 40 | ||
| 41 | // A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of | 41 | // A class that wraps a VfsDirectory with methods that return ResultVal and ResultCode instead of |
| 42 | // pointers and booleans. This makes using a VfsDirectory with switch services much easier and | 42 | // pointers and booleans. This makes using a VfsDirectory with switch services much easier and |
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 6f286ea74..11951adaf 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -198,7 +198,7 @@ void AddNamedPort(std::string name, SharedPtr<ClientPort> port) { | |||
| 198 | } | 198 | } |
| 199 | 199 | ||
| 200 | /// Initialize ServiceManager | 200 | /// Initialize ServiceManager |
| 201 | void Init(std::shared_ptr<SM::ServiceManager>& sm) { | 201 | void Init(std::shared_ptr<SM::ServiceManager>& sm, const FileSys::VirtualFilesystem& rfs) { |
| 202 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 202 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 203 | // here and pass it into the respective InstallInterfaces functions. | 203 | // here and pass it into the respective InstallInterfaces functions. |
| 204 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); | 204 | auto nv_flinger = std::make_shared<NVFlinger::NVFlinger>(); |
| @@ -221,7 +221,7 @@ void Init(std::shared_ptr<SM::ServiceManager>& sm) { | |||
| 221 | EUPLD::InstallInterfaces(*sm); | 221 | EUPLD::InstallInterfaces(*sm); |
| 222 | Fatal::InstallInterfaces(*sm); | 222 | Fatal::InstallInterfaces(*sm); |
| 223 | FGM::InstallInterfaces(*sm); | 223 | FGM::InstallInterfaces(*sm); |
| 224 | FileSystem::InstallInterfaces(*sm); | 224 | FileSystem::InstallInterfaces(*sm, rfs); |
| 225 | Friend::InstallInterfaces(*sm); | 225 | Friend::InstallInterfaces(*sm); |
| 226 | GRC::InstallInterfaces(*sm); | 226 | GRC::InstallInterfaces(*sm); |
| 227 | HID::InstallInterfaces(*sm); | 227 | HID::InstallInterfaces(*sm); |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 046c5e18d..8a294c0f2 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -22,6 +22,10 @@ class ServerSession; | |||
| 22 | class HLERequestContext; | 22 | class HLERequestContext; |
| 23 | } // namespace Kernel | 23 | } // namespace Kernel |
| 24 | 24 | ||
| 25 | namespace FileSys { | ||
| 26 | struct VfsFilesystem; | ||
| 27 | } | ||
| 28 | |||
| 25 | namespace Service { | 29 | namespace Service { |
| 26 | 30 | ||
| 27 | namespace SM { | 31 | namespace SM { |
| @@ -177,7 +181,8 @@ private: | |||
| 177 | }; | 181 | }; |
| 178 | 182 | ||
| 179 | /// Initialize ServiceManager | 183 | /// Initialize ServiceManager |
| 180 | void Init(std::shared_ptr<SM::ServiceManager>& sm); | 184 | void Init(std::shared_ptr<SM::ServiceManager>& sm, |
| 185 | const std::shared_ptr<FileSys::VfsFilesystem>& vfs); | ||
| 181 | 186 | ||
| 182 | /// Shutdown ServiceManager | 187 | /// Shutdown ServiceManager |
| 183 | void Shutdown(); | 188 | void Shutdown(); |