From 6334616b44a0b9fc5d601b6deb13fc2c861f253c Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 16:13:01 -0500 Subject: olsc: move INativeHandleHolder, IOlscServiceForApplication, IOlscServiceForSystemService, ITransferTaskListController --- src/core/CMakeLists.txt | 8 + src/core/hle/service/olsc/native_handle_holder.cpp | 21 +++ src/core/hle/service/olsc/native_handle_holder.h | 14 ++ src/core/hle/service/olsc/olsc.cpp | 209 +-------------------- .../service/olsc/olsc_service_for_application.cpp | 70 +++++++ .../service/olsc/olsc_service_for_application.h | 21 +++ .../olsc/olsc_service_for_system_service.cpp | 87 +++++++++ .../service/olsc/olsc_service_for_system_service.h | 17 ++ .../service/olsc/transfer_task_list_controller.cpp | 56 ++++++ .../service/olsc/transfer_task_list_controller.h | 17 ++ 10 files changed, 313 insertions(+), 207 deletions(-) create mode 100644 src/core/hle/service/olsc/native_handle_holder.cpp create mode 100644 src/core/hle/service/olsc/native_handle_holder.h create mode 100644 src/core/hle/service/olsc/olsc_service_for_application.cpp create mode 100644 src/core/hle/service/olsc/olsc_service_for_application.h create mode 100644 src/core/hle/service/olsc/olsc_service_for_system_service.cpp create mode 100644 src/core/hle/service/olsc/olsc_service_for_system_service.h create mode 100644 src/core/hle/service/olsc/transfer_task_list_controller.cpp create mode 100644 src/core/hle/service/olsc/transfer_task_list_controller.h (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index f67a12f8f..8221f0d17 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -860,8 +860,16 @@ add_library(core STATIC hle/service/nvnflinger/ui/graphic_buffer.cpp hle/service/nvnflinger/ui/graphic_buffer.h hle/service/nvnflinger/window.h + hle/service/olsc/native_handle_holder.cpp + hle/service/olsc/native_handle_holder.h + hle/service/olsc/olsc_service_for_application.cpp + hle/service/olsc/olsc_service_for_application.h + hle/service/olsc/olsc_service_for_system_service.cpp + hle/service/olsc/olsc_service_for_system_service.h hle/service/olsc/olsc.cpp hle/service/olsc/olsc.h + hle/service/olsc/transfer_task_list_controller.cpp + hle/service/olsc/transfer_task_list_controller.h hle/service/omm/omm.cpp hle/service/omm/omm.h hle/service/omm/operation_mode_manager.cpp diff --git a/src/core/hle/service/olsc/native_handle_holder.cpp b/src/core/hle/service/olsc/native_handle_holder.cpp new file mode 100644 index 000000000..ac5af5497 --- /dev/null +++ b/src/core/hle/service/olsc/native_handle_holder.cpp @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/olsc/native_handle_holder.h" + +namespace Service::OLSC { + +INativeHandleHolder::INativeHandleHolder(Core::System& system_) + : ServiceFramework{system_, "INativeHandleHolder"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetNativeHandle"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +INativeHandleHolder::~INativeHandleHolder() = default; + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/native_handle_holder.h b/src/core/hle/service/olsc/native_handle_holder.h new file mode 100644 index 000000000..bb8973a1d --- /dev/null +++ b/src/core/hle/service/olsc/native_handle_holder.h @@ -0,0 +1,14 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/service.h" + +namespace Service::OLSC { + +class INativeHandleHolder final : public ServiceFramework { +public: + explicit INativeHandleHolder(Core::System& system_); + ~INativeHandleHolder() override; +}; + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/olsc.cpp b/src/core/hle/service/olsc/olsc.cpp index 889f27c31..26d93cf20 100644 --- a/src/core/hle/service/olsc/olsc.cpp +++ b/src/core/hle/service/olsc/olsc.cpp @@ -1,219 +1,14 @@ // SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/ipc_helpers.h" #include "core/hle/service/olsc/olsc.h" +#include "core/hle/service/olsc/olsc_service_for_application.h" +#include "core/hle/service/olsc/olsc_service_for_system_service.h" #include "core/hle/service/server_manager.h" #include "core/hle/service/service.h" namespace Service::OLSC { -class IOlscServiceForApplication final : public ServiceFramework { -public: - explicit IOlscServiceForApplication(Core::System& system_) - : ServiceFramework{system_, "olsc:u"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &IOlscServiceForApplication::Initialize, "Initialize"}, - {10, nullptr, "VerifySaveDataBackupLicenseAsync"}, - {13, &IOlscServiceForApplication::GetSaveDataBackupSetting, "GetSaveDataBackupSetting"}, - {14, &IOlscServiceForApplication::SetSaveDataBackupSettingEnabled, "SetSaveDataBackupSettingEnabled"}, - {15, nullptr, "SetCustomData"}, - {16, nullptr, "DeleteSaveDataBackupSetting"}, - {18, nullptr, "GetSaveDataBackupInfoCache"}, - {19, nullptr, "UpdateSaveDataBackupInfoCacheAsync"}, - {22, nullptr, "DeleteSaveDataBackupAsync"}, - {25, nullptr, "ListDownloadableSaveDataBackupInfoAsync"}, - {26, nullptr, "DownloadSaveDataBackupAsync"}, - {27, nullptr, "UploadSaveDataBackupAsync"}, - {9010, nullptr, "VerifySaveDataBackupLicenseAsyncForDebug"}, - {9013, nullptr, "GetSaveDataBackupSettingForDebug"}, - {9014, nullptr, "SetSaveDataBackupSettingEnabledForDebug"}, - {9015, nullptr, "SetCustomDataForDebug"}, - {9016, nullptr, "DeleteSaveDataBackupSettingForDebug"}, - {9018, nullptr, "GetSaveDataBackupInfoCacheForDebug"}, - {9019, nullptr, "UpdateSaveDataBackupInfoCacheAsyncForDebug"}, - {9022, nullptr, "DeleteSaveDataBackupAsyncForDebug"}, - {9025, nullptr, "ListDownloadableSaveDataBackupInfoAsyncForDebug"}, - {9026, nullptr, "DownloadSaveDataBackupAsyncForDebug"}, - }; - // clang-format on - - RegisterHandlers(functions); - } - -private: - void Initialize(HLERequestContext& ctx) { - LOG_WARNING(Service_OLSC, "(STUBBED) called"); - - initialized = true; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - void GetSaveDataBackupSetting(HLERequestContext& ctx) { - LOG_WARNING(Service_OLSC, "(STUBBED) called"); - - // backup_setting is set to 0 since real value is unknown - constexpr u64 backup_setting = 0; - - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(ResultSuccess); - rb.Push(backup_setting); - } - - void SetSaveDataBackupSettingEnabled(HLERequestContext& ctx) { - LOG_WARNING(Service_OLSC, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - bool initialized{}; -}; - -class INativeHandleHolder final : public ServiceFramework { -public: - explicit INativeHandleHolder(Core::System& system_) - : ServiceFramework{system_, "INativeHandleHolder"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "GetNativeHandle"}, - }; - // clang-format on - - RegisterHandlers(functions); - } -}; - -class ITransferTaskListController final : public ServiceFramework { -public: - explicit ITransferTaskListController(Core::System& system_) - : ServiceFramework{system_, "ITransferTaskListController"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "Unknown0"}, - {1, nullptr, "Unknown1"}, - {2, nullptr, "Unknown2"}, - {3, nullptr, "Unknown3"}, - {4, nullptr, "Unknown4"}, - {5, &ITransferTaskListController::GetNativeHandleHolder , "GetNativeHandleHolder"}, - {6, nullptr, "Unknown6"}, - {7, nullptr, "Unknown7"}, - {8, nullptr, "GetRemoteStorageController"}, - {9, &ITransferTaskListController::GetNativeHandleHolder, "GetNativeHandleHolder2"}, - {10, nullptr, "Unknown10"}, - {11, nullptr, "Unknown11"}, - {12, nullptr, "Unknown12"}, - {13, nullptr, "Unknown13"}, - {14, nullptr, "Unknown14"}, - {15, nullptr, "Unknown15"}, - {16, nullptr, "Unknown16"}, - {17, nullptr, "Unknown17"}, - {18, nullptr, "Unknown18"}, - {19, nullptr, "Unknown19"}, - {20, nullptr, "Unknown20"}, - {21, nullptr, "Unknown21"}, - {22, nullptr, "Unknown22"}, - {23, nullptr, "Unknown23"}, - {24, nullptr, "Unknown24"}, - {25, nullptr, "Unknown25"}, - }; - // clang-format on - - RegisterHandlers(functions); - } - -private: - void GetNativeHandleHolder(HLERequestContext& ctx) { - LOG_INFO(Service_OLSC, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); - } -}; - -class IOlscServiceForSystemService final : public ServiceFramework { -public: - explicit IOlscServiceForSystemService(Core::System& system_) - : ServiceFramework{system_, "olsc:s"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, &IOlscServiceForSystemService::OpenTransferTaskListController, "OpenTransferTaskListController"}, - {1, nullptr, "OpenRemoteStorageController"}, - {2, nullptr, "OpenDaemonController"}, - {10, nullptr, "Unknown10"}, - {11, nullptr, "Unknown11"}, - {12, nullptr, "Unknown12"}, - {13, nullptr, "Unknown13"}, - {100, nullptr, "ListLastTransferTaskErrorInfo"}, - {101, nullptr, "GetLastErrorInfoCount"}, - {102, nullptr, "RemoveLastErrorInfoOld"}, - {103, nullptr, "GetLastErrorInfo"}, - {104, nullptr, "GetLastErrorEventHolder"}, - {105, nullptr, "GetLastTransferTaskErrorInfo"}, - {200, nullptr, "GetDataTransferPolicyInfo"}, - {201, nullptr, "RemoveDataTransferPolicyInfo"}, - {202, nullptr, "UpdateDataTransferPolicyOld"}, - {203, nullptr, "UpdateDataTransferPolicy"}, - {204, nullptr, "CleanupDataTransferPolicyInfo"}, - {205, nullptr, "RequestDataTransferPolicy"}, - {300, nullptr, "GetAutoTransferSeriesInfo"}, - {301, nullptr, "UpdateAutoTransferSeriesInfo"}, - {400, nullptr, "CleanupSaveDataArchiveInfoType1"}, - {900, nullptr, "CleanupTransferTask"}, - {902, nullptr, "CleanupSeriesInfoType0"}, - {903, nullptr, "CleanupSaveDataArchiveInfoType0"}, - {904, nullptr, "CleanupApplicationAutoTransferSetting"}, - {905, nullptr, "CleanupErrorHistory"}, - {906, nullptr, "SetLastError"}, - {907, nullptr, "AddSaveDataArchiveInfoType0"}, - {908, nullptr, "RemoveSeriesInfoType0"}, - {909, nullptr, "GetSeriesInfoType0"}, - {910, nullptr, "RemoveLastErrorInfo"}, - {911, nullptr, "CleanupSeriesInfoType1"}, - {912, nullptr, "RemoveSeriesInfoType1"}, - {913, nullptr, "GetSeriesInfoType1"}, - {1000, nullptr, "UpdateIssueOld"}, - {1010, nullptr, "Unknown1010"}, - {1011, nullptr, "ListIssueInfoOld"}, - {1012, nullptr, "GetIssueOld"}, - {1013, nullptr, "GetIssue2Old"}, - {1014, nullptr, "GetIssue3Old"}, - {1020, nullptr, "RepairIssueOld"}, - {1021, nullptr, "RepairIssueWithUserIdOld"}, - {1022, nullptr, "RepairIssue2Old"}, - {1023, nullptr, "RepairIssue3Old"}, - {1024, nullptr, "Unknown1024"}, - {1100, nullptr, "UpdateIssue"}, - {1110, nullptr, "Unknown1110"}, - {1111, nullptr, "ListIssueInfo"}, - {1112, nullptr, "GetIssue"}, - {1113, nullptr, "GetIssue2"}, - {1114, nullptr, "GetIssue3"}, - {1120, nullptr, "RepairIssue"}, - {1121, nullptr, "RepairIssueWithUserId"}, - {1122, nullptr, "RepairIssue2"}, - {1123, nullptr, "RepairIssue3"}, - {1124, nullptr, "Unknown1124"}, - }; - // clang-format on - - RegisterHandlers(functions); - } - -private: - void OpenTransferTaskListController(HLERequestContext& ctx) { - LOG_INFO(Service_OLSC, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); - } -}; - void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); diff --git a/src/core/hle/service/olsc/olsc_service_for_application.cpp b/src/core/hle/service/olsc/olsc_service_for_application.cpp new file mode 100644 index 000000000..ae3ed1e3f --- /dev/null +++ b/src/core/hle/service/olsc/olsc_service_for_application.cpp @@ -0,0 +1,70 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/olsc/olsc_service_for_application.h" + +namespace Service::OLSC { + +IOlscServiceForApplication::IOlscServiceForApplication(Core::System& system_) + : ServiceFramework{system_, "olsc:u"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, &IOlscServiceForApplication::Initialize, "Initialize"}, + {10, nullptr, "VerifySaveDataBackupLicenseAsync"}, + {13, &IOlscServiceForApplication::GetSaveDataBackupSetting, "GetSaveDataBackupSetting"}, + {14, &IOlscServiceForApplication::SetSaveDataBackupSettingEnabled, "SetSaveDataBackupSettingEnabled"}, + {15, nullptr, "SetCustomData"}, + {16, nullptr, "DeleteSaveDataBackupSetting"}, + {18, nullptr, "GetSaveDataBackupInfoCache"}, + {19, nullptr, "UpdateSaveDataBackupInfoCacheAsync"}, + {22, nullptr, "DeleteSaveDataBackupAsync"}, + {25, nullptr, "ListDownloadableSaveDataBackupInfoAsync"}, + {26, nullptr, "DownloadSaveDataBackupAsync"}, + {27, nullptr, "UploadSaveDataBackupAsync"}, + {9010, nullptr, "VerifySaveDataBackupLicenseAsyncForDebug"}, + {9013, nullptr, "GetSaveDataBackupSettingForDebug"}, + {9014, nullptr, "SetSaveDataBackupSettingEnabledForDebug"}, + {9015, nullptr, "SetCustomDataForDebug"}, + {9016, nullptr, "DeleteSaveDataBackupSettingForDebug"}, + {9018, nullptr, "GetSaveDataBackupInfoCacheForDebug"}, + {9019, nullptr, "UpdateSaveDataBackupInfoCacheAsyncForDebug"}, + {9022, nullptr, "DeleteSaveDataBackupAsyncForDebug"}, + {9025, nullptr, "ListDownloadableSaveDataBackupInfoAsyncForDebug"}, + {9026, nullptr, "DownloadSaveDataBackupAsyncForDebug"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IOlscServiceForApplication::~IOlscServiceForApplication() = default; + +void IOlscServiceForApplication::Initialize(HLERequestContext& ctx) { + LOG_WARNING(Service_OLSC, "(STUBBED) called"); + + initialized = true; + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IOlscServiceForApplication::GetSaveDataBackupSetting(HLERequestContext& ctx) { + LOG_WARNING(Service_OLSC, "(STUBBED) called"); + + // backup_setting is set to 0 since real value is unknown + constexpr u64 backup_setting = 0; + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(backup_setting); +} + +void IOlscServiceForApplication::SetSaveDataBackupSettingEnabled(HLERequestContext& ctx) { + LOG_WARNING(Service_OLSC, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/olsc_service_for_application.h b/src/core/hle/service/olsc/olsc_service_for_application.h new file mode 100644 index 000000000..29074054b --- /dev/null +++ b/src/core/hle/service/olsc/olsc_service_for_application.h @@ -0,0 +1,21 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/service.h" + +namespace Service::OLSC { + +class IOlscServiceForApplication final : public ServiceFramework { +public: + explicit IOlscServiceForApplication(Core::System& system_); + ~IOlscServiceForApplication() override; + +private: + void Initialize(HLERequestContext& ctx); + void GetSaveDataBackupSetting(HLERequestContext& ctx); + void SetSaveDataBackupSettingEnabled(HLERequestContext& ctx); + + bool initialized{}; +}; + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/olsc_service_for_system_service.cpp b/src/core/hle/service/olsc/olsc_service_for_system_service.cpp new file mode 100644 index 000000000..1873f1245 --- /dev/null +++ b/src/core/hle/service/olsc/olsc_service_for_system_service.cpp @@ -0,0 +1,87 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/olsc/olsc_service_for_system_service.h" +#include "core/hle/service/olsc/transfer_task_list_controller.h" + +namespace Service::OLSC { + +IOlscServiceForSystemService::IOlscServiceForSystemService(Core::System& system_) + : ServiceFramework{system_, "olsc:s"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, &IOlscServiceForSystemService::OpenTransferTaskListController, "OpenTransferTaskListController"}, + {1, nullptr, "OpenRemoteStorageController"}, + {2, nullptr, "OpenDaemonController"}, + {10, nullptr, "Unknown10"}, + {11, nullptr, "Unknown11"}, + {12, nullptr, "Unknown12"}, + {13, nullptr, "Unknown13"}, + {100, nullptr, "ListLastTransferTaskErrorInfo"}, + {101, nullptr, "GetLastErrorInfoCount"}, + {102, nullptr, "RemoveLastErrorInfoOld"}, + {103, nullptr, "GetLastErrorInfo"}, + {104, nullptr, "GetLastErrorEventHolder"}, + {105, nullptr, "GetLastTransferTaskErrorInfo"}, + {200, nullptr, "GetDataTransferPolicyInfo"}, + {201, nullptr, "RemoveDataTransferPolicyInfo"}, + {202, nullptr, "UpdateDataTransferPolicyOld"}, + {203, nullptr, "UpdateDataTransferPolicy"}, + {204, nullptr, "CleanupDataTransferPolicyInfo"}, + {205, nullptr, "RequestDataTransferPolicy"}, + {300, nullptr, "GetAutoTransferSeriesInfo"}, + {301, nullptr, "UpdateAutoTransferSeriesInfo"}, + {400, nullptr, "CleanupSaveDataArchiveInfoType1"}, + {900, nullptr, "CleanupTransferTask"}, + {902, nullptr, "CleanupSeriesInfoType0"}, + {903, nullptr, "CleanupSaveDataArchiveInfoType0"}, + {904, nullptr, "CleanupApplicationAutoTransferSetting"}, + {905, nullptr, "CleanupErrorHistory"}, + {906, nullptr, "SetLastError"}, + {907, nullptr, "AddSaveDataArchiveInfoType0"}, + {908, nullptr, "RemoveSeriesInfoType0"}, + {909, nullptr, "GetSeriesInfoType0"}, + {910, nullptr, "RemoveLastErrorInfo"}, + {911, nullptr, "CleanupSeriesInfoType1"}, + {912, nullptr, "RemoveSeriesInfoType1"}, + {913, nullptr, "GetSeriesInfoType1"}, + {1000, nullptr, "UpdateIssueOld"}, + {1010, nullptr, "Unknown1010"}, + {1011, nullptr, "ListIssueInfoOld"}, + {1012, nullptr, "GetIssueOld"}, + {1013, nullptr, "GetIssue2Old"}, + {1014, nullptr, "GetIssue3Old"}, + {1020, nullptr, "RepairIssueOld"}, + {1021, nullptr, "RepairIssueWithUserIdOld"}, + {1022, nullptr, "RepairIssue2Old"}, + {1023, nullptr, "RepairIssue3Old"}, + {1024, nullptr, "Unknown1024"}, + {1100, nullptr, "UpdateIssue"}, + {1110, nullptr, "Unknown1110"}, + {1111, nullptr, "ListIssueInfo"}, + {1112, nullptr, "GetIssue"}, + {1113, nullptr, "GetIssue2"}, + {1114, nullptr, "GetIssue3"}, + {1120, nullptr, "RepairIssue"}, + {1121, nullptr, "RepairIssueWithUserId"}, + {1122, nullptr, "RepairIssue2"}, + {1123, nullptr, "RepairIssue3"}, + {1124, nullptr, "Unknown1124"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IOlscServiceForSystemService::~IOlscServiceForSystemService() = default; + +void IOlscServiceForSystemService::OpenTransferTaskListController(HLERequestContext& ctx) { + LOG_INFO(Service_OLSC, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface(system); +} + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/olsc_service_for_system_service.h b/src/core/hle/service/olsc/olsc_service_for_system_service.h new file mode 100644 index 000000000..a81fba0dc --- /dev/null +++ b/src/core/hle/service/olsc/olsc_service_for_system_service.h @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/service.h" + +namespace Service::OLSC { + +class IOlscServiceForSystemService final : public ServiceFramework { +public: + explicit IOlscServiceForSystemService(Core::System& system_); + ~IOlscServiceForSystemService() override; + +private: + void OpenTransferTaskListController(HLERequestContext& ctx); +}; + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/transfer_task_list_controller.cpp b/src/core/hle/service/olsc/transfer_task_list_controller.cpp new file mode 100644 index 000000000..9aa941309 --- /dev/null +++ b/src/core/hle/service/olsc/transfer_task_list_controller.cpp @@ -0,0 +1,56 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/olsc/native_handle_holder.h" +#include "core/hle/service/olsc/transfer_task_list_controller.h" + +namespace Service::OLSC { + +ITransferTaskListController::ITransferTaskListController(Core::System& system_) + : ServiceFramework{system_, "ITransferTaskListController"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "Unknown0"}, + {1, nullptr, "Unknown1"}, + {2, nullptr, "Unknown2"}, + {3, nullptr, "Unknown3"}, + {4, nullptr, "Unknown4"}, + {5, &ITransferTaskListController::GetNativeHandleHolder , "GetNativeHandleHolder"}, + {6, nullptr, "Unknown6"}, + {7, nullptr, "Unknown7"}, + {8, nullptr, "GetRemoteStorageController"}, + {9, &ITransferTaskListController::GetNativeHandleHolder, "GetNativeHandleHolder2"}, + {10, nullptr, "Unknown10"}, + {11, nullptr, "Unknown11"}, + {12, nullptr, "Unknown12"}, + {13, nullptr, "Unknown13"}, + {14, nullptr, "Unknown14"}, + {15, nullptr, "Unknown15"}, + {16, nullptr, "Unknown16"}, + {17, nullptr, "Unknown17"}, + {18, nullptr, "Unknown18"}, + {19, nullptr, "Unknown19"}, + {20, nullptr, "Unknown20"}, + {21, nullptr, "Unknown21"}, + {22, nullptr, "Unknown22"}, + {23, nullptr, "Unknown23"}, + {24, nullptr, "Unknown24"}, + {25, nullptr, "Unknown25"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +ITransferTaskListController::~ITransferTaskListController() = default; + +void ITransferTaskListController::GetNativeHandleHolder(HLERequestContext& ctx) { + LOG_INFO(Service_OLSC, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface(system); +} + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/transfer_task_list_controller.h b/src/core/hle/service/olsc/transfer_task_list_controller.h new file mode 100644 index 000000000..daf476d8a --- /dev/null +++ b/src/core/hle/service/olsc/transfer_task_list_controller.h @@ -0,0 +1,17 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/service.h" + +namespace Service::OLSC { + +class ITransferTaskListController final : public ServiceFramework { +public: + explicit ITransferTaskListController(Core::System& system_); + ~ITransferTaskListController() override; + +private: + void GetNativeHandleHolder(HLERequestContext& ctx); +}; + +} // namespace Service::OLSC -- cgit v1.2.3 From 8ffa27b311060061a5e9b240d92c7df1c81ac011 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 16:23:13 -0500 Subject: olsc: rewrite IOlscServiceForApplication --- src/core/hle/service/olsc/olsc.cpp | 14 ++++++--- .../service/olsc/olsc_service_for_application.cpp | 35 +++++++++------------- .../service/olsc/olsc_service_for_application.h | 8 +++-- 3 files changed, 29 insertions(+), 28 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/olsc/olsc.cpp b/src/core/hle/service/olsc/olsc.cpp index 26d93cf20..18e5ad43f 100644 --- a/src/core/hle/service/olsc/olsc.cpp +++ b/src/core/hle/service/olsc/olsc.cpp @@ -12,10 +12,16 @@ namespace Service::OLSC { void LoopProcess(Core::System& system) { auto server_manager = std::make_unique(system); - server_manager->RegisterNamedService("olsc:u", - std::make_shared(system)); - server_manager->RegisterNamedService("olsc:s", - std::make_shared(system)); + const auto OlscFactoryForApplication = [&] { + return std::make_shared(system); + }; + + const auto OlscFactoryForSystemService = [&] { + return std::make_shared(system); + }; + + server_manager->RegisterNamedService("olsc:u", OlscFactoryForApplication); + server_manager->RegisterNamedService("olsc:s", OlscFactoryForSystemService); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/olsc/olsc_service_for_application.cpp b/src/core/hle/service/olsc/olsc_service_for_application.cpp index ae3ed1e3f..01360f5ef 100644 --- a/src/core/hle/service/olsc/olsc_service_for_application.cpp +++ b/src/core/hle/service/olsc/olsc_service_for_application.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/olsc/olsc_service_for_application.h" namespace Service::OLSC { @@ -10,10 +10,10 @@ IOlscServiceForApplication::IOlscServiceForApplication(Core::System& system_) : ServiceFramework{system_, "olsc:u"} { // clang-format off static const FunctionInfo functions[] = { - {0, &IOlscServiceForApplication::Initialize, "Initialize"}, + {0, D<&IOlscServiceForApplication::Initialize>, "Initialize"}, {10, nullptr, "VerifySaveDataBackupLicenseAsync"}, - {13, &IOlscServiceForApplication::GetSaveDataBackupSetting, "GetSaveDataBackupSetting"}, - {14, &IOlscServiceForApplication::SetSaveDataBackupSettingEnabled, "SetSaveDataBackupSettingEnabled"}, + {13, D<&IOlscServiceForApplication::GetSaveDataBackupSetting>, "GetSaveDataBackupSetting"}, + {14, D<&IOlscServiceForApplication::SetSaveDataBackupSettingEnabled>, "SetSaveDataBackupSettingEnabled"}, {15, nullptr, "SetCustomData"}, {16, nullptr, "DeleteSaveDataBackupSetting"}, {18, nullptr, "GetSaveDataBackupInfoCache"}, @@ -40,31 +40,24 @@ IOlscServiceForApplication::IOlscServiceForApplication(Core::System& system_) IOlscServiceForApplication::~IOlscServiceForApplication() = default; -void IOlscServiceForApplication::Initialize(HLERequestContext& ctx) { +Result IOlscServiceForApplication::Initialize(ClientProcessId process_id) { LOG_WARNING(Service_OLSC, "(STUBBED) called"); - initialized = true; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + R_SUCCEED(); } -void IOlscServiceForApplication::GetSaveDataBackupSetting(HLERequestContext& ctx) { +Result IOlscServiceForApplication::GetSaveDataBackupSetting(Out out_save_data_backup_setting) { LOG_WARNING(Service_OLSC, "(STUBBED) called"); - // backup_setting is set to 0 since real value is unknown - constexpr u64 backup_setting = 0; - - IPC::ResponseBuilder rb{ctx, 4}; - rb.Push(ResultSuccess); - rb.Push(backup_setting); + *out_save_data_backup_setting = 0; + R_SUCCEED(); } -void IOlscServiceForApplication::SetSaveDataBackupSettingEnabled(HLERequestContext& ctx) { - LOG_WARNING(Service_OLSC, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); +Result IOlscServiceForApplication::SetSaveDataBackupSettingEnabled(bool enabled, + NS::Uid account_id) { + LOG_WARNING(Service_OLSC, "(STUBBED) called, enabled={}, account_id={}", enabled, + account_id.uuid.FormattedString()); + R_SUCCEED(); } } // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/olsc_service_for_application.h b/src/core/hle/service/olsc/olsc_service_for_application.h index 29074054b..3f9ac7536 100644 --- a/src/core/hle/service/olsc/olsc_service_for_application.h +++ b/src/core/hle/service/olsc/olsc_service_for_application.h @@ -1,6 +1,8 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/ns/ns_types.h" #include "core/hle/service/service.h" namespace Service::OLSC { @@ -11,9 +13,9 @@ public: ~IOlscServiceForApplication() override; private: - void Initialize(HLERequestContext& ctx); - void GetSaveDataBackupSetting(HLERequestContext& ctx); - void SetSaveDataBackupSettingEnabled(HLERequestContext& ctx); + Result Initialize(ClientProcessId process_id); + Result GetSaveDataBackupSetting(Out out_save_data_backup_setting); + Result SetSaveDataBackupSettingEnabled(bool enabled, NS::Uid account_id); bool initialized{}; }; -- cgit v1.2.3 From 868937083097ad5ea2ce5c2b209762064b9c9381 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 18:19:48 -0500 Subject: olsc: rewrite INativeHandleHolder --- src/core/hle/service/olsc/native_handle_holder.cpp | 9 ++++++++- src/core/hle/service/olsc/native_handle_holder.h | 8 ++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/hle/service/olsc/native_handle_holder.cpp b/src/core/hle/service/olsc/native_handle_holder.cpp index ac5af5497..3cb5d7b11 100644 --- a/src/core/hle/service/olsc/native_handle_holder.cpp +++ b/src/core/hle/service/olsc/native_handle_holder.cpp @@ -1,6 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/olsc/native_handle_holder.h" namespace Service::OLSC { @@ -9,7 +10,7 @@ INativeHandleHolder::INativeHandleHolder(Core::System& system_) : ServiceFramework{system_, "INativeHandleHolder"} { // clang-format off static const FunctionInfo functions[] = { - {0, nullptr, "GetNativeHandle"}, + {0, D<&INativeHandleHolder::GetNativeHandle>, "GetNativeHandle"}, }; // clang-format on @@ -18,4 +19,10 @@ INativeHandleHolder::INativeHandleHolder(Core::System& system_) INativeHandleHolder::~INativeHandleHolder() = default; +Result INativeHandleHolder::GetNativeHandle(OutCopyHandle out_event) { + LOG_WARNING(Service_OLSC, "(STUBBED) called"); + *out_event = nullptr; + R_SUCCEED(); +} + } // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/native_handle_holder.h b/src/core/hle/service/olsc/native_handle_holder.h index bb8973a1d..a44754c20 100644 --- a/src/core/hle/service/olsc/native_handle_holder.h +++ b/src/core/hle/service/olsc/native_handle_holder.h @@ -1,14 +1,22 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" +namespace Kernel { +class KReadableEvent; +} + namespace Service::OLSC { class INativeHandleHolder final : public ServiceFramework { public: explicit INativeHandleHolder(Core::System& system_); ~INativeHandleHolder() override; + +private: + Result GetNativeHandle(OutCopyHandle out_event); }; } // namespace Service::OLSC -- cgit v1.2.3 From 6b956a695196d73c38fd717c516f3ae27e0f2387 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 18:36:17 -0500 Subject: olsc: rewrite ITransferTaskListController --- .../service/olsc/transfer_task_list_controller.cpp | 69 +++++++++++----------- .../service/olsc/transfer_task_list_controller.h | 5 +- 2 files changed, 38 insertions(+), 36 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/olsc/transfer_task_list_controller.cpp b/src/core/hle/service/olsc/transfer_task_list_controller.cpp index 9aa941309..8ea9a0f1e 100644 --- a/src/core/hle/service/olsc/transfer_task_list_controller.cpp +++ b/src/core/hle/service/olsc/transfer_task_list_controller.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/olsc/native_handle_holder.h" #include "core/hle/service/olsc/transfer_task_list_controller.h" @@ -10,34 +10,34 @@ namespace Service::OLSC { ITransferTaskListController::ITransferTaskListController(Core::System& system_) : ServiceFramework{system_, "ITransferTaskListController"} { // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "Unknown0"}, - {1, nullptr, "Unknown1"}, - {2, nullptr, "Unknown2"}, - {3, nullptr, "Unknown3"}, - {4, nullptr, "Unknown4"}, - {5, &ITransferTaskListController::GetNativeHandleHolder , "GetNativeHandleHolder"}, - {6, nullptr, "Unknown6"}, - {7, nullptr, "Unknown7"}, - {8, nullptr, "GetRemoteStorageController"}, - {9, &ITransferTaskListController::GetNativeHandleHolder, "GetNativeHandleHolder2"}, - {10, nullptr, "Unknown10"}, - {11, nullptr, "Unknown11"}, - {12, nullptr, "Unknown12"}, - {13, nullptr, "Unknown13"}, - {14, nullptr, "Unknown14"}, - {15, nullptr, "Unknown15"}, - {16, nullptr, "Unknown16"}, - {17, nullptr, "Unknown17"}, - {18, nullptr, "Unknown18"}, - {19, nullptr, "Unknown19"}, - {20, nullptr, "Unknown20"}, - {21, nullptr, "Unknown21"}, - {22, nullptr, "Unknown22"}, - {23, nullptr, "Unknown23"}, - {24, nullptr, "Unknown24"}, - {25, nullptr, "Unknown25"}, - }; + static const FunctionInfo functions[] = { + {0, nullptr, "Unknown0"}, + {1, nullptr, "Unknown1"}, + {2, nullptr, "Unknown2"}, + {3, nullptr, "Unknown3"}, + {4, nullptr, "Unknown4"}, + {5, D<&ITransferTaskListController::GetNativeHandleHolder>, "GetNativeHandleHolder"}, + {6, nullptr, "Unknown6"}, + {7, nullptr, "Unknown7"}, + {8, nullptr, "GetRemoteStorageController"}, + {9, D<&ITransferTaskListController::GetNativeHandleHolder>, "GetNativeHandleHolder2"}, + {10, nullptr, "Unknown10"}, + {11, nullptr, "Unknown11"}, + {12, nullptr, "Unknown12"}, + {13, nullptr, "Unknown13"}, + {14, nullptr, "Unknown14"}, + {15, nullptr, "Unknown15"}, + {16, nullptr, "Unknown16"}, + {17, nullptr, "Unknown17"}, + {18, nullptr, "Unknown18"}, + {19, nullptr, "Unknown19"}, + {20, nullptr, "Unknown20"}, + {21, nullptr, "Unknown21"}, + {22, nullptr, "Unknown22"}, + {23, nullptr, "Unknown23"}, + {24, nullptr, "Unknown24"}, + {25, nullptr, "Unknown25"}, + }; // clang-format on RegisterHandlers(functions); @@ -45,12 +45,11 @@ ITransferTaskListController::ITransferTaskListController(Core::System& system_) ITransferTaskListController::~ITransferTaskListController() = default; -void ITransferTaskListController::GetNativeHandleHolder(HLERequestContext& ctx) { - LOG_INFO(Service_OLSC, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); +Result ITransferTaskListController::GetNativeHandleHolder( + Out> out_holder) { + LOG_WARNING(Service_OLSC, "(STUBBED) called"); + *out_holder = std::make_shared(system); + R_SUCCEED(); } } // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/transfer_task_list_controller.h b/src/core/hle/service/olsc/transfer_task_list_controller.h index daf476d8a..f10a71375 100644 --- a/src/core/hle/service/olsc/transfer_task_list_controller.h +++ b/src/core/hle/service/olsc/transfer_task_list_controller.h @@ -1,17 +1,20 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" namespace Service::OLSC { +class INativeHandleHolder; + class ITransferTaskListController final : public ServiceFramework { public: explicit ITransferTaskListController(Core::System& system_); ~ITransferTaskListController() override; private: - void GetNativeHandleHolder(HLERequestContext& ctx); + Result GetNativeHandleHolder(Out> out_holder); }; } // namespace Service::OLSC -- cgit v1.2.3 From 5f3c03d6a8f9bc83e78025edfd4b20b2f19cb04f Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 18:42:06 -0500 Subject: olsc: add IDaemonController --- src/core/CMakeLists.txt | 2 ++ src/core/hle/service/olsc/daemon_controller.cpp | 40 +++++++++++++++++++++++++ src/core/hle/service/olsc/daemon_controller.h | 20 +++++++++++++ 3 files changed, 62 insertions(+) create mode 100644 src/core/hle/service/olsc/daemon_controller.cpp create mode 100644 src/core/hle/service/olsc/daemon_controller.h (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8221f0d17..36bc9103e 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -860,6 +860,8 @@ add_library(core STATIC hle/service/nvnflinger/ui/graphic_buffer.cpp hle/service/nvnflinger/ui/graphic_buffer.h hle/service/nvnflinger/window.h + hle/service/olsc/daemon_controller.cpp + hle/service/olsc/daemon_controller.h hle/service/olsc/native_handle_holder.cpp hle/service/olsc/native_handle_holder.h hle/service/olsc/olsc_service_for_application.cpp diff --git a/src/core/hle/service/olsc/daemon_controller.cpp b/src/core/hle/service/olsc/daemon_controller.cpp new file mode 100644 index 000000000..7823780a8 --- /dev/null +++ b/src/core/hle/service/olsc/daemon_controller.cpp @@ -0,0 +1,40 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/olsc/daemon_controller.h" + +namespace Service::OLSC { + +IDaemonController::IDaemonController(Core::System& system_) + : ServiceFramework{system_, "IDaemonController"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, D<&IDaemonController::GetAutoTransferEnabledForAccountAndApplication>, "GetAutoTransferEnabledForAccountAndApplication"}, + {1, nullptr, "SetAutoTransferEnabledForAccountAndApplication"}, + {2, nullptr, "GetGlobalUploadEnabledForAccount"}, + {3, nullptr, "SetGlobalUploadEnabledForAccount"}, + {4, nullptr, "TouchAccount"}, + {5, nullptr, "GetGlobalDownloadEnabledForAccount"}, + {6, nullptr, "SetGlobalDownloadEnabledForAccount"}, + {10, nullptr, "GetForbiddenSaveDataIndication"}, + {11, nullptr, "GetStopperObject"}, + {12, nullptr, "GetState"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IDaemonController::~IDaemonController() = default; + +Result IDaemonController::GetAutoTransferEnabledForAccountAndApplication(Out out_is_enabled, + Common::UUID user_id, + u64 application_id) { + LOG_WARNING(Service_OLSC, "(STUBBED) called, user_id={} application_id={:016X}", + user_id.FormattedString(), application_id); + *out_is_enabled = false; + R_SUCCEED(); +} + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/daemon_controller.h b/src/core/hle/service/olsc/daemon_controller.h new file mode 100644 index 000000000..dfad7f52a --- /dev/null +++ b/src/core/hle/service/olsc/daemon_controller.h @@ -0,0 +1,20 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "common/uuid.h" +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Service::OLSC { + +class IDaemonController final : public ServiceFramework { +public: + explicit IDaemonController(Core::System& system_); + ~IDaemonController() override; + +private: + Result GetAutoTransferEnabledForAccountAndApplication(Out out_is_enabled, + Common::UUID user_id, u64 application_id); +}; + +} // namespace Service::OLSC -- cgit v1.2.3 From a8bca2429299dbc436b8c167107580a9e4697cb6 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 19:47:38 -0500 Subject: olsc: add IRemoteStorageController --- .../hle/service/olsc/remote_storage_controller.cpp | 54 ++++++++++++++++++++++ .../hle/service/olsc/remote_storage_controller.h | 19 ++++++++ 2 files changed, 73 insertions(+) create mode 100644 src/core/hle/service/olsc/remote_storage_controller.cpp create mode 100644 src/core/hle/service/olsc/remote_storage_controller.h (limited to 'src/core') diff --git a/src/core/hle/service/olsc/remote_storage_controller.cpp b/src/core/hle/service/olsc/remote_storage_controller.cpp new file mode 100644 index 000000000..81d9c96ab --- /dev/null +++ b/src/core/hle/service/olsc/remote_storage_controller.cpp @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/olsc/remote_storage_controller.h" + +namespace Service::OLSC { + +IRemoteStorageController::IRemoteStorageController(Core::System& system_) + : ServiceFramework{system_, "IRemoteStorageController"} { + // clang-format off + static const FunctionInfo functions[] = { + {0, nullptr, "GetSaveDataArchiveInfoBySaveDataId"}, + {1, nullptr, "GetSaveDataArchiveInfoByApplicationId"}, + {3, nullptr, "GetSaveDataArchiveCount"}, + {6, nullptr, "CleanupSaveDataArchives"}, + {7, nullptr, "CreateSaveDataArchiveCacheUpdationTask"}, + {8, nullptr, "CreateSaveDataArchiveCacheUpdationForSpecifiedApplicationTask"}, + {9, nullptr, "Delete"}, + {10, nullptr, "GetSeriesInfo"}, + {11, nullptr, "CreateDeleteDataTask"}, + {12, nullptr, "DeleteSeriesInfo"}, + {13, nullptr, "CreateRegisterNotificationTokenTask"}, + {14, nullptr, "UpdateSeriesInfo"}, + {15, nullptr, "RegisterUploadSaveDataTransferTaskForAutonomyRegistration"}, + {16, nullptr, "CreateCleanupToDeleteSaveDataArchiveInfoTask"}, + {17, nullptr, "ListDataInfo"}, + {18, nullptr, "GetDataInfo"}, + {19, nullptr, "Unknown19"}, + {20, nullptr, "CreateSaveDataArchiveInfoCacheForSaveDataBackupUpdationTask"}, + {21, nullptr, "ListSecondarySaves"}, + {22, D<&IRemoteStorageController::GetSecondarySave>, "GetSecondarySave"}, + {23, nullptr, "TouchSecondarySave"}, + {24, nullptr, "GetSecondarySaveDataInfo"}, + {25, nullptr, "RegisterDownloadSaveDataTransferTaskForAutonomyRegistration"}, + {900, nullptr, "Unknown900"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IRemoteStorageController::~IRemoteStorageController() = default; + +Result IRemoteStorageController::GetSecondarySave(Out out_has_secondary_save, + Out> out_unknown, + u64 application_id) { + LOG_ERROR(Service_OLSC, "(STUBBED) called, application_id={:016X}", application_id); + *out_has_secondary_save = false; + *out_unknown = {}; + R_SUCCEED(); +} + +} // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/remote_storage_controller.h b/src/core/hle/service/olsc/remote_storage_controller.h new file mode 100644 index 000000000..e7a0b5244 --- /dev/null +++ b/src/core/hle/service/olsc/remote_storage_controller.h @@ -0,0 +1,19 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Service::OLSC { + +class IRemoteStorageController final : public ServiceFramework { +public: + explicit IRemoteStorageController(Core::System& system_); + ~IRemoteStorageController() override; + +private: + Result GetSecondarySave(Out out_has_secondary_save, Out> out_unknown, + u64 application_id); +}; + +} // namespace Service::OLSC -- cgit v1.2.3 From e540757279ee2e9cc1ed395f0480d6136d57e1b9 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 19:59:41 -0500 Subject: olsc: rewrite IOlscServiceForSystemService --- src/core/CMakeLists.txt | 2 + .../olsc/olsc_service_for_system_service.cpp | 48 ++++++++++++++++++---- .../service/olsc/olsc_service_for_system_service.h | 12 +++++- 3 files changed, 52 insertions(+), 10 deletions(-) (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 36bc9103e..d48696654 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -870,6 +870,8 @@ add_library(core STATIC hle/service/olsc/olsc_service_for_system_service.h hle/service/olsc/olsc.cpp hle/service/olsc/olsc.h + hle/service/olsc/remote_storage_controller.cpp + hle/service/olsc/remote_storage_controller.h hle/service/olsc/transfer_task_list_controller.cpp hle/service/olsc/transfer_task_list_controller.h hle/service/omm/omm.cpp diff --git a/src/core/hle/service/olsc/olsc_service_for_system_service.cpp b/src/core/hle/service/olsc/olsc_service_for_system_service.cpp index 1873f1245..f027933c9 100644 --- a/src/core/hle/service/olsc/olsc_service_for_system_service.cpp +++ b/src/core/hle/service/olsc/olsc_service_for_system_service.cpp @@ -1,8 +1,10 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/olsc/daemon_controller.h" #include "core/hle/service/olsc/olsc_service_for_system_service.h" +#include "core/hle/service/olsc/remote_storage_controller.h" #include "core/hle/service/olsc/transfer_task_list_controller.h" namespace Service::OLSC { @@ -11,9 +13,9 @@ IOlscServiceForSystemService::IOlscServiceForSystemService(Core::System& system_ : ServiceFramework{system_, "olsc:s"} { // clang-format off static const FunctionInfo functions[] = { - {0, &IOlscServiceForSystemService::OpenTransferTaskListController, "OpenTransferTaskListController"}, - {1, nullptr, "OpenRemoteStorageController"}, - {2, nullptr, "OpenDaemonController"}, + {0, D<&IOlscServiceForSystemService::OpenTransferTaskListController>, "OpenTransferTaskListController"}, + {1, D<&IOlscServiceForSystemService::OpenRemoteStorageController>, "OpenRemoteStorageController"}, + {2, D<&IOlscServiceForSystemService::OpenDaemonController>, "OpenDaemonController"}, {10, nullptr, "Unknown10"}, {11, nullptr, "Unknown11"}, {12, nullptr, "Unknown12"}, @@ -24,7 +26,7 @@ IOlscServiceForSystemService::IOlscServiceForSystemService(Core::System& system_ {103, nullptr, "GetLastErrorInfo"}, {104, nullptr, "GetLastErrorEventHolder"}, {105, nullptr, "GetLastTransferTaskErrorInfo"}, - {200, nullptr, "GetDataTransferPolicyInfo"}, + {200, D<&IOlscServiceForSystemService::GetDataTransferPolicyInfo>, "GetDataTransferPolicyInfo"}, {201, nullptr, "RemoveDataTransferPolicyInfo"}, {202, nullptr, "UpdateDataTransferPolicyOld"}, {203, nullptr, "UpdateDataTransferPolicy"}, @@ -68,6 +70,7 @@ IOlscServiceForSystemService::IOlscServiceForSystemService(Core::System& system_ {1122, nullptr, "RepairIssue2"}, {1123, nullptr, "RepairIssue3"}, {1124, nullptr, "Unknown1124"}, + {10000, D<&IOlscServiceForSystemService::CloneService>, "CloneService"}, }; // clang-format on @@ -76,12 +79,39 @@ IOlscServiceForSystemService::IOlscServiceForSystemService(Core::System& system_ IOlscServiceForSystemService::~IOlscServiceForSystemService() = default; -void IOlscServiceForSystemService::OpenTransferTaskListController(HLERequestContext& ctx) { +Result IOlscServiceForSystemService::OpenTransferTaskListController( + Out> out_interface) { LOG_INFO(Service_OLSC, "called"); + *out_interface = std::make_shared(system); + R_SUCCEED(); +} + +Result IOlscServiceForSystemService::OpenRemoteStorageController( + Out> out_interface) { + LOG_INFO(Service_OLSC, "called"); + *out_interface = std::make_shared(system); + R_SUCCEED(); +} + +Result IOlscServiceForSystemService::OpenDaemonController( + Out> out_interface) { + LOG_INFO(Service_OLSC, "called"); + *out_interface = std::make_shared(system); + R_SUCCEED(); +} - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system); +Result IOlscServiceForSystemService::GetDataTransferPolicyInfo(Out out_policy_info, + u64 application_id) { + LOG_WARNING(Service_OLSC, "(STUBBED) called"); + *out_policy_info = 0; + R_SUCCEED(); +} + +Result IOlscServiceForSystemService::CloneService( + Out> out_interface) { + LOG_INFO(Service_OLSC, "called"); + *out_interface = std::static_pointer_cast(shared_from_this()); + R_SUCCEED(); } } // namespace Service::OLSC diff --git a/src/core/hle/service/olsc/olsc_service_for_system_service.h b/src/core/hle/service/olsc/olsc_service_for_system_service.h index a81fba0dc..13026272a 100644 --- a/src/core/hle/service/olsc/olsc_service_for_system_service.h +++ b/src/core/hle/service/olsc/olsc_service_for_system_service.h @@ -1,17 +1,27 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/cmif_types.h" #include "core/hle/service/service.h" namespace Service::OLSC { +class IDaemonController; +class IRemoteStorageController; +class ITransferTaskListController; + class IOlscServiceForSystemService final : public ServiceFramework { public: explicit IOlscServiceForSystemService(Core::System& system_); ~IOlscServiceForSystemService() override; private: - void OpenTransferTaskListController(HLERequestContext& ctx); + Result OpenTransferTaskListController( + Out> out_interface); + Result OpenRemoteStorageController(Out> out_interface); + Result OpenDaemonController(Out> out_interface); + Result GetDataTransferPolicyInfo(Out out_policy_info, u64 application_id); + Result CloneService(Out> out_interface); }; } // namespace Service::OLSC -- cgit v1.2.3 From 01d89acd139e50470c41e5cd04df4acd49b635c6 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 20:52:51 -0500 Subject: pctl: move types and results --- src/core/CMakeLists.txt | 2 + src/core/hle/service/pctl/pctl_module.cpp | 82 ++++++++++--------------------- src/core/hle/service/pctl/pctl_module.h | 13 +---- src/core/hle/service/pctl/pctl_results.h | 15 ++++++ src/core/hle/service/pctl/pctl_types.h | 43 ++++++++++++++++ 5 files changed, 88 insertions(+), 67 deletions(-) create mode 100644 src/core/hle/service/pctl/pctl_results.h create mode 100644 src/core/hle/service/pctl/pctl_types.h (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d48696654..9e913fb10 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -897,6 +897,8 @@ add_library(core STATIC hle/service/pctl/pctl.h hle/service/pctl/pctl_module.cpp hle/service/pctl/pctl_module.h + hle/service/pctl/pctl_results.h + hle/service/pctl/pctl_types.h hle/service/pcv/pcv.cpp hle/service/pcv/pcv.h hle/service/pm/pm.cpp diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp index 6a7fd72bc..dab37cdc4 100644 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ b/src/core/hle/service/pctl/pctl_module.cpp @@ -9,18 +9,28 @@ #include "core/hle/service/kernel_helpers.h" #include "core/hle/service/pctl/pctl.h" #include "core/hle/service/pctl/pctl_module.h" +#include "core/hle/service/pctl/pctl_results.h" +#include "core/hle/service/pctl/pctl_types.h" #include "core/hle/service/server_manager.h" namespace Service::PCTL { -namespace Error { - -constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101}; -constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104}; -constexpr Result ResultNoCapability{ErrorModule::PCTL, 131}; -constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; +struct States { + u64 current_tid{}; + ApplicationInfo application_info{}; + u64 tid_from_event{}; + bool launch_time_valid{}; + bool is_suspended{}; + bool temporary_unlocked{}; + bool free_communication{}; + bool stereo_vision{}; +}; -} // namespace Error +struct ParentalControlSettings { + bool is_stero_vision_restricted{}; + bool is_free_communication_default_on{}; + bool disabled{}; +}; class IParentalControlService final : public ServiceFramework { public: @@ -214,7 +224,7 @@ private: states.free_communication = false; states.stereo_vision = false; states.application_info = ApplicationInfo{ - .tid = tid, + .application_id = tid, .age_rating = control.first->GetRatingAge(), .parental_control_flag = control.first->GetParentalControlFlag(), .capability = capability, @@ -234,7 +244,7 @@ private: IPC::ResponseBuilder rb{ctx, 2}; if (!CheckFreeCommunicationPermissionImpl()) { - rb.Push(Error::ResultNoFreeCommunication); + rb.Push(ResultNoFreeCommunication); } else { rb.Push(ResultSuccess); } @@ -246,7 +256,7 @@ private: LOG_WARNING(Service_PCTL, "(STUBBED) called"); IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(Error::ResultNoFreeCommunication); + rb.Push(ResultNoFreeCommunication); } void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { @@ -280,7 +290,7 @@ private: IPC::ResponseBuilder rb{ctx, 2}; if (!CheckFreeCommunicationPermissionImpl()) { - rb.Push(Error::ResultNoFreeCommunication); + rb.Push(ResultNoFreeCommunication); } else { rb.Push(ResultSuccess); } @@ -292,7 +302,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; if (False(capability & (Capability::Status | Capability::Recovery))) { LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); - rb.Push(Error::ResultNoCapability); + rb.Push(ResultNoCapability); rb.Push(false); return; } @@ -335,12 +345,12 @@ private: if (False(capability & Capability::StereoVision)) { LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(Error::ResultNoCapability); + rb.Push(ResultNoCapability); return; } if (pin_code[0] == '\0') { - rb.Push(Error::ResultNoRestrictionEnabled); + rb.Push(ResultNoRestrictionEnabled); return; } @@ -352,7 +362,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; if (!ConfirmStereoVisionPermissionImpl()) { - rb.Push(Error::ResultStereoVisionRestricted); + rb.Push(ResultStereoVisionRestricted); rb.Push(false); } else { rb.Push(ResultSuccess); @@ -423,7 +433,7 @@ private: IPC::ResponseBuilder rb{ctx, 2}; if (False(capability & Capability::StereoVision)) { LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(Error::ResultNoCapability); + rb.Push(ResultNoCapability); return; } @@ -437,7 +447,7 @@ private: IPC::ResponseBuilder rb{ctx, 3}; if (False(capability & Capability::StereoVision)) { LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(Error::ResultNoCapability); + rb.Push(ResultNoCapability); rb.Push(false); return; } @@ -455,44 +465,6 @@ private: rb.Push(ResultSuccess); } - struct ApplicationInfo { - u64 tid{}; - std::array age_rating{}; - u32 parental_control_flag{}; - Capability capability{}; - }; - - struct States { - u64 current_tid{}; - ApplicationInfo application_info{}; - u64 tid_from_event{}; - bool launch_time_valid{}; - bool is_suspended{}; - bool temporary_unlocked{}; - bool free_communication{}; - bool stereo_vision{}; - }; - - struct ParentalControlSettings { - bool is_stero_vision_restricted{}; - bool is_free_communication_default_on{}; - bool disabled{}; - }; - - // This is nn::pctl::RestrictionSettings - struct RestrictionSettings { - u8 rating_age; - bool sns_post_restriction; - bool free_communication_restriction; - }; - static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size."); - - // This is nn::pctl::PlayTimerSettings - struct PlayTimerSettings { - std::array settings; - }; - static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size."); - States states{}; ParentalControlSettings settings{}; RestrictionSettings restriction_settings{}; diff --git a/src/core/hle/service/pctl/pctl_module.h b/src/core/hle/service/pctl/pctl_module.h index dff0d3f08..715c05b20 100644 --- a/src/core/hle/service/pctl/pctl_module.h +++ b/src/core/hle/service/pctl/pctl_module.h @@ -3,7 +3,7 @@ #pragma once -#include "common/common_funcs.h" +#include "core/hle/service/pctl/pctl_types.h" #include "core/hle/service/service.h" namespace Core { @@ -12,17 +12,6 @@ class System; namespace Service::PCTL { -enum class Capability : u32 { - None = 0, - Application = 1 << 0, - SnsPost = 1 << 1, - Recovery = 1 << 6, - Status = 1 << 8, - StereoVision = 1 << 9, - System = 1 << 15, -}; -DECLARE_ENUM_FLAG_OPERATORS(Capability); - class Module final { public: class Interface : public ServiceFramework { diff --git a/src/core/hle/service/pctl/pctl_results.h b/src/core/hle/service/pctl/pctl_results.h new file mode 100644 index 000000000..1fc54727b --- /dev/null +++ b/src/core/hle/service/pctl/pctl_results.h @@ -0,0 +1,15 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/result.h" + +namespace Service::PCTL { + +constexpr Result ResultNoFreeCommunication{ErrorModule::PCTL, 101}; +constexpr Result ResultStereoVisionRestricted{ErrorModule::PCTL, 104}; +constexpr Result ResultNoCapability{ErrorModule::PCTL, 131}; +constexpr Result ResultNoRestrictionEnabled{ErrorModule::PCTL, 181}; + +} // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/pctl_types.h b/src/core/hle/service/pctl/pctl_types.h new file mode 100644 index 000000000..daaecdf48 --- /dev/null +++ b/src/core/hle/service/pctl/pctl_types.h @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "common/common_funcs.h" + +namespace Service::PCTL { + +enum class Capability : u32 { + None = 0, + Application = 1 << 0, + SnsPost = 1 << 1, + Recovery = 1 << 6, + Status = 1 << 8, + StereoVision = 1 << 9, + System = 1 << 15, +}; +DECLARE_ENUM_FLAG_OPERATORS(Capability); + +struct ApplicationInfo { + u64 application_id{}; + std::array age_rating{}; + u32 parental_control_flag{}; + Capability capability{}; +}; +static_assert(sizeof(ApplicationInfo) == 0x30, "ApplicationInfo has incorrect size."); + +// This is nn::pctl::RestrictionSettings +struct RestrictionSettings { + u8 rating_age; + bool sns_post_restriction; + bool free_communication_restriction; +}; +static_assert(sizeof(RestrictionSettings) == 0x3, "RestrictionSettings has incorrect size."); + +// This is nn::pctl::PlayTimerSettings +struct PlayTimerSettings { + std::array settings; +}; +static_assert(sizeof(PlayTimerSettings) == 0x34, "PlayTimerSettings has incorrect size."); + +} // namespace Service::PCTL -- cgit v1.2.3 From a37bd0b9a706f63cf1eb4503549171c232bf4238 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 20:59:33 -0500 Subject: pctl: move IParentalControlService --- src/core/CMakeLists.txt | 2 + .../hle/service/pctl/parental_control_service.cpp | 441 +++++++++++++++++++ .../hle/service/pctl/parental_control_service.h | 74 ++++ src/core/hle/service/pctl/pctl_module.cpp | 468 +-------------------- 4 files changed, 518 insertions(+), 467 deletions(-) create mode 100644 src/core/hle/service/pctl/parental_control_service.cpp create mode 100644 src/core/hle/service/pctl/parental_control_service.h (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 9e913fb10..d0fdae8db 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -893,6 +893,8 @@ add_library(core STATIC hle/service/os/mutex.h hle/service/pcie/pcie.cpp hle/service/pcie/pcie.h + hle/service/pctl/parental_control_service.cpp + hle/service/pctl/parental_control_service.h hle/service/pctl/pctl.cpp hle/service/pctl/pctl.h hle/service/pctl/pctl_module.cpp diff --git a/src/core/hle/service/pctl/parental_control_service.cpp b/src/core/hle/service/pctl/parental_control_service.cpp new file mode 100644 index 000000000..4248b0184 --- /dev/null +++ b/src/core/hle/service/pctl/parental_control_service.cpp @@ -0,0 +1,441 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/core.h" +#include "core/file_sys/control_metadata.h" +#include "core/file_sys/patch_manager.h" +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/pctl/parental_control_service.h" +#include "core/hle/service/pctl/pctl_results.h" + +namespace Service::PCTL { + +IParentalControlService::IParentalControlService(Core::System& system_, Capability capability_) + : ServiceFramework{system_, "IParentalControlService"}, capability{capability_}, + service_context{system_, "IParentalControlService"} { + // clang-format off + static const FunctionInfo functions[] = { + {1, &IParentalControlService::Initialize, "Initialize"}, + {1001, &IParentalControlService::CheckFreeCommunicationPermission, "CheckFreeCommunicationPermission"}, + {1002, nullptr, "ConfirmLaunchApplicationPermission"}, + {1003, nullptr, "ConfirmResumeApplicationPermission"}, + {1004, &IParentalControlService::ConfirmSnsPostPermission, "ConfirmSnsPostPermission"}, + {1005, nullptr, "ConfirmSystemSettingsPermission"}, + {1006, &IParentalControlService::IsRestrictionTemporaryUnlocked, "IsRestrictionTemporaryUnlocked"}, + {1007, nullptr, "RevertRestrictionTemporaryUnlocked"}, + {1008, nullptr, "EnterRestrictedSystemSettings"}, + {1009, nullptr, "LeaveRestrictedSystemSettings"}, + {1010, nullptr, "IsRestrictedSystemSettingsEntered"}, + {1011, nullptr, "RevertRestrictedSystemSettingsEntered"}, + {1012, nullptr, "GetRestrictedFeatures"}, + {1013, &IParentalControlService::ConfirmStereoVisionPermission, "ConfirmStereoVisionPermission"}, + {1014, nullptr, "ConfirmPlayableApplicationVideoOld"}, + {1015, nullptr, "ConfirmPlayableApplicationVideo"}, + {1016, nullptr, "ConfirmShowNewsPermission"}, + {1017, &IParentalControlService::EndFreeCommunication, "EndFreeCommunication"}, + {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"}, + {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"}, + {1032, &IParentalControlService::GetSafetyLevel, "GetSafetyLevel"}, + {1033, nullptr, "SetSafetyLevel"}, + {1034, nullptr, "GetSafetyLevelSettings"}, + {1035, &IParentalControlService::GetCurrentSettings, "GetCurrentSettings"}, + {1036, nullptr, "SetCustomSafetyLevelSettings"}, + {1037, nullptr, "GetDefaultRatingOrganization"}, + {1038, nullptr, "SetDefaultRatingOrganization"}, + {1039, &IParentalControlService::GetFreeCommunicationApplicationListCount, "GetFreeCommunicationApplicationListCount"}, + {1042, nullptr, "AddToFreeCommunicationApplicationList"}, + {1043, nullptr, "DeleteSettings"}, + {1044, nullptr, "GetFreeCommunicationApplicationList"}, + {1045, nullptr, "UpdateFreeCommunicationApplicationList"}, + {1046, nullptr, "DisableFeaturesForReset"}, + {1047, nullptr, "NotifyApplicationDownloadStarted"}, + {1048, nullptr, "NotifyNetworkProfileCreated"}, + {1049, nullptr, "ResetFreeCommunicationApplicationList"}, + {1061, &IParentalControlService::ConfirmStereoVisionRestrictionConfigurable, "ConfirmStereoVisionRestrictionConfigurable"}, + {1062, &IParentalControlService::GetStereoVisionRestriction, "GetStereoVisionRestriction"}, + {1063, &IParentalControlService::SetStereoVisionRestriction, "SetStereoVisionRestriction"}, + {1064, &IParentalControlService::ResetConfirmedStereoVisionPermission, "ResetConfirmedStereoVisionPermission"}, + {1065, &IParentalControlService::IsStereoVisionPermitted, "IsStereoVisionPermitted"}, + {1201, nullptr, "UnlockRestrictionTemporarily"}, + {1202, nullptr, "UnlockSystemSettingsRestriction"}, + {1203, nullptr, "SetPinCode"}, + {1204, nullptr, "GenerateInquiryCode"}, + {1205, nullptr, "CheckMasterKey"}, + {1206, nullptr, "GetPinCodeLength"}, + {1207, nullptr, "GetPinCodeChangedEvent"}, + {1208, nullptr, "GetPinCode"}, + {1403, &IParentalControlService::IsPairingActive, "IsPairingActive"}, + {1406, nullptr, "GetSettingsLastUpdated"}, + {1411, nullptr, "GetPairingAccountInfo"}, + {1421, nullptr, "GetAccountNickname"}, + {1424, nullptr, "GetAccountState"}, + {1425, nullptr, "RequestPostEvents"}, + {1426, nullptr, "GetPostEventInterval"}, + {1427, nullptr, "SetPostEventInterval"}, + {1432, &IParentalControlService::GetSynchronizationEvent, "GetSynchronizationEvent"}, + {1451, nullptr, "StartPlayTimer"}, + {1452, nullptr, "StopPlayTimer"}, + {1453, nullptr, "IsPlayTimerEnabled"}, + {1454, nullptr, "GetPlayTimerRemainingTime"}, + {1455, nullptr, "IsRestrictedByPlayTimer"}, + {1456, &IParentalControlService::GetPlayTimerSettings, "GetPlayTimerSettings"}, + {1457, &IParentalControlService::GetPlayTimerEventToRequestSuspension, "GetPlayTimerEventToRequestSuspension"}, + {1458, &IParentalControlService::IsPlayTimerAlarmDisabled, "IsPlayTimerAlarmDisabled"}, + {1471, nullptr, "NotifyWrongPinCodeInputManyTimes"}, + {1472, nullptr, "CancelNetworkRequest"}, + {1473, &IParentalControlService::GetUnlinkedEvent, "GetUnlinkedEvent"}, + {1474, nullptr, "ClearUnlinkedEvent"}, + {1601, nullptr, "DisableAllFeatures"}, + {1602, nullptr, "PostEnableAllFeatures"}, + {1603, nullptr, "IsAllFeaturesDisabled"}, + {1901, nullptr, "DeleteFromFreeCommunicationApplicationListForDebug"}, + {1902, nullptr, "ClearFreeCommunicationApplicationListForDebug"}, + {1903, nullptr, "GetExemptApplicationListCountForDebug"}, + {1904, nullptr, "GetExemptApplicationListForDebug"}, + {1905, nullptr, "UpdateExemptApplicationListForDebug"}, + {1906, nullptr, "AddToExemptApplicationListForDebug"}, + {1907, nullptr, "DeleteFromExemptApplicationListForDebug"}, + {1908, nullptr, "ClearExemptApplicationListForDebug"}, + {1941, nullptr, "DeletePairing"}, + {1951, nullptr, "SetPlayTimerSettingsForDebug"}, + {1952, nullptr, "GetPlayTimerSpentTimeForTest"}, + {1953, nullptr, "SetPlayTimerAlarmDisabledForDebug"}, + {2001, nullptr, "RequestPairingAsync"}, + {2002, nullptr, "FinishRequestPairing"}, + {2003, nullptr, "AuthorizePairingAsync"}, + {2004, nullptr, "FinishAuthorizePairing"}, + {2005, nullptr, "RetrievePairingInfoAsync"}, + {2006, nullptr, "FinishRetrievePairingInfo"}, + {2007, nullptr, "UnlinkPairingAsync"}, + {2008, nullptr, "FinishUnlinkPairing"}, + {2009, nullptr, "GetAccountMiiImageAsync"}, + {2010, nullptr, "FinishGetAccountMiiImage"}, + {2011, nullptr, "GetAccountMiiImageContentTypeAsync"}, + {2012, nullptr, "FinishGetAccountMiiImageContentType"}, + {2013, nullptr, "SynchronizeParentalControlSettingsAsync"}, + {2014, nullptr, "FinishSynchronizeParentalControlSettings"}, + {2015, nullptr, "FinishSynchronizeParentalControlSettingsWithLastUpdated"}, + {2016, nullptr, "RequestUpdateExemptionListAsync"}, + }; + // clang-format on + RegisterHandlers(functions); + + synchronization_event = + service_context.CreateEvent("IParentalControlService::SynchronizationEvent"); + unlinked_event = service_context.CreateEvent("IParentalControlService::UnlinkedEvent"); + request_suspension_event = + service_context.CreateEvent("IParentalControlService::RequestSuspensionEvent"); +} + +IParentalControlService::~IParentalControlService() { + service_context.CloseEvent(synchronization_event); + service_context.CloseEvent(unlinked_event); + service_context.CloseEvent(request_suspension_event); +} + +bool IParentalControlService::CheckFreeCommunicationPermissionImpl() const { + if (states.temporary_unlocked) { + return true; + } + if ((states.application_info.parental_control_flag & 1) == 0) { + return true; + } + if (pin_code[0] == '\0') { + return true; + } + if (!settings.is_free_communication_default_on) { + return true; + } + // TODO(ogniK): Check for blacklisted/exempted applications. Return false can happen here + // but as we don't have multiproceses support yet, we can just assume our application is + // valid for the time being + return true; +} + +bool IParentalControlService::ConfirmStereoVisionPermissionImpl() const { + if (states.temporary_unlocked) { + return true; + } + if (pin_code[0] == '\0') { + return true; + } + if (!settings.is_stero_vision_restricted) { + return false; + } + return true; +} + +void IParentalControlService::SetStereoVisionRestrictionImpl(bool is_restricted) { + if (settings.disabled) { + return; + } + + if (pin_code[0] == '\0') { + return; + } + settings.is_stero_vision_restricted = is_restricted; +} + +void IParentalControlService::Initialize(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + IPC::ResponseBuilder rb{ctx, 2}; + + if (False(capability & (Capability::Application | Capability::System))) { + LOG_ERROR(Service_PCTL, "Invalid capability! capability={:X}", capability); + return; + } + + // TODO(ogniK): Recovery flag initialization for pctl:r + + const auto tid = system.GetApplicationProcessProgramID(); + if (tid != 0) { + const FileSys::PatchManager pm{tid, system.GetFileSystemController(), + system.GetContentProvider()}; + const auto control = pm.GetControlMetadata(); + if (control.first) { + states.tid_from_event = 0; + states.launch_time_valid = false; + states.is_suspended = false; + states.free_communication = false; + states.stereo_vision = false; + states.application_info = ApplicationInfo{ + .application_id = tid, + .age_rating = control.first->GetRatingAge(), + .parental_control_flag = control.first->GetParentalControlFlag(), + .capability = capability, + }; + + if (False(capability & (Capability::System | Capability::Recovery))) { + // TODO(ogniK): Signal application launch event + } + } + } + + rb.Push(ResultSuccess); +} + +void IParentalControlService::CheckFreeCommunicationPermission(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2}; + if (!CheckFreeCommunicationPermissionImpl()) { + rb.Push(PCTL::ResultNoFreeCommunication); + } else { + rb.Push(ResultSuccess); + } + + states.free_communication = true; +} + +void IParentalControlService::ConfirmSnsPostPermission(HLERequestContext& ctx) { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(PCTL::ResultNoFreeCommunication); +} + +void IParentalControlService::IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { + const bool is_temporary_unlocked = false; + + LOG_WARNING(Service_PCTL, "(STUBBED) called, is_temporary_unlocked={}", is_temporary_unlocked); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(is_temporary_unlocked); +} + +void IParentalControlService::ConfirmStereoVisionPermission(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + states.stereo_vision = true; + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IParentalControlService::EndFreeCommunication(HLERequestContext& ctx) { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +void IParentalControlService::IsFreeCommunicationAvailable(HLERequestContext& ctx) { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + + IPC::ResponseBuilder rb{ctx, 2}; + if (!CheckFreeCommunicationPermissionImpl()) { + rb.Push(PCTL::ResultNoFreeCommunication); + } else { + rb.Push(ResultSuccess); + } +} + +void IParentalControlService::IsRestrictionEnabled(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 3}; + if (False(capability & (Capability::Status | Capability::Recovery))) { + LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); + rb.Push(PCTL::ResultNoCapability); + rb.Push(false); + return; + } + + rb.Push(pin_code[0] != '\0'); +} + +void IParentalControlService::GetSafetyLevel(HLERequestContext& ctx) { + const u32 safety_level = 0; + + LOG_WARNING(Service_PCTL, "(STUBBED) called, safety_level={}", safety_level); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(safety_level); +} + +void IParentalControlService::GetCurrentSettings(HLERequestContext& ctx) { + LOG_INFO(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.PushRaw(restriction_settings); +} + +void IParentalControlService::GetFreeCommunicationApplicationListCount(HLERequestContext& ctx) { + const u32 count = 4; + + LOG_WARNING(Service_PCTL, "(STUBBED) called, count={}", count); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(count); +} + +void IParentalControlService::ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2}; + + if (False(capability & Capability::StereoVision)) { + LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); + rb.Push(PCTL::ResultNoCapability); + return; + } + + if (pin_code[0] == '\0') { + rb.Push(PCTL::ResultNoRestrictionEnabled); + return; + } + + rb.Push(ResultSuccess); +} + +void IParentalControlService::IsStereoVisionPermitted(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 3}; + if (!ConfirmStereoVisionPermissionImpl()) { + rb.Push(PCTL::ResultStereoVisionRestricted); + rb.Push(false); + } else { + rb.Push(ResultSuccess); + rb.Push(true); + } +} + +void IParentalControlService::IsPairingActive(HLERequestContext& ctx) { + const bool is_pairing_active = false; + + LOG_WARNING(Service_PCTL, "(STUBBED) called, is_pairing_active={}", is_pairing_active); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(is_pairing_active); +} + +void IParentalControlService::GetSynchronizationEvent(HLERequestContext& ctx) { + LOG_INFO(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(synchronization_event->GetReadableEvent()); +} + +void IParentalControlService::GetPlayTimerSettings(HLERequestContext& ctx) { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + + const PlayTimerSettings timer_settings{}; + + IPC::ResponseBuilder rb{ctx, 15}; + rb.Push(ResultSuccess); + rb.PushRaw(timer_settings); +} + +void IParentalControlService::GetPlayTimerEventToRequestSuspension(HLERequestContext& ctx) { + LOG_INFO(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(request_suspension_event->GetReadableEvent()); +} + +void IParentalControlService::IsPlayTimerAlarmDisabled(HLERequestContext& ctx) { + const bool is_play_timer_alarm_disabled = false; + + LOG_INFO(Service_PCTL, "called, is_play_timer_alarm_disabled={}", is_play_timer_alarm_disabled); + + IPC::ResponseBuilder rb{ctx, 3}; + rb.Push(ResultSuccess); + rb.Push(is_play_timer_alarm_disabled); +} + +void IParentalControlService::GetUnlinkedEvent(HLERequestContext& ctx) { + LOG_INFO(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 1}; + rb.Push(ResultSuccess); + rb.PushCopyObjects(unlinked_event->GetReadableEvent()); +} + +void IParentalControlService::SetStereoVisionRestriction(HLERequestContext& ctx) { + IPC::RequestParser rp{ctx}; + const auto can_use = rp.Pop(); + LOG_DEBUG(Service_PCTL, "called, can_use={}", can_use); + + IPC::ResponseBuilder rb{ctx, 2}; + if (False(capability & Capability::StereoVision)) { + LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); + rb.Push(PCTL::ResultNoCapability); + return; + } + + SetStereoVisionRestrictionImpl(can_use); + rb.Push(ResultSuccess); +} + +void IParentalControlService::GetStereoVisionRestriction(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 3}; + if (False(capability & Capability::StereoVision)) { + LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); + rb.Push(PCTL::ResultNoCapability); + rb.Push(false); + return; + } + + rb.Push(ResultSuccess); + rb.Push(settings.is_stero_vision_restricted); +} + +void IParentalControlService::ResetConfirmedStereoVisionPermission(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + states.stereo_vision = false; + + IPC::ResponseBuilder rb{ctx, 2}; + rb.Push(ResultSuccess); +} + +} // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/parental_control_service.h b/src/core/hle/service/pctl/parental_control_service.h new file mode 100644 index 000000000..dcc357f65 --- /dev/null +++ b/src/core/hle/service/pctl/parental_control_service.h @@ -0,0 +1,74 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/pctl/pctl_types.h" +#include "core/hle/service/service.h" + +namespace Service::PCTL { + +class IParentalControlService final : public ServiceFramework { +public: + explicit IParentalControlService(Core::System& system_, Capability capability_); + ~IParentalControlService() override; + +private: + bool CheckFreeCommunicationPermissionImpl() const; + bool ConfirmStereoVisionPermissionImpl() const; + void SetStereoVisionRestrictionImpl(bool is_restricted); + + void Initialize(HLERequestContext& ctx); + void CheckFreeCommunicationPermission(HLERequestContext& ctx); + void ConfirmSnsPostPermission(HLERequestContext& ctx); + void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx); + void ConfirmStereoVisionPermission(HLERequestContext& ctx); + void EndFreeCommunication(HLERequestContext& ctx); + void IsFreeCommunicationAvailable(HLERequestContext& ctx); + void IsRestrictionEnabled(HLERequestContext& ctx); + void GetSafetyLevel(HLERequestContext& ctx); + void GetCurrentSettings(HLERequestContext& ctx); + void GetFreeCommunicationApplicationListCount(HLERequestContext& ctx); + void ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx); + void IsStereoVisionPermitted(HLERequestContext& ctx); + void IsPairingActive(HLERequestContext& ctx); + void GetSynchronizationEvent(HLERequestContext& ctx); + void GetPlayTimerSettings(HLERequestContext& ctx); + void GetPlayTimerEventToRequestSuspension(HLERequestContext& ctx); + void IsPlayTimerAlarmDisabled(HLERequestContext& ctx); + void GetUnlinkedEvent(HLERequestContext& ctx); + void SetStereoVisionRestriction(HLERequestContext& ctx); + void GetStereoVisionRestriction(HLERequestContext& ctx); + void ResetConfirmedStereoVisionPermission(HLERequestContext& ctx); + + struct States { + u64 current_tid{}; + ApplicationInfo application_info{}; + u64 tid_from_event{}; + bool launch_time_valid{}; + bool is_suspended{}; + bool temporary_unlocked{}; + bool free_communication{}; + bool stereo_vision{}; + }; + + struct ParentalControlSettings { + bool is_stero_vision_restricted{}; + bool is_free_communication_default_on{}; + bool disabled{}; + }; + + States states{}; + ParentalControlSettings settings{}; + RestrictionSettings restriction_settings{}; + std::array pin_code{}; + Capability capability{}; + + Kernel::KEvent* synchronization_event; + Kernel::KEvent* unlinked_event; + Kernel::KEvent* request_suspension_event; + KernelHelpers::ServiceContext service_context; +}; + +} // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp index dab37cdc4..118856574 100644 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ b/src/core/hle/service/pctl/pctl_module.cpp @@ -2,481 +2,15 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/logging/log.h" -#include "core/core.h" -#include "core/file_sys/control_metadata.h" -#include "core/file_sys/patch_manager.h" #include "core/hle/service/ipc_helpers.h" #include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/pctl/parental_control_service.h" #include "core/hle/service/pctl/pctl.h" #include "core/hle/service/pctl/pctl_module.h" -#include "core/hle/service/pctl/pctl_results.h" -#include "core/hle/service/pctl/pctl_types.h" #include "core/hle/service/server_manager.h" namespace Service::PCTL { -struct States { - u64 current_tid{}; - ApplicationInfo application_info{}; - u64 tid_from_event{}; - bool launch_time_valid{}; - bool is_suspended{}; - bool temporary_unlocked{}; - bool free_communication{}; - bool stereo_vision{}; -}; - -struct ParentalControlSettings { - bool is_stero_vision_restricted{}; - bool is_free_communication_default_on{}; - bool disabled{}; -}; - -class IParentalControlService final : public ServiceFramework { -public: - explicit IParentalControlService(Core::System& system_, Capability capability_) - : ServiceFramework{system_, "IParentalControlService"}, capability{capability_}, - service_context{system_, "IParentalControlService"} { - // clang-format off - static const FunctionInfo functions[] = { - {1, &IParentalControlService::Initialize, "Initialize"}, - {1001, &IParentalControlService::CheckFreeCommunicationPermission, "CheckFreeCommunicationPermission"}, - {1002, nullptr, "ConfirmLaunchApplicationPermission"}, - {1003, nullptr, "ConfirmResumeApplicationPermission"}, - {1004, &IParentalControlService::ConfirmSnsPostPermission, "ConfirmSnsPostPermission"}, - {1005, nullptr, "ConfirmSystemSettingsPermission"}, - {1006, &IParentalControlService::IsRestrictionTemporaryUnlocked, "IsRestrictionTemporaryUnlocked"}, - {1007, nullptr, "RevertRestrictionTemporaryUnlocked"}, - {1008, nullptr, "EnterRestrictedSystemSettings"}, - {1009, nullptr, "LeaveRestrictedSystemSettings"}, - {1010, nullptr, "IsRestrictedSystemSettingsEntered"}, - {1011, nullptr, "RevertRestrictedSystemSettingsEntered"}, - {1012, nullptr, "GetRestrictedFeatures"}, - {1013, &IParentalControlService::ConfirmStereoVisionPermission, "ConfirmStereoVisionPermission"}, - {1014, nullptr, "ConfirmPlayableApplicationVideoOld"}, - {1015, nullptr, "ConfirmPlayableApplicationVideo"}, - {1016, nullptr, "ConfirmShowNewsPermission"}, - {1017, &IParentalControlService::EndFreeCommunication, "EndFreeCommunication"}, - {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"}, - {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"}, - {1032, &IParentalControlService::GetSafetyLevel, "GetSafetyLevel"}, - {1033, nullptr, "SetSafetyLevel"}, - {1034, nullptr, "GetSafetyLevelSettings"}, - {1035, &IParentalControlService::GetCurrentSettings, "GetCurrentSettings"}, - {1036, nullptr, "SetCustomSafetyLevelSettings"}, - {1037, nullptr, "GetDefaultRatingOrganization"}, - {1038, nullptr, "SetDefaultRatingOrganization"}, - {1039, &IParentalControlService::GetFreeCommunicationApplicationListCount, "GetFreeCommunicationApplicationListCount"}, - {1042, nullptr, "AddToFreeCommunicationApplicationList"}, - {1043, nullptr, "DeleteSettings"}, - {1044, nullptr, "GetFreeCommunicationApplicationList"}, - {1045, nullptr, "UpdateFreeCommunicationApplicationList"}, - {1046, nullptr, "DisableFeaturesForReset"}, - {1047, nullptr, "NotifyApplicationDownloadStarted"}, - {1048, nullptr, "NotifyNetworkProfileCreated"}, - {1049, nullptr, "ResetFreeCommunicationApplicationList"}, - {1061, &IParentalControlService::ConfirmStereoVisionRestrictionConfigurable, "ConfirmStereoVisionRestrictionConfigurable"}, - {1062, &IParentalControlService::GetStereoVisionRestriction, "GetStereoVisionRestriction"}, - {1063, &IParentalControlService::SetStereoVisionRestriction, "SetStereoVisionRestriction"}, - {1064, &IParentalControlService::ResetConfirmedStereoVisionPermission, "ResetConfirmedStereoVisionPermission"}, - {1065, &IParentalControlService::IsStereoVisionPermitted, "IsStereoVisionPermitted"}, - {1201, nullptr, "UnlockRestrictionTemporarily"}, - {1202, nullptr, "UnlockSystemSettingsRestriction"}, - {1203, nullptr, "SetPinCode"}, - {1204, nullptr, "GenerateInquiryCode"}, - {1205, nullptr, "CheckMasterKey"}, - {1206, nullptr, "GetPinCodeLength"}, - {1207, nullptr, "GetPinCodeChangedEvent"}, - {1208, nullptr, "GetPinCode"}, - {1403, &IParentalControlService::IsPairingActive, "IsPairingActive"}, - {1406, nullptr, "GetSettingsLastUpdated"}, - {1411, nullptr, "GetPairingAccountInfo"}, - {1421, nullptr, "GetAccountNickname"}, - {1424, nullptr, "GetAccountState"}, - {1425, nullptr, "RequestPostEvents"}, - {1426, nullptr, "GetPostEventInterval"}, - {1427, nullptr, "SetPostEventInterval"}, - {1432, &IParentalControlService::GetSynchronizationEvent, "GetSynchronizationEvent"}, - {1451, nullptr, "StartPlayTimer"}, - {1452, nullptr, "StopPlayTimer"}, - {1453, nullptr, "IsPlayTimerEnabled"}, - {1454, nullptr, "GetPlayTimerRemainingTime"}, - {1455, nullptr, "IsRestrictedByPlayTimer"}, - {1456, &IParentalControlService::GetPlayTimerSettings, "GetPlayTimerSettings"}, - {1457, &IParentalControlService::GetPlayTimerEventToRequestSuspension, "GetPlayTimerEventToRequestSuspension"}, - {1458, &IParentalControlService::IsPlayTimerAlarmDisabled, "IsPlayTimerAlarmDisabled"}, - {1471, nullptr, "NotifyWrongPinCodeInputManyTimes"}, - {1472, nullptr, "CancelNetworkRequest"}, - {1473, &IParentalControlService::GetUnlinkedEvent, "GetUnlinkedEvent"}, - {1474, nullptr, "ClearUnlinkedEvent"}, - {1601, nullptr, "DisableAllFeatures"}, - {1602, nullptr, "PostEnableAllFeatures"}, - {1603, nullptr, "IsAllFeaturesDisabled"}, - {1901, nullptr, "DeleteFromFreeCommunicationApplicationListForDebug"}, - {1902, nullptr, "ClearFreeCommunicationApplicationListForDebug"}, - {1903, nullptr, "GetExemptApplicationListCountForDebug"}, - {1904, nullptr, "GetExemptApplicationListForDebug"}, - {1905, nullptr, "UpdateExemptApplicationListForDebug"}, - {1906, nullptr, "AddToExemptApplicationListForDebug"}, - {1907, nullptr, "DeleteFromExemptApplicationListForDebug"}, - {1908, nullptr, "ClearExemptApplicationListForDebug"}, - {1941, nullptr, "DeletePairing"}, - {1951, nullptr, "SetPlayTimerSettingsForDebug"}, - {1952, nullptr, "GetPlayTimerSpentTimeForTest"}, - {1953, nullptr, "SetPlayTimerAlarmDisabledForDebug"}, - {2001, nullptr, "RequestPairingAsync"}, - {2002, nullptr, "FinishRequestPairing"}, - {2003, nullptr, "AuthorizePairingAsync"}, - {2004, nullptr, "FinishAuthorizePairing"}, - {2005, nullptr, "RetrievePairingInfoAsync"}, - {2006, nullptr, "FinishRetrievePairingInfo"}, - {2007, nullptr, "UnlinkPairingAsync"}, - {2008, nullptr, "FinishUnlinkPairing"}, - {2009, nullptr, "GetAccountMiiImageAsync"}, - {2010, nullptr, "FinishGetAccountMiiImage"}, - {2011, nullptr, "GetAccountMiiImageContentTypeAsync"}, - {2012, nullptr, "FinishGetAccountMiiImageContentType"}, - {2013, nullptr, "SynchronizeParentalControlSettingsAsync"}, - {2014, nullptr, "FinishSynchronizeParentalControlSettings"}, - {2015, nullptr, "FinishSynchronizeParentalControlSettingsWithLastUpdated"}, - {2016, nullptr, "RequestUpdateExemptionListAsync"}, - }; - // clang-format on - RegisterHandlers(functions); - - synchronization_event = - service_context.CreateEvent("IParentalControlService::SynchronizationEvent"); - unlinked_event = service_context.CreateEvent("IParentalControlService::UnlinkedEvent"); - request_suspension_event = - service_context.CreateEvent("IParentalControlService::RequestSuspensionEvent"); - } - - ~IParentalControlService() { - service_context.CloseEvent(synchronization_event); - service_context.CloseEvent(unlinked_event); - service_context.CloseEvent(request_suspension_event); - }; - -private: - bool CheckFreeCommunicationPermissionImpl() const { - if (states.temporary_unlocked) { - return true; - } - if ((states.application_info.parental_control_flag & 1) == 0) { - return true; - } - if (pin_code[0] == '\0') { - return true; - } - if (!settings.is_free_communication_default_on) { - return true; - } - // TODO(ogniK): Check for blacklisted/exempted applications. Return false can happen here - // but as we don't have multiproceses support yet, we can just assume our application is - // valid for the time being - return true; - } - - bool ConfirmStereoVisionPermissionImpl() const { - if (states.temporary_unlocked) { - return true; - } - if (pin_code[0] == '\0') { - return true; - } - if (!settings.is_stero_vision_restricted) { - return false; - } - return true; - } - - void SetStereoVisionRestrictionImpl(bool is_restricted) { - if (settings.disabled) { - return; - } - - if (pin_code[0] == '\0') { - return; - } - settings.is_stero_vision_restricted = is_restricted; - } - - void Initialize(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 2}; - - if (False(capability & (Capability::Application | Capability::System))) { - LOG_ERROR(Service_PCTL, "Invalid capability! capability={:X}", capability); - return; - } - - // TODO(ogniK): Recovery flag initialization for pctl:r - - const auto tid = system.GetApplicationProcessProgramID(); - if (tid != 0) { - const FileSys::PatchManager pm{tid, system.GetFileSystemController(), - system.GetContentProvider()}; - const auto control = pm.GetControlMetadata(); - if (control.first) { - states.tid_from_event = 0; - states.launch_time_valid = false; - states.is_suspended = false; - states.free_communication = false; - states.stereo_vision = false; - states.application_info = ApplicationInfo{ - .application_id = tid, - .age_rating = control.first->GetRatingAge(), - .parental_control_flag = control.first->GetParentalControlFlag(), - .capability = capability, - }; - - if (False(capability & (Capability::System | Capability::Recovery))) { - // TODO(ogniK): Signal application launch event - } - } - } - - rb.Push(ResultSuccess); - } - - void CheckFreeCommunicationPermission(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2}; - if (!CheckFreeCommunicationPermissionImpl()) { - rb.Push(ResultNoFreeCommunication); - } else { - rb.Push(ResultSuccess); - } - - states.free_communication = true; - } - - void ConfirmSnsPostPermission(HLERequestContext& ctx) { - LOG_WARNING(Service_PCTL, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultNoFreeCommunication); - } - - void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { - const bool is_temporary_unlocked = false; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, is_temporary_unlocked={}", - is_temporary_unlocked); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_temporary_unlocked); - } - - void ConfirmStereoVisionPermission(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - states.stereo_vision = true; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - void EndFreeCommunication(HLERequestContext& ctx) { - LOG_WARNING(Service_PCTL, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - void IsFreeCommunicationAvailable(HLERequestContext& ctx) { - LOG_WARNING(Service_PCTL, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 2}; - if (!CheckFreeCommunicationPermissionImpl()) { - rb.Push(ResultNoFreeCommunication); - } else { - rb.Push(ResultSuccess); - } - } - - void IsRestrictionEnabled(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 3}; - if (False(capability & (Capability::Status | Capability::Recovery))) { - LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); - rb.Push(ResultNoCapability); - rb.Push(false); - return; - } - - rb.Push(pin_code[0] != '\0'); - } - - void GetSafetyLevel(HLERequestContext& ctx) { - const u32 safety_level = 0; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, safety_level={}", safety_level); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(safety_level); - } - - void GetCurrentSettings(HLERequestContext& ctx) { - LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.PushRaw(restriction_settings); - } - - void GetFreeCommunicationApplicationListCount(HLERequestContext& ctx) { - const u32 count = 4; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, count={}", count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(count); - } - - void ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2}; - - if (False(capability & Capability::StereoVision)) { - LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(ResultNoCapability); - return; - } - - if (pin_code[0] == '\0') { - rb.Push(ResultNoRestrictionEnabled); - return; - } - - rb.Push(ResultSuccess); - } - - void IsStereoVisionPermitted(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 3}; - if (!ConfirmStereoVisionPermissionImpl()) { - rb.Push(ResultStereoVisionRestricted); - rb.Push(false); - } else { - rb.Push(ResultSuccess); - rb.Push(true); - } - } - - void IsPairingActive(HLERequestContext& ctx) { - const bool is_pairing_active = false; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, is_pairing_active={}", is_pairing_active); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_pairing_active); - } - - void GetSynchronizationEvent(HLERequestContext& ctx) { - LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(synchronization_event->GetReadableEvent()); - } - - void GetPlayTimerSettings(HLERequestContext& ctx) { - LOG_WARNING(Service_PCTL, "(STUBBED) called"); - - const PlayTimerSettings timer_settings{}; - - IPC::ResponseBuilder rb{ctx, 15}; - rb.Push(ResultSuccess); - rb.PushRaw(timer_settings); - } - - void GetPlayTimerEventToRequestSuspension(HLERequestContext& ctx) { - LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(request_suspension_event->GetReadableEvent()); - } - - void IsPlayTimerAlarmDisabled(HLERequestContext& ctx) { - const bool is_play_timer_alarm_disabled = false; - - LOG_INFO(Service_PCTL, "called, is_play_timer_alarm_disabled={}", - is_play_timer_alarm_disabled); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_play_timer_alarm_disabled); - } - - void GetUnlinkedEvent(HLERequestContext& ctx) { - LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(unlinked_event->GetReadableEvent()); - } - - void SetStereoVisionRestriction(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto can_use = rp.Pop(); - LOG_DEBUG(Service_PCTL, "called, can_use={}", can_use); - - IPC::ResponseBuilder rb{ctx, 2}; - if (False(capability & Capability::StereoVision)) { - LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(ResultNoCapability); - return; - } - - SetStereoVisionRestrictionImpl(can_use); - rb.Push(ResultSuccess); - } - - void GetStereoVisionRestriction(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 3}; - if (False(capability & Capability::StereoVision)) { - LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(ResultNoCapability); - rb.Push(false); - return; - } - - rb.Push(ResultSuccess); - rb.Push(settings.is_stero_vision_restricted); - } - - void ResetConfirmedStereoVisionPermission(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - states.stereo_vision = false; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); - } - - States states{}; - ParentalControlSettings settings{}; - RestrictionSettings restriction_settings{}; - std::array pin_code{}; - Capability capability{}; - - Kernel::KEvent* synchronization_event; - Kernel::KEvent* unlinked_event; - Kernel::KEvent* request_suspension_event; - KernelHelpers::ServiceContext service_context; -}; - void Module::Interface::CreateService(HLERequestContext& ctx) { LOG_DEBUG(Service_PCTL, "called"); -- cgit v1.2.3 From 0e74204aadb1753e402b333692d36b1bc7221463 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 21:05:30 -0500 Subject: pctl: move IParentalControlServiceFactory --- src/core/CMakeLists.txt | 4 +- .../pctl/parental_control_service_factory.cpp | 35 ++++++++++++++ .../pctl/parental_control_service_factory.h | 30 ++++++++++++ src/core/hle/service/pctl/pctl.cpp | 27 +++++++---- src/core/hle/service/pctl/pctl.h | 9 +--- src/core/hle/service/pctl/pctl_module.cpp | 56 ---------------------- src/core/hle/service/pctl/pctl_module.h | 36 -------------- src/core/hle/service/services.cpp | 2 +- 8 files changed, 87 insertions(+), 112 deletions(-) create mode 100644 src/core/hle/service/pctl/parental_control_service_factory.cpp create mode 100644 src/core/hle/service/pctl/parental_control_service_factory.h delete mode 100644 src/core/hle/service/pctl/pctl_module.cpp delete mode 100644 src/core/hle/service/pctl/pctl_module.h (limited to 'src/core') diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d0fdae8db..45b4b203d 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -893,12 +893,12 @@ add_library(core STATIC hle/service/os/mutex.h hle/service/pcie/pcie.cpp hle/service/pcie/pcie.h + hle/service/pctl/parental_control_service_factory.cpp + hle/service/pctl/parental_control_service_factory.h hle/service/pctl/parental_control_service.cpp hle/service/pctl/parental_control_service.h hle/service/pctl/pctl.cpp hle/service/pctl/pctl.h - hle/service/pctl/pctl_module.cpp - hle/service/pctl/pctl_module.h hle/service/pctl/pctl_results.h hle/service/pctl/pctl_types.h hle/service/pcv/pcv.cpp diff --git a/src/core/hle/service/pctl/parental_control_service_factory.cpp b/src/core/hle/service/pctl/parental_control_service_factory.cpp new file mode 100644 index 000000000..1427f5a96 --- /dev/null +++ b/src/core/hle/service/pctl/parental_control_service_factory.cpp @@ -0,0 +1,35 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/pctl/parental_control_service.h" +#include "core/hle/service/pctl/parental_control_service_factory.h" + +namespace Service::PCTL { + +IParentalControlServiceFactory::IParentalControlServiceFactory(Core::System& system_, + const char* name_, + Capability capability_) + : ServiceFramework{system_, name_}, capability{capability_} {} + +IParentalControlServiceFactory::~IParentalControlServiceFactory() = default; + +void IParentalControlServiceFactory::CreateService(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + // TODO(ogniK): Get TID from process + + rb.PushIpcInterface(system, capability); +} + +void IParentalControlServiceFactory::CreateServiceWithoutInitialize(HLERequestContext& ctx) { + LOG_DEBUG(Service_PCTL, "called"); + + IPC::ResponseBuilder rb{ctx, 2, 0, 1}; + rb.Push(ResultSuccess); + rb.PushIpcInterface(system, capability); +} + +} // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/parental_control_service_factory.h b/src/core/hle/service/pctl/parental_control_service_factory.h new file mode 100644 index 000000000..19195aa38 --- /dev/null +++ b/src/core/hle/service/pctl/parental_control_service_factory.h @@ -0,0 +1,30 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/hle/service/pctl/pctl_types.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::PCTL { + +class IParentalControlServiceFactory : public ServiceFramework { +public: + explicit IParentalControlServiceFactory(Core::System& system_, const char* name_, + Capability capability_); + ~IParentalControlServiceFactory() override; + + void CreateService(HLERequestContext& ctx); + void CreateServiceWithoutInitialize(HLERequestContext& ctx); + +private: + Capability capability{}; +}; + +void LoopProcess(Core::System& system); + +} // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/pctl.cpp b/src/core/hle/service/pctl/pctl.cpp index 3f47bf094..d92dbe216 100644 --- a/src/core/hle/service/pctl/pctl.cpp +++ b/src/core/hle/service/pctl/pctl.cpp @@ -1,19 +1,28 @@ // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later +#include "core/hle/service/pctl/parental_control_service_factory.h" #include "core/hle/service/pctl/pctl.h" +#include "core/hle/service/server_manager.h" namespace Service::PCTL { -PCTL::PCTL(Core::System& system_, std::shared_ptr module_, const char* name, - Capability capability_) - : Interface{system_, std::move(module_), name, capability_} { - static const FunctionInfo functions[] = { - {0, &PCTL::CreateService, "CreateService"}, - {1, &PCTL::CreateServiceWithoutInitialize, "CreateServiceWithoutInitialize"}, - }; - RegisterHandlers(functions); +void LoopProcess(Core::System& system) { + auto server_manager = std::make_unique(system); + + server_manager->RegisterNamedService("pctl", + std::make_shared( + system, "pctl", + Capability::Application | Capability::SnsPost | + Capability::Status | Capability::StereoVision)); + // TODO(ogniK): Implement remaining capabilities + server_manager->RegisterNamedService("pctl:a", std::make_shared( + system, "pctl:a", Capability::None)); + server_manager->RegisterNamedService("pctl:r", std::make_shared( + system, "pctl:r", Capability::None)); + server_manager->RegisterNamedService("pctl:s", std::make_shared( + system, "pctl:s", Capability::None)); + ServerManager::RunServer(std::move(server_manager)); } -PCTL::~PCTL() = default; } // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/pctl.h b/src/core/hle/service/pctl/pctl.h index 87f93161e..5f9d03d4d 100644 --- a/src/core/hle/service/pctl/pctl.h +++ b/src/core/hle/service/pctl/pctl.h @@ -3,19 +3,12 @@ #pragma once -#include "core/hle/service/pctl/pctl_module.h" - namespace Core { class System; } namespace Service::PCTL { -class PCTL final : public Module::Interface { -public: - explicit PCTL(Core::System& system_, std::shared_ptr module_, const char* name, - Capability capability_); - ~PCTL() override; -}; +void LoopProcess(Core::System& system); } // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp deleted file mode 100644 index 118856574..000000000 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ /dev/null @@ -1,56 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "common/logging/log.h" -#include "core/hle/service/ipc_helpers.h" -#include "core/hle/service/kernel_helpers.h" -#include "core/hle/service/pctl/parental_control_service.h" -#include "core/hle/service/pctl/pctl.h" -#include "core/hle/service/pctl/pctl_module.h" -#include "core/hle/service/server_manager.h" - -namespace Service::PCTL { - -void Module::Interface::CreateService(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - // TODO(ogniK): Get TID from process - - rb.PushIpcInterface(system, capability); -} - -void Module::Interface::CreateServiceWithoutInitialize(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, capability); -} - -Module::Interface::Interface(Core::System& system_, std::shared_ptr module_, - const char* name_, Capability capability_) - : ServiceFramework{system_, name_}, module{std::move(module_)}, capability{capability_} {} - -Module::Interface::~Interface() = default; - -void LoopProcess(Core::System& system) { - auto server_manager = std::make_unique(system); - - auto module = std::make_shared(); - server_manager->RegisterNamedService( - "pctl", std::make_shared(system, module, "pctl", - Capability::Application | Capability::SnsPost | - Capability::Status | Capability::StereoVision)); - // TODO(ogniK): Implement remaining capabilities - server_manager->RegisterNamedService( - "pctl:a", std::make_shared(system, module, "pctl:a", Capability::None)); - server_manager->RegisterNamedService( - "pctl:r", std::make_shared(system, module, "pctl:r", Capability::None)); - server_manager->RegisterNamedService( - "pctl:s", std::make_shared(system, module, "pctl:s", Capability::None)); - ServerManager::RunServer(std::move(server_manager)); -} - -} // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/pctl_module.h b/src/core/hle/service/pctl/pctl_module.h deleted file mode 100644 index 715c05b20..000000000 --- a/src/core/hle/service/pctl/pctl_module.h +++ /dev/null @@ -1,36 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/pctl/pctl_types.h" -#include "core/hle/service/service.h" - -namespace Core { -class System; -} - -namespace Service::PCTL { - -class Module final { -public: - class Interface : public ServiceFramework { - public: - explicit Interface(Core::System& system_, std::shared_ptr module_, - const char* name_, Capability capability_); - ~Interface() override; - - void CreateService(HLERequestContext& ctx); - void CreateServiceWithoutInitialize(HLERequestContext& ctx); - - protected: - std::shared_ptr module; - - private: - Capability capability{}; - }; -}; - -void LoopProcess(Core::System& system); - -} // namespace Service::PCTL diff --git a/src/core/hle/service/services.cpp b/src/core/hle/service/services.cpp index d6c6eff50..1aa85ea54 100644 --- a/src/core/hle/service/services.cpp +++ b/src/core/hle/service/services.cpp @@ -46,7 +46,7 @@ #include "core/hle/service/olsc/olsc.h" #include "core/hle/service/omm/omm.h" #include "core/hle/service/pcie/pcie.h" -#include "core/hle/service/pctl/pctl_module.h" +#include "core/hle/service/pctl/pctl.h" #include "core/hle/service/pcv/pcv.h" #include "core/hle/service/pm/pm.h" #include "core/hle/service/prepo/prepo.h" -- cgit v1.2.3 From 5ab49c833d26b870ee250ef008e4aa1087b46f98 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 21:10:49 -0500 Subject: pctl: rewrite IParentalControlServiceFactory --- .../pctl/parental_control_service_factory.cpp | 33 +++++++++++++--------- .../pctl/parental_control_service_factory.h | 13 +++++---- 2 files changed, 26 insertions(+), 20 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/pctl/parental_control_service_factory.cpp b/src/core/hle/service/pctl/parental_control_service_factory.cpp index 1427f5a96..7d8f361e9 100644 --- a/src/core/hle/service/pctl/parental_control_service_factory.cpp +++ b/src/core/hle/service/pctl/parental_control_service_factory.cpp @@ -1,7 +1,7 @@ // SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/pctl/parental_control_service.h" #include "core/hle/service/pctl/parental_control_service_factory.h" @@ -10,26 +10,31 @@ namespace Service::PCTL { IParentalControlServiceFactory::IParentalControlServiceFactory(Core::System& system_, const char* name_, Capability capability_) - : ServiceFramework{system_, name_}, capability{capability_} {} + : ServiceFramework{system_, name_}, capability{capability_} { + static const FunctionInfo functions[] = { + {0, D<&IParentalControlServiceFactory::CreateService>, "CreateService"}, + {1, D<&IParentalControlServiceFactory::CreateServiceWithoutInitialize>, + "CreateServiceWithoutInitialize"}, + }; + RegisterHandlers(functions); +} IParentalControlServiceFactory::~IParentalControlServiceFactory() = default; -void IParentalControlServiceFactory::CreateService(HLERequestContext& ctx) { +Result IParentalControlServiceFactory::CreateService( + Out> out_service, ClientProcessId process_id) { LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - // TODO(ogniK): Get TID from process - - rb.PushIpcInterface(system, capability); + // TODO(ogniK): Get application id from process + *out_service = std::make_shared(system, capability); + R_SUCCEED(); } -void IParentalControlServiceFactory::CreateServiceWithoutInitialize(HLERequestContext& ctx) { +Result IParentalControlServiceFactory::CreateServiceWithoutInitialize( + Out> out_service, ClientProcessId process_id) { LOG_DEBUG(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 0, 1}; - rb.Push(ResultSuccess); - rb.PushIpcInterface(system, capability); + // TODO(ogniK): Get application id from process + *out_service = std::make_shared(system, capability); + R_SUCCEED(); } } // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/parental_control_service_factory.h b/src/core/hle/service/pctl/parental_control_service_factory.h index 19195aa38..362988add 100644 --- a/src/core/hle/service/pctl/parental_control_service_factory.h +++ b/src/core/hle/service/pctl/parental_control_service_factory.h @@ -3,23 +3,24 @@ #pragma once +#include "core/hle/service/cmif_types.h" #include "core/hle/service/pctl/pctl_types.h" #include "core/hle/service/service.h" -namespace Core { -class System; -} - namespace Service::PCTL { +class IParentalControlService; + class IParentalControlServiceFactory : public ServiceFramework { public: explicit IParentalControlServiceFactory(Core::System& system_, const char* name_, Capability capability_); ~IParentalControlServiceFactory() override; - void CreateService(HLERequestContext& ctx); - void CreateServiceWithoutInitialize(HLERequestContext& ctx); + Result CreateService(Out> out_service, + ClientProcessId process_id); + Result CreateServiceWithoutInitialize(Out> out_service, + ClientProcessId process_id); private: Capability capability{}; -- cgit v1.2.3 From 89c2fd3d2830d5b1e73c9e051e4af39772963036 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 21 Feb 2024 21:41:55 -0500 Subject: pctl: rewrite IParentalControlService --- .../hle/service/pctl/parental_control_service.cpp | 341 ++++++++++----------- .../hle/service/pctl/parental_control_service.h | 62 ++-- 2 files changed, 204 insertions(+), 199 deletions(-) (limited to 'src/core') diff --git a/src/core/hle/service/pctl/parental_control_service.cpp b/src/core/hle/service/pctl/parental_control_service.cpp index 4248b0184..f57f2f157 100644 --- a/src/core/hle/service/pctl/parental_control_service.cpp +++ b/src/core/hle/service/pctl/parental_control_service.cpp @@ -4,7 +4,7 @@ #include "core/core.h" #include "core/file_sys/control_metadata.h" #include "core/file_sys/patch_manager.h" -#include "core/hle/service/ipc_helpers.h" +#include "core/hle/service/cmif_serialization.h" #include "core/hle/service/pctl/parental_control_service.h" #include "core/hle/service/pctl/pctl_results.h" @@ -12,37 +12,38 @@ namespace Service::PCTL { IParentalControlService::IParentalControlService(Core::System& system_, Capability capability_) : ServiceFramework{system_, "IParentalControlService"}, capability{capability_}, - service_context{system_, "IParentalControlService"} { + service_context{system_, "IParentalControlService"}, synchronization_event{service_context}, + unlinked_event{service_context}, request_suspension_event{service_context} { // clang-format off static const FunctionInfo functions[] = { - {1, &IParentalControlService::Initialize, "Initialize"}, - {1001, &IParentalControlService::CheckFreeCommunicationPermission, "CheckFreeCommunicationPermission"}, - {1002, nullptr, "ConfirmLaunchApplicationPermission"}, - {1003, nullptr, "ConfirmResumeApplicationPermission"}, - {1004, &IParentalControlService::ConfirmSnsPostPermission, "ConfirmSnsPostPermission"}, + {1, D<&IParentalControlService::Initialize>, "Initialize"}, + {1001, D<&IParentalControlService::CheckFreeCommunicationPermission>, "CheckFreeCommunicationPermission"}, + {1002, D<&IParentalControlService::ConfirmLaunchApplicationPermission>, "ConfirmLaunchApplicationPermission"}, + {1003, D<&IParentalControlService::ConfirmResumeApplicationPermission>, "ConfirmResumeApplicationPermission"}, + {1004, D<&IParentalControlService::ConfirmSnsPostPermission>, "ConfirmSnsPostPermission"}, {1005, nullptr, "ConfirmSystemSettingsPermission"}, - {1006, &IParentalControlService::IsRestrictionTemporaryUnlocked, "IsRestrictionTemporaryUnlocked"}, + {1006, D<&IParentalControlService::IsRestrictionTemporaryUnlocked>, "IsRestrictionTemporaryUnlocked"}, {1007, nullptr, "RevertRestrictionTemporaryUnlocked"}, {1008, nullptr, "EnterRestrictedSystemSettings"}, {1009, nullptr, "LeaveRestrictedSystemSettings"}, - {1010, nullptr, "IsRestrictedSystemSettingsEntered"}, + {1010, D<&IParentalControlService::IsRestrictedSystemSettingsEntered>, "IsRestrictedSystemSettingsEntered"}, {1011, nullptr, "RevertRestrictedSystemSettingsEntered"}, {1012, nullptr, "GetRestrictedFeatures"}, - {1013, &IParentalControlService::ConfirmStereoVisionPermission, "ConfirmStereoVisionPermission"}, + {1013, D<&IParentalControlService::ConfirmStereoVisionPermission>, "ConfirmStereoVisionPermission"}, {1014, nullptr, "ConfirmPlayableApplicationVideoOld"}, {1015, nullptr, "ConfirmPlayableApplicationVideo"}, {1016, nullptr, "ConfirmShowNewsPermission"}, - {1017, &IParentalControlService::EndFreeCommunication, "EndFreeCommunication"}, - {1018, &IParentalControlService::IsFreeCommunicationAvailable, "IsFreeCommunicationAvailable"}, - {1031, &IParentalControlService::IsRestrictionEnabled, "IsRestrictionEnabled"}, - {1032, &IParentalControlService::GetSafetyLevel, "GetSafetyLevel"}, + {1017, D<&IParentalControlService::EndFreeCommunication>, "EndFreeCommunication"}, + {1018, D<&IParentalControlService::IsFreeCommunicationAvailable>, "IsFreeCommunicationAvailable"}, + {1031, D<&IParentalControlService::IsRestrictionEnabled>, "IsRestrictionEnabled"}, + {1032, D<&IParentalControlService::GetSafetyLevel>, "GetSafetyLevel"}, {1033, nullptr, "SetSafetyLevel"}, {1034, nullptr, "GetSafetyLevelSettings"}, - {1035, &IParentalControlService::GetCurrentSettings, "GetCurrentSettings"}, + {1035, D<&IParentalControlService::GetCurrentSettings>, "GetCurrentSettings"}, {1036, nullptr, "SetCustomSafetyLevelSettings"}, {1037, nullptr, "GetDefaultRatingOrganization"}, {1038, nullptr, "SetDefaultRatingOrganization"}, - {1039, &IParentalControlService::GetFreeCommunicationApplicationListCount, "GetFreeCommunicationApplicationListCount"}, + {1039, D<&IParentalControlService::GetFreeCommunicationApplicationListCount>, "GetFreeCommunicationApplicationListCount"}, {1042, nullptr, "AddToFreeCommunicationApplicationList"}, {1043, nullptr, "DeleteSettings"}, {1044, nullptr, "GetFreeCommunicationApplicationList"}, @@ -51,20 +52,20 @@ IParentalControlService::IParentalControlService(Core::System& system_, Capabili {1047, nullptr, "NotifyApplicationDownloadStarted"}, {1048, nullptr, "NotifyNetworkProfileCreated"}, {1049, nullptr, "ResetFreeCommunicationApplicationList"}, - {1061, &IParentalControlService::ConfirmStereoVisionRestrictionConfigurable, "ConfirmStereoVisionRestrictionConfigurable"}, - {1062, &IParentalControlService::GetStereoVisionRestriction, "GetStereoVisionRestriction"}, - {1063, &IParentalControlService::SetStereoVisionRestriction, "SetStereoVisionRestriction"}, - {1064, &IParentalControlService::ResetConfirmedStereoVisionPermission, "ResetConfirmedStereoVisionPermission"}, - {1065, &IParentalControlService::IsStereoVisionPermitted, "IsStereoVisionPermitted"}, + {1061, D<&IParentalControlService::ConfirmStereoVisionRestrictionConfigurable>, "ConfirmStereoVisionRestrictionConfigurable"}, + {1062, D<&IParentalControlService::GetStereoVisionRestriction>, "GetStereoVisionRestriction"}, + {1063, D<&IParentalControlService::SetStereoVisionRestriction>, "SetStereoVisionRestriction"}, + {1064, D<&IParentalControlService::ResetConfirmedStereoVisionPermission>, "ResetConfirmedStereoVisionPermission"}, + {1065, D<&IParentalControlService::IsStereoVisionPermitted>, "IsStereoVisionPermitted"}, {1201, nullptr, "UnlockRestrictionTemporarily"}, {1202, nullptr, "UnlockSystemSettingsRestriction"}, {1203, nullptr, "SetPinCode"}, {1204, nullptr, "GenerateInquiryCode"}, {1205, nullptr, "CheckMasterKey"}, - {1206, nullptr, "GetPinCodeLength"}, + {1206, D<&IParentalControlService::GetPinCodeLength>, "GetPinCodeLength"}, {1207, nullptr, "GetPinCodeChangedEvent"}, {1208, nullptr, "GetPinCode"}, - {1403, &IParentalControlService::IsPairingActive, "IsPairingActive"}, + {1403, D<&IParentalControlService::IsPairingActive>, "IsPairingActive"}, {1406, nullptr, "GetSettingsLastUpdated"}, {1411, nullptr, "GetPairingAccountInfo"}, {1421, nullptr, "GetAccountNickname"}, @@ -72,18 +73,18 @@ IParentalControlService::IParentalControlService(Core::System& system_, Capabili {1425, nullptr, "RequestPostEvents"}, {1426, nullptr, "GetPostEventInterval"}, {1427, nullptr, "SetPostEventInterval"}, - {1432, &IParentalControlService::GetSynchronizationEvent, "GetSynchronizationEvent"}, - {1451, nullptr, "StartPlayTimer"}, - {1452, nullptr, "StopPlayTimer"}, - {1453, nullptr, "IsPlayTimerEnabled"}, + {1432, D<&IParentalControlService::GetSynchronizationEvent>, "GetSynchronizationEvent"}, + {1451, D<&IParentalControlService::StartPlayTimer>, "StartPlayTimer"}, + {1452, D<&IParentalControlService::StopPlayTimer>, "StopPlayTimer"}, + {1453, D<&IParentalControlService::IsPlayTimerEnabled>, "IsPlayTimerEnabled"}, {1454, nullptr, "GetPlayTimerRemainingTime"}, - {1455, nullptr, "IsRestrictedByPlayTimer"}, - {1456, &IParentalControlService::GetPlayTimerSettings, "GetPlayTimerSettings"}, - {1457, &IParentalControlService::GetPlayTimerEventToRequestSuspension, "GetPlayTimerEventToRequestSuspension"}, - {1458, &IParentalControlService::IsPlayTimerAlarmDisabled, "IsPlayTimerAlarmDisabled"}, + {1455, D<&IParentalControlService::IsRestrictedByPlayTimer>, "IsRestrictedByPlayTimer"}, + {1456, D<&IParentalControlService::GetPlayTimerSettings>, "GetPlayTimerSettings"}, + {1457, D<&IParentalControlService::GetPlayTimerEventToRequestSuspension>, "GetPlayTimerEventToRequestSuspension"}, + {1458, D<&IParentalControlService::IsPlayTimerAlarmDisabled>, "IsPlayTimerAlarmDisabled"}, {1471, nullptr, "NotifyWrongPinCodeInputManyTimes"}, {1472, nullptr, "CancelNetworkRequest"}, - {1473, &IParentalControlService::GetUnlinkedEvent, "GetUnlinkedEvent"}, + {1473, D<&IParentalControlService::GetUnlinkedEvent>, "GetUnlinkedEvent"}, {1474, nullptr, "ClearUnlinkedEvent"}, {1601, nullptr, "DisableAllFeatures"}, {1602, nullptr, "PostEnableAllFeatures"}, @@ -119,19 +120,9 @@ IParentalControlService::IParentalControlService(Core::System& system_, Capabili }; // clang-format on RegisterHandlers(functions); - - synchronization_event = - service_context.CreateEvent("IParentalControlService::SynchronizationEvent"); - unlinked_event = service_context.CreateEvent("IParentalControlService::UnlinkedEvent"); - request_suspension_event = - service_context.CreateEvent("IParentalControlService::RequestSuspensionEvent"); } -IParentalControlService::~IParentalControlService() { - service_context.CloseEvent(synchronization_event); - service_context.CloseEvent(unlinked_event); - service_context.CloseEvent(request_suspension_event); -} +IParentalControlService::~IParentalControlService() = default; bool IParentalControlService::CheckFreeCommunicationPermissionImpl() const { if (states.temporary_unlocked) { @@ -176,20 +167,19 @@ void IParentalControlService::SetStereoVisionRestrictionImpl(bool is_restricted) settings.is_stero_vision_restricted = is_restricted; } -void IParentalControlService::Initialize(HLERequestContext& ctx) { +Result IParentalControlService::Initialize() { LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 2}; if (False(capability & (Capability::Application | Capability::System))) { LOG_ERROR(Service_PCTL, "Invalid capability! capability={:X}", capability); - return; + R_THROW(PCTL::ResultNoCapability); } // TODO(ogniK): Recovery flag initialization for pctl:r - const auto tid = system.GetApplicationProcessProgramID(); - if (tid != 0) { - const FileSys::PatchManager pm{tid, system.GetFileSystemController(), + const auto program_id = system.GetApplicationProcessProgramID(); + if (program_id != 0) { + const FileSys::PatchManager pm{program_id, system.GetFileSystemController(), system.GetContentProvider()}; const auto control = pm.GetControlMetadata(); if (control.first) { @@ -199,7 +189,7 @@ void IParentalControlService::Initialize(HLERequestContext& ctx) { states.free_communication = false; states.stereo_vision = false; states.application_info = ApplicationInfo{ - .application_id = tid, + .application_id = program_id, .age_rating = control.first->GetRatingAge(), .parental_control_flag = control.first->GetParentalControlFlag(), .capability = capability, @@ -211,231 +201,234 @@ void IParentalControlService::Initialize(HLERequestContext& ctx) { } } - rb.Push(ResultSuccess); + R_SUCCEED(); } -void IParentalControlService::CheckFreeCommunicationPermission(HLERequestContext& ctx) { +Result IParentalControlService::CheckFreeCommunicationPermission() { LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 2}; if (!CheckFreeCommunicationPermissionImpl()) { - rb.Push(PCTL::ResultNoFreeCommunication); + R_THROW(PCTL::ResultNoFreeCommunication); } else { - rb.Push(ResultSuccess); + states.free_communication = true; + R_SUCCEED(); } - - states.free_communication = true; } -void IParentalControlService::ConfirmSnsPostPermission(HLERequestContext& ctx) { - LOG_WARNING(Service_PCTL, "(STUBBED) called"); +Result IParentalControlService::ConfirmLaunchApplicationPermission( + InBuffer restriction_bitset, u64 nacp_flag, u64 application_id) { + LOG_WARNING(Service_PCTL, "(STUBBED) called, nacp_flag={:#x} application_id={:016X}", nacp_flag, + application_id); + R_SUCCEED(); +} - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(PCTL::ResultNoFreeCommunication); +Result IParentalControlService::ConfirmResumeApplicationPermission( + InBuffer restriction_bitset, u64 nacp_flag, u64 application_id) { + LOG_WARNING(Service_PCTL, "(STUBBED) called, nacp_flag={:#x} application_id={:016X}", nacp_flag, + application_id); + R_SUCCEED(); } -void IParentalControlService::IsRestrictionTemporaryUnlocked(HLERequestContext& ctx) { - const bool is_temporary_unlocked = false; +Result IParentalControlService::ConfirmSnsPostPermission() { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + R_THROW(PCTL::ResultNoFreeCommunication); +} - LOG_WARNING(Service_PCTL, "(STUBBED) called, is_temporary_unlocked={}", is_temporary_unlocked); +Result IParentalControlService::IsRestrictionTemporaryUnlocked( + Out out_is_temporary_unlocked) { + *out_is_temporary_unlocked = false; + LOG_WARNING(Service_PCTL, "(STUBBED) called, is_temporary_unlocked={}", + *out_is_temporary_unlocked); + R_SUCCEED(); +} - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_temporary_unlocked); +Result IParentalControlService::IsRestrictedSystemSettingsEntered( + Out out_is_restricted_system_settings_entered) { + *out_is_restricted_system_settings_entered = false; + LOG_WARNING(Service_PCTL, "(STUBBED) called, is_temporary_unlocked={}", + *out_is_restricted_system_settings_entered); + R_SUCCEED(); } -void IParentalControlService::ConfirmStereoVisionPermission(HLERequestContext& ctx) { +Result IParentalControlService::ConfirmStereoVisionPermission() { LOG_DEBUG(Service_PCTL, "called"); states.stereo_vision = true; - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + R_SUCCEED(); } -void IParentalControlService::EndFreeCommunication(HLERequestContext& ctx) { +Result IParentalControlService::EndFreeCommunication() { LOG_WARNING(Service_PCTL, "(STUBBED) called"); - - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + R_SUCCEED(); } -void IParentalControlService::IsFreeCommunicationAvailable(HLERequestContext& ctx) { +Result IParentalControlService::IsFreeCommunicationAvailable() { LOG_WARNING(Service_PCTL, "(STUBBED) called"); - IPC::ResponseBuilder rb{ctx, 2}; if (!CheckFreeCommunicationPermissionImpl()) { - rb.Push(PCTL::ResultNoFreeCommunication); + R_THROW(PCTL::ResultNoFreeCommunication); } else { - rb.Push(ResultSuccess); + R_SUCCEED(); } } -void IParentalControlService::IsRestrictionEnabled(HLERequestContext& ctx) { +Result IParentalControlService::IsRestrictionEnabled(Out out_restriction_enabled) { LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 3}; if (False(capability & (Capability::Status | Capability::Recovery))) { LOG_ERROR(Service_PCTL, "Application does not have Status or Recovery capabilities!"); - rb.Push(PCTL::ResultNoCapability); - rb.Push(false); - return; + *out_restriction_enabled = false; + R_THROW(PCTL::ResultNoCapability); } - rb.Push(pin_code[0] != '\0'); + *out_restriction_enabled = pin_code[0] != '\0'; + R_SUCCEED(); } -void IParentalControlService::GetSafetyLevel(HLERequestContext& ctx) { - const u32 safety_level = 0; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, safety_level={}", safety_level); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(safety_level); +Result IParentalControlService::GetSafetyLevel(Out out_safety_level) { + *out_safety_level = 0; + LOG_WARNING(Service_PCTL, "(STUBBED) called, safety_level={}", *out_safety_level); + R_SUCCEED(); } -void IParentalControlService::GetCurrentSettings(HLERequestContext& ctx) { +Result IParentalControlService::GetCurrentSettings(Out out_settings) { LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.PushRaw(restriction_settings); + *out_settings = restriction_settings; + R_SUCCEED(); } -void IParentalControlService::GetFreeCommunicationApplicationListCount(HLERequestContext& ctx) { - const u32 count = 4; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, count={}", count); - - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(count); +Result IParentalControlService::GetFreeCommunicationApplicationListCount(Out out_count) { + *out_count = 4; + LOG_WARNING(Service_PCTL, "(STUBBED) called, count={}", *out_count); + R_SUCCEED(); } -void IParentalControlService::ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx) { +Result IParentalControlService::ConfirmStereoVisionRestrictionConfigurable() { LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 2}; - if (False(capability & Capability::StereoVision)) { LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(PCTL::ResultNoCapability); - return; + R_THROW(PCTL::ResultNoCapability); } if (pin_code[0] == '\0') { - rb.Push(PCTL::ResultNoRestrictionEnabled); - return; + R_THROW(PCTL::ResultNoRestrictionEnabled); } - rb.Push(ResultSuccess); + R_SUCCEED(); } -void IParentalControlService::IsStereoVisionPermitted(HLERequestContext& ctx) { +Result IParentalControlService::IsStereoVisionPermitted(Out out_is_permitted) { LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 3}; if (!ConfirmStereoVisionPermissionImpl()) { - rb.Push(PCTL::ResultStereoVisionRestricted); - rb.Push(false); + *out_is_permitted = false; + R_THROW(PCTL::ResultStereoVisionRestricted); } else { - rb.Push(ResultSuccess); - rb.Push(true); + *out_is_permitted = true; + R_SUCCEED(); } } -void IParentalControlService::IsPairingActive(HLERequestContext& ctx) { - const bool is_pairing_active = false; - - LOG_WARNING(Service_PCTL, "(STUBBED) called, is_pairing_active={}", is_pairing_active); +Result IParentalControlService::GetPinCodeLength(Out out_length) { + *out_length = 0; + LOG_WARNING(Service_PCTL, "(STUBBED) called, length={}", *out_length); + R_SUCCEED(); +} - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_pairing_active); +Result IParentalControlService::IsPairingActive(Out out_is_pairing_active) { + *out_is_pairing_active = false; + LOG_WARNING(Service_PCTL, "(STUBBED) called, is_pairing_active={}", *out_is_pairing_active); + R_SUCCEED(); } -void IParentalControlService::GetSynchronizationEvent(HLERequestContext& ctx) { +Result IParentalControlService::GetSynchronizationEvent( + OutCopyHandle out_event) { LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(synchronization_event->GetReadableEvent()); + *out_event = synchronization_event.GetHandle(); + R_SUCCEED(); } -void IParentalControlService::GetPlayTimerSettings(HLERequestContext& ctx) { +Result IParentalControlService::StartPlayTimer() { LOG_WARNING(Service_PCTL, "(STUBBED) called"); + R_SUCCEED(); +} - const PlayTimerSettings timer_settings{}; - - IPC::ResponseBuilder rb{ctx, 15}; - rb.Push(ResultSuccess); - rb.PushRaw(timer_settings); +Result IParentalControlService::StopPlayTimer() { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + R_SUCCEED(); } -void IParentalControlService::GetPlayTimerEventToRequestSuspension(HLERequestContext& ctx) { - LOG_INFO(Service_PCTL, "called"); +Result IParentalControlService::IsPlayTimerEnabled(Out out_is_play_timer_enabled) { + *out_is_play_timer_enabled = false; + LOG_WARNING(Service_PCTL, "(STUBBED) called, enabled={}", *out_is_play_timer_enabled); + R_SUCCEED(); +} - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(request_suspension_event->GetReadableEvent()); +Result IParentalControlService::IsRestrictedByPlayTimer(Out out_is_restricted_by_play_timer) { + *out_is_restricted_by_play_timer = false; + LOG_WARNING(Service_PCTL, "(STUBBED) called, restricted={}", *out_is_restricted_by_play_timer); + R_SUCCEED(); } -void IParentalControlService::IsPlayTimerAlarmDisabled(HLERequestContext& ctx) { - const bool is_play_timer_alarm_disabled = false; +Result IParentalControlService::GetPlayTimerSettings( + Out out_play_timer_settings) { + LOG_WARNING(Service_PCTL, "(STUBBED) called"); + *out_play_timer_settings = {}; + R_SUCCEED(); +} - LOG_INFO(Service_PCTL, "called, is_play_timer_alarm_disabled={}", is_play_timer_alarm_disabled); +Result IParentalControlService::GetPlayTimerEventToRequestSuspension( + OutCopyHandle out_event) { + LOG_INFO(Service_PCTL, "called"); + *out_event = request_suspension_event.GetHandle(); + R_SUCCEED(); +} - IPC::ResponseBuilder rb{ctx, 3}; - rb.Push(ResultSuccess); - rb.Push(is_play_timer_alarm_disabled); +Result IParentalControlService::IsPlayTimerAlarmDisabled(Out out_play_timer_alarm_disabled) { + *out_play_timer_alarm_disabled = false; + LOG_INFO(Service_PCTL, "called, is_play_timer_alarm_disabled={}", + *out_play_timer_alarm_disabled); + R_SUCCEED(); } -void IParentalControlService::GetUnlinkedEvent(HLERequestContext& ctx) { +Result IParentalControlService::GetUnlinkedEvent(OutCopyHandle out_event) { LOG_INFO(Service_PCTL, "called"); - - IPC::ResponseBuilder rb{ctx, 2, 1}; - rb.Push(ResultSuccess); - rb.PushCopyObjects(unlinked_event->GetReadableEvent()); + *out_event = unlinked_event.GetHandle(); + R_SUCCEED(); } -void IParentalControlService::SetStereoVisionRestriction(HLERequestContext& ctx) { - IPC::RequestParser rp{ctx}; - const auto can_use = rp.Pop(); - LOG_DEBUG(Service_PCTL, "called, can_use={}", can_use); +Result IParentalControlService::GetStereoVisionRestriction( + Out out_stereo_vision_restriction) { + LOG_DEBUG(Service_PCTL, "called"); - IPC::ResponseBuilder rb{ctx, 2}; if (False(capability & Capability::StereoVision)) { LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(PCTL::ResultNoCapability); - return; + *out_stereo_vision_restriction = false; + R_THROW(PCTL::ResultNoCapability); } - SetStereoVisionRestrictionImpl(can_use); - rb.Push(ResultSuccess); + *out_stereo_vision_restriction = settings.is_stero_vision_restricted; + R_SUCCEED(); } -void IParentalControlService::GetStereoVisionRestriction(HLERequestContext& ctx) { - LOG_DEBUG(Service_PCTL, "called"); +Result IParentalControlService::SetStereoVisionRestriction(bool stereo_vision_restriction) { + LOG_DEBUG(Service_PCTL, "called, can_use={}", stereo_vision_restriction); - IPC::ResponseBuilder rb{ctx, 3}; if (False(capability & Capability::StereoVision)) { LOG_ERROR(Service_PCTL, "Application does not have StereoVision capability!"); - rb.Push(PCTL::ResultNoCapability); - rb.Push(false); - return; + R_THROW(PCTL::ResultNoCapability); } - rb.Push(ResultSuccess); - rb.Push(settings.is_stero_vision_restricted); + SetStereoVisionRestrictionImpl(stereo_vision_restriction); + R_SUCCEED(); } -void IParentalControlService::ResetConfirmedStereoVisionPermission(HLERequestContext& ctx) { +Result IParentalControlService::ResetConfirmedStereoVisionPermission() { LOG_DEBUG(Service_PCTL, "called"); states.stereo_vision = false; - IPC::ResponseBuilder rb{ctx, 2}; - rb.Push(ResultSuccess); + R_SUCCEED(); } } // namespace Service::PCTL diff --git a/src/core/hle/service/pctl/parental_control_service.h b/src/core/hle/service/pctl/parental_control_service.h index dcc357f65..03dbaa2e5 100644 --- a/src/core/hle/service/pctl/parental_control_service.h +++ b/src/core/hle/service/pctl/parental_control_service.h @@ -3,7 +3,9 @@ #pragma once +#include "core/hle/service/cmif_types.h" #include "core/hle/service/kernel_helpers.h" +#include "core/hle/service/os/event.h" #include "core/hle/service/pctl/pctl_types.h" #include "core/hle/service/service.h" @@ -19,28 +21,38 @@ private: bool ConfirmStereoVisionPermissionImpl() const; void SetStereoVisionRestrictionImpl(bool is_restricted); - void Initialize(HLERequestContext& ctx); - void CheckFreeCommunicationPermission(HLERequestContext& ctx); - void ConfirmSnsPostPermission(HLERequestContext& ctx); - void IsRestrictionTemporaryUnlocked(HLERequestContext& ctx); - void ConfirmStereoVisionPermission(HLERequestContext& ctx); - void EndFreeCommunication(HLERequestContext& ctx); - void IsFreeCommunicationAvailable(HLERequestContext& ctx); - void IsRestrictionEnabled(HLERequestContext& ctx); - void GetSafetyLevel(HLERequestContext& ctx); - void GetCurrentSettings(HLERequestContext& ctx); - void GetFreeCommunicationApplicationListCount(HLERequestContext& ctx); - void ConfirmStereoVisionRestrictionConfigurable(HLERequestContext& ctx); - void IsStereoVisionPermitted(HLERequestContext& ctx); - void IsPairingActive(HLERequestContext& ctx); - void GetSynchronizationEvent(HLERequestContext& ctx); - void GetPlayTimerSettings(HLERequestContext& ctx); - void GetPlayTimerEventToRequestSuspension(HLERequestContext& ctx); - void IsPlayTimerAlarmDisabled(HLERequestContext& ctx); - void GetUnlinkedEvent(HLERequestContext& ctx); - void SetStereoVisionRestriction(HLERequestContext& ctx); - void GetStereoVisionRestriction(HLERequestContext& ctx); - void ResetConfirmedStereoVisionPermission(HLERequestContext& ctx); + Result Initialize(); + Result CheckFreeCommunicationPermission(); + Result ConfirmLaunchApplicationPermission(InBuffer restriction_bitset, + u64 nacp_flag, u64 application_id); + Result ConfirmResumeApplicationPermission(InBuffer restriction_bitset, + u64 nacp_flag, u64 application_id); + Result ConfirmSnsPostPermission(); + Result IsRestrictionTemporaryUnlocked(Out out_is_temporary_unlocked); + Result IsRestrictedSystemSettingsEntered(Out out_is_restricted_system_settings_entered); + Result ConfirmStereoVisionPermission(); + Result EndFreeCommunication(); + Result IsFreeCommunicationAvailable(); + Result IsRestrictionEnabled(Out out_restriction_enabled); + Result GetSafetyLevel(Out out_safety_level); + Result GetCurrentSettings(Out out_settings); + Result GetFreeCommunicationApplicationListCount(Out out_count); + Result ConfirmStereoVisionRestrictionConfigurable(); + Result IsStereoVisionPermitted(Out out_is_permitted); + Result GetPinCodeLength(Out out_length); + Result IsPairingActive(Out out_is_pairing_active); + Result GetSynchronizationEvent(OutCopyHandle out_event); + Result StartPlayTimer(); + Result StopPlayTimer(); + Result IsPlayTimerEnabled(Out out_is_play_timer_enabled); + Result IsRestrictedByPlayTimer(Out out_is_restricted_by_play_timer); + Result GetPlayTimerSettings(Out out_play_timer_settings); + Result GetPlayTimerEventToRequestSuspension(OutCopyHandle out_event); + Result IsPlayTimerAlarmDisabled(Out out_play_timer_alarm_disabled); + Result GetUnlinkedEvent(OutCopyHandle out_event); + Result GetStereoVisionRestriction(Out out_stereo_vision_restriction); + Result SetStereoVisionRestriction(bool stereo_vision_restriction); + Result ResetConfirmedStereoVisionPermission(); struct States { u64 current_tid{}; @@ -65,10 +77,10 @@ private: std::array pin_code{}; Capability capability{}; - Kernel::KEvent* synchronization_event; - Kernel::KEvent* unlinked_event; - Kernel::KEvent* request_suspension_event; KernelHelpers::ServiceContext service_context; + Event synchronization_event; + Event unlinked_event; + Event request_suspension_event; }; } // namespace Service::PCTL -- cgit v1.2.3