summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Liam2024-02-17 14:34:13 -0500
committerGravatar Liam2024-02-18 10:35:39 -0500
commit2d43831d1f787fe96a30f668fe01bcb73061764c (patch)
tree3f910ad14677b7b9464daf9ea34394d1be694def /src/core
parentns: rewrite IApplicationManagerInterface (diff)
downloadyuzu-2d43831d1f787fe96a30f668fe01bcb73061764c.tar.gz
yuzu-2d43831d1f787fe96a30f668fe01bcb73061764c.tar.xz
yuzu-2d43831d1f787fe96a30f668fe01bcb73061764c.zip
ns: rewrite IServiceGetterInterface
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt2
-rw-r--r--src/core/hle/service/am/service/application_functions.cpp8
-rw-r--r--src/core/hle/service/am/service/library_applet_self_accessor.cpp8
-rw-r--r--src/core/hle/service/ns/ns.cpp95
-rw-r--r--src/core/hle/service/ns/ns.h21
-rw-r--r--src/core/hle/service/ns/service_getter_interface.cpp120
-rw-r--r--src/core/hle/service/ns/service_getter_interface.h47
7 files changed, 192 insertions, 109 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 43d377913..1339cb182 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -773,6 +773,8 @@ add_library(core STATIC
773 hle/service/ns/read_only_application_control_data_interface.h 773 hle/service/ns/read_only_application_control_data_interface.h
774 hle/service/ns/read_only_application_record_interface.cpp 774 hle/service/ns/read_only_application_record_interface.cpp
775 hle/service/ns/read_only_application_record_interface.h 775 hle/service/ns/read_only_application_record_interface.h
776 hle/service/ns/service_getter_interface.cpp
777 hle/service/ns/service_getter_interface.h
776 hle/service/ns/system_update_control.cpp 778 hle/service/ns/system_update_control.cpp
777 hle/service/ns/system_update_control.h 779 hle/service/ns/system_update_control.h
778 hle/service/ns/system_update_interface.cpp 780 hle/service/ns/system_update_interface.cpp
diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp
index a40789c01..cb53b07e0 100644
--- a/src/core/hle/service/am/service/application_functions.cpp
+++ b/src/core/hle/service/am/service/application_functions.cpp
@@ -17,7 +17,7 @@
17#include "core/hle/service/filesystem/save_data_controller.h" 17#include "core/hle/service/filesystem/save_data_controller.h"
18#include "core/hle/service/glue/glue_manager.h" 18#include "core/hle/service/glue/glue_manager.h"
19#include "core/hle/service/ns/application_manager_interface.h" 19#include "core/hle/service/ns/application_manager_interface.h"
20#include "core/hle/service/ns/ns.h" 20#include "core/hle/service/ns/service_getter_interface.h"
21#include "core/hle/service/sm/sm.h" 21#include "core/hle/service/sm/sm.h"
22 22
23namespace Service::AM { 23namespace Service::AM {
@@ -164,8 +164,10 @@ Result IApplicationFunctions::GetDesiredLanguage(Out<u64> out_language_code) {
164 164
165 // Call IApplicationManagerInterface implementation. 165 // Call IApplicationManagerInterface implementation.
166 auto& service_manager = system.ServiceManager(); 166 auto& service_manager = system.ServiceManager();
167 auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2"); 167 auto ns_am2 = service_manager.GetService<NS::IServiceGetterInterface>("ns:am2");
168 auto app_man = ns_am2->GetApplicationManagerInterface(); 168
169 std::shared_ptr<NS::IApplicationManagerInterface> app_man;
170 R_TRY(ns_am2->GetApplicationManagerInterface(&app_man));
169 171
170 // Get desired application language 172 // Get desired application language
171 NS::ApplicationLanguage desired_language{}; 173 NS::ApplicationLanguage desired_language{};
diff --git a/src/core/hle/service/am/service/library_applet_self_accessor.cpp b/src/core/hle/service/am/service/library_applet_self_accessor.cpp
index 932e354e0..963e67487 100644
--- a/src/core/hle/service/am/service/library_applet_self_accessor.cpp
+++ b/src/core/hle/service/am/service/library_applet_self_accessor.cpp
@@ -15,7 +15,7 @@
15#include "core/hle/service/filesystem/filesystem.h" 15#include "core/hle/service/filesystem/filesystem.h"
16#include "core/hle/service/glue/glue_manager.h" 16#include "core/hle/service/glue/glue_manager.h"
17#include "core/hle/service/ns/application_manager_interface.h" 17#include "core/hle/service/ns/application_manager_interface.h"
18#include "core/hle/service/ns/ns.h" 18#include "core/hle/service/ns/service_getter_interface.h"
19#include "core/hle/service/sm/sm.h" 19#include "core/hle/service/sm/sm.h"
20 20
21namespace Service::AM { 21namespace Service::AM {
@@ -257,8 +257,10 @@ Result ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage(
257 257
258 // Call IApplicationManagerInterface implementation. 258 // Call IApplicationManagerInterface implementation.
259 auto& service_manager = system.ServiceManager(); 259 auto& service_manager = system.ServiceManager();
260 auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2"); 260 auto ns_am2 = service_manager.GetService<NS::IServiceGetterInterface>("ns:am2");
261 auto app_man = ns_am2->GetApplicationManagerInterface(); 261
262 std::shared_ptr<NS::IApplicationManagerInterface> app_man;
263 R_TRY(ns_am2->GetApplicationManagerInterface(&app_man));
262 264
263 // Get desired application language 265 // Get desired application language
264 NS::ApplicationLanguage desired_language{}; 266 NS::ApplicationLanguage desired_language{};
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 9937e7bb7..96fa221b0 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -1,101 +1,32 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project 1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later 2// SPDX-License-Identifier: GPL-2.0-or-later
3 3
4#include "common/logging/log.h"
5#include "common/settings.h"
6#include "core/arm/debug.h"
7#include "core/core.h"
8#include "core/file_sys/control_metadata.h"
9#include "core/file_sys/patch_manager.h"
10#include "core/file_sys/vfs/vfs.h"
11#include "core/hle/service/filesystem/filesystem.h"
12#include "core/hle/service/glue/glue_manager.h"
13#include "core/hle/service/ipc_helpers.h"
14#include "core/hle/service/ns/account_proxy_interface.h"
15#include "core/hle/service/ns/application_manager_interface.h"
16#include "core/hle/service/ns/application_version_interface.h"
17#include "core/hle/service/ns/content_management_interface.h"
18#include "core/hle/service/ns/develop_interface.h" 4#include "core/hle/service/ns/develop_interface.h"
19#include "core/hle/service/ns/document_interface.h"
20#include "core/hle/service/ns/download_task_interface.h"
21#include "core/hle/service/ns/dynamic_rights_interface.h"
22#include "core/hle/service/ns/ecommerce_interface.h"
23#include "core/hle/service/ns/factory_reset_interface.h"
24#include "core/hle/service/ns/language.h"
25#include "core/hle/service/ns/ns.h" 5#include "core/hle/service/ns/ns.h"
26#include "core/hle/service/ns/ns_results.h"
27#include "core/hle/service/ns/pdm_qry.h" 6#include "core/hle/service/ns/pdm_qry.h"
28#include "core/hle/service/ns/platform_service_manager.h" 7#include "core/hle/service/ns/platform_service_manager.h"
29#include "core/hle/service/ns/read_only_application_control_data_interface.h" 8#include "core/hle/service/ns/service_getter_interface.h"
30#include "core/hle/service/ns/read_only_application_record_interface.h"
31#include "core/hle/service/ns/system_update_control.h"
32#include "core/hle/service/ns/system_update_interface.h" 9#include "core/hle/service/ns/system_update_interface.h"
33#include "core/hle/service/ns/vulnerability_manager_interface.h" 10#include "core/hle/service/ns/vulnerability_manager_interface.h"
34#include "core/hle/service/server_manager.h" 11#include "core/hle/service/server_manager.h"
35#include "core/hle/service/set/settings_server.h"
36 12
37namespace Service::NS { 13namespace Service::NS {
38 14
39NS::NS(const char* name, Core::System& system_) : ServiceFramework{system_, name} {
40 // clang-format off
41 static const FunctionInfo functions[] = {
42 {7988, &NS::PushInterface<IDynamicRightsInterface>, "GetDynamicRightsInterface"},
43 {7989, &NS::PushInterface<IReadOnlyApplicationControlDataInterface>, "GetReadOnlyApplicationControlDataInterface"},
44 {7991, &NS::PushInterface<IReadOnlyApplicationRecordInterface>, "GetReadOnlyApplicationRecordInterface"},
45 {7992, &NS::PushInterface<IECommerceInterface>, "GetECommerceInterface"},
46 {7993, &NS::PushInterface<IApplicationVersionInterface>, "GetApplicationVersionInterface"},
47 {7994, &NS::PushInterface<IFactoryResetInterface>, "GetFactoryResetInterface"},
48 {7995, &NS::PushInterface<IAccountProxyInterface>, "GetAccountProxyInterface"},
49 {7996, &NS::PushIApplicationManagerInterface, "GetApplicationManagerInterface"},
50 {7997, &NS::PushInterface<IDownloadTaskInterface>, "GetDownloadTaskInterface"},
51 {7998, &NS::PushInterface<IContentManagementInterface>, "GetContentManagementInterface"},
52 {7999, &NS::PushInterface<IDocumentInterface>, "GetDocumentInterface"},
53 };
54 // clang-format on
55
56 RegisterHandlers(functions);
57}
58
59NS::~NS() = default;
60
61std::shared_ptr<IApplicationManagerInterface> NS::GetApplicationManagerInterface() const {
62 return GetInterface<IApplicationManagerInterface>(system);
63}
64
65template <typename T, typename... Args>
66void NS::PushInterface(HLERequestContext& ctx) {
67 LOG_DEBUG(Service_NS, "called");
68
69 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
70 rb.Push(ResultSuccess);
71 rb.PushIpcInterface<T>(system);
72}
73
74void NS::PushIApplicationManagerInterface(HLERequestContext& ctx) {
75 LOG_DEBUG(Service_NS, "called");
76
77 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
78 rb.Push(ResultSuccess);
79 rb.PushIpcInterface<IApplicationManagerInterface>(system);
80}
81
82template <typename T, typename... Args>
83std::shared_ptr<T> NS::GetInterface(Args&&... args) const {
84 static_assert(std::is_base_of_v<SessionRequestHandler, T>,
85 "Not a base of ServiceFrameworkBase");
86
87 return std::make_shared<T>(std::forward<Args>(args)...);
88}
89
90void LoopProcess(Core::System& system) { 15void LoopProcess(Core::System& system) {
91 auto server_manager = std::make_unique<ServerManager>(system); 16 auto server_manager = std::make_unique<ServerManager>(system);
92 17
93 server_manager->RegisterNamedService("ns:am2", std::make_shared<NS>("ns:am2", system)); 18 server_manager->RegisterNamedService(
94 server_manager->RegisterNamedService("ns:ec", std::make_shared<NS>("ns:ec", system)); 19 "ns:am2", std::make_shared<IServiceGetterInterface>(system, "ns:am2"));
95 server_manager->RegisterNamedService("ns:rid", std::make_shared<NS>("ns:rid", system)); 20 server_manager->RegisterNamedService(
96 server_manager->RegisterNamedService("ns:rt", std::make_shared<NS>("ns:rt", system)); 21 "ns:ec", std::make_shared<IServiceGetterInterface>(system, "ns:ec"));
97 server_manager->RegisterNamedService("ns:web", std::make_shared<NS>("ns:web", system)); 22 server_manager->RegisterNamedService(
98 server_manager->RegisterNamedService("ns:ro", std::make_shared<NS>("ns:ro", system)); 23 "ns:rid", std::make_shared<IServiceGetterInterface>(system, "ns:rid"));
24 server_manager->RegisterNamedService(
25 "ns:rt", std::make_shared<IServiceGetterInterface>(system, "ns:rt"));
26 server_manager->RegisterNamedService(
27 "ns:web", std::make_shared<IServiceGetterInterface>(system, "ns:web"));
28 server_manager->RegisterNamedService(
29 "ns:ro", std::make_shared<IServiceGetterInterface>(system, "ns:ro"));
99 30
100 server_manager->RegisterNamedService("ns:dev", std::make_shared<IDevelopInterface>(system)); 31 server_manager->RegisterNamedService("ns:dev", std::make_shared<IDevelopInterface>(system));
101 server_manager->RegisterNamedService("ns:su", std::make_shared<ISystemUpdateInterface>(system)); 32 server_manager->RegisterNamedService("ns:su", std::make_shared<ISystemUpdateInterface>(system));
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h
index ef5c575da..f79b4ae3d 100644
--- a/src/core/hle/service/ns/ns.h
+++ b/src/core/hle/service/ns/ns.h
@@ -3,33 +3,12 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "core/hle/service/service.h"
7
8namespace Core { 6namespace Core {
9class System; 7class System;
10} 8}
11 9
12namespace Service::NS { 10namespace Service::NS {
13 11
14class IApplicationManagerInterface;
15
16class NS final : public ServiceFramework<NS> {
17public:
18 explicit NS(const char* name, Core::System& system_);
19 ~NS() override;
20
21 std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface() const;
22
23private:
24 template <typename T, typename... Args>
25 void PushInterface(HLERequestContext& ctx);
26
27 void PushIApplicationManagerInterface(HLERequestContext& ctx);
28
29 template <typename T, typename... Args>
30 std::shared_ptr<T> GetInterface(Args&&... args) const;
31};
32
33void LoopProcess(Core::System& system); 12void LoopProcess(Core::System& system);
34 13
35} // namespace Service::NS 14} // namespace Service::NS
diff --git a/src/core/hle/service/ns/service_getter_interface.cpp b/src/core/hle/service/ns/service_getter_interface.cpp
new file mode 100644
index 000000000..1a3dd7166
--- /dev/null
+++ b/src/core/hle/service/ns/service_getter_interface.cpp
@@ -0,0 +1,120 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/cmif_serialization.h"
5#include "core/hle/service/ns/account_proxy_interface.h"
6#include "core/hle/service/ns/application_manager_interface.h"
7#include "core/hle/service/ns/application_version_interface.h"
8#include "core/hle/service/ns/content_management_interface.h"
9#include "core/hle/service/ns/document_interface.h"
10#include "core/hle/service/ns/download_task_interface.h"
11#include "core/hle/service/ns/dynamic_rights_interface.h"
12#include "core/hle/service/ns/ecommerce_interface.h"
13#include "core/hle/service/ns/factory_reset_interface.h"
14#include "core/hle/service/ns/read_only_application_control_data_interface.h"
15#include "core/hle/service/ns/read_only_application_record_interface.h"
16#include "core/hle/service/ns/service_getter_interface.h"
17
18namespace Service::NS {
19
20IServiceGetterInterface::IServiceGetterInterface(Core::System& system_, const char* name)
21 : ServiceFramework{system_, name} {
22 // clang-format off
23 static const FunctionInfo functions[] = {
24 {7988, D<&IServiceGetterInterface::GetDynamicRightsInterface>, "GetDynamicRightsInterface"},
25 {7989, D<&IServiceGetterInterface::GetReadOnlyApplicationControlDataInterface>, "GetReadOnlyApplicationControlDataInterface"},
26 {7991, D<&IServiceGetterInterface::GetReadOnlyApplicationRecordInterface>, "GetReadOnlyApplicationRecordInterface"},
27 {7992, D<&IServiceGetterInterface::GetECommerceInterface>, "GetECommerceInterface"},
28 {7993, D<&IServiceGetterInterface::GetApplicationVersionInterface>, "GetApplicationVersionInterface"},
29 {7994, D<&IServiceGetterInterface::GetFactoryResetInterface>, "GetFactoryResetInterface"},
30 {7995, D<&IServiceGetterInterface::GetAccountProxyInterface>, "GetAccountProxyInterface"},
31 {7996, D<&IServiceGetterInterface::GetApplicationManagerInterface>, "GetApplicationManagerInterface"},
32 {7997, D<&IServiceGetterInterface::GetDownloadTaskInterface>, "GetDownloadTaskInterface"},
33 {7998, D<&IServiceGetterInterface::GetContentManagementInterface>, "GetContentManagementInterface"},
34 {7999, D<&IServiceGetterInterface::GetDocumentInterface>, "GetDocumentInterface"},
35 };
36 // clang-format on
37
38 RegisterHandlers(functions);
39}
40
41IServiceGetterInterface::~IServiceGetterInterface() = default;
42
43Result IServiceGetterInterface::GetDynamicRightsInterface(
44 Out<SharedPointer<IDynamicRightsInterface>> out_interface) {
45 LOG_DEBUG(Service_NS, "called");
46 *out_interface = std::make_shared<IDynamicRightsInterface>(system);
47 R_SUCCEED();
48}
49
50Result IServiceGetterInterface::GetReadOnlyApplicationControlDataInterface(
51 Out<SharedPointer<IReadOnlyApplicationControlDataInterface>> out_interface) {
52 LOG_DEBUG(Service_NS, "called");
53 *out_interface = std::make_shared<IReadOnlyApplicationControlDataInterface>(system);
54 R_SUCCEED();
55}
56
57Result IServiceGetterInterface::GetReadOnlyApplicationRecordInterface(
58 Out<SharedPointer<IReadOnlyApplicationRecordInterface>> out_interface) {
59 LOG_DEBUG(Service_NS, "called");
60 *out_interface = std::make_shared<IReadOnlyApplicationRecordInterface>(system);
61 R_SUCCEED();
62}
63
64Result IServiceGetterInterface::GetECommerceInterface(
65 Out<SharedPointer<IECommerceInterface>> out_interface) {
66 LOG_DEBUG(Service_NS, "called");
67 *out_interface = std::make_shared<IECommerceInterface>(system);
68 R_SUCCEED();
69}
70
71Result IServiceGetterInterface::GetApplicationVersionInterface(
72 Out<SharedPointer<IApplicationVersionInterface>> out_interface) {
73 LOG_DEBUG(Service_NS, "called");
74 *out_interface = std::make_shared<IApplicationVersionInterface>(system);
75 R_SUCCEED();
76}
77
78Result IServiceGetterInterface::GetFactoryResetInterface(
79 Out<SharedPointer<IFactoryResetInterface>> out_interface) {
80 LOG_DEBUG(Service_NS, "called");
81 *out_interface = std::make_shared<IFactoryResetInterface>(system);
82 R_SUCCEED();
83}
84
85Result IServiceGetterInterface::GetAccountProxyInterface(
86 Out<SharedPointer<IAccountProxyInterface>> out_interface) {
87 LOG_DEBUG(Service_NS, "called");
88 *out_interface = std::make_shared<IAccountProxyInterface>(system);
89 R_SUCCEED();
90}
91
92Result IServiceGetterInterface::GetApplicationManagerInterface(
93 Out<SharedPointer<IApplicationManagerInterface>> out_interface) {
94 LOG_DEBUG(Service_NS, "called");
95 *out_interface = std::make_shared<IApplicationManagerInterface>(system);
96 R_SUCCEED();
97}
98
99Result IServiceGetterInterface::GetDownloadTaskInterface(
100 Out<SharedPointer<IDownloadTaskInterface>> out_interface) {
101 LOG_DEBUG(Service_NS, "called");
102 *out_interface = std::make_shared<IDownloadTaskInterface>(system);
103 R_SUCCEED();
104}
105
106Result IServiceGetterInterface::GetContentManagementInterface(
107 Out<SharedPointer<IContentManagementInterface>> out_interface) {
108 LOG_DEBUG(Service_NS, "called");
109 *out_interface = std::make_shared<IContentManagementInterface>(system);
110 R_SUCCEED();
111}
112
113Result IServiceGetterInterface::GetDocumentInterface(
114 Out<SharedPointer<IDocumentInterface>> out_interface) {
115 LOG_DEBUG(Service_NS, "called");
116 *out_interface = std::make_shared<IDocumentInterface>(system);
117 R_SUCCEED();
118}
119
120} // namespace Service::NS
diff --git a/src/core/hle/service/ns/service_getter_interface.h b/src/core/hle/service/ns/service_getter_interface.h
new file mode 100644
index 000000000..bbc18d444
--- /dev/null
+++ b/src/core/hle/service/ns/service_getter_interface.h
@@ -0,0 +1,47 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "core/hle/service/cmif_types.h"
7#include "core/hle/service/service.h"
8
9namespace Service::NS {
10
11class IDynamicRightsInterface;
12class IReadOnlyApplicationControlDataInterface;
13class IReadOnlyApplicationRecordInterface;
14class IECommerceInterface;
15class IApplicationVersionInterface;
16class IFactoryResetInterface;
17class IAccountProxyInterface;
18class IApplicationManagerInterface;
19class IDownloadTaskInterface;
20class IContentManagementInterface;
21class IDocumentInterface;
22
23class IServiceGetterInterface : public ServiceFramework<IServiceGetterInterface> {
24public:
25 explicit IServiceGetterInterface(Core::System& system_, const char* name);
26 ~IServiceGetterInterface() override;
27
28public:
29 Result GetDynamicRightsInterface(Out<SharedPointer<IDynamicRightsInterface>> out_interface);
30 Result GetReadOnlyApplicationControlDataInterface(
31 Out<SharedPointer<IReadOnlyApplicationControlDataInterface>> out_interface);
32 Result GetReadOnlyApplicationRecordInterface(
33 Out<SharedPointer<IReadOnlyApplicationRecordInterface>> out_interface);
34 Result GetECommerceInterface(Out<SharedPointer<IECommerceInterface>> out_interface);
35 Result GetApplicationVersionInterface(
36 Out<SharedPointer<IApplicationVersionInterface>> out_interface);
37 Result GetFactoryResetInterface(Out<SharedPointer<IFactoryResetInterface>> out_interface);
38 Result GetAccountProxyInterface(Out<SharedPointer<IAccountProxyInterface>> out_interface);
39 Result GetApplicationManagerInterface(
40 Out<SharedPointer<IApplicationManagerInterface>> out_interface);
41 Result GetDownloadTaskInterface(Out<SharedPointer<IDownloadTaskInterface>> out_interface);
42 Result GetContentManagementInterface(
43 Out<SharedPointer<IContentManagementInterface>> out_interface);
44 Result GetDocumentInterface(Out<SharedPointer<IDocumentInterface>> out_interface);
45};
46
47} // namespace Service::NS