summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Liam2024-02-17 14:49:47 -0500
committerGravatar Liam2024-02-18 10:35:39 -0500
commit4cdf18095d8f049d9bf19d22e8915032c6b4d738 (patch)
tree9be4ad9772d06cb767085d9b1e65344307bd5d66
parentns: rewrite IServiceGetterInterface (diff)
downloadyuzu-4cdf18095d8f049d9bf19d22e8915032c6b4d738.tar.gz
yuzu-4cdf18095d8f049d9bf19d22e8915032c6b4d738.tar.xz
yuzu-4cdf18095d8f049d9bf19d22e8915032c6b4d738.zip
ns: rewrite IQueryService
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/hle/service/ns/ns.cpp4
-rw-r--r--src/core/hle/service/ns/pdm_qry.cpp67
-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
5 files changed, 69 insertions, 75 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 1339cb182..7949e056c 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -765,10 +765,10 @@ add_library(core STATIC
765 hle/service/ns/ns_types.h 765 hle/service/ns/ns_types.h
766 hle/service/ns/ns.cpp 766 hle/service/ns/ns.cpp
767 hle/service/ns/ns.h 767 hle/service/ns/ns.h
768 hle/service/ns/pdm_qry.cpp
769 hle/service/ns/pdm_qry.h
770 hle/service/ns/platform_service_manager.cpp 768 hle/service/ns/platform_service_manager.cpp
771 hle/service/ns/platform_service_manager.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 772 hle/service/ns/read_only_application_control_data_interface.cpp
773 hle/service/ns/read_only_application_control_data_interface.h 773 hle/service/ns/read_only_application_control_data_interface.h
774 hle/service/ns/read_only_application_record_interface.cpp 774 hle/service/ns/read_only_application_record_interface.cpp
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp
index 96fa221b0..8402e83cb 100644
--- a/src/core/hle/service/ns/ns.cpp
+++ b/src/core/hle/service/ns/ns.cpp
@@ -3,8 +3,8 @@
3 3
4#include "core/hle/service/ns/develop_interface.h" 4#include "core/hle/service/ns/develop_interface.h"
5#include "core/hle/service/ns/ns.h" 5#include "core/hle/service/ns/ns.h"
6#include "core/hle/service/ns/pdm_qry.h"
7#include "core/hle/service/ns/platform_service_manager.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" 8#include "core/hle/service/ns/service_getter_interface.h"
9#include "core/hle/service/ns/system_update_interface.h" 9#include "core/hle/service/ns/system_update_interface.h"
10#include "core/hle/service/ns/vulnerability_manager_interface.h" 10#include "core/hle/service/ns/vulnerability_manager_interface.h"
@@ -32,7 +32,7 @@ void LoopProcess(Core::System& system) {
32 server_manager->RegisterNamedService("ns:su", std::make_shared<ISystemUpdateInterface>(system)); 32 server_manager->RegisterNamedService("ns:su", std::make_shared<ISystemUpdateInterface>(system));
33 server_manager->RegisterNamedService("ns:vm", 33 server_manager->RegisterNamedService("ns:vm",
34 std::make_shared<IVulnerabilityManagerInterface>(system)); 34 std::make_shared<IVulnerabilityManagerInterface>(system));
35 server_manager->RegisterNamedService("pdm:qry", std::make_shared<PDM_QRY>(system)); 35 server_manager->RegisterNamedService("pdm:qry", std::make_shared<IQueryService>(system));
36 36
37 server_manager->RegisterNamedService("pl:s", 37 server_manager->RegisterNamedService("pl:s",
38 std::make_shared<IPlatformServiceManager>(system, "pl:s")); 38 std::make_shared<IPlatformServiceManager>(system, "pl:s"));
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/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