summaryrefslogtreecommitdiff
path: root/src/core/hle/service/filesystem
diff options
context:
space:
mode:
authorGravatar Lioncash2020-11-26 15:19:08 -0500
committerGravatar Lioncash2020-11-26 20:03:11 -0500
commit1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f (patch)
tree3593cd42e0ba676c3919561983f7e9766fcb641c /src/core/hle/service/filesystem
parentMerge pull request #4975 from comex/invalid-syncpoint-id (diff)
downloadyuzu-1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f.tar.gz
yuzu-1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f.tar.xz
yuzu-1a954b2a596fdfd4fc4b5feb9b43c8147de4cc7f.zip
service: Eliminate usages of the global system instance
Completely removes all usages of the global system instance within the services code by passing in the using system instance to the services.
Diffstat (limited to 'src/core/hle/service/filesystem')
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp8
-rw-r--r--src/core/hle/service/filesystem/fsp_ldr.cpp2
-rw-r--r--src/core/hle/service/filesystem/fsp_ldr.h6
-rw-r--r--src/core/hle/service/filesystem/fsp_pr.cpp2
-rw-r--r--src/core/hle/service/filesystem/fsp_pr.h6
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp57
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.h3
7 files changed, 47 insertions, 37 deletions
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 2e53cae5b..af97561e4 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -728,11 +728,9 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
728} 728}
729 729
730void InstallInterfaces(Core::System& system) { 730void InstallInterfaces(Core::System& system) {
731 std::make_shared<FSP_LDR>()->InstallAsService(system.ServiceManager()); 731 std::make_shared<FSP_LDR>(system)->InstallAsService(system.ServiceManager());
732 std::make_shared<FSP_PR>()->InstallAsService(system.ServiceManager()); 732 std::make_shared<FSP_PR>(system)->InstallAsService(system.ServiceManager());
733 std::make_shared<FSP_SRV>(system.GetFileSystemController(), system.GetContentProvider(), 733 std::make_shared<FSP_SRV>(system)->InstallAsService(system.ServiceManager());
734 system.GetReporter())
735 ->InstallAsService(system.ServiceManager());
736} 734}
737 735
738} // namespace Service::FileSystem 736} // namespace Service::FileSystem
diff --git a/src/core/hle/service/filesystem/fsp_ldr.cpp b/src/core/hle/service/filesystem/fsp_ldr.cpp
index fb487d5bc..1f6c17ba5 100644
--- a/src/core/hle/service/filesystem/fsp_ldr.cpp
+++ b/src/core/hle/service/filesystem/fsp_ldr.cpp
@@ -7,7 +7,7 @@
7 7
8namespace Service::FileSystem { 8namespace Service::FileSystem {
9 9
10FSP_LDR::FSP_LDR() : ServiceFramework{"fsp:ldr"} { 10FSP_LDR::FSP_LDR(Core::System& system_) : ServiceFramework{system_, "fsp:ldr"} {
11 // clang-format off 11 // clang-format off
12 static const FunctionInfo functions[] = { 12 static const FunctionInfo functions[] = {
13 {0, nullptr, "OpenCodeFileSystem"}, 13 {0, nullptr, "OpenCodeFileSystem"},
diff --git a/src/core/hle/service/filesystem/fsp_ldr.h b/src/core/hle/service/filesystem/fsp_ldr.h
index 8210b7729..d6432a0e1 100644
--- a/src/core/hle/service/filesystem/fsp_ldr.h
+++ b/src/core/hle/service/filesystem/fsp_ldr.h
@@ -6,11 +6,15 @@
6 6
7#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
8 8
9namespace Core {
10class System;
11}
12
9namespace Service::FileSystem { 13namespace Service::FileSystem {
10 14
11class FSP_LDR final : public ServiceFramework<FSP_LDR> { 15class FSP_LDR final : public ServiceFramework<FSP_LDR> {
12public: 16public:
13 explicit FSP_LDR(); 17 explicit FSP_LDR(Core::System& system_);
14 ~FSP_LDR() override; 18 ~FSP_LDR() override;
15}; 19};
16 20
diff --git a/src/core/hle/service/filesystem/fsp_pr.cpp b/src/core/hle/service/filesystem/fsp_pr.cpp
index 378201610..00e4d1662 100644
--- a/src/core/hle/service/filesystem/fsp_pr.cpp
+++ b/src/core/hle/service/filesystem/fsp_pr.cpp
@@ -7,7 +7,7 @@
7 7
8namespace Service::FileSystem { 8namespace Service::FileSystem {
9 9
10FSP_PR::FSP_PR() : ServiceFramework{"fsp:pr"} { 10FSP_PR::FSP_PR(Core::System& system_) : ServiceFramework{system_, "fsp:pr"} {
11 // clang-format off 11 // clang-format off
12 static const FunctionInfo functions[] = { 12 static const FunctionInfo functions[] = {
13 {0, nullptr, "RegisterProgram"}, 13 {0, nullptr, "RegisterProgram"},
diff --git a/src/core/hle/service/filesystem/fsp_pr.h b/src/core/hle/service/filesystem/fsp_pr.h
index 556ae5ce9..9e622518c 100644
--- a/src/core/hle/service/filesystem/fsp_pr.h
+++ b/src/core/hle/service/filesystem/fsp_pr.h
@@ -6,11 +6,15 @@
6 6
7#include "core/hle/service/service.h" 7#include "core/hle/service/service.h"
8 8
9namespace Core {
10class System;
11}
12
9namespace Service::FileSystem { 13namespace Service::FileSystem {
10 14
11class FSP_PR final : public ServiceFramework<FSP_PR> { 15class FSP_PR final : public ServiceFramework<FSP_PR> {
12public: 16public:
13 explicit FSP_PR(); 17 explicit FSP_PR(Core::System& system_);
14 ~FSP_PR() override; 18 ~FSP_PR() override;
15}; 19};
16 20
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 031c6dbf6..b3480494c 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -14,6 +14,7 @@
14#include "common/hex_util.h" 14#include "common/hex_util.h"
15#include "common/logging/log.h" 15#include "common/logging/log.h"
16#include "common/string_util.h" 16#include "common/string_util.h"
17#include "core/core.h"
17#include "core/file_sys/directory.h" 18#include "core/file_sys/directory.h"
18#include "core/file_sys/errors.h" 19#include "core/file_sys/errors.h"
19#include "core/file_sys/mode.h" 20#include "core/file_sys/mode.h"
@@ -56,8 +57,8 @@ enum class FileSystemType : u8 {
56 57
57class IStorage final : public ServiceFramework<IStorage> { 58class IStorage final : public ServiceFramework<IStorage> {
58public: 59public:
59 explicit IStorage(FileSys::VirtualFile backend_) 60 explicit IStorage(Core::System& system_, FileSys::VirtualFile backend_)
60 : ServiceFramework("IStorage"), backend(std::move(backend_)) { 61 : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) {
61 static const FunctionInfo functions[] = { 62 static const FunctionInfo functions[] = {
62 {0, &IStorage::Read, "Read"}, 63 {0, &IStorage::Read, "Read"},
63 {1, nullptr, "Write"}, 64 {1, nullptr, "Write"},
@@ -114,8 +115,8 @@ private:
114 115
115class IFile final : public ServiceFramework<IFile> { 116class IFile final : public ServiceFramework<IFile> {
116public: 117public:
117 explicit IFile(FileSys::VirtualFile backend_) 118 explicit IFile(Core::System& system_, FileSys::VirtualFile backend_)
118 : ServiceFramework("IFile"), backend(std::move(backend_)) { 119 : ServiceFramework{system_, "IFile"}, backend(std::move(backend_)) {
119 static const FunctionInfo functions[] = { 120 static const FunctionInfo functions[] = {
120 {0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"}, 121 {0, &IFile::Read, "Read"}, {1, &IFile::Write, "Write"},
121 {2, &IFile::Flush, "Flush"}, {3, &IFile::SetSize, "SetSize"}, 122 {2, &IFile::Flush, "Flush"}, {3, &IFile::SetSize, "SetSize"},
@@ -246,8 +247,8 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec
246 247
247class IDirectory final : public ServiceFramework<IDirectory> { 248class IDirectory final : public ServiceFramework<IDirectory> {
248public: 249public:
249 explicit IDirectory(FileSys::VirtualDir backend_) 250 explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_)
250 : ServiceFramework("IDirectory"), backend(std::move(backend_)) { 251 : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) {
251 static const FunctionInfo functions[] = { 252 static const FunctionInfo functions[] = {
252 {0, &IDirectory::Read, "Read"}, 253 {0, &IDirectory::Read, "Read"},
253 {1, &IDirectory::GetEntryCount, "GetEntryCount"}, 254 {1, &IDirectory::GetEntryCount, "GetEntryCount"},
@@ -302,8 +303,9 @@ private:
302 303
303class IFileSystem final : public ServiceFramework<IFileSystem> { 304class IFileSystem final : public ServiceFramework<IFileSystem> {
304public: 305public:
305 explicit IFileSystem(FileSys::VirtualDir backend, SizeGetter size) 306 explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_)
306 : ServiceFramework("IFileSystem"), backend(std::move(backend)), size(std::move(size)) { 307 : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move(
308 size_)} {
307 static const FunctionInfo functions[] = { 309 static const FunctionInfo functions[] = {
308 {0, &IFileSystem::CreateFile, "CreateFile"}, 310 {0, &IFileSystem::CreateFile, "CreateFile"},
309 {1, &IFileSystem::DeleteFile, "DeleteFile"}, 311 {1, &IFileSystem::DeleteFile, "DeleteFile"},
@@ -420,7 +422,7 @@ public:
420 return; 422 return;
421 } 423 }
422 424
423 auto file = std::make_shared<IFile>(result.Unwrap()); 425 auto file = std::make_shared<IFile>(system, result.Unwrap());
424 426
425 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 427 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
426 rb.Push(RESULT_SUCCESS); 428 rb.Push(RESULT_SUCCESS);
@@ -445,7 +447,7 @@ public:
445 return; 447 return;
446 } 448 }
447 449
448 auto directory = std::make_shared<IDirectory>(result.Unwrap()); 450 auto directory = std::make_shared<IDirectory>(system, result.Unwrap());
449 451
450 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 452 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
451 rb.Push(RESULT_SUCCESS); 453 rb.Push(RESULT_SUCCESS);
@@ -500,8 +502,9 @@ private:
500 502
501class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> { 503class ISaveDataInfoReader final : public ServiceFramework<ISaveDataInfoReader> {
502public: 504public:
503 explicit ISaveDataInfoReader(FileSys::SaveDataSpaceId space, FileSystemController& fsc) 505 explicit ISaveDataInfoReader(Core::System& system_, FileSys::SaveDataSpaceId space,
504 : ServiceFramework("ISaveDataInfoReader"), fsc(fsc) { 506 FileSystemController& fsc_)
507 : ServiceFramework{system_, "ISaveDataInfoReader"}, fsc{fsc_} {
505 static const FunctionInfo functions[] = { 508 static const FunctionInfo functions[] = {
506 {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"}, 509 {0, &ISaveDataInfoReader::ReadSaveDataInfo, "ReadSaveDataInfo"},
507 }; 510 };
@@ -650,10 +653,9 @@ private:
650 u64 next_entry_index = 0; 653 u64 next_entry_index = 0;
651}; 654};
652 655
653FSP_SRV::FSP_SRV(FileSystemController& fsc_, const FileSys::ContentProvider& content_provider_, 656FSP_SRV::FSP_SRV(Core::System& system_)
654 const Core::Reporter& reporter_) 657 : ServiceFramework{system_, "fsp-srv"}, fsc{system.GetFileSystemController()},
655 : ServiceFramework("fsp-srv"), fsc(fsc_), content_provider{content_provider_}, 658 content_provider{system.GetContentProvider()}, reporter{system.GetReporter()} {
656 reporter(reporter_) {
657 // clang-format off 659 // clang-format off
658 static const FunctionInfo functions[] = { 660 static const FunctionInfo functions[] = {
659 {0, nullptr, "OpenFileSystem"}, 661 {0, nullptr, "OpenFileSystem"},
@@ -803,8 +805,9 @@ void FSP_SRV::OpenFileSystemWithPatch(Kernel::HLERequestContext& ctx) {
803void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) { 805void FSP_SRV::OpenSdCardFileSystem(Kernel::HLERequestContext& ctx) {
804 LOG_DEBUG(Service_FS, "called"); 806 LOG_DEBUG(Service_FS, "called");
805 807
806 auto filesystem = std::make_shared<IFileSystem>( 808 auto filesystem =
807 fsc.OpenSDMC().Unwrap(), SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard)); 809 std::make_shared<IFileSystem>(system, fsc.OpenSDMC().Unwrap(),
810 SizeGetter::FromStorageId(fsc, FileSys::StorageId::SdCard));
808 811
809 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 812 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
810 rb.Push(RESULT_SUCCESS); 813 rb.Push(RESULT_SUCCESS);
@@ -864,8 +867,8 @@ void FSP_SRV::OpenSaveDataFileSystem(Kernel::HLERequestContext& ctx) {
864 UNREACHABLE(); 867 UNREACHABLE();
865 } 868 }
866 869
867 auto filesystem = 870 auto filesystem = std::make_shared<IFileSystem>(system, std::move(dir.Unwrap()),
868 std::make_shared<IFileSystem>(std::move(dir.Unwrap()), SizeGetter::FromStorageId(fsc, id)); 871 SizeGetter::FromStorageId(fsc, id));
869 872
870 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 873 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
871 rb.Push(RESULT_SUCCESS); 874 rb.Push(RESULT_SUCCESS);
@@ -884,7 +887,8 @@ void FSP_SRV::OpenSaveDataInfoReaderBySaveDataSpaceId(Kernel::HLERequestContext&
884 887
885 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 888 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
886 rb.Push(RESULT_SUCCESS); 889 rb.Push(RESULT_SUCCESS);
887 rb.PushIpcInterface<ISaveDataInfoReader>(std::make_shared<ISaveDataInfoReader>(space, fsc)); 890 rb.PushIpcInterface<ISaveDataInfoReader>(
891 std::make_shared<ISaveDataInfoReader>(system, space, fsc));
888} 892}
889 893
890void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(Kernel::HLERequestContext& ctx) { 894void FSP_SRV::WriteSaveDataFileSystemExtraDataBySaveDataAttribute(Kernel::HLERequestContext& ctx) {
@@ -933,7 +937,7 @@ void FSP_SRV::OpenDataStorageByCurrentProcess(Kernel::HLERequestContext& ctx) {
933 return; 937 return;
934 } 938 }
935 939
936 auto storage = std::make_shared<IStorage>(std::move(romfs.Unwrap())); 940 auto storage = std::make_shared<IStorage>(system, std::move(romfs.Unwrap()));
937 941
938 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 942 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
939 rb.Push(RESULT_SUCCESS); 943 rb.Push(RESULT_SUCCESS);
@@ -957,7 +961,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) {
957 if (archive != nullptr) { 961 if (archive != nullptr) {
958 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 962 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
959 rb.Push(RESULT_SUCCESS); 963 rb.Push(RESULT_SUCCESS);
960 rb.PushIpcInterface(std::make_shared<IStorage>(archive)); 964 rb.PushIpcInterface(std::make_shared<IStorage>(system, archive));
961 return; 965 return;
962 } 966 }
963 967
@@ -973,7 +977,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) {
973 const FileSys::PatchManager pm{title_id, fsc, content_provider}; 977 const FileSys::PatchManager pm{title_id, fsc, content_provider};
974 978
975 auto storage = std::make_shared<IStorage>( 979 auto storage = std::make_shared<IStorage>(
976 pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data)); 980 system, pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data));
977 981
978 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 982 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
979 rb.Push(RESULT_SUCCESS); 983 rb.Push(RESULT_SUCCESS);
@@ -1035,7 +1039,8 @@ void FSP_SRV::GetAccessLogVersionInfo(Kernel::HLERequestContext& ctx) {
1035 1039
1036class IMultiCommitManager final : public ServiceFramework<IMultiCommitManager> { 1040class IMultiCommitManager final : public ServiceFramework<IMultiCommitManager> {
1037public: 1041public:
1038 explicit IMultiCommitManager() : ServiceFramework("IMultiCommitManager") { 1042 explicit IMultiCommitManager(Core::System& system_)
1043 : ServiceFramework{system_, "IMultiCommitManager"} {
1039 static const FunctionInfo functions[] = { 1044 static const FunctionInfo functions[] = {
1040 {1, &IMultiCommitManager::Add, "Add"}, 1045 {1, &IMultiCommitManager::Add, "Add"},
1041 {2, &IMultiCommitManager::Commit, "Commit"}, 1046 {2, &IMultiCommitManager::Commit, "Commit"},
@@ -1066,7 +1071,7 @@ void FSP_SRV::OpenMultiCommitManager(Kernel::HLERequestContext& ctx) {
1066 1071
1067 IPC::ResponseBuilder rb{ctx, 2, 0, 1}; 1072 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
1068 rb.Push(RESULT_SUCCESS); 1073 rb.Push(RESULT_SUCCESS);
1069 rb.PushIpcInterface<IMultiCommitManager>(std::make_shared<IMultiCommitManager>()); 1074 rb.PushIpcInterface<IMultiCommitManager>(std::make_shared<IMultiCommitManager>(system));
1070} 1075}
1071 1076
1072} // namespace Service::FileSystem 1077} // namespace Service::FileSystem
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h
index 6c7239e6a..472286d6e 100644
--- a/src/core/hle/service/filesystem/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp_srv.h
@@ -33,8 +33,7 @@ enum class LogMode : u32 {
33 33
34class FSP_SRV final : public ServiceFramework<FSP_SRV> { 34class FSP_SRV final : public ServiceFramework<FSP_SRV> {
35public: 35public:
36 explicit FSP_SRV(FileSystemController& fsc_, const FileSys::ContentProvider& content_provider_, 36 explicit FSP_SRV(Core::System& system_);
37 const Core::Reporter& reporter_);
38 ~FSP_SRV() override; 37 ~FSP_SRV() override;
39 38
40private: 39private: