summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorGravatar Narr the Reg2024-02-18 23:36:29 -0600
committerGravatar GitHub2024-02-18 23:36:29 -0600
commitd0af52f28e99676d47d6a9b33709bc20e77b7d2f (patch)
treea4b10e073fa20b007d09c55116f723efdc779d8d /src/core
parentMerge pull request #13070 from liamwhite/offset (diff)
parentns: address review comments (diff)
downloadyuzu-d0af52f28e99676d47d6a9b33709bc20e77b7d2f.tar.gz
yuzu-d0af52f28e99676d47d6a9b33709bc20e77b7d2f.tar.xz
yuzu-d0af52f28e99676d47d6a9b33709bc20e77b7d2f.zip
Merge pull request #13048 from liamwhite/new-shell
ns: rewrite for new IPC
Diffstat (limited to 'src/core')
-rw-r--r--src/core/CMakeLists.txt43
-rw-r--r--src/core/file_sys/system_archive/shared_font.cpp2
-rw-r--r--src/core/hle/service/am/frontend/applet_web_browser.cpp2
-rw-r--r--src/core/hle/service/am/service/application_functions.cpp11
-rw-r--r--src/core/hle/service/am/service/library_applet_self_accessor.cpp11
-rw-r--r--src/core/hle/service/ns/account_proxy_interface.cpp21
-rw-r--r--src/core/hle/service/ns/account_proxy_interface.h16
-rw-r--r--src/core/hle/service/ns/application_manager_interface.cpp519
-rw-r--r--src/core/hle/service/ns/application_manager_interface.h62
-rw-r--r--src/core/hle/service/ns/application_version_interface.cpp33
-rw-r--r--src/core/hle/service/ns/application_version_interface.h16
-rw-r--r--src/core/hle/service/ns/content_management_interface.cpp72
-rw-r--r--src/core/hle/service/ns/content_management_interface.h25
-rw-r--r--src/core/hle/service/ns/develop_interface.cpp38
-rw-r--r--src/core/hle/service/ns/develop_interface.h16
-rw-r--r--src/core/hle/service/ns/document_interface.cpp38
-rw-r--r--src/core/hle/service/ns/document_interface.h22
-rw-r--r--src/core/hle/service/ns/download_task_interface.cpp39
-rw-r--r--src/core/hle/service/ns/download_task_interface.h20
-rw-r--r--src/core/hle/service/ns/dynamic_rights_interface.cpp62
-rw-r--r--src/core/hle/service/ns/dynamic_rights_interface.h22
-rw-r--r--src/core/hle/service/ns/ecommerce_interface.cpp27
-rw-r--r--src/core/hle/service/ns/ecommerce_interface.h16
-rw-r--r--src/core/hle/service/ns/factory_reset_interface.cpp27
-rw-r--r--src/core/hle/service/ns/factory_reset_interface.h16
-rw-r--r--src/core/hle/service/ns/ns.cpp903
-rw-r--r--src/core/hle/service/ns/ns.h133
-rw-r--r--src/core/hle/service/ns/ns_results.h (renamed from src/core/hle/service/ns/errors.h)0
-rw-r--r--src/core/hle/service/ns/ns_types.h111
-rw-r--r--src/core/hle/service/ns/pdm_qry.cpp67
-rw-r--r--src/core/hle/service/ns/platform_service_manager.cpp (renamed from src/core/hle/service/ns/iplatform_service_manager.cpp)130
-rw-r--r--src/core/hle/service/ns/platform_service_manager.h (renamed from src/core/hle/service/ns/iplatform_service_manager.h)33
-rw-r--r--src/core/hle/service/ns/query_service.cpp57
-rw-r--r--src/core/hle/service/ns/query_service.h (renamed from src/core/hle/service/ns/pdm_qry.h)12
-rw-r--r--src/core/hle/service/ns/read_only_application_control_data_interface.cpp122
-rw-r--r--src/core/hle/service/ns/read_only_application_control_data_interface.h30
-rw-r--r--src/core/hle/service/ns/read_only_application_record_interface.cpp38
-rw-r--r--src/core/hle/service/ns/read_only_application_record_interface.h22
-rw-r--r--src/core/hle/service/ns/service_getter_interface.cpp120
-rw-r--r--src/core/hle/service/ns/service_getter_interface.h47
-rw-r--r--src/core/hle/service/ns/system_update_control.cpp44
-rw-r--r--src/core/hle/service/ns/system_update_control.h16
-rw-r--r--src/core/hle/service/ns/system_update_interface.cpp61
-rw-r--r--src/core/hle/service/ns/system_update_interface.h38
-rw-r--r--src/core/hle/service/ns/vulnerability_manager_interface.cpp31
-rw-r--r--src/core/hle/service/ns/vulnerability_manager_interface.h21
46 files changed, 2029 insertions, 1183 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index df47033e3..c2bdc0b1a 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -739,15 +739,48 @@ add_library(core STATIC
739 hle/service/nim/nim.h 739 hle/service/nim/nim.h
740 hle/service/npns/npns.cpp 740 hle/service/npns/npns.cpp
741 hle/service/npns/npns.h 741 hle/service/npns/npns.h
742 hle/service/ns/errors.h 742 hle/service/ns/account_proxy_interface.cpp
743 hle/service/ns/iplatform_service_manager.cpp 743 hle/service/ns/account_proxy_interface.h
744 hle/service/ns/iplatform_service_manager.h 744 hle/service/ns/application_manager_interface.cpp
745 hle/service/ns/application_manager_interface.h
746 hle/service/ns/application_version_interface.cpp
747 hle/service/ns/application_version_interface.h
748 hle/service/ns/content_management_interface.cpp
749 hle/service/ns/content_management_interface.h
750 hle/service/ns/develop_interface.cpp
751 hle/service/ns/develop_interface.h
752 hle/service/ns/document_interface.cpp
753 hle/service/ns/document_interface.h
754 hle/service/ns/download_task_interface.cpp
755 hle/service/ns/download_task_interface.h
756 hle/service/ns/dynamic_rights_interface.cpp
757 hle/service/ns/dynamic_rights_interface.h
758 hle/service/ns/ecommerce_interface.cpp
759 hle/service/ns/ecommerce_interface.h
760 hle/service/ns/factory_reset_interface.cpp
761 hle/service/ns/factory_reset_interface.h
745 hle/service/ns/language.cpp 762 hle/service/ns/language.cpp
746 hle/service/ns/language.h 763 hle/service/ns/language.h
764 hle/service/ns/ns_results.h
765 hle/service/ns/ns_types.h
747 hle/service/ns/ns.cpp 766 hle/service/ns/ns.cpp
748 hle/service/ns/ns.h 767 hle/service/ns/ns.h
749 hle/service/ns/pdm_qry.cpp 768 hle/service/ns/platform_service_manager.cpp
750 hle/service/ns/pdm_qry.h 769 hle/service/ns/platform_service_manager.h
770 hle/service/ns/query_service.cpp
771 hle/service/ns/query_service.h
772 hle/service/ns/read_only_application_control_data_interface.cpp
773 hle/service/ns/read_only_application_control_data_interface.h
774 hle/service/ns/read_only_application_record_interface.cpp
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
778 hle/service/ns/system_update_control.cpp
779 hle/service/ns/system_update_control.h
780 hle/service/ns/system_update_interface.cpp
781 hle/service/ns/system_update_interface.h
782 hle/service/ns/vulnerability_manager_interface.cpp
783 hle/service/ns/vulnerability_manager_interface.h
751 hle/service/nvdrv/core/container.cpp 784 hle/service/nvdrv/core/container.cpp
752 hle/service/nvdrv/core/container.h 785 hle/service/nvdrv/core/container.h
753 hle/service/nvdrv/core/heap_mapper.cpp 786 hle/service/nvdrv/core/heap_mapper.cpp
diff --git a/src/core/file_sys/system_archive/shared_font.cpp b/src/core/file_sys/system_archive/shared_font.cpp
index deb52069d..9ea16aa59 100644
--- a/src/core/file_sys/system_archive/shared_font.cpp
+++ b/src/core/file_sys/system_archive/shared_font.cpp
@@ -9,7 +9,7 @@
9#include "core/file_sys/system_archive/data/font_standard.h" 9#include "core/file_sys/system_archive/data/font_standard.h"
10#include "core/file_sys/system_archive/shared_font.h" 10#include "core/file_sys/system_archive/shared_font.h"
11#include "core/file_sys/vfs/vfs_vector.h" 11#include "core/file_sys/vfs/vfs_vector.h"
12#include "core/hle/service/ns/iplatform_service_manager.h" 12#include "core/hle/service/ns/platform_service_manager.h"
13 13
14namespace FileSys::SystemArchive { 14namespace FileSys::SystemArchive {
15 15
diff --git a/src/core/hle/service/am/frontend/applet_web_browser.cpp b/src/core/hle/service/am/frontend/applet_web_browser.cpp
index bb60260b4..835c20c4e 100644
--- a/src/core/hle/service/am/frontend/applet_web_browser.cpp
+++ b/src/core/hle/service/am/frontend/applet_web_browser.cpp
@@ -22,7 +22,7 @@
22#include "core/hle/service/am/frontend/applet_web_browser.h" 22#include "core/hle/service/am/frontend/applet_web_browser.h"
23#include "core/hle/service/am/service/storage.h" 23#include "core/hle/service/am/service/storage.h"
24#include "core/hle/service/filesystem/filesystem.h" 24#include "core/hle/service/filesystem/filesystem.h"
25#include "core/hle/service/ns/iplatform_service_manager.h" 25#include "core/hle/service/ns/platform_service_manager.h"
26#include "core/loader/loader.h" 26#include "core/loader/loader.h"
27 27
28namespace Service::AM::Frontend { 28namespace Service::AM::Frontend {
diff --git a/src/core/hle/service/am/service/application_functions.cpp b/src/core/hle/service/am/service/application_functions.cpp
index 63dd12a47..cb53b07e0 100644
--- a/src/core/hle/service/am/service/application_functions.cpp
+++ b/src/core/hle/service/am/service/application_functions.cpp
@@ -16,7 +16,8 @@
16#include "core/hle/service/filesystem/filesystem.h" 16#include "core/hle/service/filesystem/filesystem.h"
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/ns.h" 19#include "core/hle/service/ns/application_manager_interface.h"
20#include "core/hle/service/ns/service_getter_interface.h"
20#include "core/hle/service/sm/sm.h" 21#include "core/hle/service/sm/sm.h"
21 22
22namespace Service::AM { 23namespace Service::AM {
@@ -163,11 +164,13 @@ Result IApplicationFunctions::GetDesiredLanguage(Out<u64> out_language_code) {
163 164
164 // Call IApplicationManagerInterface implementation. 165 // Call IApplicationManagerInterface implementation.
165 auto& service_manager = system.ServiceManager(); 166 auto& service_manager = system.ServiceManager();
166 auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2"); 167 auto ns_am2 = service_manager.GetService<NS::IServiceGetterInterface>("ns:am2");
167 auto app_man = ns_am2->GetApplicationManagerInterface(); 168
169 std::shared_ptr<NS::IApplicationManagerInterface> app_man;
170 R_TRY(ns_am2->GetApplicationManagerInterface(&app_man));
168 171
169 // Get desired application language 172 // Get desired application language
170 u8 desired_language{}; 173 NS::ApplicationLanguage desired_language{};
171 R_TRY(app_man->GetApplicationDesiredLanguage(&desired_language, supported_languages)); 174 R_TRY(app_man->GetApplicationDesiredLanguage(&desired_language, supported_languages));
172 175
173 // Convert to settings language code. 176 // Convert to settings language code.
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 94bd4dae6..330eb26f0 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
@@ -14,7 +14,8 @@
14#include "core/hle/service/cmif_serialization.h" 14#include "core/hle/service/cmif_serialization.h"
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/ns.h" 17#include "core/hle/service/ns/application_manager_interface.h"
18#include "core/hle/service/ns/service_getter_interface.h"
18#include "core/hle/service/sm/sm.h" 19#include "core/hle/service/sm/sm.h"
19 20
20namespace Service::AM { 21namespace Service::AM {
@@ -256,11 +257,13 @@ Result ILibraryAppletSelfAccessor::GetMainAppletApplicationDesiredLanguage(
256 257
257 // Call IApplicationManagerInterface implementation. 258 // Call IApplicationManagerInterface implementation.
258 auto& service_manager = system.ServiceManager(); 259 auto& service_manager = system.ServiceManager();
259 auto ns_am2 = service_manager.GetService<NS::NS>("ns:am2"); 260 auto ns_am2 = service_manager.GetService<NS::IServiceGetterInterface>("ns:am2");
260 auto app_man = ns_am2->GetApplicationManagerInterface(); 261
262 std::shared_ptr<NS::IApplicationManagerInterface> app_man;
263 R_TRY(ns_am2->GetApplicationManagerInterface(&app_man));
261 264
262 // Get desired application language 265 // Get desired application language
263 u8 desired_language{}; 266 NS::ApplicationLanguage desired_language{};
264 R_TRY(app_man->GetApplicationDesiredLanguage(&desired_language, supported_languages)); 267 R_TRY(app_man->GetApplicationDesiredLanguage(&desired_language, supported_languages));
265 268
266 // Convert to settings language code. 269 // Convert to settings language code.
diff --git a/src/core/hle/service/ns/account_proxy_interface.cpp b/src/core/hle/service/ns/account_proxy_interface.cpp
new file mode 100644
index 000000000..e5041af66
--- /dev/null
+++ b/src/core/hle/service/ns/account_proxy_interface.cpp
@@ -0,0 +1,21 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/ns/account_proxy_interface.h"
5
6namespace Service::NS {
7
8IAccountProxyInterface::IAccountProxyInterface(Core::System& system_)
9 : ServiceFramework{system_, "IAccountProxyInterface"} {
10 // clang-format off
11 static const FunctionInfo functions[] = {
12 {0, nullptr, "CreateUserAccount"},
13 };
14 // clang-format on
15
16 RegisterHandlers(functions);
17}
18
19IAccountProxyInterface::~IAccountProxyInterface() = default;
20
21} // namespace Service::NS
diff --git a/src/core/hle/service/ns/account_proxy_interface.h b/src/core/hle/service/ns/account_proxy_interface.h
new file mode 100644
index 000000000..e944d2a75
--- /dev/null
+++ b/src/core/hle/service/ns/account_proxy_interface.h
@@ -0,0 +1,16 @@
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/service.h"
7
8namespace Service::NS {
9
10class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> {
11public:
12 explicit IAccountProxyInterface(Core::System& system_);
13 ~IAccountProxyInterface() override;
14};
15
16} // namespace Service::NS
diff --git a/src/core/hle/service/ns/application_manager_interface.cpp b/src/core/hle/service/ns/application_manager_interface.cpp
new file mode 100644
index 000000000..2e3a44c0d
--- /dev/null
+++ b/src/core/hle/service/ns/application_manager_interface.cpp
@@ -0,0 +1,519 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/file_sys/nca_metadata.h"
5#include "core/file_sys/registered_cache.h"
6#include "core/hle/service/cmif_serialization.h"
7#include "core/hle/service/filesystem/filesystem.h"
8#include "core/hle/service/ns/application_manager_interface.h"
9#include "core/hle/service/ns/content_management_interface.h"
10#include "core/hle/service/ns/read_only_application_control_data_interface.h"
11
12namespace Service::NS {
13
14IApplicationManagerInterface::IApplicationManagerInterface(Core::System& system_)
15 : ServiceFramework{system_, "IApplicationManagerInterface"},
16 service_context{system, "IApplicationManagerInterface"},
17 record_update_system_event{service_context}, sd_card_mount_status_event{service_context},
18 gamecard_update_detection_event{service_context},
19 gamecard_mount_status_event{service_context}, gamecard_mount_failure_event{service_context} {
20 // clang-format off
21 static const FunctionInfo functions[] = {
22 {0, D<&IApplicationManagerInterface::ListApplicationRecord>, "ListApplicationRecord"},
23 {1, nullptr, "GenerateApplicationRecordCount"},
24 {2, D<&IApplicationManagerInterface::GetApplicationRecordUpdateSystemEvent>, "GetApplicationRecordUpdateSystemEvent"},
25 {3, nullptr, "GetApplicationViewDeprecated"},
26 {4, nullptr, "DeleteApplicationEntity"},
27 {5, nullptr, "DeleteApplicationCompletely"},
28 {6, nullptr, "IsAnyApplicationEntityRedundant"},
29 {7, nullptr, "DeleteRedundantApplicationEntity"},
30 {8, nullptr, "IsApplicationEntityMovable"},
31 {9, nullptr, "MoveApplicationEntity"},
32 {11, nullptr, "CalculateApplicationOccupiedSize"},
33 {16, nullptr, "PushApplicationRecord"},
34 {17, nullptr, "ListApplicationRecordContentMeta"},
35 {19, nullptr, "LaunchApplicationOld"},
36 {21, nullptr, "GetApplicationContentPath"},
37 {22, nullptr, "TerminateApplication"},
38 {23, nullptr, "ResolveApplicationContentPath"},
39 {26, nullptr, "BeginInstallApplication"},
40 {27, nullptr, "DeleteApplicationRecord"},
41 {30, nullptr, "RequestApplicationUpdateInfo"},
42 {31, nullptr, "Unknown31"},
43 {32, nullptr, "CancelApplicationDownload"},
44 {33, nullptr, "ResumeApplicationDownload"},
45 {35, nullptr, "UpdateVersionList"},
46 {36, nullptr, "PushLaunchVersion"},
47 {37, nullptr, "ListRequiredVersion"},
48 {38, D<&IApplicationManagerInterface::CheckApplicationLaunchVersion>, "CheckApplicationLaunchVersion"},
49 {39, nullptr, "CheckApplicationLaunchRights"},
50 {40, nullptr, "GetApplicationLogoData"},
51 {41, nullptr, "CalculateApplicationDownloadRequiredSize"},
52 {42, nullptr, "CleanupSdCard"},
53 {43, D<&IApplicationManagerInterface::CheckSdCardMountStatus>, "CheckSdCardMountStatus"},
54 {44, D<&IApplicationManagerInterface::GetSdCardMountStatusChangedEvent>, "GetSdCardMountStatusChangedEvent"},
55 {45, nullptr, "GetGameCardAttachmentEvent"},
56 {46, nullptr, "GetGameCardAttachmentInfo"},
57 {47, nullptr, "GetTotalSpaceSize"},
58 {48, D<&IApplicationManagerInterface::GetFreeSpaceSize>, "GetFreeSpaceSize"},
59 {49, nullptr, "GetSdCardRemovedEvent"},
60 {52, D<&IApplicationManagerInterface::GetGameCardUpdateDetectionEvent>, "GetGameCardUpdateDetectionEvent"},
61 {53, nullptr, "DisableApplicationAutoDelete"},
62 {54, nullptr, "EnableApplicationAutoDelete"},
63 {55, D<&IApplicationManagerInterface::GetApplicationDesiredLanguage>, "GetApplicationDesiredLanguage"},
64 {56, nullptr, "SetApplicationTerminateResult"},
65 {57, nullptr, "ClearApplicationTerminateResult"},
66 {58, nullptr, "GetLastSdCardMountUnexpectedResult"},
67 {59, D<&IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode>, "ConvertApplicationLanguageToLanguageCode"},
68 {60, nullptr, "ConvertLanguageCodeToApplicationLanguage"},
69 {61, nullptr, "GetBackgroundDownloadStressTaskInfo"},
70 {62, nullptr, "GetGameCardStopper"},
71 {63, nullptr, "IsSystemProgramInstalled"},
72 {64, nullptr, "StartApplyDeltaTask"},
73 {65, nullptr, "GetRequestServerStopper"},
74 {66, nullptr, "GetBackgroundApplyDeltaStressTaskInfo"},
75 {67, nullptr, "CancelApplicationApplyDelta"},
76 {68, nullptr, "ResumeApplicationApplyDelta"},
77 {69, nullptr, "CalculateApplicationApplyDeltaRequiredSize"},
78 {70, D<&IApplicationManagerInterface::ResumeAll>, "ResumeAll"},
79 {71, D<&IApplicationManagerInterface::GetStorageSize>, "GetStorageSize"},
80 {80, nullptr, "RequestDownloadApplication"},
81 {81, nullptr, "RequestDownloadAddOnContent"},
82 {82, nullptr, "DownloadApplication"},
83 {83, nullptr, "CheckApplicationResumeRights"},
84 {84, nullptr, "GetDynamicCommitEvent"},
85 {85, nullptr, "RequestUpdateApplication2"},
86 {86, nullptr, "EnableApplicationCrashReport"},
87 {87, nullptr, "IsApplicationCrashReportEnabled"},
88 {90, nullptr, "BoostSystemMemoryResourceLimit"},
89 {91, nullptr, "DeprecatedLaunchApplication"},
90 {92, nullptr, "GetRunningApplicationProgramId"},
91 {93, nullptr, "GetMainApplicationProgramIndex"},
92 {94, nullptr, "LaunchApplication"},
93 {95, nullptr, "GetApplicationLaunchInfo"},
94 {96, nullptr, "AcquireApplicationLaunchInfo"},
95 {97, nullptr, "GetMainApplicationProgramIndexByApplicationLaunchInfo"},
96 {98, nullptr, "EnableApplicationAllThreadDumpOnCrash"},
97 {99, nullptr, "LaunchDevMenu"},
98 {100, nullptr, "ResetToFactorySettings"},
99 {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"},
100 {102, nullptr, "ResetToFactorySettingsForRefurbishment"},
101 {103, nullptr, "ResetToFactorySettingsWithPlatformRegion"},
102 {104, nullptr, "ResetToFactorySettingsWithPlatformRegionAuthentication"},
103 {105, nullptr, "RequestResetToFactorySettingsSecurely"},
104 {106, nullptr, "RequestResetToFactorySettingsWithPlatformRegionAuthenticationSecurely"},
105 {200, nullptr, "CalculateUserSaveDataStatistics"},
106 {201, nullptr, "DeleteUserSaveDataAll"},
107 {210, nullptr, "DeleteUserSystemSaveData"},
108 {211, nullptr, "DeleteSaveData"},
109 {220, nullptr, "UnregisterNetworkServiceAccount"},
110 {221, nullptr, "UnregisterNetworkServiceAccountWithUserSaveDataDeletion"},
111 {300, nullptr, "GetApplicationShellEvent"},
112 {301, nullptr, "PopApplicationShellEventInfo"},
113 {302, nullptr, "LaunchLibraryApplet"},
114 {303, nullptr, "TerminateLibraryApplet"},
115 {304, nullptr, "LaunchSystemApplet"},
116 {305, nullptr, "TerminateSystemApplet"},
117 {306, nullptr, "LaunchOverlayApplet"},
118 {307, nullptr, "TerminateOverlayApplet"},
119 {400, D<&IApplicationManagerInterface::GetApplicationControlData>, "GetApplicationControlData"},
120 {401, nullptr, "InvalidateAllApplicationControlCache"},
121 {402, nullptr, "RequestDownloadApplicationControlData"},
122 {403, nullptr, "GetMaxApplicationControlCacheCount"},
123 {404, nullptr, "InvalidateApplicationControlCache"},
124 {405, nullptr, "ListApplicationControlCacheEntryInfo"},
125 {406, nullptr, "GetApplicationControlProperty"},
126 {407, nullptr, "ListApplicationTitle"},
127 {408, nullptr, "ListApplicationIcon"},
128 {502, nullptr, "RequestCheckGameCardRegistration"},
129 {503, nullptr, "RequestGameCardRegistrationGoldPoint"},
130 {504, nullptr, "RequestRegisterGameCard"},
131 {505, D<&IApplicationManagerInterface::GetGameCardMountFailureEvent>, "GetGameCardMountFailureEvent"},
132 {506, nullptr, "IsGameCardInserted"},
133 {507, nullptr, "EnsureGameCardAccess"},
134 {508, nullptr, "GetLastGameCardMountFailureResult"},
135 {509, nullptr, "ListApplicationIdOnGameCard"},
136 {510, nullptr, "GetGameCardPlatformRegion"},
137 {600, nullptr, "CountApplicationContentMeta"},
138 {601, nullptr, "ListApplicationContentMetaStatus"},
139 {602, nullptr, "ListAvailableAddOnContent"},
140 {603, nullptr, "GetOwnedApplicationContentMetaStatus"},
141 {604, nullptr, "RegisterContentsExternalKey"},
142 {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"},
143 {606, nullptr, "GetContentMetaStorage"},
144 {607, nullptr, "ListAvailableAddOnContent"},
145 {609, nullptr, "ListAvailabilityAssuredAddOnContent"},
146 {610, nullptr, "GetInstalledContentMetaStorage"},
147 {611, nullptr, "PrepareAddOnContent"},
148 {700, nullptr, "PushDownloadTaskList"},
149 {701, nullptr, "ClearTaskStatusList"},
150 {702, nullptr, "RequestDownloadTaskList"},
151 {703, nullptr, "RequestEnsureDownloadTask"},
152 {704, nullptr, "ListDownloadTaskStatus"},
153 {705, nullptr, "RequestDownloadTaskListData"},
154 {800, nullptr, "RequestVersionList"},
155 {801, nullptr, "ListVersionList"},
156 {802, nullptr, "RequestVersionListData"},
157 {900, nullptr, "GetApplicationRecord"},
158 {901, nullptr, "GetApplicationRecordProperty"},
159 {902, nullptr, "EnableApplicationAutoUpdate"},
160 {903, nullptr, "DisableApplicationAutoUpdate"},
161 {904, nullptr, "TouchApplication"},
162 {905, nullptr, "RequestApplicationUpdate"},
163 {906, D<&IApplicationManagerInterface::IsApplicationUpdateRequested>, "IsApplicationUpdateRequested"},
164 {907, nullptr, "WithdrawApplicationUpdateRequest"},
165 {908, nullptr, "ListApplicationRecordInstalledContentMeta"},
166 {909, nullptr, "WithdrawCleanupAddOnContentsWithNoRightsRecommendation"},
167 {910, nullptr, "HasApplicationRecord"},
168 {911, nullptr, "SetPreInstalledApplication"},
169 {912, nullptr, "ClearPreInstalledApplicationFlag"},
170 {913, nullptr, "ListAllApplicationRecord"},
171 {914, nullptr, "HideApplicationRecord"},
172 {915, nullptr, "ShowApplicationRecord"},
173 {916, nullptr, "IsApplicationAutoDeleteDisabled"},
174 {1000, nullptr, "RequestVerifyApplicationDeprecated"},
175 {1001, nullptr, "CorruptApplicationForDebug"},
176 {1002, nullptr, "RequestVerifyAddOnContentsRights"},
177 {1003, nullptr, "RequestVerifyApplication"},
178 {1004, nullptr, "CorruptContentForDebug"},
179 {1200, nullptr, "NeedsUpdateVulnerability"},
180 {1300, D<&IApplicationManagerInterface::IsAnyApplicationEntityInstalled>, "IsAnyApplicationEntityInstalled"},
181 {1301, nullptr, "DeleteApplicationContentEntities"},
182 {1302, nullptr, "CleanupUnrecordedApplicationEntity"},
183 {1303, nullptr, "CleanupAddOnContentsWithNoRights"},
184 {1304, nullptr, "DeleteApplicationContentEntity"},
185 {1305, nullptr, "TryDeleteRunningApplicationEntity"},
186 {1306, nullptr, "TryDeleteRunningApplicationCompletely"},
187 {1307, nullptr, "TryDeleteRunningApplicationContentEntities"},
188 {1308, nullptr, "DeleteApplicationCompletelyForDebug"},
189 {1309, nullptr, "CleanupUnavailableAddOnContents"},
190 {1310, nullptr, "RequestMoveApplicationEntity"},
191 {1311, nullptr, "EstimateSizeToMove"},
192 {1312, nullptr, "HasMovableEntity"},
193 {1313, nullptr, "CleanupOrphanContents"},
194 {1314, nullptr, "CheckPreconditionSatisfiedToMove"},
195 {1400, nullptr, "PrepareShutdown"},
196 {1500, nullptr, "FormatSdCard"},
197 {1501, nullptr, "NeedsSystemUpdateToFormatSdCard"},
198 {1502, nullptr, "GetLastSdCardFormatUnexpectedResult"},
199 {1504, nullptr, "InsertSdCard"},
200 {1505, nullptr, "RemoveSdCard"},
201 {1506, nullptr, "GetSdCardStartupStatus"},
202 {1600, nullptr, "GetSystemSeedForPseudoDeviceId"},
203 {1601, nullptr, "ResetSystemSeedForPseudoDeviceId"},
204 {1700, nullptr, "ListApplicationDownloadingContentMeta"},
205 {1701, D<&IApplicationManagerInterface::GetApplicationView>, "GetApplicationView"},
206 {1702, nullptr, "GetApplicationDownloadTaskStatus"},
207 {1703, nullptr, "GetApplicationViewDownloadErrorContext"},
208 {1704, D<&IApplicationManagerInterface::GetApplicationViewWithPromotionInfo>, "GetApplicationViewWithPromotionInfo"},
209 {1705, nullptr, "IsPatchAutoDeletableApplication"},
210 {1800, nullptr, "IsNotificationSetupCompleted"},
211 {1801, nullptr, "GetLastNotificationInfoCount"},
212 {1802, nullptr, "ListLastNotificationInfo"},
213 {1803, nullptr, "ListNotificationTask"},
214 {1900, nullptr, "IsActiveAccount"},
215 {1901, nullptr, "RequestDownloadApplicationPrepurchasedRights"},
216 {1902, nullptr, "GetApplicationTicketInfo"},
217 {1903, nullptr, "RequestDownloadApplicationPrepurchasedRightsForAccount"},
218 {2000, nullptr, "GetSystemDeliveryInfo"},
219 {2001, nullptr, "SelectLatestSystemDeliveryInfo"},
220 {2002, nullptr, "VerifyDeliveryProtocolVersion"},
221 {2003, nullptr, "GetApplicationDeliveryInfo"},
222 {2004, nullptr, "HasAllContentsToDeliver"},
223 {2005, nullptr, "CompareApplicationDeliveryInfo"},
224 {2006, nullptr, "CanDeliverApplication"},
225 {2007, nullptr, "ListContentMetaKeyToDeliverApplication"},
226 {2008, nullptr, "NeedsSystemUpdateToDeliverApplication"},
227 {2009, nullptr, "EstimateRequiredSize"},
228 {2010, nullptr, "RequestReceiveApplication"},
229 {2011, nullptr, "CommitReceiveApplication"},
230 {2012, nullptr, "GetReceiveApplicationProgress"},
231 {2013, nullptr, "RequestSendApplication"},
232 {2014, nullptr, "GetSendApplicationProgress"},
233 {2015, nullptr, "CompareSystemDeliveryInfo"},
234 {2016, nullptr, "ListNotCommittedContentMeta"},
235 {2017, nullptr, "CreateDownloadTask"},
236 {2018, nullptr, "GetApplicationDeliveryInfoHash"},
237 {2050, D<&IApplicationManagerInterface::GetApplicationRightsOnClient>, "GetApplicationRightsOnClient"},
238 {2051, nullptr, "InvalidateRightsIdCache"},
239 {2100, D<&IApplicationManagerInterface::GetApplicationTerminateResult>, "GetApplicationTerminateResult"},
240 {2101, nullptr, "GetRawApplicationTerminateResult"},
241 {2150, nullptr, "CreateRightsEnvironment"},
242 {2151, nullptr, "DestroyRightsEnvironment"},
243 {2152, nullptr, "ActivateRightsEnvironment"},
244 {2153, nullptr, "DeactivateRightsEnvironment"},
245 {2154, nullptr, "ForceActivateRightsContextForExit"},
246 {2155, nullptr, "UpdateRightsEnvironmentStatus"},
247 {2156, nullptr, "CreateRightsEnvironmentForMicroApplication"},
248 {2160, nullptr, "AddTargetApplicationToRightsEnvironment"},
249 {2161, nullptr, "SetUsersToRightsEnvironment"},
250 {2170, nullptr, "GetRightsEnvironmentStatus"},
251 {2171, nullptr, "GetRightsEnvironmentStatusChangedEvent"},
252 {2180, nullptr, "RequestExtendRightsInRightsEnvironment"},
253 {2181, nullptr, "GetResultOfExtendRightsInRightsEnvironment"},
254 {2182, nullptr, "SetActiveRightsContextUsingStateToRightsEnvironment"},
255 {2190, nullptr, "GetRightsEnvironmentHandleForApplication"},
256 {2199, nullptr, "GetRightsEnvironmentCountForDebug"},
257 {2200, nullptr, "GetGameCardApplicationCopyIdentifier"},
258 {2201, nullptr, "GetInstalledApplicationCopyIdentifier"},
259 {2250, nullptr, "RequestReportActiveELicence"},
260 {2300, nullptr, "ListEventLog"},
261 {2350, nullptr, "PerformAutoUpdateByApplicationId"},
262 {2351, nullptr, "RequestNoDownloadRightsErrorResolution"},
263 {2352, nullptr, "RequestResolveNoDownloadRightsError"},
264 {2353, nullptr, "GetApplicationDownloadTaskInfo"},
265 {2354, nullptr, "PrioritizeApplicationBackgroundTask"},
266 {2355, nullptr, "PreferStorageEfficientUpdate"},
267 {2356, nullptr, "RequestStorageEfficientUpdatePreferable"},
268 {2357, nullptr, "EnableMultiCoreDownload"},
269 {2358, nullptr, "DisableMultiCoreDownload"},
270 {2359, nullptr, "IsMultiCoreDownloadEnabled"},
271 {2400, nullptr, "GetPromotionInfo"},
272 {2401, nullptr, "CountPromotionInfo"},
273 {2402, nullptr, "ListPromotionInfo"},
274 {2403, nullptr, "ImportPromotionJsonForDebug"},
275 {2404, nullptr, "ClearPromotionInfoForDebug"},
276 {2500, nullptr, "ConfirmAvailableTime"},
277 {2510, nullptr, "CreateApplicationResource"},
278 {2511, nullptr, "GetApplicationResource"},
279 {2513, nullptr, "LaunchMicroApplication"},
280 {2514, nullptr, "ClearTaskOfAsyncTaskManager"},
281 {2515, nullptr, "CleanupAllPlaceHolderAndFragmentsIfNoTask"},
282 {2516, nullptr, "EnsureApplicationCertificate"},
283 {2517, nullptr, "CreateApplicationInstance"},
284 {2518, nullptr, "UpdateQualificationForDebug"},
285 {2519, nullptr, "IsQualificationTransitionSupported"},
286 {2520, nullptr, "IsQualificationTransitionSupportedByProcessId"},
287 {2521, nullptr, "GetRightsUserChangedEvent"},
288 {2522, nullptr, "IsRomRedirectionAvailable"},
289 {2800, nullptr, "GetApplicationIdOfPreomia"},
290 {3000, nullptr, "RegisterDeviceLockKey"},
291 {3001, nullptr, "UnregisterDeviceLockKey"},
292 {3002, nullptr, "VerifyDeviceLockKey"},
293 {3003, nullptr, "HideApplicationIcon"},
294 {3004, nullptr, "ShowApplicationIcon"},
295 {3005, nullptr, "HideApplicationTitle"},
296 {3006, nullptr, "ShowApplicationTitle"},
297 {3007, nullptr, "EnableGameCard"},
298 {3008, nullptr, "DisableGameCard"},
299 {3009, nullptr, "EnableLocalContentShare"},
300 {3010, nullptr, "DisableLocalContentShare"},
301 {3011, nullptr, "IsApplicationIconHidden"},
302 {3012, nullptr, "IsApplicationTitleHidden"},
303 {3013, nullptr, "IsGameCardEnabled"},
304 {3014, nullptr, "IsLocalContentShareEnabled"},
305 {3050, nullptr, "ListAssignELicenseTaskResult"},
306 {9999, nullptr, "GetApplicationCertificate"},
307 };
308 // clang-format on
309
310 RegisterHandlers(functions);
311}
312
313IApplicationManagerInterface::~IApplicationManagerInterface() = default;
314
315Result IApplicationManagerInterface::GetApplicationControlData(
316 OutBuffer<BufferAttr_HipcMapAlias> out_buffer, Out<u32> out_actual_size,
317 ApplicationControlSource application_control_source, u64 application_id) {
318 LOG_DEBUG(Service_NS, "called");
319 R_RETURN(IReadOnlyApplicationControlDataInterface(system).GetApplicationControlData(
320 out_buffer, out_actual_size, application_control_source, application_id));
321}
322
323Result IApplicationManagerInterface::GetApplicationDesiredLanguage(
324 Out<ApplicationLanguage> out_desired_language, u32 supported_languages) {
325 LOG_DEBUG(Service_NS, "called");
326 R_RETURN(IReadOnlyApplicationControlDataInterface(system).GetApplicationDesiredLanguage(
327 out_desired_language, supported_languages));
328}
329
330Result IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode(
331 Out<u64> out_language_code, ApplicationLanguage application_language) {
332 LOG_DEBUG(Service_NS, "called");
333 R_RETURN(
334 IReadOnlyApplicationControlDataInterface(system).ConvertApplicationLanguageToLanguageCode(
335 out_language_code, application_language));
336}
337
338Result IApplicationManagerInterface::ListApplicationRecord(
339 OutArray<ApplicationRecord, BufferAttr_HipcMapAlias> out_records, Out<s32> out_count,
340 s32 offset) {
341 const auto limit = out_records.size();
342
343 LOG_WARNING(Service_NS, "(STUBBED) called");
344 const auto& cache = system.GetContentProviderUnion();
345 const auto installed_games = cache.ListEntriesFilterOrigin(
346 std::nullopt, FileSys::TitleType::Application, FileSys::ContentRecordType::Program);
347
348 size_t i = 0;
349 u8 ii = 24;
350
351 for (const auto& [slot, game] : installed_games) {
352 if (i >= limit) {
353 break;
354 }
355 if (game.title_id == 0 || game.title_id < 0x0100000000001FFFull) {
356 continue;
357 }
358 if (offset > 0) {
359 offset--;
360 continue;
361 }
362
363 ApplicationRecord record{};
364 record.application_id = game.title_id;
365 record.type = ApplicationRecordType::Installed;
366 record.unknown = 0; // 2 = needs update
367 record.unknown2 = ii++;
368
369 out_records[i++] = record;
370 }
371
372 *out_count = static_cast<s32>(i);
373 R_SUCCEED();
374}
375
376Result IApplicationManagerInterface::GetApplicationRecordUpdateSystemEvent(
377 OutCopyHandle<Kernel::KReadableEvent> out_event) {
378 LOG_WARNING(Service_NS, "(STUBBED) called");
379
380 record_update_system_event.Signal();
381 *out_event = record_update_system_event.GetHandle();
382
383 R_SUCCEED();
384}
385
386Result IApplicationManagerInterface::GetGameCardMountFailureEvent(
387 OutCopyHandle<Kernel::KReadableEvent> out_event) {
388 LOG_WARNING(Service_NS, "(STUBBED) called");
389 *out_event = gamecard_mount_failure_event.GetHandle();
390 R_SUCCEED();
391}
392
393Result IApplicationManagerInterface::IsAnyApplicationEntityInstalled(
394 Out<bool> out_is_any_application_entity_installed) {
395 LOG_WARNING(Service_NS, "(STUBBED) called");
396 *out_is_any_application_entity_installed = true;
397 R_SUCCEED();
398}
399
400Result IApplicationManagerInterface::GetApplicationView(
401 OutArray<ApplicationView, BufferAttr_HipcMapAlias> out_application_views,
402 InArray<u64, BufferAttr_HipcMapAlias> application_ids) {
403 const auto size = std::min(out_application_views.size(), application_ids.size());
404 LOG_WARNING(Service_NS, "(STUBBED) called, size={}", application_ids.size());
405
406 for (size_t i = 0; i < size; i++) {
407 ApplicationView view{};
408 view.application_id = application_ids[i];
409 view.unk = 0x70000;
410 view.flags = 0x401f17;
411
412 out_application_views[i] = view;
413 }
414
415 R_SUCCEED();
416}
417
418Result IApplicationManagerInterface::GetApplicationViewWithPromotionInfo(
419 OutArray<ApplicationViewWithPromotionInfo, BufferAttr_HipcMapAlias> out_application_views,
420 InArray<u64, BufferAttr_HipcMapAlias> application_ids) {
421 const auto size = std::min(out_application_views.size(), application_ids.size());
422 LOG_WARNING(Service_NS, "(STUBBED) called, size={}", application_ids.size());
423
424 for (size_t i = 0; i < size; i++) {
425 ApplicationViewWithPromotionInfo view{};
426 view.view.application_id = application_ids[i];
427 view.view.unk = 0x70000;
428 view.view.flags = 0x401f17;
429 view.promotion = {};
430
431 out_application_views[i] = view;
432 }
433
434 R_SUCCEED();
435}
436
437Result IApplicationManagerInterface::GetApplicationRightsOnClient(
438 OutArray<ApplicationRightsOnClient, BufferAttr_HipcMapAlias> out_rights, Out<u32> out_count,
439 Common::UUID account_id, u32 flags, u64 application_id) {
440 LOG_WARNING(Service_NS, "(STUBBED) called, flags={}, application_id={:016X}, account_id={}",
441 flags, application_id, account_id.FormattedString());
442
443 if (!out_rights.empty()) {
444 ApplicationRightsOnClient rights{};
445 rights.application_id = application_id;
446 rights.uid = account_id;
447 rights.flags = 0;
448 rights.flags2 = 0;
449
450 out_rights[0] = rights;
451 *out_count = 1;
452 } else {
453 *out_count = 0;
454 }
455
456 R_SUCCEED();
457}
458
459Result IApplicationManagerInterface::CheckSdCardMountStatus() {
460 LOG_DEBUG(Service_NS, "called");
461 R_RETURN(IContentManagementInterface(system).CheckSdCardMountStatus());
462}
463
464Result IApplicationManagerInterface::GetSdCardMountStatusChangedEvent(
465 OutCopyHandle<Kernel::KReadableEvent> out_event) {
466 LOG_WARNING(Service_NS, "(STUBBED) called");
467 *out_event = sd_card_mount_status_event.GetHandle();
468 R_SUCCEED();
469}
470
471Result IApplicationManagerInterface::GetFreeSpaceSize(Out<s64> out_free_space_size,
472 FileSys::StorageId storage_id) {
473 LOG_DEBUG(Service_NS, "called");
474 R_RETURN(IContentManagementInterface(system).GetFreeSpaceSize(out_free_space_size, storage_id));
475}
476
477Result IApplicationManagerInterface::GetGameCardUpdateDetectionEvent(
478 OutCopyHandle<Kernel::KReadableEvent> out_event) {
479 LOG_WARNING(Service_NS, "(STUBBED) called");
480 *out_event = gamecard_update_detection_event.GetHandle();
481 R_SUCCEED();
482}
483
484Result IApplicationManagerInterface::ResumeAll() {
485 LOG_WARNING(Service_NS, "(STUBBED) called");
486 R_SUCCEED();
487}
488
489Result IApplicationManagerInterface::GetStorageSize(Out<s64> out_total_space_size,
490 Out<s64> out_free_space_size,
491 FileSys::StorageId storage_id) {
492 LOG_INFO(Service_NS, "called, storage_id={}", storage_id);
493 *out_total_space_size = system.GetFileSystemController().GetTotalSpaceSize(storage_id);
494 *out_free_space_size = system.GetFileSystemController().GetFreeSpaceSize(storage_id);
495 R_SUCCEED();
496}
497
498Result IApplicationManagerInterface::IsApplicationUpdateRequested(Out<bool> out_update_required,
499 Out<u32> out_update_version,
500 u64 application_id) {
501 LOG_WARNING(Service_NS, "(STUBBED) called. application_id={:016X}", application_id);
502 *out_update_required = false;
503 *out_update_version = 0;
504 R_SUCCEED();
505}
506
507Result IApplicationManagerInterface::CheckApplicationLaunchVersion(u64 application_id) {
508 LOG_WARNING(Service_NS, "(STUBBED) called. application_id={:016X}", application_id);
509 R_SUCCEED();
510}
511
512Result IApplicationManagerInterface::GetApplicationTerminateResult(Out<Result> out_result,
513 u64 application_id) {
514 LOG_WARNING(Service_NS, "(STUBBED) called. application_id={:016X}", application_id);
515 *out_result = ResultSuccess;
516 R_SUCCEED();
517}
518
519} // namespace Service::NS
diff --git a/src/core/hle/service/ns/application_manager_interface.h b/src/core/hle/service/ns/application_manager_interface.h
new file mode 100644
index 000000000..350ec37ce
--- /dev/null
+++ b/src/core/hle/service/ns/application_manager_interface.h
@@ -0,0 +1,62 @@
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/ns/language.h"
8#include "core/hle/service/ns/ns_types.h"
9#include "core/hle/service/os/event.h"
10#include "core/hle/service/service.h"
11
12namespace Service::NS {
13
14class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> {
15public:
16 explicit IApplicationManagerInterface(Core::System& system_);
17 ~IApplicationManagerInterface() override;
18
19 Result GetApplicationControlData(OutBuffer<BufferAttr_HipcMapAlias> out_buffer,
20 Out<u32> out_actual_size,
21 ApplicationControlSource application_control_source,
22 u64 application_id);
23 Result GetApplicationDesiredLanguage(Out<ApplicationLanguage> out_desired_language,
24 u32 supported_languages);
25 Result ConvertApplicationLanguageToLanguageCode(Out<u64> out_language_code,
26 ApplicationLanguage application_language);
27 Result ListApplicationRecord(OutArray<ApplicationRecord, BufferAttr_HipcMapAlias> out_records,
28 Out<s32> out_count, s32 offset);
29 Result GetApplicationRecordUpdateSystemEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
30 Result GetGameCardMountFailureEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
31 Result IsAnyApplicationEntityInstalled(Out<bool> out_is_any_application_entity_installed);
32 Result GetApplicationView(
33 OutArray<ApplicationView, BufferAttr_HipcMapAlias> out_application_views,
34 InArray<u64, BufferAttr_HipcMapAlias> application_ids);
35 Result GetApplicationViewWithPromotionInfo(
36 OutArray<ApplicationViewWithPromotionInfo, BufferAttr_HipcMapAlias> out_application_views,
37 InArray<u64, BufferAttr_HipcMapAlias> application_ids);
38 Result GetApplicationRightsOnClient(
39 OutArray<ApplicationRightsOnClient, BufferAttr_HipcMapAlias> out_rights, Out<u32> out_count,
40 Common::UUID account_id, u32 flags, u64 application_id);
41 Result CheckSdCardMountStatus();
42 Result GetSdCardMountStatusChangedEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
43 Result GetFreeSpaceSize(Out<s64> out_free_space_size, FileSys::StorageId storage_id);
44 Result GetGameCardUpdateDetectionEvent(OutCopyHandle<Kernel::KReadableEvent> out_event);
45 Result ResumeAll();
46 Result GetStorageSize(Out<s64> out_total_space_size, Out<s64> out_free_space_size,
47 FileSys::StorageId storage_id);
48 Result IsApplicationUpdateRequested(Out<bool> out_update_required, Out<u32> out_update_version,
49 u64 application_id);
50 Result CheckApplicationLaunchVersion(u64 application_id);
51 Result GetApplicationTerminateResult(Out<Result> out_result, u64 application_id);
52
53private:
54 KernelHelpers::ServiceContext service_context;
55 Event record_update_system_event;
56 Event sd_card_mount_status_event;
57 Event gamecard_update_detection_event;
58 Event gamecard_mount_status_event;
59 Event gamecard_mount_failure_event;
60};
61
62} // namespace Service::NS
diff --git a/src/core/hle/service/ns/application_version_interface.cpp b/src/core/hle/service/ns/application_version_interface.cpp
new file mode 100644
index 000000000..b89e127db
--- /dev/null
+++ b/src/core/hle/service/ns/application_version_interface.cpp
@@ -0,0 +1,33 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/ns/application_version_interface.h"
5
6namespace Service::NS {
7
8IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_)
9 : ServiceFramework{system_, "IApplicationVersionInterface"} {
10 // clang-format off
11 static const FunctionInfo functions[] = {
12 {0, nullptr, "GetLaunchRequiredVersion"},
13 {1, nullptr, "UpgradeLaunchRequiredVersion"},
14 {35, nullptr, "UpdateVersionList"},
15 {36, nullptr, "PushLaunchVersion"},
16 {37, nullptr, "ListRequiredVersion"},
17 {800, nullptr, "RequestVersionList"},
18 {801, nullptr, "ListVersionList"},
19 {802, nullptr, "RequestVersionListData"},
20 {900, nullptr, "ImportAutoUpdatePolicyJsonForDebug"},
21 {901, nullptr, "ListDefaultAutoUpdatePolicy"},
22 {902, nullptr, "ListAutoUpdatePolicyForSpecificApplication"},
23 {1000, nullptr, "PerformAutoUpdate"},
24 {1001, nullptr, "ListAutoUpdateSchedule"},
25 };
26 // clang-format on
27
28 RegisterHandlers(functions);
29}
30
31IApplicationVersionInterface::~IApplicationVersionInterface() = default;
32
33} // namespace Service::NS
diff --git a/src/core/hle/service/ns/application_version_interface.h b/src/core/hle/service/ns/application_version_interface.h
new file mode 100644
index 000000000..b288cff1b
--- /dev/null
+++ b/src/core/hle/service/ns/application_version_interface.h
@@ -0,0 +1,16 @@
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/service.h"
7
8namespace Service::NS {
9
10class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> {
11public:
12 explicit IApplicationVersionInterface(Core::System& system_);
13 ~IApplicationVersionInterface() override;
14};
15
16} // namespace Service::NS
diff --git a/src/core/hle/service/ns/content_management_interface.cpp b/src/core/hle/service/ns/content_management_interface.cpp
new file mode 100644
index 000000000..69bb3f6e4
--- /dev/null
+++ b/src/core/hle/service/ns/content_management_interface.cpp
@@ -0,0 +1,72 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/common_funcs.h"
5#include "core/core.h"
6#include "core/hle/service/cmif_serialization.h"
7#include "core/hle/service/filesystem/filesystem.h"
8#include "core/hle/service/ns/content_management_interface.h"
9#include "core/hle/service/ns/ns_types.h"
10
11namespace Service::NS {
12
13IContentManagementInterface::IContentManagementInterface(Core::System& system_)
14 : ServiceFramework{system_, "IContentManagementInterface"} {
15 // clang-format off
16 static const FunctionInfo functions[] = {
17 {11, D<&IContentManagementInterface::CalculateApplicationOccupiedSize>, "CalculateApplicationOccupiedSize"},
18 {43, D<&IContentManagementInterface::CheckSdCardMountStatus>, "CheckSdCardMountStatus"},
19 {47, D<&IContentManagementInterface::GetTotalSpaceSize>, "GetTotalSpaceSize"},
20 {48, D<&IContentManagementInterface::GetFreeSpaceSize>, "GetFreeSpaceSize"},
21 {600, nullptr, "CountApplicationContentMeta"},
22 {601, nullptr, "ListApplicationContentMetaStatus"},
23 {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"},
24 {607, nullptr, "IsAnyApplicationRunning"},
25 };
26 // clang-format on
27
28 RegisterHandlers(functions);
29}
30
31IContentManagementInterface::~IContentManagementInterface() = default;
32
33Result IContentManagementInterface::CalculateApplicationOccupiedSize(
34 Out<ApplicationOccupiedSize> out_size, u64 application_id) {
35 LOG_WARNING(Service_NS, "(STUBBED) called, application_id={:016X}", application_id);
36
37 using namespace Common::Literals;
38
39 constexpr ApplicationOccupiedSizeEntity stub_entity{
40 .storage_id = FileSys::StorageId::SdCard,
41 .app_size = 8_GiB,
42 .patch_size = 2_GiB,
43 .aoc_size = 12_MiB,
44 };
45
46 for (auto& entity : out_size->entities) {
47 entity = stub_entity;
48 }
49
50 R_SUCCEED();
51}
52
53Result IContentManagementInterface::CheckSdCardMountStatus() {
54 LOG_WARNING(Service_NS, "(STUBBED) called");
55 R_SUCCEED();
56}
57
58Result IContentManagementInterface::GetTotalSpaceSize(Out<s64> out_total_space_size,
59 FileSys::StorageId storage_id) {
60 LOG_INFO(Service_NS, "(STUBBED) called, storage_id={}", storage_id);
61 *out_total_space_size = system.GetFileSystemController().GetTotalSpaceSize(storage_id);
62 R_SUCCEED();
63}
64
65Result IContentManagementInterface::GetFreeSpaceSize(Out<s64> out_free_space_size,
66 FileSys::StorageId storage_id) {
67 LOG_INFO(Service_NS, "(STUBBED) called, storage_id={}", storage_id);
68 *out_free_space_size = system.GetFileSystemController().GetFreeSpaceSize(storage_id);
69 R_SUCCEED();
70}
71
72} // namespace Service::NS
diff --git a/src/core/hle/service/ns/content_management_interface.h b/src/core/hle/service/ns/content_management_interface.h
new file mode 100644
index 000000000..2894628e5
--- /dev/null
+++ b/src/core/hle/service/ns/content_management_interface.h
@@ -0,0 +1,25 @@
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/ns/ns_types.h"
8#include "core/hle/service/service.h"
9
10namespace Service::NS {
11
12class IContentManagementInterface final : public ServiceFramework<IContentManagementInterface> {
13public:
14 explicit IContentManagementInterface(Core::System& system_);
15 ~IContentManagementInterface() override;
16
17public:
18 Result CalculateApplicationOccupiedSize(Out<ApplicationOccupiedSize> out_size,
19 u64 application_id);
20 Result CheckSdCardMountStatus();
21 Result GetTotalSpaceSize(Out<s64> out_total_space_size, FileSys::StorageId storage_id);
22 Result GetFreeSpaceSize(Out<s64> out_free_space_size, FileSys::StorageId storage_id);
23};
24
25} // namespace Service::NS
diff --git a/src/core/hle/service/ns/develop_interface.cpp b/src/core/hle/service/ns/develop_interface.cpp
new file mode 100644
index 000000000..880bdbebb
--- /dev/null
+++ b/src/core/hle/service/ns/develop_interface.cpp
@@ -0,0 +1,38 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/ns/develop_interface.h"
5
6namespace Service::NS {
7
8IDevelopInterface::IDevelopInterface(Core::System& system_) : ServiceFramework{system_, "ns:dev"} {
9 // clang-format off
10 static const FunctionInfo functions[] = {
11 {0, nullptr, "LaunchProgram"},
12 {1, nullptr, "TerminateProcess"},
13 {2, nullptr, "TerminateProgram"},
14 {4, nullptr, "GetShellEvent"},
15 {5, nullptr, "GetShellEventInfo"},
16 {6, nullptr, "TerminateApplication"},
17 {7, nullptr, "PrepareLaunchProgramFromHost"},
18 {8, nullptr, "LaunchApplicationFromHost"},
19 {9, nullptr, "LaunchApplicationWithStorageIdForDevelop"},
20 {10, nullptr, "IsSystemMemoryResourceLimitBoosted"},
21 {11, nullptr, "GetRunningApplicationProcessIdForDevelop"},
22 {12, nullptr, "SetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop"},
23 {13, nullptr, "CreateApplicationResourceForDevelop"},
24 {14, nullptr, "IsPreomiaForDevelop"},
25 {15, nullptr, "GetApplicationProgramIdFromHost"},
26 {16, nullptr, "RefreshCachedDebugValues"},
27 {17, nullptr, "PrepareLaunchApplicationFromHost"},
28 {18, nullptr, "GetLaunchEvent"},
29 {19, nullptr, "GetLaunchResult"},
30 };
31 // clang-format on
32
33 RegisterHandlers(functions);
34}
35
36IDevelopInterface::~IDevelopInterface() = default;
37
38} // namespace Service::NS
diff --git a/src/core/hle/service/ns/develop_interface.h b/src/core/hle/service/ns/develop_interface.h
new file mode 100644
index 000000000..a9f81ccd6
--- /dev/null
+++ b/src/core/hle/service/ns/develop_interface.h
@@ -0,0 +1,16 @@
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/service.h"
7
8namespace Service::NS {
9
10class IDevelopInterface final : public ServiceFramework<IDevelopInterface> {
11public:
12 explicit IDevelopInterface(Core::System& system_);
13 ~IDevelopInterface() override;
14};
15
16} // namespace Service::NS
diff --git a/src/core/hle/service/ns/document_interface.cpp b/src/core/hle/service/ns/document_interface.cpp
new file mode 100644
index 000000000..51a1e46c0
--- /dev/null
+++ b/src/core/hle/service/ns/document_interface.cpp
@@ -0,0 +1,38 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/core.h"
5#include "core/hle/service/cmif_serialization.h"
6#include "core/hle/service/ns/document_interface.h"
7
8namespace Service::NS {
9
10IDocumentInterface::IDocumentInterface(Core::System& system_)
11 : ServiceFramework{system_, "IDocumentInterface"} {
12 // clang-format off
13 static const FunctionInfo functions[] = {
14 {21, nullptr, "GetApplicationContentPath"},
15 {23, D<&IDocumentInterface::ResolveApplicationContentPath>, "ResolveApplicationContentPath"},
16 {92, D<&IDocumentInterface::GetRunningApplicationProgramId>, "GetRunningApplicationProgramId"},
17 };
18 // clang-format on
19
20 RegisterHandlers(functions);
21}
22
23IDocumentInterface::~IDocumentInterface() = default;
24
25Result IDocumentInterface::ResolveApplicationContentPath(ContentPath content_path) {
26 LOG_WARNING(Service_NS, "(STUBBED) called, file_system_proxy_type={}, program_id={:016X}",
27 content_path.file_system_proxy_type, content_path.program_id);
28 R_SUCCEED();
29}
30
31Result IDocumentInterface::GetRunningApplicationProgramId(Out<u64> out_program_id,
32 u64 caller_program_id) {
33 LOG_WARNING(Service_NS, "(STUBBED) called, caller_program_id={:016X}", caller_program_id);
34 *out_program_id = system.GetApplicationProcessProgramID();
35 R_SUCCEED();
36}
37
38} // namespace Service::NS
diff --git a/src/core/hle/service/ns/document_interface.h b/src/core/hle/service/ns/document_interface.h
new file mode 100644
index 000000000..cd461652c
--- /dev/null
+++ b/src/core/hle/service/ns/document_interface.h
@@ -0,0 +1,22 @@
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/ns/ns_types.h"
8#include "core/hle/service/service.h"
9
10namespace Service::NS {
11
12class IDocumentInterface final : public ServiceFramework<IDocumentInterface> {
13public:
14 explicit IDocumentInterface(Core::System& system_);
15 ~IDocumentInterface() override;
16
17private:
18 Result ResolveApplicationContentPath(ContentPath content_path);
19 Result GetRunningApplicationProgramId(Out<u64> out_program_id, u64 caller_program_id);
20};
21
22} // namespace Service::NS
diff --git a/src/core/hle/service/ns/download_task_interface.cpp b/src/core/hle/service/ns/download_task_interface.cpp
new file mode 100644
index 000000000..62dc7f187
--- /dev/null
+++ b/src/core/hle/service/ns/download_task_interface.cpp
@@ -0,0 +1,39 @@
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/download_task_interface.h"
6
7namespace Service::NS {
8
9IDownloadTaskInterface::IDownloadTaskInterface(Core::System& system_)
10 : ServiceFramework{system_, "IDownloadTaskInterface"} {
11 // clang-format off
12 static const FunctionInfo functions[] = {
13 {701, nullptr, "ClearTaskStatusList"},
14 {702, nullptr, "RequestDownloadTaskList"},
15 {703, nullptr, "RequestEnsureDownloadTask"},
16 {704, nullptr, "ListDownloadTaskStatus"},
17 {705, nullptr, "RequestDownloadTaskListData"},
18 {706, nullptr, "TryCommitCurrentApplicationDownloadTask"},
19 {707, D<&IDownloadTaskInterface::EnableAutoCommit>, "EnableAutoCommit"},
20 {708, D<&IDownloadTaskInterface::DisableAutoCommit>, "DisableAutoCommit"},
21 {709, nullptr, "TriggerDynamicCommitEvent"},
22 };
23 // clang-format on
24
25 RegisterHandlers(functions);
26}
27
28IDownloadTaskInterface::~IDownloadTaskInterface() = default;
29
30Result IDownloadTaskInterface::EnableAutoCommit() {
31 LOG_WARNING(Service_NS, "(STUBBED) called");
32 R_SUCCEED();
33}
34Result IDownloadTaskInterface::DisableAutoCommit() {
35 LOG_WARNING(Service_NS, "(STUBBED) called");
36 R_SUCCEED();
37}
38
39} // namespace Service::NS
diff --git a/src/core/hle/service/ns/download_task_interface.h b/src/core/hle/service/ns/download_task_interface.h
new file mode 100644
index 000000000..b1cb69cb8
--- /dev/null
+++ b/src/core/hle/service/ns/download_task_interface.h
@@ -0,0 +1,20 @@
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/service.h"
7
8namespace Service::NS {
9
10class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> {
11public:
12 explicit IDownloadTaskInterface(Core::System& system_);
13 ~IDownloadTaskInterface() override;
14
15private:
16 Result EnableAutoCommit();
17 Result DisableAutoCommit();
18};
19
20} // namespace Service::NS
diff --git a/src/core/hle/service/ns/dynamic_rights_interface.cpp b/src/core/hle/service/ns/dynamic_rights_interface.cpp
new file mode 100644
index 000000000..ce81e203f
--- /dev/null
+++ b/src/core/hle/service/ns/dynamic_rights_interface.cpp
@@ -0,0 +1,62 @@
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/dynamic_rights_interface.h"
6
7namespace Service::NS {
8
9IDynamicRightsInterface::IDynamicRightsInterface(Core::System& system_)
10 : ServiceFramework{system_, "DynamicRightsInterface"} {
11 // clang-format off
12 static const FunctionInfo functions[] = {
13 {0, nullptr, "RequestApplicationRightsOnServer"},
14 {1, nullptr, "RequestAssignRights"},
15 {4, nullptr, "DeprecatedRequestAssignRightsToResume"},
16 {5, D<&IDynamicRightsInterface::VerifyActivatedRightsOwners>, "VerifyActivatedRightsOwners"},
17 {6, nullptr, "DeprecatedGetApplicationRightsStatus"},
18 {7, nullptr, "RequestPrefetchForDynamicRights"},
19 {8, nullptr, "GetDynamicRightsState"},
20 {9, nullptr, "RequestApplicationRightsOnServerToResume"},
21 {10, nullptr, "RequestAssignRightsToResume"},
22 {11, nullptr, "GetActivatedRightsUsers"},
23 {12, nullptr, "GetApplicationRightsStatus"},
24 {13, D<&IDynamicRightsInterface::GetRunningApplicationStatus>, "GetRunningApplicationStatus"},
25 {14, nullptr, "SelectApplicationLicense"},
26 {15, nullptr, "RequestContentsAuthorizationToken"},
27 {16, nullptr, "QualifyUser"},
28 {17, nullptr, "QualifyUserWithProcessId"},
29 {18, D<&IDynamicRightsInterface::NotifyApplicationRightsCheckStart>, "NotifyApplicationRightsCheckStart"},
30 {19, nullptr, "UpdateUserList"},
31 {20, nullptr, "IsRightsLostUser"},
32 {21, nullptr, "SetRequiredAddOnContentsOnContentsAvailabilityTransition"},
33 {22, nullptr, "GetLimitedApplicationLicense"},
34 {23, nullptr, "GetLimitedApplicationLicenseUpgradableEvent"},
35 {24, nullptr, "NotifyLimitedApplicationLicenseUpgradableEventForDebug"},
36 {25, nullptr, "RequestProceedDynamicRightsState"},
37 };
38 // clang-format on
39
40 RegisterHandlers(functions);
41}
42
43IDynamicRightsInterface::~IDynamicRightsInterface() = default;
44
45Result IDynamicRightsInterface::NotifyApplicationRightsCheckStart() {
46 LOG_WARNING(Service_NS, "(STUBBED) called");
47 R_SUCCEED();
48}
49
50Result IDynamicRightsInterface::GetRunningApplicationStatus(Out<u32> out_status,
51 u64 rights_handle) {
52 LOG_WARNING(Service_NS, "(STUBBED) called, rights_handle={:#x}", rights_handle);
53 *out_status = 0;
54 R_SUCCEED();
55}
56
57Result IDynamicRightsInterface::VerifyActivatedRightsOwners(u64 rights_handle) {
58 LOG_WARNING(Service_NS, "(STUBBED) called, rights_handle={:#x}", rights_handle);
59 R_SUCCEED();
60}
61
62} // namespace Service::NS
diff --git a/src/core/hle/service/ns/dynamic_rights_interface.h b/src/core/hle/service/ns/dynamic_rights_interface.h
new file mode 100644
index 000000000..877e009b0
--- /dev/null
+++ b/src/core/hle/service/ns/dynamic_rights_interface.h
@@ -0,0 +1,22 @@
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 final : public ServiceFramework<IDynamicRightsInterface> {
12public:
13 explicit IDynamicRightsInterface(Core::System& system_);
14 ~IDynamicRightsInterface() override;
15
16private:
17 Result NotifyApplicationRightsCheckStart();
18 Result GetRunningApplicationStatus(Out<u32> out_status, u64 rights_handle);
19 Result VerifyActivatedRightsOwners(u64 rights_handle);
20};
21
22} // namespace Service::NS
diff --git a/src/core/hle/service/ns/ecommerce_interface.cpp b/src/core/hle/service/ns/ecommerce_interface.cpp
new file mode 100644
index 000000000..76fc425f0
--- /dev/null
+++ b/src/core/hle/service/ns/ecommerce_interface.cpp
@@ -0,0 +1,27 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/ns/ecommerce_interface.h"
5
6namespace Service::NS {
7
8IECommerceInterface::IECommerceInterface(Core::System& system_)
9 : ServiceFramework{system_, "IECommerceInterface"} {
10 // clang-format off
11 static const FunctionInfo functions[] = {
12 {0, nullptr, "RequestLinkDevice"},
13 {1, nullptr, "RequestCleanupAllPreInstalledApplications"},
14 {2, nullptr, "RequestCleanupPreInstalledApplication"},
15 {3, nullptr, "RequestSyncRights"},
16 {4, nullptr, "RequestUnlinkDevice"},
17 {5, nullptr, "RequestRevokeAllELicense"},
18 {6, nullptr, "RequestSyncRightsBasedOnAssignedELicenses"},
19 };
20 // clang-format on
21
22 RegisterHandlers(functions);
23}
24
25IECommerceInterface::~IECommerceInterface() = default;
26
27} // namespace Service::NS
diff --git a/src/core/hle/service/ns/ecommerce_interface.h b/src/core/hle/service/ns/ecommerce_interface.h
new file mode 100644
index 000000000..4352101f4
--- /dev/null
+++ b/src/core/hle/service/ns/ecommerce_interface.h
@@ -0,0 +1,16 @@
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/service.h"
7
8namespace Service::NS {
9
10class IECommerceInterface final : public ServiceFramework<IECommerceInterface> {
11public:
12 explicit IECommerceInterface(Core::System& system_);
13 ~IECommerceInterface() override;
14};
15
16} // namespace Service::NS
diff --git a/src/core/hle/service/ns/factory_reset_interface.cpp b/src/core/hle/service/ns/factory_reset_interface.cpp
new file mode 100644
index 000000000..fd5cf7e1f
--- /dev/null
+++ b/src/core/hle/service/ns/factory_reset_interface.cpp
@@ -0,0 +1,27 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "core/hle/service/ns/factory_reset_interface.h"
5
6namespace Service::NS {
7
8IFactoryResetInterface::IFactoryResetInterface(Core::System& system_)
9 : ServiceFramework{system_, "IFactoryResetInterface"} {
10 // clang-format off
11 static const FunctionInfo functions[] = {
12 {100, nullptr, "ResetToFactorySettings"},
13 {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"},
14 {102, nullptr, "ResetToFactorySettingsForRefurbishment"},
15 {103, nullptr, "ResetToFactorySettingsWithPlatformRegion"},
16 {104, nullptr, "ResetToFactorySettingsWithPlatformRegionAuthentication"},
17 {105, nullptr, "RequestResetToFactorySettingsSecurely"},
18 {106, nullptr, "RequestResetToFactorySettingsWithPlatformRegionAuthenticationSecurely"},
19 };
20 // clang-format on
21
22 RegisterHandlers(functions);
23}
24
25IFactoryResetInterface::~IFactoryResetInterface() = default;
26
27} // namespace Service::NS
diff --git a/src/core/hle/service/ns/factory_reset_interface.h b/src/core/hle/service/ns/factory_reset_interface.h
new file mode 100644
index 000000000..50d125123
--- /dev/null
+++ b/src/core/hle/service/ns/factory_reset_interface.h
@@ -0,0 +1,16 @@
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/service.h"
7
8namespace Service::NS {
9
10class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> {
11public:
12 explicit IFactoryResetInterface(Core::System& system_);
13 ~IFactoryResetInterface() override;
14};
15
16} // namespace Service::NS
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 19c3ff01b..8402e83cb 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -1,893 +1,38 @@
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" 4#include "core/hle/service/ns/develop_interface.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/errors.h"
15#include "core/hle/service/ns/iplatform_service_manager.h"
16#include "core/hle/service/ns/language.h"
17#include "core/hle/service/ns/ns.h" 5#include "core/hle/service/ns/ns.h"
18#include "core/hle/service/ns/pdm_qry.h" 6#include "core/hle/service/ns/platform_service_manager.h"
7#include "core/hle/service/ns/query_service.h"
8#include "core/hle/service/ns/service_getter_interface.h"
9#include "core/hle/service/ns/system_update_interface.h"
10#include "core/hle/service/ns/vulnerability_manager_interface.h"
19#include "core/hle/service/server_manager.h" 11#include "core/hle/service/server_manager.h"
20#include "core/hle/service/set/settings_server.h"
21 12
22namespace Service::NS { 13namespace Service::NS {
23 14
24IAccountProxyInterface::IAccountProxyInterface(Core::System& system_)
25 : ServiceFramework{system_, "IAccountProxyInterface"} {
26 // clang-format off
27 static const FunctionInfo functions[] = {
28 {0, nullptr, "CreateUserAccount"},
29 };
30 // clang-format on
31
32 RegisterHandlers(functions);
33}
34
35IAccountProxyInterface::~IAccountProxyInterface() = default;
36
37IApplicationManagerInterface::IApplicationManagerInterface(Core::System& system_)
38 : ServiceFramework{system_, "IApplicationManagerInterface"} {
39 // clang-format off
40 static const FunctionInfo functions[] = {
41 {0, nullptr, "ListApplicationRecord"},
42 {1, nullptr, "GenerateApplicationRecordCount"},
43 {2, nullptr, "GetApplicationRecordUpdateSystemEvent"},
44 {3, nullptr, "GetApplicationViewDeprecated"},
45 {4, nullptr, "DeleteApplicationEntity"},
46 {5, nullptr, "DeleteApplicationCompletely"},
47 {6, nullptr, "IsAnyApplicationEntityRedundant"},
48 {7, nullptr, "DeleteRedundantApplicationEntity"},
49 {8, nullptr, "IsApplicationEntityMovable"},
50 {9, nullptr, "MoveApplicationEntity"},
51 {11, nullptr, "CalculateApplicationOccupiedSize"},
52 {16, nullptr, "PushApplicationRecord"},
53 {17, nullptr, "ListApplicationRecordContentMeta"},
54 {19, nullptr, "LaunchApplicationOld"},
55 {21, nullptr, "GetApplicationContentPath"},
56 {22, nullptr, "TerminateApplication"},
57 {23, nullptr, "ResolveApplicationContentPath"},
58 {26, nullptr, "BeginInstallApplication"},
59 {27, nullptr, "DeleteApplicationRecord"},
60 {30, nullptr, "RequestApplicationUpdateInfo"},
61 {31, nullptr, "Unknown31"},
62 {32, nullptr, "CancelApplicationDownload"},
63 {33, nullptr, "ResumeApplicationDownload"},
64 {35, nullptr, "UpdateVersionList"},
65 {36, nullptr, "PushLaunchVersion"},
66 {37, nullptr, "ListRequiredVersion"},
67 {38, nullptr, "CheckApplicationLaunchVersion"},
68 {39, nullptr, "CheckApplicationLaunchRights"},
69 {40, nullptr, "GetApplicationLogoData"},
70 {41, nullptr, "CalculateApplicationDownloadRequiredSize"},
71 {42, nullptr, "CleanupSdCard"},
72 {43, nullptr, "CheckSdCardMountStatus"},
73 {44, nullptr, "GetSdCardMountStatusChangedEvent"},
74 {45, nullptr, "GetGameCardAttachmentEvent"},
75 {46, nullptr, "GetGameCardAttachmentInfo"},
76 {47, nullptr, "GetTotalSpaceSize"},
77 {48, nullptr, "GetFreeSpaceSize"},
78 {49, nullptr, "GetSdCardRemovedEvent"},
79 {52, nullptr, "GetGameCardUpdateDetectionEvent"},
80 {53, nullptr, "DisableApplicationAutoDelete"},
81 {54, nullptr, "EnableApplicationAutoDelete"},
82 {55, &IApplicationManagerInterface::GetApplicationDesiredLanguage, "GetApplicationDesiredLanguage"},
83 {56, nullptr, "SetApplicationTerminateResult"},
84 {57, nullptr, "ClearApplicationTerminateResult"},
85 {58, nullptr, "GetLastSdCardMountUnexpectedResult"},
86 {59, &IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode, "ConvertApplicationLanguageToLanguageCode"},
87 {60, nullptr, "ConvertLanguageCodeToApplicationLanguage"},
88 {61, nullptr, "GetBackgroundDownloadStressTaskInfo"},
89 {62, nullptr, "GetGameCardStopper"},
90 {63, nullptr, "IsSystemProgramInstalled"},
91 {64, nullptr, "StartApplyDeltaTask"},
92 {65, nullptr, "GetRequestServerStopper"},
93 {66, nullptr, "GetBackgroundApplyDeltaStressTaskInfo"},
94 {67, nullptr, "CancelApplicationApplyDelta"},
95 {68, nullptr, "ResumeApplicationApplyDelta"},
96 {69, nullptr, "CalculateApplicationApplyDeltaRequiredSize"},
97 {70, nullptr, "ResumeAll"},
98 {71, nullptr, "GetStorageSize"},
99 {80, nullptr, "RequestDownloadApplication"},
100 {81, nullptr, "RequestDownloadAddOnContent"},
101 {82, nullptr, "DownloadApplication"},
102 {83, nullptr, "CheckApplicationResumeRights"},
103 {84, nullptr, "GetDynamicCommitEvent"},
104 {85, nullptr, "RequestUpdateApplication2"},
105 {86, nullptr, "EnableApplicationCrashReport"},
106 {87, nullptr, "IsApplicationCrashReportEnabled"},
107 {90, nullptr, "BoostSystemMemoryResourceLimit"},
108 {91, nullptr, "DeprecatedLaunchApplication"},
109 {92, nullptr, "GetRunningApplicationProgramId"},
110 {93, nullptr, "GetMainApplicationProgramIndex"},
111 {94, nullptr, "LaunchApplication"},
112 {95, nullptr, "GetApplicationLaunchInfo"},
113 {96, nullptr, "AcquireApplicationLaunchInfo"},
114 {97, nullptr, "GetMainApplicationProgramIndexByApplicationLaunchInfo"},
115 {98, nullptr, "EnableApplicationAllThreadDumpOnCrash"},
116 {99, nullptr, "LaunchDevMenu"},
117 {100, nullptr, "ResetToFactorySettings"},
118 {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"},
119 {102, nullptr, "ResetToFactorySettingsForRefurbishment"},
120 {103, nullptr, "ResetToFactorySettingsWithPlatformRegion"},
121 {104, nullptr, "ResetToFactorySettingsWithPlatformRegionAuthentication"},
122 {105, nullptr, "RequestResetToFactorySettingsSecurely"},
123 {106, nullptr, "RequestResetToFactorySettingsWithPlatformRegionAuthenticationSecurely"},
124 {200, nullptr, "CalculateUserSaveDataStatistics"},
125 {201, nullptr, "DeleteUserSaveDataAll"},
126 {210, nullptr, "DeleteUserSystemSaveData"},
127 {211, nullptr, "DeleteSaveData"},
128 {220, nullptr, "UnregisterNetworkServiceAccount"},
129 {221, nullptr, "UnregisterNetworkServiceAccountWithUserSaveDataDeletion"},
130 {300, nullptr, "GetApplicationShellEvent"},
131 {301, nullptr, "PopApplicationShellEventInfo"},
132 {302, nullptr, "LaunchLibraryApplet"},
133 {303, nullptr, "TerminateLibraryApplet"},
134 {304, nullptr, "LaunchSystemApplet"},
135 {305, nullptr, "TerminateSystemApplet"},
136 {306, nullptr, "LaunchOverlayApplet"},
137 {307, nullptr, "TerminateOverlayApplet"},
138 {400, &IApplicationManagerInterface::GetApplicationControlData, "GetApplicationControlData"},
139 {401, nullptr, "InvalidateAllApplicationControlCache"},
140 {402, nullptr, "RequestDownloadApplicationControlData"},
141 {403, nullptr, "GetMaxApplicationControlCacheCount"},
142 {404, nullptr, "InvalidateApplicationControlCache"},
143 {405, nullptr, "ListApplicationControlCacheEntryInfo"},
144 {406, nullptr, "GetApplicationControlProperty"},
145 {407, nullptr, "ListApplicationTitle"},
146 {408, nullptr, "ListApplicationIcon"},
147 {502, nullptr, "RequestCheckGameCardRegistration"},
148 {503, nullptr, "RequestGameCardRegistrationGoldPoint"},
149 {504, nullptr, "RequestRegisterGameCard"},
150 {505, nullptr, "GetGameCardMountFailureEvent"},
151 {506, nullptr, "IsGameCardInserted"},
152 {507, nullptr, "EnsureGameCardAccess"},
153 {508, nullptr, "GetLastGameCardMountFailureResult"},
154 {509, nullptr, "ListApplicationIdOnGameCard"},
155 {510, nullptr, "GetGameCardPlatformRegion"},
156 {600, nullptr, "CountApplicationContentMeta"},
157 {601, nullptr, "ListApplicationContentMetaStatus"},
158 {602, nullptr, "ListAvailableAddOnContent"},
159 {603, nullptr, "GetOwnedApplicationContentMetaStatus"},
160 {604, nullptr, "RegisterContentsExternalKey"},
161 {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"},
162 {606, nullptr, "GetContentMetaStorage"},
163 {607, nullptr, "ListAvailableAddOnContent"},
164 {609, nullptr, "ListAvailabilityAssuredAddOnContent"},
165 {610, nullptr, "GetInstalledContentMetaStorage"},
166 {611, nullptr, "PrepareAddOnContent"},
167 {700, nullptr, "PushDownloadTaskList"},
168 {701, nullptr, "ClearTaskStatusList"},
169 {702, nullptr, "RequestDownloadTaskList"},
170 {703, nullptr, "RequestEnsureDownloadTask"},
171 {704, nullptr, "ListDownloadTaskStatus"},
172 {705, nullptr, "RequestDownloadTaskListData"},
173 {800, nullptr, "RequestVersionList"},
174 {801, nullptr, "ListVersionList"},
175 {802, nullptr, "RequestVersionListData"},
176 {900, nullptr, "GetApplicationRecord"},
177 {901, nullptr, "GetApplicationRecordProperty"},
178 {902, nullptr, "EnableApplicationAutoUpdate"},
179 {903, nullptr, "DisableApplicationAutoUpdate"},
180 {904, nullptr, "TouchApplication"},
181 {905, nullptr, "RequestApplicationUpdate"},
182 {906, nullptr, "IsApplicationUpdateRequested"},
183 {907, nullptr, "WithdrawApplicationUpdateRequest"},
184 {908, nullptr, "ListApplicationRecordInstalledContentMeta"},
185 {909, nullptr, "WithdrawCleanupAddOnContentsWithNoRightsRecommendation"},
186 {910, nullptr, "HasApplicationRecord"},
187 {911, nullptr, "SetPreInstalledApplication"},
188 {912, nullptr, "ClearPreInstalledApplicationFlag"},
189 {913, nullptr, "ListAllApplicationRecord"},
190 {914, nullptr, "HideApplicationRecord"},
191 {915, nullptr, "ShowApplicationRecord"},
192 {916, nullptr, "IsApplicationAutoDeleteDisabled"},
193 {1000, nullptr, "RequestVerifyApplicationDeprecated"},
194 {1001, nullptr, "CorruptApplicationForDebug"},
195 {1002, nullptr, "RequestVerifyAddOnContentsRights"},
196 {1003, nullptr, "RequestVerifyApplication"},
197 {1004, nullptr, "CorruptContentForDebug"},
198 {1200, nullptr, "NeedsUpdateVulnerability"},
199 {1300, nullptr, "IsAnyApplicationEntityInstalled"},
200 {1301, nullptr, "DeleteApplicationContentEntities"},
201 {1302, nullptr, "CleanupUnrecordedApplicationEntity"},
202 {1303, nullptr, "CleanupAddOnContentsWithNoRights"},
203 {1304, nullptr, "DeleteApplicationContentEntity"},
204 {1305, nullptr, "TryDeleteRunningApplicationEntity"},
205 {1306, nullptr, "TryDeleteRunningApplicationCompletely"},
206 {1307, nullptr, "TryDeleteRunningApplicationContentEntities"},
207 {1308, nullptr, "DeleteApplicationCompletelyForDebug"},
208 {1309, nullptr, "CleanupUnavailableAddOnContents"},
209 {1310, nullptr, "RequestMoveApplicationEntity"},
210 {1311, nullptr, "EstimateSizeToMove"},
211 {1312, nullptr, "HasMovableEntity"},
212 {1313, nullptr, "CleanupOrphanContents"},
213 {1314, nullptr, "CheckPreconditionSatisfiedToMove"},
214 {1400, nullptr, "PrepareShutdown"},
215 {1500, nullptr, "FormatSdCard"},
216 {1501, nullptr, "NeedsSystemUpdateToFormatSdCard"},
217 {1502, nullptr, "GetLastSdCardFormatUnexpectedResult"},
218 {1504, nullptr, "InsertSdCard"},
219 {1505, nullptr, "RemoveSdCard"},
220 {1506, nullptr, "GetSdCardStartupStatus"},
221 {1600, nullptr, "GetSystemSeedForPseudoDeviceId"},
222 {1601, nullptr, "ResetSystemSeedForPseudoDeviceId"},
223 {1700, nullptr, "ListApplicationDownloadingContentMeta"},
224 {1701, nullptr, "GetApplicationView"},
225 {1702, nullptr, "GetApplicationDownloadTaskStatus"},
226 {1703, nullptr, "GetApplicationViewDownloadErrorContext"},
227 {1704, nullptr, "GetApplicationViewWithPromotionInfo"},
228 {1705, nullptr, "IsPatchAutoDeletableApplication"},
229 {1800, nullptr, "IsNotificationSetupCompleted"},
230 {1801, nullptr, "GetLastNotificationInfoCount"},
231 {1802, nullptr, "ListLastNotificationInfo"},
232 {1803, nullptr, "ListNotificationTask"},
233 {1900, nullptr, "IsActiveAccount"},
234 {1901, nullptr, "RequestDownloadApplicationPrepurchasedRights"},
235 {1902, nullptr, "GetApplicationTicketInfo"},
236 {1903, nullptr, "RequestDownloadApplicationPrepurchasedRightsForAccount"},
237 {2000, nullptr, "GetSystemDeliveryInfo"},
238 {2001, nullptr, "SelectLatestSystemDeliveryInfo"},
239 {2002, nullptr, "VerifyDeliveryProtocolVersion"},
240 {2003, nullptr, "GetApplicationDeliveryInfo"},
241 {2004, nullptr, "HasAllContentsToDeliver"},
242 {2005, nullptr, "CompareApplicationDeliveryInfo"},
243 {2006, nullptr, "CanDeliverApplication"},
244 {2007, nullptr, "ListContentMetaKeyToDeliverApplication"},
245 {2008, nullptr, "NeedsSystemUpdateToDeliverApplication"},
246 {2009, nullptr, "EstimateRequiredSize"},
247 {2010, nullptr, "RequestReceiveApplication"},
248 {2011, nullptr, "CommitReceiveApplication"},
249 {2012, nullptr, "GetReceiveApplicationProgress"},
250 {2013, nullptr, "RequestSendApplication"},
251 {2014, nullptr, "GetSendApplicationProgress"},
252 {2015, nullptr, "CompareSystemDeliveryInfo"},
253 {2016, nullptr, "ListNotCommittedContentMeta"},
254 {2017, nullptr, "CreateDownloadTask"},
255 {2018, nullptr, "GetApplicationDeliveryInfoHash"},
256 {2050, nullptr, "GetApplicationRightsOnClient"},
257 {2051, nullptr, "InvalidateRightsIdCache"},
258 {2100, nullptr, "GetApplicationTerminateResult"},
259 {2101, nullptr, "GetRawApplicationTerminateResult"},
260 {2150, nullptr, "CreateRightsEnvironment"},
261 {2151, nullptr, "DestroyRightsEnvironment"},
262 {2152, nullptr, "ActivateRightsEnvironment"},
263 {2153, nullptr, "DeactivateRightsEnvironment"},
264 {2154, nullptr, "ForceActivateRightsContextForExit"},
265 {2155, nullptr, "UpdateRightsEnvironmentStatus"},
266 {2156, nullptr, "CreateRightsEnvironmentForMicroApplication"},
267 {2160, nullptr, "AddTargetApplicationToRightsEnvironment"},
268 {2161, nullptr, "SetUsersToRightsEnvironment"},
269 {2170, nullptr, "GetRightsEnvironmentStatus"},
270 {2171, nullptr, "GetRightsEnvironmentStatusChangedEvent"},
271 {2180, nullptr, "RequestExtendRightsInRightsEnvironment"},
272 {2181, nullptr, "GetResultOfExtendRightsInRightsEnvironment"},
273 {2182, nullptr, "SetActiveRightsContextUsingStateToRightsEnvironment"},
274 {2190, nullptr, "GetRightsEnvironmentHandleForApplication"},
275 {2199, nullptr, "GetRightsEnvironmentCountForDebug"},
276 {2200, nullptr, "GetGameCardApplicationCopyIdentifier"},
277 {2201, nullptr, "GetInstalledApplicationCopyIdentifier"},
278 {2250, nullptr, "RequestReportActiveELicence"},
279 {2300, nullptr, "ListEventLog"},
280 {2350, nullptr, "PerformAutoUpdateByApplicationId"},
281 {2351, nullptr, "RequestNoDownloadRightsErrorResolution"},
282 {2352, nullptr, "RequestResolveNoDownloadRightsError"},
283 {2353, nullptr, "GetApplicationDownloadTaskInfo"},
284 {2354, nullptr, "PrioritizeApplicationBackgroundTask"},
285 {2355, nullptr, "PreferStorageEfficientUpdate"},
286 {2356, nullptr, "RequestStorageEfficientUpdatePreferable"},
287 {2357, nullptr, "EnableMultiCoreDownload"},
288 {2358, nullptr, "DisableMultiCoreDownload"},
289 {2359, nullptr, "IsMultiCoreDownloadEnabled"},
290 {2400, nullptr, "GetPromotionInfo"},
291 {2401, nullptr, "CountPromotionInfo"},
292 {2402, nullptr, "ListPromotionInfo"},
293 {2403, nullptr, "ImportPromotionJsonForDebug"},
294 {2404, nullptr, "ClearPromotionInfoForDebug"},
295 {2500, nullptr, "ConfirmAvailableTime"},
296 {2510, nullptr, "CreateApplicationResource"},
297 {2511, nullptr, "GetApplicationResource"},
298 {2513, nullptr, "LaunchMicroApplication"},
299 {2514, nullptr, "ClearTaskOfAsyncTaskManager"},
300 {2515, nullptr, "CleanupAllPlaceHolderAndFragmentsIfNoTask"},
301 {2516, nullptr, "EnsureApplicationCertificate"},
302 {2517, nullptr, "CreateApplicationInstance"},
303 {2518, nullptr, "UpdateQualificationForDebug"},
304 {2519, nullptr, "IsQualificationTransitionSupported"},
305 {2520, nullptr, "IsQualificationTransitionSupportedByProcessId"},
306 {2521, nullptr, "GetRightsUserChangedEvent"},
307 {2522, nullptr, "IsRomRedirectionAvailable"},
308 {2800, nullptr, "GetApplicationIdOfPreomia"},
309 {3000, nullptr, "RegisterDeviceLockKey"},
310 {3001, nullptr, "UnregisterDeviceLockKey"},
311 {3002, nullptr, "VerifyDeviceLockKey"},
312 {3003, nullptr, "HideApplicationIcon"},
313 {3004, nullptr, "ShowApplicationIcon"},
314 {3005, nullptr, "HideApplicationTitle"},
315 {3006, nullptr, "ShowApplicationTitle"},
316 {3007, nullptr, "EnableGameCard"},
317 {3008, nullptr, "DisableGameCard"},
318 {3009, nullptr, "EnableLocalContentShare"},
319 {3010, nullptr, "DisableLocalContentShare"},
320 {3011, nullptr, "IsApplicationIconHidden"},
321 {3012, nullptr, "IsApplicationTitleHidden"},
322 {3013, nullptr, "IsGameCardEnabled"},
323 {3014, nullptr, "IsLocalContentShareEnabled"},
324 {3050, nullptr, "ListAssignELicenseTaskResult"},
325 {9999, nullptr, "GetApplicationCertificate"},
326 };
327 // clang-format on
328
329 RegisterHandlers(functions);
330}
331
332IApplicationManagerInterface::~IApplicationManagerInterface() = default;
333
334void IApplicationManagerInterface::GetApplicationControlData(HLERequestContext& ctx) {
335 IPC::RequestParser rp{ctx};
336 const auto flag = rp.PopRaw<u64>();
337 LOG_DEBUG(Service_NS, "called with flag={:016X}", flag);
338
339 const auto title_id = rp.PopRaw<u64>();
340
341 const auto size = ctx.GetWriteBufferSize();
342
343 const FileSys::PatchManager pm{title_id, system.GetFileSystemController(),
344 system.GetContentProvider()};
345 const auto control = pm.GetControlMetadata();
346
347 std::vector<u8> out;
348
349 if (control.first != nullptr) {
350 if (size < 0x4000) {
351 LOG_ERROR(Service_NS,
352 "output buffer is too small! (actual={:016X}, expected_min=0x4000)", size);
353 IPC::ResponseBuilder rb{ctx, 2};
354 // TODO(DarkLordZach): Find a better error code for this.
355 rb.Push(ResultUnknown);
356 return;
357 }
358
359 out.resize(0x4000);
360 const auto bytes = control.first->GetRawBytes();
361 std::memcpy(out.data(), bytes.data(), bytes.size());
362 } else {
363 LOG_WARNING(Service_NS, "missing NACP data for title_id={:016X}, defaulting to zeros.",
364 title_id);
365 out.resize(std::min<u64>(0x4000, size));
366 }
367
368 if (control.second != nullptr) {
369 if (size < 0x4000 + control.second->GetSize()) {
370 LOG_ERROR(Service_NS,
371 "output buffer is too small! (actual={:016X}, expected_min={:016X})", size,
372 0x4000 + control.second->GetSize());
373 IPC::ResponseBuilder rb{ctx, 2};
374 // TODO(DarkLordZach): Find a better error code for this.
375 rb.Push(ResultUnknown);
376 return;
377 }
378
379 out.resize(0x4000 + control.second->GetSize());
380 control.second->Read(out.data() + 0x4000, control.second->GetSize());
381 } else {
382 LOG_WARNING(Service_NS, "missing icon data for title_id={:016X}, defaulting to zeros.",
383 title_id);
384 }
385
386 ctx.WriteBuffer(out);
387
388 IPC::ResponseBuilder rb{ctx, 3};
389 rb.Push(ResultSuccess);
390 rb.Push<u32>(static_cast<u32>(out.size()));
391}
392
393void IApplicationManagerInterface::GetApplicationDesiredLanguage(HLERequestContext& ctx) {
394 IPC::RequestParser rp{ctx};
395 const auto supported_languages = rp.Pop<u32>();
396
397 u8 desired_language{};
398 const auto res = GetApplicationDesiredLanguage(&desired_language, supported_languages);
399 if (res == ResultSuccess) {
400 IPC::ResponseBuilder rb{ctx, 3};
401 rb.Push(ResultSuccess);
402 rb.Push<u32>(desired_language);
403 } else {
404 IPC::ResponseBuilder rb{ctx, 2};
405 rb.Push(res);
406 }
407}
408
409Result IApplicationManagerInterface::GetApplicationDesiredLanguage(u8* out_desired_language,
410 const u32 supported_languages) {
411 LOG_DEBUG(Service_NS, "called with supported_languages={:08X}", supported_languages);
412
413 // Get language code from settings
414 const auto language_code =
415 Set::GetLanguageCodeFromIndex(static_cast<s32>(Settings::values.language_index.GetValue()));
416
417 // Convert to application language, get priority list
418 const auto application_language = ConvertToApplicationLanguage(language_code);
419 if (application_language == std::nullopt) {
420 LOG_ERROR(Service_NS, "Could not convert application language! language_code={}",
421 language_code);
422 return Service::NS::ResultApplicationLanguageNotFound;
423 }
424 const auto priority_list = GetApplicationLanguagePriorityList(*application_language);
425 if (!priority_list) {
426 LOG_ERROR(Service_NS,
427 "Could not find application language priorities! application_language={}",
428 *application_language);
429 return Service::NS::ResultApplicationLanguageNotFound;
430 }
431
432 // Try to find a valid language.
433 for (const auto lang : *priority_list) {
434 const auto supported_flag = GetSupportedLanguageFlag(lang);
435 if (supported_languages == 0 || (supported_languages & supported_flag) == supported_flag) {
436 *out_desired_language = static_cast<u8>(lang);
437 return ResultSuccess;
438 }
439 }
440
441 LOG_ERROR(Service_NS, "Could not find a valid language! supported_languages={:08X}",
442 supported_languages);
443 return Service::NS::ResultApplicationLanguageNotFound;
444}
445
446void IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode(
447 HLERequestContext& ctx) {
448 IPC::RequestParser rp{ctx};
449 const auto application_language = rp.Pop<u8>();
450
451 u64 language_code{};
452 const auto res = ConvertApplicationLanguageToLanguageCode(&language_code, application_language);
453 if (res == ResultSuccess) {
454 IPC::ResponseBuilder rb{ctx, 4};
455 rb.Push(ResultSuccess);
456 rb.Push(language_code);
457 } else {
458 IPC::ResponseBuilder rb{ctx, 2};
459 rb.Push(res);
460 }
461}
462
463Result IApplicationManagerInterface::ConvertApplicationLanguageToLanguageCode(
464 u64* out_language_code, u8 application_language) {
465 const auto language_code =
466 ConvertToLanguageCode(static_cast<ApplicationLanguage>(application_language));
467 if (language_code == std::nullopt) {
468 LOG_ERROR(Service_NS, "Language not found! application_language={}", application_language);
469 return Service::NS::ResultApplicationLanguageNotFound;
470 }
471
472 *out_language_code = static_cast<u64>(*language_code);
473 return ResultSuccess;
474}
475
476IApplicationVersionInterface::IApplicationVersionInterface(Core::System& system_)
477 : ServiceFramework{system_, "IApplicationVersionInterface"} {
478 // clang-format off
479 static const FunctionInfo functions[] = {
480 {0, nullptr, "GetLaunchRequiredVersion"},
481 {1, nullptr, "UpgradeLaunchRequiredVersion"},
482 {35, nullptr, "UpdateVersionList"},
483 {36, nullptr, "PushLaunchVersion"},
484 {37, nullptr, "ListRequiredVersion"},
485 {800, nullptr, "RequestVersionList"},
486 {801, nullptr, "ListVersionList"},
487 {802, nullptr, "RequestVersionListData"},
488 {900, nullptr, "ImportAutoUpdatePolicyJsonForDebug"},
489 {901, nullptr, "ListDefaultAutoUpdatePolicy"},
490 {902, nullptr, "ListAutoUpdatePolicyForSpecificApplication"},
491 {1000, nullptr, "PerformAutoUpdate"},
492 {1001, nullptr, "ListAutoUpdateSchedule"},
493 };
494 // clang-format on
495
496 RegisterHandlers(functions);
497}
498
499IApplicationVersionInterface::~IApplicationVersionInterface() = default;
500
501IContentManagementInterface::IContentManagementInterface(Core::System& system_)
502 : ServiceFramework{system_, "IContentManagementInterface"} {
503 // clang-format off
504 static const FunctionInfo functions[] = {
505 {11, nullptr, "CalculateApplicationOccupiedSize"},
506 {43, nullptr, "CheckSdCardMountStatus"},
507 {47, &IContentManagementInterface::GetTotalSpaceSize, "GetTotalSpaceSize"},
508 {48, &IContentManagementInterface::GetFreeSpaceSize, "GetFreeSpaceSize"},
509 {600, nullptr, "CountApplicationContentMeta"},
510 {601, nullptr, "ListApplicationContentMetaStatus"},
511 {605, nullptr, "ListApplicationContentMetaStatusWithRightsCheck"},
512 {607, nullptr, "IsAnyApplicationRunning"},
513 };
514 // clang-format on
515
516 RegisterHandlers(functions);
517}
518
519IContentManagementInterface::~IContentManagementInterface() = default;
520
521void IContentManagementInterface::GetTotalSpaceSize(HLERequestContext& ctx) {
522 IPC::RequestParser rp{ctx};
523 const auto storage{rp.PopEnum<FileSys::StorageId>()};
524
525 LOG_INFO(Service_Capture, "called, storage={}", storage);
526
527 IPC::ResponseBuilder rb{ctx, 4};
528 rb.Push(ResultSuccess);
529 rb.Push<u64>(system.GetFileSystemController().GetTotalSpaceSize(storage));
530}
531
532void IContentManagementInterface::GetFreeSpaceSize(HLERequestContext& ctx) {
533 IPC::RequestParser rp{ctx};
534 const auto storage{rp.PopEnum<FileSys::StorageId>()};
535
536 LOG_INFO(Service_Capture, "called, storage={}", storage);
537
538 IPC::ResponseBuilder rb{ctx, 4};
539 rb.Push(ResultSuccess);
540 rb.Push<u64>(system.GetFileSystemController().GetFreeSpaceSize(storage));
541}
542
543IDocumentInterface::IDocumentInterface(Core::System& system_)
544 : ServiceFramework{system_, "IDocumentInterface"} {
545 // clang-format off
546 static const FunctionInfo functions[] = {
547 {21, nullptr, "GetApplicationContentPath"},
548 {23, &IDocumentInterface::ResolveApplicationContentPath, "ResolveApplicationContentPath"},
549 {92, &IDocumentInterface::GetRunningApplicationProgramId, "GetRunningApplicationProgramId"},
550 };
551 // clang-format on
552
553 RegisterHandlers(functions);
554}
555
556IDocumentInterface::~IDocumentInterface() = default;
557
558void IDocumentInterface::ResolveApplicationContentPath(HLERequestContext& ctx) {
559 struct ContentPath {
560 u8 file_system_proxy_type;
561 u64 program_id;
562 };
563 static_assert(sizeof(ContentPath) == 0x10, "ContentPath has wrong size");
564
565 IPC::RequestParser rp{ctx};
566 auto content_path = rp.PopRaw<ContentPath>();
567 LOG_WARNING(Service_NS, "(STUBBED) called, file_system_proxy_type={}, program_id={:016X}",
568 content_path.file_system_proxy_type, content_path.program_id);
569
570 IPC::ResponseBuilder rb{ctx, 2};
571 rb.Push(ResultSuccess);
572}
573
574void IDocumentInterface::GetRunningApplicationProgramId(HLERequestContext& ctx) {
575 IPC::RequestParser rp{ctx};
576 const auto caller_program_id = rp.PopRaw<u64>();
577 LOG_WARNING(Service_NS, "(STUBBED) called, caller_program_id={:016X}", caller_program_id);
578
579 IPC::ResponseBuilder rb{ctx, 4};
580 rb.Push(ResultSuccess);
581 rb.Push<u64>(system.GetApplicationProcessProgramID());
582}
583
584IDownloadTaskInterface::IDownloadTaskInterface(Core::System& system_)
585 : ServiceFramework{system_, "IDownloadTaskInterface"} {
586 // clang-format off
587 static const FunctionInfo functions[] = {
588 {701, nullptr, "ClearTaskStatusList"},
589 {702, nullptr, "RequestDownloadTaskList"},
590 {703, nullptr, "RequestEnsureDownloadTask"},
591 {704, nullptr, "ListDownloadTaskStatus"},
592 {705, nullptr, "RequestDownloadTaskListData"},
593 {706, nullptr, "TryCommitCurrentApplicationDownloadTask"},
594 {707, nullptr, "EnableAutoCommit"},
595 {708, nullptr, "DisableAutoCommit"},
596 {709, nullptr, "TriggerDynamicCommitEvent"},
597 };
598 // clang-format on
599
600 RegisterHandlers(functions);
601}
602
603IDownloadTaskInterface::~IDownloadTaskInterface() = default;
604
605IECommerceInterface::IECommerceInterface(Core::System& system_)
606 : ServiceFramework{system_, "IECommerceInterface"} {
607 // clang-format off
608 static const FunctionInfo functions[] = {
609 {0, nullptr, "RequestLinkDevice"},
610 {1, nullptr, "RequestCleanupAllPreInstalledApplications"},
611 {2, nullptr, "RequestCleanupPreInstalledApplication"},
612 {3, nullptr, "RequestSyncRights"},
613 {4, nullptr, "RequestUnlinkDevice"},
614 {5, nullptr, "RequestRevokeAllELicense"},
615 {6, nullptr, "RequestSyncRightsBasedOnAssignedELicenses"},
616 };
617 // clang-format on
618
619 RegisterHandlers(functions);
620}
621
622IECommerceInterface::~IECommerceInterface() = default;
623
624IFactoryResetInterface::IFactoryResetInterface(Core::System& system_)
625 : ServiceFramework{system_, "IFactoryResetInterface"} {
626 // clang-format off
627 static const FunctionInfo functions[] = {
628 {100, nullptr, "ResetToFactorySettings"},
629 {101, nullptr, "ResetToFactorySettingsWithoutUserSaveData"},
630 {102, nullptr, "ResetToFactorySettingsForRefurbishment"},
631 {103, nullptr, "ResetToFactorySettingsWithPlatformRegion"},
632 {104, nullptr, "ResetToFactorySettingsWithPlatformRegionAuthentication"},
633 {105, nullptr, "RequestResetToFactorySettingsSecurely"},
634 {106, nullptr, "RequestResetToFactorySettingsWithPlatformRegionAuthenticationSecurely"},
635 };
636 // clang-format on
637
638 RegisterHandlers(functions);
639}
640
641IFactoryResetInterface::~IFactoryResetInterface() = default;
642
643IReadOnlyApplicationRecordInterface::IReadOnlyApplicationRecordInterface(Core::System& system_)
644 : ServiceFramework{system_, "IReadOnlyApplicationRecordInterface"} {
645 static const FunctionInfo functions[] = {
646 {0, &IReadOnlyApplicationRecordInterface::HasApplicationRecord, "HasApplicationRecord"},
647 {1, nullptr, "NotifyApplicationFailure"},
648 {2, &IReadOnlyApplicationRecordInterface::IsDataCorruptedResult, "IsDataCorruptedResult"},
649 };
650 // clang-format on
651
652 RegisterHandlers(functions);
653}
654
655IReadOnlyApplicationRecordInterface::~IReadOnlyApplicationRecordInterface() = default;
656
657void IReadOnlyApplicationRecordInterface::HasApplicationRecord(HLERequestContext& ctx) {
658 IPC::RequestParser rp{ctx};
659 const u64 program_id = rp.PopRaw<u64>();
660 LOG_WARNING(Service_NS, "(STUBBED) called, program_id={:X}", program_id);
661
662 IPC::ResponseBuilder rb{ctx, 3};
663 rb.Push(ResultSuccess);
664 rb.Push<u8>(1);
665}
666
667void IReadOnlyApplicationRecordInterface::IsDataCorruptedResult(HLERequestContext& ctx) {
668 IPC::RequestParser rp{ctx};
669 const auto result = rp.PopRaw<Result>();
670 LOG_WARNING(Service_NS, "(STUBBED) called, result={:#x}", result.GetInnerValue());
671
672 IPC::ResponseBuilder rb{ctx, 3};
673 rb.Push(ResultSuccess);
674 rb.Push<u8>(0);
675}
676
677IReadOnlyApplicationControlDataInterface::IReadOnlyApplicationControlDataInterface(
678 Core::System& system_)
679 : ServiceFramework{system_, "IReadOnlyApplicationControlDataInterface"} {
680 // clang-format off
681 static const FunctionInfo functions[] = {
682 {0, &IReadOnlyApplicationControlDataInterface::GetApplicationControlData, "GetApplicationControlData"},
683 {1, nullptr, "GetApplicationDesiredLanguage"},
684 {2, nullptr, "ConvertApplicationLanguageToLanguageCode"},
685 {3, nullptr, "ConvertLanguageCodeToApplicationLanguage"},
686 {4, nullptr, "SelectApplicationDesiredLanguage"},
687 };
688 // clang-format on
689
690 RegisterHandlers(functions);
691}
692
693IReadOnlyApplicationControlDataInterface::~IReadOnlyApplicationControlDataInterface() = default;
694
695void IReadOnlyApplicationControlDataInterface::GetApplicationControlData(HLERequestContext& ctx) {
696 enum class ApplicationControlSource : u8 {
697 CacheOnly,
698 Storage,
699 StorageOnly,
700 };
701
702 struct RequestParameters {
703 ApplicationControlSource source;
704 u64 application_id;
705 };
706 static_assert(sizeof(RequestParameters) == 0x10, "RequestParameters has incorrect size.");
707
708 IPC::RequestParser rp{ctx};
709 std::vector<u8> nacp_data{};
710 const auto parameters{rp.PopRaw<RequestParameters>()};
711 const auto result =
712 system.GetARPManager().GetControlProperty(&nacp_data, parameters.application_id);
713
714 if (result == ResultSuccess) {
715 ctx.WriteBuffer(nacp_data.data(), nacp_data.size());
716 }
717
718 IPC::ResponseBuilder rb{ctx, 2};
719 rb.Push(result);
720}
721
722NS::NS(const char* name, Core::System& system_) : ServiceFramework{system_, name} {
723 // clang-format off
724 static const FunctionInfo functions[] = {
725 {7988, nullptr, "GetDynamicRightsInterface"},
726 {7989, &NS::PushInterface<IReadOnlyApplicationControlDataInterface>, "GetReadOnlyApplicationControlDataInterface"},
727 {7991, &NS::PushInterface<IReadOnlyApplicationRecordInterface>, "GetReadOnlyApplicationRecordInterface"},
728 {7992, &NS::PushInterface<IECommerceInterface>, "GetECommerceInterface"},
729 {7993, &NS::PushInterface<IApplicationVersionInterface>, "GetApplicationVersionInterface"},
730 {7994, &NS::PushInterface<IFactoryResetInterface>, "GetFactoryResetInterface"},
731 {7995, &NS::PushInterface<IAccountProxyInterface>, "GetAccountProxyInterface"},
732 {7996, &NS::PushIApplicationManagerInterface, "GetApplicationManagerInterface"},
733 {7997, &NS::PushInterface<IDownloadTaskInterface>, "GetDownloadTaskInterface"},
734 {7998, &NS::PushInterface<IContentManagementInterface>, "GetContentManagementInterface"},
735 {7999, &NS::PushInterface<IDocumentInterface>, "GetDocumentInterface"},
736 };
737 // clang-format on
738
739 RegisterHandlers(functions);
740}
741
742NS::~NS() = default;
743
744std::shared_ptr<IApplicationManagerInterface> NS::GetApplicationManagerInterface() const {
745 return GetInterface<IApplicationManagerInterface>(system);
746}
747
748class NS_DEV final : public ServiceFramework<NS_DEV> {
749public:
750 explicit NS_DEV(Core::System& system_) : ServiceFramework{system_, "ns:dev"} {
751 // clang-format off
752 static const FunctionInfo functions[] = {
753 {0, nullptr, "LaunchProgram"},
754 {1, nullptr, "TerminateProcess"},
755 {2, nullptr, "TerminateProgram"},
756 {4, nullptr, "GetShellEvent"},
757 {5, nullptr, "GetShellEventInfo"},
758 {6, nullptr, "TerminateApplication"},
759 {7, nullptr, "PrepareLaunchProgramFromHost"},
760 {8, nullptr, "LaunchApplicationFromHost"},
761 {9, nullptr, "LaunchApplicationWithStorageIdForDevelop"},
762 {10, nullptr, "IsSystemMemoryResourceLimitBoosted"},
763 {11, nullptr, "GetRunningApplicationProcessIdForDevelop"},
764 {12, nullptr, "SetCurrentApplicationRightsEnvironmentCanBeActiveForDevelop"},
765 {13, nullptr, "CreateApplicationResourceForDevelop"},
766 {14, nullptr, "IsPreomiaForDevelop"},
767 {15, nullptr, "GetApplicationProgramIdFromHost"},
768 {16, nullptr, "RefreshCachedDebugValues"},
769 {17, nullptr, "PrepareLaunchApplicationFromHost"},
770 {18, nullptr, "GetLaunchEvent"},
771 {19, nullptr, "GetLaunchResult"},
772 };
773 // clang-format on
774
775 RegisterHandlers(functions);
776 }
777};
778
779class ISystemUpdateControl final : public ServiceFramework<ISystemUpdateControl> {
780public:
781 explicit ISystemUpdateControl(Core::System& system_)
782 : ServiceFramework{system_, "ISystemUpdateControl"} {
783 // clang-format off
784 static const FunctionInfo functions[] = {
785 {0, nullptr, "HasDownloaded"},
786 {1, nullptr, "RequestCheckLatestUpdate"},
787 {2, nullptr, "RequestDownloadLatestUpdate"},
788 {3, nullptr, "GetDownloadProgress"},
789 {4, nullptr, "ApplyDownloadedUpdate"},
790 {5, nullptr, "RequestPrepareCardUpdate"},
791 {6, nullptr, "GetPrepareCardUpdateProgress"},
792 {7, nullptr, "HasPreparedCardUpdate"},
793 {8, nullptr, "ApplyCardUpdate"},
794 {9, nullptr, "GetDownloadedEulaDataSize"},
795 {10, nullptr, "GetDownloadedEulaData"},
796 {11, nullptr, "SetupCardUpdate"},
797 {12, nullptr, "GetPreparedCardUpdateEulaDataSize"},
798 {13, nullptr, "GetPreparedCardUpdateEulaData"},
799 {14, nullptr, "SetupCardUpdateViaSystemUpdater"},
800 {15, nullptr, "HasReceived"},
801 {16, nullptr, "RequestReceiveSystemUpdate"},
802 {17, nullptr, "GetReceiveProgress"},
803 {18, nullptr, "ApplyReceivedUpdate"},
804 {19, nullptr, "GetReceivedEulaDataSize"},
805 {20, nullptr, "GetReceivedEulaData"},
806 {21, nullptr, "SetupToReceiveSystemUpdate"},
807 {22, nullptr, "RequestCheckLatestUpdateIncludesRebootlessUpdate"},
808 };
809 // clang-format on
810
811 RegisterHandlers(functions);
812 }
813};
814
815class NS_SU final : public ServiceFramework<NS_SU> {
816public:
817 explicit NS_SU(Core::System& system_) : ServiceFramework{system_, "ns:su"} {
818 // clang-format off
819 static const FunctionInfo functions[] = {
820 {0, nullptr, "GetBackgroundNetworkUpdateState"},
821 {1, &NS_SU::OpenSystemUpdateControl, "OpenSystemUpdateControl"},
822 {2, nullptr, "NotifyExFatDriverRequired"},
823 {3, nullptr, "ClearExFatDriverStatusForDebug"},
824 {4, nullptr, "RequestBackgroundNetworkUpdate"},
825 {5, nullptr, "NotifyBackgroundNetworkUpdate"},
826 {6, nullptr, "NotifyExFatDriverDownloadedForDebug"},
827 {9, nullptr, "GetSystemUpdateNotificationEventForContentDelivery"},
828 {10, nullptr, "NotifySystemUpdateForContentDelivery"},
829 {11, nullptr, "PrepareShutdown"},
830 {12, nullptr, "Unknown12"},
831 {13, nullptr, "Unknown13"},
832 {14, nullptr, "Unknown14"},
833 {15, nullptr, "Unknown15"},
834 {16, nullptr, "DestroySystemUpdateTask"},
835 {17, nullptr, "RequestSendSystemUpdate"},
836 {18, nullptr, "GetSendSystemUpdateProgress"},
837 };
838 // clang-format on
839
840 RegisterHandlers(functions);
841 }
842
843private:
844 void OpenSystemUpdateControl(HLERequestContext& ctx) {
845 LOG_DEBUG(Service_NS, "called");
846
847 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
848 rb.Push(ResultSuccess);
849 rb.PushIpcInterface<ISystemUpdateControl>(system);
850 }
851};
852
853class NS_VM final : public ServiceFramework<NS_VM> {
854public:
855 explicit NS_VM(Core::System& system_) : ServiceFramework{system_, "ns:vm"} {
856 // clang-format off
857 static const FunctionInfo functions[] = {
858 {1200, &NS_VM::NeedsUpdateVulnerability, "NeedsUpdateVulnerability"},
859 {1201, nullptr, "UpdateSafeSystemVersionForDebug"},
860 {1202, nullptr, "GetSafeSystemVersion"},
861 };
862 // clang-format on
863
864 RegisterHandlers(functions);
865 }
866
867private:
868 void NeedsUpdateVulnerability(HLERequestContext& ctx) {
869 LOG_WARNING(Service_NS, "(STUBBED) called");
870
871 IPC::ResponseBuilder rb{ctx, 3};
872 rb.Push(ResultSuccess);
873 rb.Push(false);
874 }
875};
876
877void LoopProcess(Core::System& system) { 15void LoopProcess(Core::System& system) {
878 auto server_manager = std::make_unique<ServerManager>(system); 16 auto server_manager = std::make_unique<ServerManager>(system);
879 17
880 server_manager->RegisterNamedService("ns:am2", std::make_shared<NS>("ns:am2", system)); 18 server_manager->RegisterNamedService(
881 server_manager->RegisterNamedService("ns:ec", std::make_shared<NS>("ns:ec", system)); 19 "ns:am2", std::make_shared<IServiceGetterInterface>(system, "ns:am2"));
882 server_manager->RegisterNamedService("ns:rid", std::make_shared<NS>("ns:rid", system)); 20 server_manager->RegisterNamedService(
883 server_manager->RegisterNamedService("ns:rt", std::make_shared<NS>("ns:rt", system)); 21 "ns:ec", std::make_shared<IServiceGetterInterface>(system, "ns:ec"));
884 server_manager->RegisterNamedService("ns:web", std::make_shared<NS>("ns:web", system)); 22 server_manager->RegisterNamedService(
885 server_manager->RegisterNamedService("ns:ro", std::make_shared<NS>("ns:ro", system)); 23 "ns:rid", std::make_shared<IServiceGetterInterface>(system, "ns:rid"));
886 24 server_manager->RegisterNamedService(
887 server_manager->RegisterNamedService("ns:dev", std::make_shared<NS_DEV>(system)); 25 "ns:rt", std::make_shared<IServiceGetterInterface>(system, "ns:rt"));
888 server_manager->RegisterNamedService("ns:su", std::make_shared<NS_SU>(system)); 26 server_manager->RegisterNamedService(
889 server_manager->RegisterNamedService("ns:vm", std::make_shared<NS_VM>(system)); 27 "ns:web", std::make_shared<IServiceGetterInterface>(system, "ns:web"));
890 server_manager->RegisterNamedService("pdm:qry", std::make_shared<PDM_QRY>(system)); 28 server_manager->RegisterNamedService(
29 "ns:ro", std::make_shared<IServiceGetterInterface>(system, "ns:ro"));
30
31 server_manager->RegisterNamedService("ns:dev", std::make_shared<IDevelopInterface>(system));
32 server_manager->RegisterNamedService("ns:su", std::make_shared<ISystemUpdateInterface>(system));
33 server_manager->RegisterNamedService("ns:vm",
34 std::make_shared<IVulnerabilityManagerInterface>(system));
35 server_manager->RegisterNamedService("pdm:qry", std::make_shared<IQueryService>(system));
891 36
892 server_manager->RegisterNamedService("pl:s", 37 server_manager->RegisterNamedService("pl:s",
893 std::make_shared<IPlatformServiceManager>(system, "pl:s")); 38 std::make_shared<IPlatformServiceManager>(system, "pl:s"));
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h
index 9ee306ef9..f79b4ae3d 100644
--- a/src/core/hle/service/ns/ns.h
+++ b/src/core/hle/service/ns/ns.h
@@ -3,141 +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 { 10namespace Service::NS {
13
14namespace FileSystem {
15class FileSystemController;
16} // namespace FileSystem
17
18namespace NS {
19
20class IAccountProxyInterface final : public ServiceFramework<IAccountProxyInterface> {
21public:
22 explicit IAccountProxyInterface(Core::System& system_);
23 ~IAccountProxyInterface() override;
24};
25
26class IApplicationManagerInterface final : public ServiceFramework<IApplicationManagerInterface> {
27public:
28 explicit IApplicationManagerInterface(Core::System& system_);
29 ~IApplicationManagerInterface() override;
30
31 Result GetApplicationDesiredLanguage(u8* out_desired_language, u32 supported_languages);
32 Result ConvertApplicationLanguageToLanguageCode(u64* out_language_code,
33 u8 application_language);
34
35private:
36 void GetApplicationControlData(HLERequestContext& ctx);
37 void GetApplicationDesiredLanguage(HLERequestContext& ctx);
38 void ConvertApplicationLanguageToLanguageCode(HLERequestContext& ctx);
39};
40
41class IApplicationVersionInterface final : public ServiceFramework<IApplicationVersionInterface> {
42public:
43 explicit IApplicationVersionInterface(Core::System& system_);
44 ~IApplicationVersionInterface() override;
45};
46
47class IContentManagementInterface final : public ServiceFramework<IContentManagementInterface> {
48public:
49 explicit IContentManagementInterface(Core::System& system_);
50 ~IContentManagementInterface() override;
51
52private:
53 void GetTotalSpaceSize(HLERequestContext& ctx);
54 void GetFreeSpaceSize(HLERequestContext& ctx);
55};
56
57class IDocumentInterface final : public ServiceFramework<IDocumentInterface> {
58public:
59 explicit IDocumentInterface(Core::System& system_);
60 ~IDocumentInterface() override;
61
62private:
63 void ResolveApplicationContentPath(HLERequestContext& ctx);
64 void GetRunningApplicationProgramId(HLERequestContext& ctx);
65};
66
67class IDownloadTaskInterface final : public ServiceFramework<IDownloadTaskInterface> {
68public:
69 explicit IDownloadTaskInterface(Core::System& system_);
70 ~IDownloadTaskInterface() override;
71};
72
73class IECommerceInterface final : public ServiceFramework<IECommerceInterface> {
74public:
75 explicit IECommerceInterface(Core::System& system_);
76 ~IECommerceInterface() override;
77};
78
79class IFactoryResetInterface final : public ServiceFramework<IFactoryResetInterface> {
80public:
81 explicit IFactoryResetInterface(Core::System& system_);
82 ~IFactoryResetInterface() override;
83};
84
85class IReadOnlyApplicationRecordInterface final
86 : public ServiceFramework<IReadOnlyApplicationRecordInterface> {
87public:
88 explicit IReadOnlyApplicationRecordInterface(Core::System& system_);
89 ~IReadOnlyApplicationRecordInterface() override;
90
91private:
92 void HasApplicationRecord(HLERequestContext& ctx);
93 void IsDataCorruptedResult(HLERequestContext& ctx);
94};
95
96class IReadOnlyApplicationControlDataInterface final
97 : public ServiceFramework<IReadOnlyApplicationControlDataInterface> {
98public:
99 explicit IReadOnlyApplicationControlDataInterface(Core::System& system_);
100 ~IReadOnlyApplicationControlDataInterface() override;
101
102private:
103 void GetApplicationControlData(HLERequestContext& ctx);
104};
105
106class NS final : public ServiceFramework<NS> {
107public:
108 explicit NS(const char* name, Core::System& system_);
109 ~NS() override;
110
111 std::shared_ptr<IApplicationManagerInterface> GetApplicationManagerInterface() const;
112
113private:
114 template <typename T, typename... Args>
115 void PushInterface(HLERequestContext& ctx) {
116 LOG_DEBUG(Service_NS, "called");
117
118 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
119 rb.Push(ResultSuccess);
120 rb.PushIpcInterface<T>(system);
121 }
122
123 void PushIApplicationManagerInterface(HLERequestContext& ctx) {
124 LOG_DEBUG(Service_NS, "called");
125
126 IPC::ResponseBuilder rb{ctx, 2, 0, 1};
127 rb.Push(ResultSuccess);
128 rb.PushIpcInterface<IApplicationManagerInterface>(system);
129 }
130
131 template <typename T, typename... Args>
132 std::shared_ptr<T> GetInterface(Args&&... args) const {
133 static_assert(std::is_base_of_v<SessionRequestHandler, T>,
134 "Not a base of ServiceFrameworkBase");
135
136 return std::make_shared<T>(std::forward<Args>(args)...);
137 }
138};
139 11
140void LoopProcess(Core::System& system); 12void LoopProcess(Core::System& system);
141 13
142} // namespace NS 14} // namespace Service::NS
143} // namespace Service
diff --git a/src/core/hle/service/ns/errors.h b/src/core/hle/service/ns/ns_results.h
index 16d2ea6f7..16d2ea6f7 100644
--- a/src/core/hle/service/ns/errors.h
+++ b/src/core/hle/service/ns/ns_results.h
diff --git a/src/core/hle/service/ns/ns_types.h b/src/core/hle/service/ns/ns_types.h
new file mode 100644
index 000000000..38421b0f4
--- /dev/null
+++ b/src/core/hle/service/ns/ns_types.h
@@ -0,0 +1,111 @@
1// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#pragma once
5
6#include "common/common_funcs.h"
7#include "common/uuid.h"
8#include "core/file_sys/romfs_factory.h"
9
10namespace Service::NS {
11
12enum class ApplicationRecordType : u8 {
13 Installing = 2,
14 Installed = 3,
15 GameCardNotInserted = 5,
16 Archived = 11,
17 GameCard = 16,
18};
19
20enum class ApplicationControlSource : u8 {
21 CacheOnly = 0,
22 Storage = 1,
23 StorageOnly = 2,
24};
25
26enum class BackgroundNetworkUpdateState : u8 {
27 None,
28 InProgress,
29 Ready,
30};
31
32struct ApplicationRecord {
33 u64 application_id;
34 ApplicationRecordType type;
35 u8 unknown;
36 INSERT_PADDING_BYTES_NOINIT(0x6);
37 u8 unknown2;
38 INSERT_PADDING_BYTES_NOINIT(0x7);
39};
40static_assert(sizeof(ApplicationRecord) == 0x18, "ApplicationRecord has incorrect size.");
41
42/// ApplicationView
43struct ApplicationView {
44 u64 application_id; ///< ApplicationId.
45 u32 unk; ///< Unknown.
46 u32 flags; ///< Flags.
47 std::array<u8, 0x10> unk_x10; ///< Unknown.
48 u32 unk_x20; ///< Unknown.
49 u16 unk_x24; ///< Unknown.
50 std::array<u8, 0x2> unk_x26; ///< Unknown.
51 std::array<u8, 0x8> unk_x28; ///< Unknown.
52 std::array<u8, 0x10> unk_x30; ///< Unknown.
53 u32 unk_x40; ///< Unknown.
54 u8 unk_x44; ///< Unknown.
55 std::array<u8, 0xb> unk_x45; ///< Unknown.
56};
57static_assert(sizeof(ApplicationView) == 0x50, "ApplicationView has incorrect size.");
58
59struct ApplicationRightsOnClient {
60 u64 application_id;
61 Common::UUID uid;
62 u8 flags;
63 u8 flags2;
64 INSERT_PADDING_BYTES_NOINIT(0x6);
65};
66static_assert(sizeof(ApplicationRightsOnClient) == 0x20,
67 "ApplicationRightsOnClient has incorrect size.");
68
69/// NsPromotionInfo
70struct PromotionInfo {
71 u64 start_timestamp; ///< POSIX timestamp for the promotion start.
72 u64 end_timestamp; ///< POSIX timestamp for the promotion end.
73 s64 remaining_time; ///< Remaining time until the promotion ends, in nanoseconds
74 ///< ({end_timestamp - current_time} converted to nanoseconds).
75 INSERT_PADDING_BYTES_NOINIT(0x4);
76 u8 flags; ///< Flags. Bit0: whether the PromotionInfo is valid (including bit1). Bit1 clear:
77 ///< remaining_time is set.
78 INSERT_PADDING_BYTES_NOINIT(0x3);
79};
80static_assert(sizeof(PromotionInfo) == 0x20, "PromotionInfo has incorrect size.");
81
82/// NsApplicationViewWithPromotionInfo
83struct ApplicationViewWithPromotionInfo {
84 ApplicationView view; ///< \ref NsApplicationView
85 PromotionInfo promotion; ///< \ref NsPromotionInfo
86};
87static_assert(sizeof(ApplicationViewWithPromotionInfo) == 0x70,
88 "ApplicationViewWithPromotionInfo has incorrect size.");
89
90struct ApplicationOccupiedSizeEntity {
91 FileSys::StorageId storage_id;
92 u64 app_size;
93 u64 patch_size;
94 u64 aoc_size;
95};
96static_assert(sizeof(ApplicationOccupiedSizeEntity) == 0x20,
97 "ApplicationOccupiedSizeEntity has incorrect size.");
98
99struct ApplicationOccupiedSize {
100 std::array<ApplicationOccupiedSizeEntity, 4> entities;
101};
102static_assert(sizeof(ApplicationOccupiedSize) == 0x80,
103 "ApplicationOccupiedSize has incorrect size.");
104
105struct ContentPath {
106 u8 file_system_proxy_type;
107 u64 program_id;
108};
109static_assert(sizeof(ContentPath) == 0x10, "ContentPath has incorrect size.");
110
111} // namespace Service::NS
diff --git a/src/core/hle/service/ns/pdm_qry.cpp b/src/core/hle/service/ns/pdm_qry.cpp
deleted file mode 100644
index ce0ee30e0..000000000
--- a/src/core/hle/service/ns/pdm_qry.cpp
+++ /dev/null
@@ -1,67 +0,0 @@
1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include <memory>
5
6#include "common/logging/log.h"
7#include "common/uuid.h"
8#include "core/hle/service/ipc_helpers.h"
9#include "core/hle/service/ns/pdm_qry.h"
10#include "core/hle/service/service.h"
11
12namespace Service::NS {
13
14PDM_QRY::PDM_QRY(Core::System& system_) : ServiceFramework{system_, "pdm:qry"} {
15 // clang-format off
16 static const FunctionInfo functions[] = {
17 {0, nullptr, "QueryAppletEvent"},
18 {1, nullptr, "QueryPlayStatistics"},
19 {2, nullptr, "QueryPlayStatisticsByUserAccountId"},
20 {3, nullptr, "QueryPlayStatisticsByNetworkServiceAccountId"},
21 {4, nullptr, "QueryPlayStatisticsByApplicationId"},
22 {5, &PDM_QRY::QueryPlayStatisticsByApplicationIdAndUserAccountId, "QueryPlayStatisticsByApplicationIdAndUserAccountId"},
23 {6, nullptr, "QueryPlayStatisticsByApplicationIdAndNetworkServiceAccountId"},
24 {7, nullptr, "QueryLastPlayTimeV0"},
25 {8, nullptr, "QueryPlayEvent"},
26 {9, nullptr, "GetAvailablePlayEventRange"},
27 {10, nullptr, "QueryAccountEvent"},
28 {11, nullptr, "QueryAccountPlayEvent"},
29 {12, nullptr, "GetAvailableAccountPlayEventRange"},
30 {13, nullptr, "QueryApplicationPlayStatisticsForSystemV0"},
31 {14, nullptr, "QueryRecentlyPlayedApplication"},
32 {15, nullptr, "GetRecentlyPlayedApplicationUpdateEvent"},
33 {16, nullptr, "QueryApplicationPlayStatisticsByUserAccountIdForSystemV0"},
34 {17, nullptr, "QueryLastPlayTime"},
35 {18, nullptr, "QueryApplicationPlayStatisticsForSystem"},
36 {19, nullptr, "QueryApplicationPlayStatisticsByUserAccountIdForSystem"},
37 };
38 // clang-format on
39
40 RegisterHandlers(functions);
41}
42
43PDM_QRY::~PDM_QRY() = default;
44
45void PDM_QRY::QueryPlayStatisticsByApplicationIdAndUserAccountId(HLERequestContext& ctx) {
46 IPC::RequestParser rp{ctx};
47 const auto unknown = rp.Pop<bool>();
48 rp.Pop<u8>(); // Padding
49 const auto application_id = rp.Pop<u64>();
50 const auto user_account_uid = rp.PopRaw<Common::UUID>();
51
52 // TODO(German77): Read statistics of the game
53 PlayStatistics statistics{
54 .application_id = application_id,
55 .total_launches = 1,
56 };
57
58 LOG_WARNING(Service_NS,
59 "(STUBBED) called. unknown={}. application_id=0x{:016X}, user_account_uid=0x{}",
60 unknown, application_id, user_account_uid.RawString());
61
62 IPC::ResponseBuilder rb{ctx, 12};
63 rb.Push(ResultSuccess);
64 rb.PushRaw(statistics);
65}
66
67} // namespace Service::NS
diff --git a/src/core/hle/service/ns/iplatform_service_manager.cpp b/src/core/hle/service/ns/platform_service_manager.cpp
index 46268be95..23cf05005 100644
--- a/src/core/hle/service/ns/iplatform_service_manager.cpp
+++ b/src/core/hle/service/ns/platform_service_manager.cpp
@@ -18,9 +18,9 @@
18#include "core/hle/kernel/k_shared_memory.h" 18#include "core/hle/kernel/k_shared_memory.h"
19#include "core/hle/kernel/kernel.h" 19#include "core/hle/kernel/kernel.h"
20#include "core/hle/kernel/physical_memory.h" 20#include "core/hle/kernel/physical_memory.h"
21#include "core/hle/service/cmif_serialization.h"
21#include "core/hle/service/filesystem/filesystem.h" 22#include "core/hle/service/filesystem/filesystem.h"
22#include "core/hle/service/ipc_helpers.h" 23#include "core/hle/service/ns/platform_service_manager.h"
23#include "core/hle/service/ns/iplatform_service_manager.h"
24 24
25namespace Service::NS { 25namespace Service::NS {
26 26
@@ -37,11 +37,6 @@ constexpr u32 EXPECTED_MAGIC{0x36f81a1e}; // What we expect the encrypted bfttf
37constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000}; 37constexpr u64 SHARED_FONT_MEM_SIZE{0x1100000};
38constexpr FontRegion EMPTY_REGION{0, 0}; 38constexpr FontRegion EMPTY_REGION{0, 0};
39 39
40enum class LoadState : u32 {
41 Loading = 0,
42 Done = 1,
43};
44
45static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMemory& output, 40static void DecryptSharedFont(const std::vector<u32>& input, Kernel::PhysicalMemory& output,
46 std::size_t& offset) { 41 std::size_t& offset) {
47 ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE, 42 ASSERT_MSG(offset + (input.size() * sizeof(u32)) < SHARED_FONT_MEM_SIZE,
@@ -138,13 +133,13 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch
138 : ServiceFramework{system_, service_name_}, impl{std::make_unique<Impl>()} { 133 : ServiceFramework{system_, service_name_}, impl{std::make_unique<Impl>()} {
139 // clang-format off 134 // clang-format off
140 static const FunctionInfo functions[] = { 135 static const FunctionInfo functions[] = {
141 {0, &IPlatformServiceManager::RequestLoad, "RequestLoad"}, 136 {0, D<&IPlatformServiceManager::RequestLoad>, "RequestLoad"},
142 {1, &IPlatformServiceManager::GetLoadState, "GetLoadState"}, 137 {1, D<&IPlatformServiceManager::GetLoadState>, "GetLoadState"},
143 {2, &IPlatformServiceManager::GetSize, "GetSize"}, 138 {2, D<&IPlatformServiceManager::GetSize>, "GetSize"},
144 {3, &IPlatformServiceManager::GetSharedMemoryAddressOffset, "GetSharedMemoryAddressOffset"}, 139 {3, D<&IPlatformServiceManager::GetSharedMemoryAddressOffset>, "GetSharedMemoryAddressOffset"},
145 {4, &IPlatformServiceManager::GetSharedMemoryNativeHandle, "GetSharedMemoryNativeHandle"}, 140 {4, D<&IPlatformServiceManager::GetSharedMemoryNativeHandle>, "GetSharedMemoryNativeHandle"},
146 {5, &IPlatformServiceManager::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriority"}, 141 {5, D<&IPlatformServiceManager::GetSharedFontInOrderOfPriority>, "GetSharedFontInOrderOfPriority"},
147 {6, &IPlatformServiceManager::GetSharedFontInOrderOfPriority, "GetSharedFontInOrderOfPriorityForSystem"}, 142 {6, D<&IPlatformServiceManager::GetSharedFontInOrderOfPriority>, "GetSharedFontInOrderOfPriorityForSystem"},
148 {100, nullptr, "RequestApplicationFunctionAuthorization"}, 143 {100, nullptr, "RequestApplicationFunctionAuthorization"},
149 {101, nullptr, "RequestApplicationFunctionAuthorizationByProcessId"}, 144 {101, nullptr, "RequestApplicationFunctionAuthorizationByProcessId"},
150 {102, nullptr, "RequestApplicationFunctionAuthorizationByApplicationId"}, 145 {102, nullptr, "RequestApplicationFunctionAuthorizationByApplicationId"},
@@ -208,47 +203,33 @@ IPlatformServiceManager::IPlatformServiceManager(Core::System& system_, const ch
208 203
209IPlatformServiceManager::~IPlatformServiceManager() = default; 204IPlatformServiceManager::~IPlatformServiceManager() = default;
210 205
211void IPlatformServiceManager::RequestLoad(HLERequestContext& ctx) { 206Result IPlatformServiceManager::RequestLoad(SharedFontType type) {
212 IPC::RequestParser rp{ctx};
213 const u32 shared_font_type{rp.Pop<u32>()};
214 // Games don't call this so all fonts should be loaded 207 // Games don't call this so all fonts should be loaded
215 LOG_DEBUG(Service_NS, "called, shared_font_type={}", shared_font_type); 208 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
216 209 R_SUCCEED();
217 IPC::ResponseBuilder rb{ctx, 2};
218 rb.Push(ResultSuccess);
219} 210}
220 211
221void IPlatformServiceManager::GetLoadState(HLERequestContext& ctx) { 212Result IPlatformServiceManager::GetLoadState(Out<LoadState> out_load_state, SharedFontType type) {
222 IPC::RequestParser rp{ctx}; 213 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
223 const u32 font_id{rp.Pop<u32>()}; 214 *out_load_state = LoadState::Loaded;
224 LOG_DEBUG(Service_NS, "called, font_id={}", font_id); 215 R_SUCCEED();
225
226 IPC::ResponseBuilder rb{ctx, 3};
227 rb.Push(ResultSuccess);
228 rb.Push<u32>(static_cast<u32>(LoadState::Done));
229} 216}
230 217
231void IPlatformServiceManager::GetSize(HLERequestContext& ctx) { 218Result IPlatformServiceManager::GetSize(Out<u32> out_size, SharedFontType type) {
232 IPC::RequestParser rp{ctx}; 219 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
233 const u32 font_id{rp.Pop<u32>()}; 220 *out_size = impl->GetSharedFontRegion(static_cast<size_t>(type)).size;
234 LOG_DEBUG(Service_NS, "called, font_id={}", font_id); 221 R_SUCCEED();
235
236 IPC::ResponseBuilder rb{ctx, 3};
237 rb.Push(ResultSuccess);
238 rb.Push<u32>(impl->GetSharedFontRegion(font_id).size);
239} 222}
240 223
241void IPlatformServiceManager::GetSharedMemoryAddressOffset(HLERequestContext& ctx) { 224Result IPlatformServiceManager::GetSharedMemoryAddressOffset(Out<u32> out_shared_memory_offset,
242 IPC::RequestParser rp{ctx}; 225 SharedFontType type) {
243 const u32 font_id{rp.Pop<u32>()}; 226 LOG_DEBUG(Service_NS, "called, shared_font_type={}", type);
244 LOG_DEBUG(Service_NS, "called, font_id={}", font_id); 227 *out_shared_memory_offset = impl->GetSharedFontRegion(static_cast<size_t>(type)).offset;
245 228 R_SUCCEED();
246 IPC::ResponseBuilder rb{ctx, 3};
247 rb.Push(ResultSuccess);
248 rb.Push<u32>(impl->GetSharedFontRegion(font_id).offset);
249} 229}
250 230
251void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx) { 231Result IPlatformServiceManager::GetSharedMemoryNativeHandle(
232 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_native_handle) {
252 // Map backing memory for the font data 233 // Map backing memory for the font data
253 LOG_DEBUG(Service_NS, "called"); 234 LOG_DEBUG(Service_NS, "called");
254 235
@@ -256,50 +237,37 @@ void IPlatformServiceManager::GetSharedMemoryNativeHandle(HLERequestContext& ctx
256 std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(), 237 std::memcpy(kernel.GetFontSharedMem().GetPointer(), impl->shared_font->data(),
257 impl->shared_font->size()); 238 impl->shared_font->size());
258 239
259 IPC::ResponseBuilder rb{ctx, 2, 1}; 240 // FIXME: this shouldn't belong to the kernel
260 rb.Push(ResultSuccess); 241 *out_shared_memory_native_handle = &kernel.GetFontSharedMem();
261 rb.PushCopyObjects(&kernel.GetFontSharedMem()); 242 R_SUCCEED();
262} 243}
263 244
264void IPlatformServiceManager::GetSharedFontInOrderOfPriority(HLERequestContext& ctx) { 245Result IPlatformServiceManager::GetSharedFontInOrderOfPriority(
246 OutArray<u32, BufferAttr_HipcMapAlias> out_font_codes,
247 OutArray<u32, BufferAttr_HipcMapAlias> out_font_offsets,
248 OutArray<u32, BufferAttr_HipcMapAlias> out_font_sizes, Out<bool> out_fonts_are_loaded,
249 Out<u32> out_font_count, Set::LanguageCode language_code) {
250 LOG_DEBUG(Service_NS, "called, language_code={:#x}", language_code);
251
265 // The maximum number of elements that can be returned is 6. Regardless of the available fonts 252 // The maximum number of elements that can be returned is 6. Regardless of the available fonts
266 // or buffer size. 253 // or buffer size.
267 constexpr std::size_t MaxElementCount = 6; 254 constexpr size_t MaxElementCount = 6;
268 IPC::RequestParser rp{ctx};
269 const u64 language_code{rp.Pop<u64>()}; // TODO(ogniK): Find out what this is used for
270 const std::size_t font_codes_count =
271 std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(0));
272 const std::size_t font_offsets_count =
273 std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(1));
274 const std::size_t font_sizes_count =
275 std::min(MaxElementCount, ctx.GetWriteBufferNumElements<u32>(2));
276 LOG_DEBUG(Service_NS, "called, language_code={:X}", language_code);
277
278 IPC::ResponseBuilder rb{ctx, 4};
279 std::vector<u32> font_codes;
280 std::vector<u32> font_offsets;
281 std::vector<u32> font_sizes;
282 255
283 // TODO(ogniK): Have actual priority order 256 // TODO(ogniK): Have actual priority order
284 for (std::size_t i = 0; i < impl->shared_font_regions.size(); i++) { 257 const auto max_size = std::min({MaxElementCount, out_font_codes.size(), out_font_offsets.size(),
285 font_codes.push_back(static_cast<u32>(i)); 258 out_font_sizes.size(), impl->shared_font_regions.size()});
286 auto region = impl->GetSharedFontRegion(i);
287 font_offsets.push_back(region.offset);
288 font_sizes.push_back(region.size);
289 }
290 259
291 // Resize buffers if game requests smaller size output 260 for (size_t i = 0; i < max_size; i++) {
292 font_codes.resize(std::min(font_codes.size(), font_codes_count)); 261 auto region = impl->GetSharedFontRegion(i);
293 font_offsets.resize(std::min(font_offsets.size(), font_offsets_count));
294 font_sizes.resize(std::min(font_sizes.size(), font_sizes_count));
295 262
296 ctx.WriteBuffer(font_codes, 0); 263 out_font_codes[i] = static_cast<u32>(i);
297 ctx.WriteBuffer(font_offsets, 1); 264 out_font_offsets[i] = region.offset;
298 ctx.WriteBuffer(font_sizes, 2); 265 out_font_sizes[i] = region.size;
266 }
299 267
300 rb.Push(ResultSuccess); 268 *out_fonts_are_loaded = true;
301 rb.Push<u8>(static_cast<u8>(LoadState::Done)); // Fonts Loaded 269 *out_font_count = static_cast<u32>(max_size);
302 rb.Push<u32>(static_cast<u32>(font_codes.size())); 270 R_SUCCEED();
303} 271}
304 272
305} // namespace Service::NS 273} // namespace Service::NS
diff --git a/src/core/hle/service/ns/iplatform_service_manager.h b/src/core/hle/service/ns/platform_service_manager.h
index 03071e02b..b82c385a6 100644
--- a/src/core/hle/service/ns/iplatform_service_manager.h
+++ b/src/core/hle/service/ns/platform_service_manager.h
@@ -5,7 +5,9 @@
5 5
6#include <memory> 6#include <memory>
7#include <vector> 7#include <vector>
8#include "core/hle/service/cmif_types.h"
8#include "core/hle/service/service.h" 9#include "core/hle/service/service.h"
10#include "core/hle/service/set/settings_types.h"
9 11
10namespace Service { 12namespace Service {
11 13
@@ -23,6 +25,20 @@ enum class FontArchives : u64 {
23 ChineseSimple = 0x0100000000000814, 25 ChineseSimple = 0x0100000000000814,
24}; 26};
25 27
28enum class SharedFontType : u32 {
29 JapanUSEuropeStandard = 0,
30 ChineseSimplified = 1,
31 ExtendedChineseSimplified = 2,
32 ChineseTraditional = 3,
33 KoreanHangul = 4,
34 NintendoExtended = 5,
35};
36
37enum class LoadState : u32 {
38 Loading = 0,
39 Loaded = 1,
40};
41
26constexpr std::array<std::pair<FontArchives, const char*>, 7> SHARED_FONTS{ 42constexpr std::array<std::pair<FontArchives, const char*>, 7> SHARED_FONTS{
27 std::make_pair(FontArchives::Standard, "nintendo_udsg-r_std_003.bfttf"), 43 std::make_pair(FontArchives::Standard, "nintendo_udsg-r_std_003.bfttf"),
28 std::make_pair(FontArchives::ChineseSimple, "nintendo_udsg-r_org_zh-cn_003.bfttf"), 44 std::make_pair(FontArchives::ChineseSimple, "nintendo_udsg-r_org_zh-cn_003.bfttf"),
@@ -42,12 +58,17 @@ public:
42 ~IPlatformServiceManager() override; 58 ~IPlatformServiceManager() override;
43 59
44private: 60private:
45 void RequestLoad(HLERequestContext& ctx); 61 Result RequestLoad(SharedFontType type);
46 void GetLoadState(HLERequestContext& ctx); 62 Result GetLoadState(Out<LoadState> out_load_state, SharedFontType type);
47 void GetSize(HLERequestContext& ctx); 63 Result GetSize(Out<u32> out_size, SharedFontType type);
48 void GetSharedMemoryAddressOffset(HLERequestContext& ctx); 64 Result GetSharedMemoryAddressOffset(Out<u32> out_shared_memory_offset, SharedFontType type);
49 void GetSharedMemoryNativeHandle(HLERequestContext& ctx); 65 Result GetSharedMemoryNativeHandle(
50 void GetSharedFontInOrderOfPriority(HLERequestContext& ctx); 66 OutCopyHandle<Kernel::KSharedMemory> out_shared_memory_native_handle);
67 Result GetSharedFontInOrderOfPriority(OutArray<u32, BufferAttr_HipcMapAlias> out_font_codes,
68 OutArray<u32, BufferAttr_HipcMapAlias> out_font_offsets,
69 OutArray<u32, BufferAttr_HipcMapAlias> out_font_sizes,
70 Out<bool> out_fonts_are_loaded, Out<u32> out_font_count,
71 Set::LanguageCode language_code);
51 72
52 struct Impl; 73 struct Impl;
53 std::unique_ptr<Impl> impl; 74 std::unique_ptr<Impl> impl;
diff --git a/src/core/hle/service/ns/query_service.cpp b/src/core/hle/service/ns/query_service.cpp
new file mode 100644
index 000000000..946b7fa23
--- /dev/null
+++ b/src/core/hle/service/ns/query_service.cpp
@@ -0,0 +1,57 @@
1// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/logging/log.h"
5#include "common/uuid.h"
6#include "core/hle/service/cmif_serialization.h"
7#include "core/hle/service/ns/query_service.h"
8#include "core/hle/service/service.h"
9
10namespace Service::NS {
11
12IQueryService::IQueryService(Core::System& system_) : ServiceFramework{system_, "pdm:qry"} {
13 // clang-format off
14 static const FunctionInfo functions[] = {
15 {0, nullptr, "QueryAppletEvent"},
16 {1, nullptr, "QueryPlayStatistics"},
17 {2, nullptr, "QueryPlayStatisticsByUserAccountId"},
18 {3, nullptr, "QueryPlayStatisticsByNetworkServiceAccountId"},
19 {4, nullptr, "QueryPlayStatisticsByApplicationId"},
20 {5, D<&IQueryService::QueryPlayStatisticsByApplicationIdAndUserAccountId>, "QueryPlayStatisticsByApplicationIdAndUserAccountId"},
21 {6, nullptr, "QueryPlayStatisticsByApplicationIdAndNetworkServiceAccountId"},
22 {7, nullptr, "QueryLastPlayTimeV0"},
23 {8, nullptr, "QueryPlayEvent"},
24 {9, nullptr, "GetAvailablePlayEventRange"},
25 {10, nullptr, "QueryAccountEvent"},
26 {11, nullptr, "QueryAccountPlayEvent"},
27 {12, nullptr, "GetAvailableAccountPlayEventRange"},
28 {13, nullptr, "QueryApplicationPlayStatisticsForSystemV0"},
29 {14, nullptr, "QueryRecentlyPlayedApplication"},
30 {15, nullptr, "GetRecentlyPlayedApplicationUpdateEvent"},
31 {16, nullptr, "QueryApplicationPlayStatisticsByUserAccountIdForSystemV0"},
32 {17, nullptr, "QueryLastPlayTime"},
33 {18, nullptr, "QueryApplicationPlayStatisticsForSystem"},
34 {19, nullptr, "QueryApplicationPlayStatisticsByUserAccountIdForSystem"},
35 };
36 // clang-format on
37
38 RegisterHandlers(functions);
39}
40
41IQueryService::~IQueryService() = default;
42
43Result IQueryService::QueryPlayStatisticsByApplicationIdAndUserAccountId(
44 Out<PlayStatistics> out_play_statistics, bool unknown, Common::UUID account_id,
45 u64 application_id) {
46 // TODO(German77): Read statistics of the game
47 *out_play_statistics = {
48 .application_id = application_id,
49 .total_launches = 1,
50 };
51
52 LOG_WARNING(Service_NS, "(STUBBED) called. unknown={}. application_id={:016X}, account_id={}",
53 unknown, application_id, account_id.FormattedString());
54 R_SUCCEED();
55}
56
57} // namespace Service::NS
diff --git a/src/core/hle/service/ns/pdm_qry.h b/src/core/hle/service/ns/query_service.h
index c98e01660..6cdbfa277 100644
--- a/src/core/hle/service/ns/pdm_qry.h
+++ b/src/core/hle/service/ns/query_service.h
@@ -3,6 +3,8 @@
3 3
4#pragma once 4#pragma once
5 5
6#include "common/uuid.h"
7#include "core/hle/service/cmif_types.h"
6#include "core/hle/service/service.h" 8#include "core/hle/service/service.h"
7 9
8namespace Service::NS { 10namespace Service::NS {
@@ -20,13 +22,15 @@ struct PlayStatistics {
20}; 22};
21static_assert(sizeof(PlayStatistics) == 0x28, "PlayStatistics is an invalid size"); 23static_assert(sizeof(PlayStatistics) == 0x28, "PlayStatistics is an invalid size");
22 24
23class PDM_QRY final : public ServiceFramework<PDM_QRY> { 25class IQueryService final : public ServiceFramework<IQueryService> {
24public: 26public:
25 explicit PDM_QRY(Core::System& system_); 27 explicit IQueryService(Core::System& system_);
26 ~PDM_QRY() override; 28 ~IQueryService() override;
27 29
28private: 30private:
29 void QueryPlayStatisticsByApplicationIdAndUserAccountId(HLERequestContext& ctx); 31 Result QueryPlayStatisticsByApplicationIdAndUserAccountId(
32 Out<PlayStatistics> out_play_statistics, bool unknown, Common::UUID account_id,
33 u64 application_id);
30}; 34};
31 35
32} // namespace Service::NS 36} // namespace Service::NS
diff --git a/src/core/hle/service/ns/read_only_application_control_data_interface.cpp b/src/core/hle/service/ns/read_only_application_control_data_interface.cpp
new file mode 100644
index 000000000..9b2ca94a4
--- /dev/null
+++ b/src/core/hle/service/ns/read_only_application_control_data_interface.cpp
@@ -0,0 +1,122 @@
1// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4#include "common/settings.h"
5#include "core/file_sys/control_metadata.h"
6#include "core/file_sys/patch_manager.h"
7#include "core/file_sys/vfs/vfs.h"
8#include "core/hle/service/cmif_serialization.h"
9#include "core/hle/service/ns/language.h"
10#include "core/hle/service/ns/ns_results.h"
11#include "core/hle/service/ns/read_only_application_control_data_interface.h"
12#include "core/hle/service/set/settings_server.h"
13
14namespace Service::NS {
15
16IReadOnlyApplicationControlDataInterface::IReadOnlyApplicationControlDataInterface(
17 Core::System& system_)
18 : ServiceFramework{system_, "IReadOnlyApplicationControlDataInterface"} {
19 // clang-format off
20 static const FunctionInfo functions[] = {
21 {0, D<&IReadOnlyApplicationControlDataInterface::GetApplicationControlData>, "GetApplicationControlData"},
22 {1, D<&IReadOnlyApplicationControlDataInterface::GetApplicationDesiredLanguage>, "GetApplicationDesiredLanguage"},
23 {2, D<&IReadOnlyApplicationControlDataInterface::ConvertApplicationLanguageToLanguageCode>, "ConvertApplicationLanguageToLanguageCode"},
24 {3, nullptr, "ConvertLanguageCodeToApplicationLanguage"},
25 {4, nullptr, "SelectApplicationDesiredLanguage"},
26 };
27 // clang-format on
28
29 RegisterHandlers(functions);
30}
31
32IReadOnlyApplicationControlDataInterface::~IReadOnlyApplicationControlDataInterface() = default;
33
34Result IReadOnlyApplicationControlDataInterface::GetApplicationControlData(
35 OutBuffer<BufferAttr_HipcMapAlias> out_buffer, Out<u32> out_actual_size,
36 ApplicationControlSource application_control_source, u64 application_id) {
37 LOG_INFO(Service_NS, "called with control_source={}, application_id={:016X}",
38 application_control_source, application_id);
39
40 const FileSys::PatchManager pm{application_id, system.GetFileSystemController(),
41 system.GetContentProvider()};
42 const auto control = pm.GetControlMetadata();
43 const auto size = out_buffer.size();
44
45 const auto icon_size = control.second ? control.second->GetSize() : 0;
46 const auto total_size = sizeof(FileSys::RawNACP) + icon_size;
47
48 if (size < total_size) {
49 LOG_ERROR(Service_NS, "output buffer is too small! (actual={:016X}, expected_min=0x4000)",
50 size);
51 R_THROW(ResultUnknown);
52 }
53
54 if (control.first != nullptr) {
55 const auto bytes = control.first->GetRawBytes();
56 std::memcpy(out_buffer.data(), bytes.data(), bytes.size());
57 } else {
58 LOG_WARNING(Service_NS, "missing NACP data for application_id={:016X}, defaulting to zero",
59 application_id);
60 std::memset(out_buffer.data(), 0, sizeof(FileSys::RawNACP));
61 }
62
63 if (control.second != nullptr) {
64 control.second->Read(out_buffer.data() + sizeof(FileSys::RawNACP), icon_size);
65 } else {
66 LOG_WARNING(Service_NS, "missing icon data for application_id={:016X}", application_id);
67 }
68
69 *out_actual_size = static_cast<u32>(total_size);
70 R_SUCCEED();
71}
72
73Result IReadOnlyApplicationControlDataInterface::GetApplicationDesiredLanguage(
74 Out<ApplicationLanguage> out_desired_language, u32 supported_languages) {
75 LOG_INFO(Service_NS, "called with supported_languages={:08X}", supported_languages);
76
77 // Get language code from settings
78 const auto language_code =
79 Set::GetLanguageCodeFromIndex(static_cast<s32>(Settings::values.language_index.GetValue()));
80
81 // Convert to application language, get priority list
82 const auto application_language = ConvertToApplicationLanguage(language_code);
83 if (application_language == std::nullopt) {
84 LOG_ERROR(Service_NS, "Could not convert application language! language_code={}",
85 language_code);
86 R_THROW(Service::NS::ResultApplicationLanguageNotFound);
87 }
88 const auto priority_list = GetApplicationLanguagePriorityList(*application_language);
89 if (!priority_list) {
90 LOG_ERROR(Service_NS,
91 "Could not find application language priorities! application_language={}",
92 *application_language);
93 R_THROW(Service::NS::ResultApplicationLanguageNotFound);
94 }
95
96 // Try to find a valid language.
97 for (const auto lang : *priority_list) {
98 const auto supported_flag = GetSupportedLanguageFlag(lang);
99 if (supported_languages == 0 || (supported_languages & supported_flag) == supported_flag) {
100 *out_desired_language = lang;
101 R_SUCCEED();
102 }
103 }
104
105 LOG_ERROR(Service_NS, "Could not find a valid language! supported_languages={:08X}",
106 supported_languages);
107 R_THROW(Service::NS::ResultApplicationLanguageNotFound);
108}
109
110Result IReadOnlyApplicationControlDataInterface::ConvertApplicationLanguageToLanguageCode(
111 Out<u64> out_language_code, ApplicationLanguage application_language) {
112 const auto language_code = ConvertToLanguageCode(application_language);
113 if (language_code == std::nullopt) {
114 LOG_ERROR(Service_NS, "Language not found! application_language={}", application_language);
115 R_THROW(Service::NS::ResultApplicationLanguageNotFound);
116 }
117
118 *out_language_code = static_cast<u64>(*language_code);
119 R_SUCCEED();
120}
121
122} // namespace Service::NS
diff --git a/src/core/hle/service/ns/read_only_application_control_data_interface.h b/src/core/hle/service/ns/read_only_application_control_data_interface.h
new file mode 100644
index 000000000..ac099435a
--- /dev/null
+++ b/src/core/hle/service/ns/read_only_application_control_data_interface.h
@@ -0,0 +1,30 @@
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/ns/language.h"
8#include "core/hle/service/ns/ns_types.h"
9#include "core/hle/service/service.h"
10
11namespace Service::NS {
12
13class IReadOnlyApplicationControlDataInterface final
14 : public ServiceFramework<IReadOnlyApplicationControlDataInterface> {
15public:
16 explicit IReadOnlyApplicationControlDataInterface(Core::System& system_);
17 ~IReadOnlyApplicationControlDataInterface() override;
18
19public:
20 Result GetApplicationControlData(OutBuffer<BufferAttr_HipcMapAlias> out_buffer,
21 Out<u32> out_actual_size,
22 ApplicationControlSource application_control_source,
23 u64 application_id);
24 Result GetApplicationDesiredLanguage(Out<ApplicationLanguage> out_desired_language,
25 u32 supported_languages);
26 Result ConvertApplicationLanguageToLanguageCode(Out<u64> out_language_code,
27 ApplicationLanguage application_language);
28};
29
30} // namespace Service::NS
diff --git a/src/core/hle/service/ns/read_only_application_record_interface.cpp b/src/core/hle/service/ns/read_only_application_record_interface.cpp
new file mode 100644
index 000000000..816a1e1dc
--- /dev/null
+++ b/src/core/hle/service/ns/read_only_application_record_interface.cpp
@@ -0,0 +1,38 @@
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/read_only_application_record_interface.h"
6
7namespace Service::NS {
8
9IReadOnlyApplicationRecordInterface::IReadOnlyApplicationRecordInterface(Core::System& system_)
10 : ServiceFramework{system_, "IReadOnlyApplicationRecordInterface"} {
11 static const FunctionInfo functions[] = {
12 {0, D<&IReadOnlyApplicationRecordInterface::HasApplicationRecord>, "HasApplicationRecord"},
13 {1, nullptr, "NotifyApplicationFailure"},
14 {2, D<&IReadOnlyApplicationRecordInterface::IsDataCorruptedResult>,
15 "IsDataCorruptedResult"},
16 };
17 // clang-format on
18
19 RegisterHandlers(functions);
20}
21
22IReadOnlyApplicationRecordInterface::~IReadOnlyApplicationRecordInterface() = default;
23
24Result IReadOnlyApplicationRecordInterface::HasApplicationRecord(
25 Out<bool> out_has_application_record, u64 program_id) {
26 LOG_WARNING(Service_NS, "(STUBBED) called, program_id={:016X}", program_id);
27 *out_has_application_record = true;
28 R_SUCCEED();
29}
30
31Result IReadOnlyApplicationRecordInterface::IsDataCorruptedResult(
32 Out<bool> out_is_data_corrupted_result, Result result) {
33 LOG_WARNING(Service_NS, "(STUBBED) called, result={:#x}", result.GetInnerValue());
34 *out_is_data_corrupted_result = false;
35 R_SUCCEED();
36}
37
38} // namespace Service::NS
diff --git a/src/core/hle/service/ns/read_only_application_record_interface.h b/src/core/hle/service/ns/read_only_application_record_interface.h
new file mode 100644
index 000000000..d06e8f5e6
--- /dev/null
+++ b/src/core/hle/service/ns/read_only_application_record_interface.h
@@ -0,0 +1,22 @@
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 IReadOnlyApplicationRecordInterface final
12 : public ServiceFramework<IReadOnlyApplicationRecordInterface> {
13public:
14 explicit IReadOnlyApplicationRecordInterface(Core::System& system_);
15 ~IReadOnlyApplicationRecordInterface() override;
16
17private:
18 Result HasApplicationRecord(Out<bool> out_has_application_record, u64 program_id);
19 Result IsDataCorruptedResult(Out<bool> out_is_data_corrupted_result, Result result);
20};
21
22} // 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
diff --git a/src/core/hle/service/ns/system_update_control.cpp b/src/core/hle/service/ns/system_update_control.cpp
new file mode 100644
index 000000000..f5f5cfd90
--- /dev/null
+++ b/src/core/hle/service/ns/system_update_control.cpp
@@ -0,0 +1,44 @@
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/system_update_control.h"
6
7namespace Service::NS {
8
9ISystemUpdateControl::ISystemUpdateControl(Core::System& system_)
10 : ServiceFramework{system_, "ISystemUpdateControl"} {
11 // clang-format off
12 static const FunctionInfo functions[] = {
13 {0, nullptr, "HasDownloaded"},
14 {1, nullptr, "RequestCheckLatestUpdate"},
15 {2, nullptr, "RequestDownloadLatestUpdate"},
16 {3, nullptr, "GetDownloadProgress"},
17 {4, nullptr, "ApplyDownloadedUpdate"},
18 {5, nullptr, "RequestPrepareCardUpdate"},
19 {6, nullptr, "GetPrepareCardUpdateProgress"},
20 {7, nullptr, "HasPreparedCardUpdate"},
21 {8, nullptr, "ApplyCardUpdate"},
22 {9, nullptr, "GetDownloadedEulaDataSize"},
23 {10, nullptr, "GetDownloadedEulaData"},
24 {11, nullptr, "SetupCardUpdate"},
25 {12, nullptr, "GetPreparedCardUpdateEulaDataSize"},
26 {13, nullptr, "GetPreparedCardUpdateEulaData"},
27 {14, nullptr, "SetupCardUpdateViaSystemUpdater"},
28 {15, nullptr, "HasReceived"},
29 {16, nullptr, "RequestReceiveSystemUpdate"},
30 {17, nullptr, "GetReceiveProgress"},
31 {18, nullptr, "ApplyReceivedUpdate"},
32 {19, nullptr, "GetReceivedEulaDataSize"},
33 {20, nullptr, "GetReceivedEulaData"},
34 {21, nullptr, "SetupToReceiveSystemUpdate"},
35 {22, nullptr, "RequestCheckLatestUpdateIncludesRebootlessUpdate"},
36 };
37 // clang-format on
38
39 RegisterHandlers(functions);
40}
41
42ISystemUpdateControl::~ISystemUpdateControl() = default;
43
44} // namespace Service::NS
diff --git a/src/core/hle/service/ns/system_update_control.h b/src/core/hle/service/ns/system_update_control.h
new file mode 100644
index 000000000..a30a09000
--- /dev/null
+++ b/src/core/hle/service/ns/system_update_control.h
@@ -0,0 +1,16 @@
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/service.h"
7
8namespace Service::NS {
9
10class ISystemUpdateControl final : public ServiceFramework<ISystemUpdateControl> {
11public:
12 explicit ISystemUpdateControl(Core::System& system_);
13 ~ISystemUpdateControl() override;
14};
15
16} // namespace Service::NS
diff --git a/src/core/hle/service/ns/system_update_interface.cpp b/src/core/hle/service/ns/system_update_interface.cpp
new file mode 100644
index 000000000..7e22ca3db
--- /dev/null
+++ b/src/core/hle/service/ns/system_update_interface.cpp
@@ -0,0 +1,61 @@
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/system_update_control.h"
6#include "core/hle/service/ns/system_update_interface.h"
7
8namespace Service::NS {
9
10ISystemUpdateInterface::ISystemUpdateInterface(Core::System& system_)
11 : ServiceFramework{system_, "ns:su"}, service_context{system_, "ns:su"},
12 update_notification_event{service_context} {
13 // clang-format off
14 static const FunctionInfo functions[] = {
15 {0, D<&ISystemUpdateInterface::GetBackgroundNetworkUpdateState>, "GetBackgroundNetworkUpdateState"},
16 {1, D<&ISystemUpdateInterface::OpenSystemUpdateControl>, "OpenSystemUpdateControl"},
17 {2, nullptr, "NotifyExFatDriverRequired"},
18 {3, nullptr, "ClearExFatDriverStatusForDebug"},
19 {4, nullptr, "RequestBackgroundNetworkUpdate"},
20 {5, nullptr, "NotifyBackgroundNetworkUpdate"},
21 {6, nullptr, "NotifyExFatDriverDownloadedForDebug"},
22 {9, D<&ISystemUpdateInterface::GetSystemUpdateNotificationEventForContentDelivery>, "GetSystemUpdateNotificationEventForContentDelivery"},
23 {10, nullptr, "NotifySystemUpdateForContentDelivery"},
24 {11, nullptr, "PrepareShutdown"},
25 {12, nullptr, "Unknown12"},
26 {13, nullptr, "Unknown13"},
27 {14, nullptr, "Unknown14"},
28 {15, nullptr, "Unknown15"},
29 {16, nullptr, "DestroySystemUpdateTask"},
30 {17, nullptr, "RequestSendSystemUpdate"},
31 {18, nullptr, "GetSendSystemUpdateProgress"},
32 };
33 // clang-format on
34
35 RegisterHandlers(functions);
36}
37
38ISystemUpdateInterface::~ISystemUpdateInterface() = default;
39
40Result ISystemUpdateInterface::GetBackgroundNetworkUpdateState(
41 Out<BackgroundNetworkUpdateState> out_background_network_update_state) {
42 LOG_WARNING(Service_AM, "(STUBBED) called");
43 *out_background_network_update_state = BackgroundNetworkUpdateState::None;
44 R_SUCCEED();
45}
46
47Result ISystemUpdateInterface::OpenSystemUpdateControl(
48 Out<SharedPointer<ISystemUpdateControl>> out_system_update_control) {
49 LOG_WARNING(Service_NS, "(STUBBED) called");
50 *out_system_update_control = std::make_shared<ISystemUpdateControl>(system);
51 R_SUCCEED();
52}
53
54Result ISystemUpdateInterface::GetSystemUpdateNotificationEventForContentDelivery(
55 OutCopyHandle<Kernel::KReadableEvent> out_event) {
56 LOG_WARNING(Service_NS, "(STUBBED) called");
57 *out_event = update_notification_event.GetHandle();
58 R_SUCCEED();
59}
60
61} // namespace Service::NS
diff --git a/src/core/hle/service/ns/system_update_interface.h b/src/core/hle/service/ns/system_update_interface.h
new file mode 100644
index 000000000..36a2880ec
--- /dev/null
+++ b/src/core/hle/service/ns/system_update_interface.h
@@ -0,0 +1,38 @@
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/kernel_helpers.h"
8#include "core/hle/service/ns/ns_types.h"
9#include "core/hle/service/os/event.h"
10#include "core/hle/service/service.h"
11
12namespace Kernel {
13class KReadableEvent;
14}
15
16namespace Service::NS {
17
18class ISystemUpdateControl;
19
20class ISystemUpdateInterface final : public ServiceFramework<ISystemUpdateInterface> {
21public:
22 explicit ISystemUpdateInterface(Core::System& system_);
23 ~ISystemUpdateInterface() override;
24
25private:
26 Result GetBackgroundNetworkUpdateState(
27 Out<BackgroundNetworkUpdateState> out_background_network_update_state);
28 Result OpenSystemUpdateControl(
29 Out<SharedPointer<ISystemUpdateControl>> out_system_update_control);
30 Result GetSystemUpdateNotificationEventForContentDelivery(
31 OutCopyHandle<Kernel::KReadableEvent> out_event);
32
33private:
34 KernelHelpers::ServiceContext service_context;
35 Event update_notification_event;
36};
37
38} // namespace Service::NS
diff --git a/src/core/hle/service/ns/vulnerability_manager_interface.cpp b/src/core/hle/service/ns/vulnerability_manager_interface.cpp
new file mode 100644
index 000000000..69c21fb89
--- /dev/null
+++ b/src/core/hle/service/ns/vulnerability_manager_interface.cpp
@@ -0,0 +1,31 @@
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/vulnerability_manager_interface.h"
6
7namespace Service::NS {
8
9IVulnerabilityManagerInterface::IVulnerabilityManagerInterface(Core::System& system_)
10 : ServiceFramework{system_, "ns:vm"} {
11 // clang-format off
12 static const FunctionInfo functions[] = {
13 {1200, D<&IVulnerabilityManagerInterface::NeedsUpdateVulnerability>, "NeedsUpdateVulnerability"},
14 {1201, nullptr, "UpdateSafeSystemVersionForDebug"},
15 {1202, nullptr, "GetSafeSystemVersion"},
16 };
17 // clang-format on
18
19 RegisterHandlers(functions);
20}
21
22IVulnerabilityManagerInterface::~IVulnerabilityManagerInterface() = default;
23
24Result IVulnerabilityManagerInterface::NeedsUpdateVulnerability(
25 Out<bool> out_needs_update_vulnerability) {
26 LOG_WARNING(Service_NS, "(STUBBED) called");
27 *out_needs_update_vulnerability = false;
28 R_SUCCEED();
29}
30
31} // namespace Service::NS
diff --git a/src/core/hle/service/ns/vulnerability_manager_interface.h b/src/core/hle/service/ns/vulnerability_manager_interface.h
new file mode 100644
index 000000000..c689cf7ec
--- /dev/null
+++ b/src/core/hle/service/ns/vulnerability_manager_interface.h
@@ -0,0 +1,21 @@
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 IVulnerabilityManagerInterface final
12 : public ServiceFramework<IVulnerabilityManagerInterface> {
13public:
14 explicit IVulnerabilityManagerInterface(Core::System& system_);
15 ~IVulnerabilityManagerInterface() override;
16
17private:
18 Result NeedsUpdateVulnerability(Out<bool> out_needs_update_vulnerability);
19};
20
21} // namespace Service::NS