VERY experimental Nintendo Switch 2 emulator
C++
pctl: move IParentalControlServiceFactory
Liam2a4e185c0ebf
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txtindex d0fdae8dbc..45b4b203d0 100644--- a/src/core/CMakeLists.txt+++ b/src/core/CMakeLists.txt@@ -893,12 +893,12 @@ add_library(core STATIChle/service/os/mutex.hhle/service/pcie/pcie.cpphle/service/pcie/pcie.h+ hle/service/pctl/parental_control_service_factory.cpp+ hle/service/pctl/parental_control_service_factory.hhle/service/pctl/parental_control_service.cpphle/service/pctl/parental_control_service.hhle/service/pctl/pctl.cpphle/service/pctl/pctl.h- hle/service/pctl/pctl_module.cpp- hle/service/pctl/pctl_module.hhle/service/pctl/pctl_results.hhle/service/pctl/pctl_types.hhle/service/pcv/pcv.cppdiff --git a/src/core/hle/service/pctl/parental_control_service_factory.cpp b/src/core/hle/service/pctl/parental_control_service_factory.cppnew file mode 100644index 0000000000..1427f5a965--- /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<IParentalControlService>(system, capability);+}++void IParentalControlServiceFactory::CreateServiceWithoutInitialize(HLERequestContext& ctx) {+ LOG_DEBUG(Service_PCTL, "called");++ IPC::ResponseBuilder rb{ctx, 2, 0, 1};+ rb.Push(ResultSuccess);+ rb.PushIpcInterface<IParentalControlService>(system, capability);+}++} // namespace Service::PCTLdiff --git a/src/core/hle/service/pctl/parental_control_service_factory.h b/src/core/hle/service/pctl/parental_control_service_factory.hnew file mode 100644index 0000000000..19195aa38e--- /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<IParentalControlServiceFactory> {+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::PCTLdiff --git a/src/core/hle/service/pctl/pctl.cpp b/src/core/hle/service/pctl/pctl.cppindex 3f47bf094f..d92dbe2169 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> 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<ServerManager>(system);++ server_manager->RegisterNamedService("pctl",+ std::make_shared<IParentalControlServiceFactory>(+ system, "pctl",+ Capability::Application | Capability::SnsPost |+ Capability::Status | Capability::StereoVision));+ // TODO(ogniK): Implement remaining capabilities+ server_manager->RegisterNamedService("pctl:a", std::make_shared<IParentalControlServiceFactory>(+ system, "pctl:a", Capability::None));+ server_manager->RegisterNamedService("pctl:r", std::make_shared<IParentalControlServiceFactory>(+ system, "pctl:r", Capability::None));+ server_manager->RegisterNamedService("pctl:s", std::make_shared<IParentalControlServiceFactory>(+ system, "pctl:s", Capability::None));+ ServerManager::RunServer(std::move(server_manager));}-PCTL::~PCTL() = default;} // namespace Service::PCTLdiff --git a/src/core/hle/service/pctl/pctl.h b/src/core/hle/service/pctl/pctl.hindex 87f93161e7..5f9d03d4df 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> module_, const char* name,- Capability capability_);- ~PCTL() override;-};+void LoopProcess(Core::System& system);} // namespace Service::PCTLdiff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cppdeleted file mode 100644index 1188565743..0000000000--- 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<IParentalControlService>(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<IParentalControlService>(system, capability);-}--Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> 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<ServerManager>(system);-- auto module = std::make_shared<Module>();- server_manager->RegisterNamedService(- "pctl", std::make_shared<PCTL>(system, module, "pctl",- Capability::Application | Capability::SnsPost |- Capability::Status | Capability::StereoVision));- // TODO(ogniK): Implement remaining capabilities- server_manager->RegisterNamedService(- "pctl:a", std::make_shared<PCTL>(system, module, "pctl:a", Capability::None));- server_manager->RegisterNamedService(- "pctl:r", std::make_shared<PCTL>(system, module, "pctl:r", Capability::None));- server_manager->RegisterNamedService(- "pctl:s", std::make_shared<PCTL>(system, module, "pctl:s", Capability::None));- ServerManager::RunServer(std::move(server_manager));-}--} // namespace Service::PCTLdiff --git a/src/core/hle/service/pctl/pctl_module.h b/src/core/hle/service/pctl/pctl_module.hdeleted file mode 100644index 715c05b205..0000000000--- 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<Interface> {- public:- explicit Interface(Core::System& system_, std::shared_ptr<Module> module_,- const char* name_, Capability capability_);- ~Interface() override;-- void CreateService(HLERequestContext& ctx);- void CreateServiceWithoutInitialize(HLERequestContext& ctx);-- protected:- std::shared_ptr<Module> module;-- private:- Capability capability{};- };-};--void LoopProcess(Core::System& system);--} // namespace Service::PCTLdiff --git a/src/core/hle/service/services.cpp b/src/core/hle/service/services.cppindex d6c6eff500..1aa85ea545 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"