summaryrefslogtreecommitdiff
path: root/src/core/hle
diff options
context:
space:
mode:
authorGravatar Lioncash2020-11-18 07:53:10 -0500
committerGravatar Lioncash2020-11-18 09:36:48 -0500
commit6f8a06bac58790d20dae3c1adb4de3b441f07b30 (patch)
treeef5e2942aa0aacbebb683da91ee6d4bd19ec15e9 /src/core/hle
parentMerge pull request #4866 from Morph1984/mjolnir-p3-prod (diff)
downloadyuzu-6f8a06bac58790d20dae3c1adb4de3b441f07b30.tar.gz
yuzu-6f8a06bac58790d20dae3c1adb4de3b441f07b30.tar.xz
yuzu-6f8a06bac58790d20dae3c1adb4de3b441f07b30.zip
patch_manager: Remove usages of the global system instance
With this, only 19 usages of the global system instance remain within the core library. We're almost there.
Diffstat (limited to 'src/core/hle')
-rw-r--r--src/core/hle/service/acc/acc.cpp6
-rw-r--r--src/core/hle/service/am/am.cpp14
-rw-r--r--src/core/hle/service/aoc/aoc_u.cpp3
-rw-r--r--src/core/hle/service/filesystem/filesystem.cpp7
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.cpp8
-rw-r--r--src/core/hle/service/filesystem/fsp_srv.h7
-rw-r--r--src/core/hle/service/ns/ns.cpp24
-rw-r--r--src/core/hle/service/ns/ns.h28
8 files changed, 66 insertions, 31 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp
index ded52ea0b..c2c11dbcb 100644
--- a/src/core/hle/service/acc/acc.cpp
+++ b/src/core/hle/service/acc/acc.cpp
@@ -742,8 +742,10 @@ void Module::Interface::IsUserAccountSwitchLocked(Kernel::HLERequestContext& ctx
742 bool is_locked = false; 742 bool is_locked = false;
743 743
744 if (res != Loader::ResultStatus::Success) { 744 if (res != Loader::ResultStatus::Success) {
745 FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()}; 745 const FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID(),
746 auto nacp_unique = pm.GetControlMetadata().first; 746 system.GetFileSystemController(),
747 system.GetContentProvider()};
748 const auto nacp_unique = pm.GetControlMetadata().first;
747 749
748 if (nacp_unique != nullptr) { 750 if (nacp_unique != nullptr) {
749 is_locked = nacp_unique->GetUserAccountSwitchLock(); 751 is_locked = nacp_unique->GetUserAccountSwitchLock();
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp
index eb097738a..63421b963 100644
--- a/src/core/hle/service/am/am.cpp
+++ b/src/core/hle/service/am/am.cpp
@@ -1381,13 +1381,16 @@ void IApplicationFunctions::GetDisplayVersion(Kernel::HLERequestContext& ctx) {
1381 const auto res = [this] { 1381 const auto res = [this] {
1382 const auto title_id = system.CurrentProcess()->GetTitleID(); 1382 const auto title_id = system.CurrentProcess()->GetTitleID();
1383 1383
1384 FileSys::PatchManager pm{title_id}; 1384 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
1385 system.GetContentProvider()};
1385 auto res = pm.GetControlMetadata(); 1386 auto res = pm.GetControlMetadata();
1386 if (res.first != nullptr) { 1387 if (res.first != nullptr) {
1387 return res; 1388 return res;
1388 } 1389 }
1389 1390
1390 FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id)}; 1391 const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id),
1392 system.GetFileSystemController(),
1393 system.GetContentProvider()};
1391 return pm_update.GetControlMetadata(); 1394 return pm_update.GetControlMetadata();
1392 }(); 1395 }();
1393 1396
@@ -1415,13 +1418,16 @@ void IApplicationFunctions::GetDesiredLanguage(Kernel::HLERequestContext& ctx) {
1415 const auto res = [this] { 1418 const auto res = [this] {
1416 const auto title_id = system.CurrentProcess()->GetTitleID(); 1419 const auto title_id = system.CurrentProcess()->GetTitleID();
1417 1420
1418 FileSys::PatchManager pm{title_id}; 1421 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
1422 system.GetContentProvider()};
1419 auto res = pm.GetControlMetadata(); 1423 auto res = pm.GetControlMetadata();
1420 if (res.first != nullptr) { 1424 if (res.first != nullptr) {
1421 return res; 1425 return res;
1422 } 1426 }
1423 1427
1424 FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id)}; 1428 const FileSys::PatchManager pm_update{FileSys::GetUpdateTitleID(title_id),
1429 system.GetFileSystemController(),
1430 system.GetContentProvider()};
1425 return pm_update.GetControlMetadata(); 1431 return pm_update.GetControlMetadata();
1426 }(); 1432 }();
1427 1433
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp
index e58b2c518..173b36da4 100644
--- a/src/core/hle/service/aoc/aoc_u.cpp
+++ b/src/core/hle/service/aoc/aoc_u.cpp
@@ -164,7 +164,8 @@ void AOC_U::GetAddOnContentBaseId(Kernel::HLERequestContext& ctx) {
164 rb.Push(RESULT_SUCCESS); 164 rb.Push(RESULT_SUCCESS);
165 165
166 const auto title_id = system.CurrentProcess()->GetTitleID(); 166 const auto title_id = system.CurrentProcess()->GetTitleID();
167 FileSys::PatchManager pm{title_id}; 167 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
168 system.GetContentProvider()};
168 169
169 const auto res = pm.GetControlMetadata(); 170 const auto res = pm.GetControlMetadata();
170 if (res.first == nullptr) { 171 if (res.first == nullptr) {
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp
index 3cdef4888..2e53cae5b 100644
--- a/src/core/hle/service/filesystem/filesystem.cpp
+++ b/src/core/hle/service/filesystem/filesystem.cpp
@@ -455,7 +455,9 @@ FileSys::SaveDataSize FileSystemController::ReadSaveDataSize(FileSys::SaveDataTy
455 const auto res = system.GetAppLoader().ReadControlData(nacp); 455 const auto res = system.GetAppLoader().ReadControlData(nacp);
456 456
457 if (res != Loader::ResultStatus::Success) { 457 if (res != Loader::ResultStatus::Success) {
458 FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID()}; 458 const FileSys::PatchManager pm{system.CurrentProcess()->GetTitleID(),
459 system.GetFileSystemController(),
460 system.GetContentProvider()};
459 const auto metadata = pm.GetControlMetadata(); 461 const auto metadata = pm.GetControlMetadata();
460 const auto& nacp_unique = metadata.first; 462 const auto& nacp_unique = metadata.first;
461 463
@@ -728,7 +730,8 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove
728void InstallInterfaces(Core::System& system) { 730void InstallInterfaces(Core::System& system) {
729 std::make_shared<FSP_LDR>()->InstallAsService(system.ServiceManager()); 731 std::make_shared<FSP_LDR>()->InstallAsService(system.ServiceManager());
730 std::make_shared<FSP_PR>()->InstallAsService(system.ServiceManager()); 732 std::make_shared<FSP_PR>()->InstallAsService(system.ServiceManager());
731 std::make_shared<FSP_SRV>(system.GetFileSystemController(), system.GetReporter()) 733 std::make_shared<FSP_SRV>(system.GetFileSystemController(), system.GetContentProvider(),
734 system.GetReporter())
732 ->InstallAsService(system.ServiceManager()); 735 ->InstallAsService(system.ServiceManager());
733} 736}
734 737
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp
index 649128be4..031c6dbf6 100644
--- a/src/core/hle/service/filesystem/fsp_srv.cpp
+++ b/src/core/hle/service/filesystem/fsp_srv.cpp
@@ -650,8 +650,10 @@ private:
650 u64 next_entry_index = 0; 650 u64 next_entry_index = 0;
651}; 651};
652 652
653FSP_SRV::FSP_SRV(FileSystemController& fsc, const Core::Reporter& reporter) 653FSP_SRV::FSP_SRV(FileSystemController& fsc_, const FileSys::ContentProvider& content_provider_,
654 : ServiceFramework("fsp-srv"), fsc(fsc), reporter(reporter) { 654 const Core::Reporter& reporter_)
655 : ServiceFramework("fsp-srv"), fsc(fsc_), content_provider{content_provider_},
656 reporter(reporter_) {
655 // clang-format off 657 // clang-format off
656 static const FunctionInfo functions[] = { 658 static const FunctionInfo functions[] = {
657 {0, nullptr, "OpenFileSystem"}, 659 {0, nullptr, "OpenFileSystem"},
@@ -968,7 +970,7 @@ void FSP_SRV::OpenDataStorageByDataId(Kernel::HLERequestContext& ctx) {
968 return; 970 return;
969 } 971 }
970 972
971 FileSys::PatchManager pm{title_id}; 973 const FileSys::PatchManager pm{title_id, fsc, content_provider};
972 974
973 auto storage = std::make_shared<IStorage>( 975 auto storage = std::make_shared<IStorage>(
974 pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data)); 976 pm.PatchRomFS(std::move(data.Unwrap()), 0, FileSys::ContentRecordType::Data));
diff --git a/src/core/hle/service/filesystem/fsp_srv.h b/src/core/hle/service/filesystem/fsp_srv.h
index 4964e874e..6c7239e6a 100644
--- a/src/core/hle/service/filesystem/fsp_srv.h
+++ b/src/core/hle/service/filesystem/fsp_srv.h
@@ -12,8 +12,9 @@ class Reporter;
12} 12}
13 13
14namespace FileSys { 14namespace FileSys {
15class ContentProvider;
15class FileSystemBackend; 16class FileSystemBackend;
16} 17} // namespace FileSys
17 18
18namespace Service::FileSystem { 19namespace Service::FileSystem {
19 20
@@ -32,7 +33,8 @@ enum class LogMode : u32 {
32 33
33class FSP_SRV final : public ServiceFramework<FSP_SRV> { 34class FSP_SRV final : public ServiceFramework<FSP_SRV> {
34public: 35public:
35 explicit FSP_SRV(FileSystemController& fsc, const Core::Reporter& reporter); 36 explicit FSP_SRV(FileSystemController& fsc_, const FileSys::ContentProvider& content_provider_,
37 const Core::Reporter& reporter_);
36 ~FSP_SRV() override; 38 ~FSP_SRV() override;
37 39
38private: 40private:
@@ -55,6 +57,7 @@ private:
55 void OpenMultiCommitManager(Kernel::HLERequestContext& ctx); 57 void OpenMultiCommitManager(Kernel::HLERequestContext& ctx);
56 58
57 FileSystemController& fsc; 59 FileSystemController& fsc;
60 const FileSys::ContentProvider& content_provider;
58 61
59 FileSys::VirtualFile romfs; 62 FileSys::VirtualFile romfs;
60 u64 current_process_id = 0; 63 u64 current_process_id = 0;
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 58ee1f712..2594e6839 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -3,6 +3,7 @@
3// Refer to the license.txt file included. 3// Refer to the license.txt file included.
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/core.h"
6#include "core/file_sys/control_metadata.h" 7#include "core/file_sys/control_metadata.h"
7#include "core/file_sys/patch_manager.h" 8#include "core/file_sys/patch_manager.h"
8#include "core/file_sys/vfs.h" 9#include "core/file_sys/vfs.h"
@@ -29,8 +30,8 @@ IAccountProxyInterface::IAccountProxyInterface() : ServiceFramework{"IAccountPro
29 30
30IAccountProxyInterface::~IAccountProxyInterface() = default; 31IAccountProxyInterface::~IAccountProxyInterface() = default;
31 32
32IApplicationManagerInterface::IApplicationManagerInterface() 33IApplicationManagerInterface::IApplicationManagerInterface(Core::System& system_)
33 : ServiceFramework{"IApplicationManagerInterface"} { 34 : ServiceFramework{"IApplicationManagerInterface"}, system{system_} {
34 // clang-format off 35 // clang-format off
35 static const FunctionInfo functions[] = { 36 static const FunctionInfo functions[] = {
36 {0, nullptr, "ListApplicationRecord"}, 37 {0, nullptr, "ListApplicationRecord"},
@@ -298,7 +299,8 @@ void IApplicationManagerInterface::GetApplicationControlData(Kernel::HLERequestC
298 299
299 const auto size = ctx.GetWriteBufferSize(); 300 const auto size = ctx.GetWriteBufferSize();
300 301
301 const FileSys::PatchManager pm{title_id}; 302 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
303 system.GetContentProvider()};
302 const auto control = pm.GetControlMetadata(); 304 const auto control = pm.GetControlMetadata();
303 305
304 std::vector<u8> out; 306 std::vector<u8> out;
@@ -538,14 +540,14 @@ IFactoryResetInterface::IFactoryResetInterface::IFactoryResetInterface()
538 540
539IFactoryResetInterface::~IFactoryResetInterface() = default; 541IFactoryResetInterface::~IFactoryResetInterface() = default;
540 542
541NS::NS(const char* name) : ServiceFramework{name} { 543NS::NS(const char* name, Core::System& system_) : ServiceFramework{name}, system{system_} {
542 // clang-format off 544 // clang-format off
543 static const FunctionInfo functions[] = { 545 static const FunctionInfo functions[] = {
544 {7992, &NS::PushInterface<IECommerceInterface>, "GetECommerceInterface"}, 546 {7992, &NS::PushInterface<IECommerceInterface>, "GetECommerceInterface"},
545 {7993, &NS::PushInterface<IApplicationVersionInterface>, "GetApplicationVersionInterface"}, 547 {7993, &NS::PushInterface<IApplicationVersionInterface>, "GetApplicationVersionInterface"},
546 {7994, &NS::PushInterface<IFactoryResetInterface>, "GetFactoryResetInterface"}, 548 {7994, &NS::PushInterface<IFactoryResetInterface>, "GetFactoryResetInterface"},
547 {7995, &NS::PushInterface<IAccountProxyInterface>, "GetAccountProxyInterface"}, 549 {7995, &NS::PushInterface<IAccountProxyInterface>, "GetAccountProxyInterface"},
548 {7996, &NS::PushInterface<IApplicationManagerInterface>, "GetApplicationManagerInterface"}, 550 {7996, &NS::PushIApplicationManagerInterface, "GetApplicationManagerInterface"},
549 {7997, &NS::PushInterface<IDownloadTaskInterface>, "GetDownloadTaskInterface"}, 551 {7997, &NS::PushInterface<IDownloadTaskInterface>, "GetDownloadTaskInterface"},
550 {7998, &NS::PushInterface<IContentManagementInterface>, "GetContentManagementInterface"}, 552 {7998, &NS::PushInterface<IContentManagementInterface>, "GetContentManagementInterface"},
551 {7999, &NS::PushInterface<IDocumentInterface>, "GetDocumentInterface"}, 553 {7999, &NS::PushInterface<IDocumentInterface>, "GetDocumentInterface"},
@@ -558,7 +560,7 @@ NS::NS(const char* name) : ServiceFramework{name} {
558NS::~NS() = default; 560NS::~NS() = default;
559 561
560std::shared_ptr<IApplicationManagerInterface> NS::GetApplicationManagerInterface() const { 562std::shared_ptr<IApplicationManagerInterface> NS::GetApplicationManagerInterface() const {
561 return GetInterface<IApplicationManagerInterface>(); 563 return GetInterface<IApplicationManagerInterface>(system);
562} 564}
563 565
564class NS_DEV final : public ServiceFramework<NS_DEV> { 566class NS_DEV final : public ServiceFramework<NS_DEV> {
@@ -678,11 +680,11 @@ public:
678 680
679void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { 681void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) {
680 682
681 std::make_shared<NS>("ns:am2")->InstallAsService(service_manager); 683 std::make_shared<NS>("ns:am2", system)->InstallAsService(service_manager);
682 std::make_shared<NS>("ns:ec")->InstallAsService(service_manager); 684 std::make_shared<NS>("ns:ec", system)->InstallAsService(service_manager);
683 std::make_shared<NS>("ns:rid")->InstallAsService(service_manager); 685 std::make_shared<NS>("ns:rid", system)->InstallAsService(service_manager);
684 std::make_shared<NS>("ns:rt")->InstallAsService(service_manager); 686 std::make_shared<NS>("ns:rt", system)->InstallAsService(service_manager);
685 std::make_shared<NS>("ns:web")->InstallAsService(service_manager); 687 std::make_shared<NS>("ns:web", system)->InstallAsService(service_manager);
686 688
687 std::make_shared<NS_DEV>()->InstallAsService(service_manager); 689 std::make_shared<NS_DEV>()->InstallAsService(service_manager);
688 std::make_shared<NS_SU>()->InstallAsService(service_manager); 690 std::make_shared<NS_SU>()->InstallAsService(service_manager);
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h
index c2554b878..c90ccd755 100644
--- a/src/core/hle/service/ns/ns.h
+++ b/src/core/hle/service/ns/ns.h
@@ -6,6 +6,10 @@
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 { 13namespace Service {
10 14
11namespace FileSystem { 15namespace FileSystem {
@@ -22,7 +26,7 @@ public:
22 26
23class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> { 27class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> {
24public: 28public:
25 explicit IApplicationManagerInterface(); 29 explicit IApplicationManagerInterface(Core::System& system_);
26 ~IApplicationManagerInterface() override; 30 ~IApplicationManagerInterface() override;
27 31
28 ResultVal<u8> GetApplicationDesiredLanguage(u32 supported_languages); 32 ResultVal<u8> GetApplicationDesiredLanguage(u32 supported_languages);
@@ -32,6 +36,8 @@ private:
32 void GetApplicationControlData(Kernel::HLERequestContext& ctx); 36 void GetApplicationControlData(Kernel::HLERequestContext& ctx);
33 void GetApplicationDesiredLanguage(Kernel::HLERequestContext& ctx); 37 void GetApplicationDesiredLanguage(Kernel::HLERequestContext& ctx);
34 void ConvertApplicationLanguageToLanguageCode(Kernel::HLERequestContext& ctx); 38 void ConvertApplicationLanguageToLanguageCode(Kernel::HLERequestContext& ctx);
39
40 Core::System& system;
35}; 41};
36 42
37class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> { 43class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> {
@@ -72,13 +78,13 @@ public:
72 78
73class NS final : public ServiceFramework<NS> { 79class NS final : public ServiceFramework<NS> {
74public: 80public:
75 explicit NS(const char* name); 81 explicit NS(const char* name, Core::System& system_);
76 ~NS() override; 82 ~NS() override;
77 83
78 std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface() const; 84 std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface() const;
79 85
80private: 86private:
81 template <typename T> 87 template <typename T, typename... Args>
82 void PushInterface(Kernel::HLERequestContext& ctx) { 88 void PushInterface(Kernel::HLERequestContext& ctx) {
83 LOG_DEBUG(Service_NS, "called"); 89 LOG_DEBUG(Service_NS, "called");
84 90
@@ -87,13 +93,23 @@ private:
87 rb.PushIpcInterface<T>(); 93 rb.PushIpcInterface<T>();
88 } 94 }
89 95
90 template <typename T> 96 void PushIApplicationManagerInterface(Kernel::HLERequestContext& ctx) {
91 std::shared_ptr<T> GetInterface() const { 97 LOG_DEBUG(Service_NS, "called");
98
99 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
100 rb.Push(RESULT_SUCCESS);
101 rb.PushIpcInterface<IApplicationManagerInterface>(system);
102 }
103
104 template <typename T, typename... Args>
105 std::shared_ptr<T> GetInterface(Args&&... args) const {
92 static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>, 106 static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>,
93 "Not a base of ServiceFrameworkBase"); 107 "Not a base of ServiceFrameworkBase");
94 108
95 return std::make_shared<T>(); 109 return std::make_shared<T>(std::forward<Args>(args)...);
96 } 110 }
111
112 Core::System& system;
97}; 113};
98 114
99/// Registers all NS services with the specified service manager. 115/// Registers all NS services with the specified service manager.