From b14f38946c57927e4a4c37cd5279c3b1217576a7 Mon Sep 17 00:00:00 2001 From: FearlessTobi Date: Thu, 22 Feb 2024 16:34:33 +0100 Subject: [PATCH] fsp: Implement IProgramRegistry --- src/core/CMakeLists.txt | 4 +- .../hle/service/filesystem/filesystem.cpp | 4 +- .../filesystem/fsp/fs_i_program_registry.cpp | 52 +++++++++++++++++++ .../filesystem/fsp/fs_i_program_registry.h | 36 +++++++++++++ .../hle/service/filesystem/fsp/fsp_pr.cpp | 23 -------- src/core/hle/service/filesystem/fsp/fsp_pr.h | 20 ------- 6 files changed, 92 insertions(+), 47 deletions(-) create mode 100644 src/core/hle/service/filesystem/fsp/fs_i_program_registry.cpp create mode 100644 src/core/hle/service/filesystem/fsp/fs_i_program_registry.h delete mode 100644 src/core/hle/service/filesystem/fsp/fsp_pr.cpp delete mode 100644 src/core/hle/service/filesystem/fsp/fsp_pr.h diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index d78f907f26..07e3504040 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -634,8 +634,8 @@ add_library(core STATIC hle/service/filesystem/fsp/fs_i_storage.h hle/service/filesystem/fsp/fsp_ldr.cpp hle/service/filesystem/fsp/fsp_ldr.h - hle/service/filesystem/fsp/fsp_pr.cpp - hle/service/filesystem/fsp/fsp_pr.h + hle/service/filesystem/fsp/fs_i_program_registry.cpp + hle/service/filesystem/fsp/fs_i_program_registry.h hle/service/filesystem/fsp/fsp_srv.cpp hle/service/filesystem/fsp/fsp_srv.h hle/service/filesystem/fsp/fsp_types.h diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index ae230afc0e..bf2e864d9b 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp @@ -20,8 +20,8 @@ #include "core/file_sys/vfs/vfs.h" #include "core/file_sys/vfs/vfs_offset.h" #include "core/hle/service/filesystem/filesystem.h" +#include "core/hle/service/filesystem/fsp/fs_i_program_registry.h" #include "core/hle/service/filesystem/fsp/fsp_ldr.h" -#include "core/hle/service/filesystem/fsp/fsp_pr.h" #include "core/hle/service/filesystem/fsp/fsp_srv.h" #include "core/hle/service/filesystem/romfs_controller.h" #include "core/hle/service/filesystem/save_data_controller.h" @@ -726,7 +726,7 @@ void LoopProcess(Core::System& system) { const auto FileSystemProxyFactory = [&] { return std::make_shared(system); }; server_manager->RegisterNamedService("fsp-ldr", std::make_shared(system)); - server_manager->RegisterNamedService("fsp:pr", std::make_shared(system)); + server_manager->RegisterNamedService("fsp:pr", std::make_shared(system)); server_manager->RegisterNamedService("fsp-srv", std::move(FileSystemProxyFactory)); ServerManager::RunServer(std::move(server_manager)); } diff --git a/src/core/hle/service/filesystem/fsp/fs_i_program_registry.cpp b/src/core/hle/service/filesystem/fsp/fs_i_program_registry.cpp new file mode 100644 index 0000000000..bc5a8d325b --- /dev/null +++ b/src/core/hle/service/filesystem/fsp/fs_i_program_registry.cpp @@ -0,0 +1,52 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "core/hle/service/cmif_serialization.h" +#include "core/hle/service/filesystem/fsp/fs_i_program_registry.h" + +namespace Service::FileSystem { + +IProgramRegistry::IProgramRegistry(Core::System& system_) + : ServiceFramework{system_, "fsp:pr"}, registry{system_} { + // clang-format off + static const FunctionInfo functions[] = { + {0, C<&IProgramRegistry::RegisterProgram>, "RegisterProgram"}, + {1, C<&IProgramRegistry::UnregisterProgram>, "UnregisterProgram"}, + {2, C<&IProgramRegistry::SetCurrentProcess>, "SetCurrentProcess"}, + {256, C<&IProgramRegistry::SetEnabledProgramVerification>, "SetEnabledProgramVerification"}, + }; + // clang-format on + + RegisterHandlers(functions); +} + +IProgramRegistry::~IProgramRegistry() = default; + +Result IProgramRegistry::RegisterProgram(u8 storage_id, u64 process_id, u64 program_id, + const InBuffer data, + s64 data_size, + const InBuffer desc, + s64 desc_size) { + LOG_INFO(Service_FS, + "called, process_id={}, program_id={}, storage_id={}, data_size={}, desc_size = {}", + process_id, program_id, storage_id, data_size, desc_size); + R_RETURN(registry.RegisterProgram(process_id, program_id, storage_id, data, data_size, desc, + desc_size)); +} + +Result IProgramRegistry::UnregisterProgram(u64 process_id) { + LOG_INFO(Service_FS, "called, process_id={}", process_id); + R_RETURN(registry.UnregisterProgram(process_id)); +} + +Result IProgramRegistry::SetCurrentProcess(const ClientProcessId& client_pid) { + LOG_INFO(Service_FS, "called, client_pid={}", client_pid.pid); + R_RETURN(registry.SetCurrentProcess(client_pid)); +} + +Result IProgramRegistry::SetEnabledProgramVerification(bool enabled) { + LOG_INFO(Service_FS, "called, enabled={}", enabled); + R_RETURN(registry.SetEnabledProgramVerification(enabled)); +} + +} // namespace Service::FileSystem diff --git a/src/core/hle/service/filesystem/fsp/fs_i_program_registry.h b/src/core/hle/service/filesystem/fsp/fs_i_program_registry.h new file mode 100644 index 0000000000..0f80b91151 --- /dev/null +++ b/src/core/hle/service/filesystem/fsp/fs_i_program_registry.h @@ -0,0 +1,36 @@ +// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "core/file_sys/fssrv/fssrv_program_registry_impl.h" +#include "core/hle/result.h" +#include "core/hle/service/cmif_types.h" +#include "core/hle/service/service.h" + +namespace Core { +class System; +} + +namespace Service::FileSystem { + +class IProgramRegistry final : public ServiceFramework { +public: + explicit IProgramRegistry(Core::System& system_); + ~IProgramRegistry() override; + + Result RegisterProgram(u8 storage_id, u64 process_id, u64 program_id, + const InBuffer data, s64 data_size, + const InBuffer desc, s64 desc_size); + + Result UnregisterProgram(u64 process_id); + + Result SetCurrentProcess(const ClientProcessId& client_pid); + + Result SetEnabledProgramVerification(bool enabled); + +private: + FileSys::FsSrv::ProgramRegistryImpl registry; +}; + +} // namespace Service::FileSystem diff --git a/src/core/hle/service/filesystem/fsp/fsp_pr.cpp b/src/core/hle/service/filesystem/fsp/fsp_pr.cpp deleted file mode 100644 index 7c03ebaeae..0000000000 --- a/src/core/hle/service/filesystem/fsp/fsp_pr.cpp +++ /dev/null @@ -1,23 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "core/hle/service/filesystem/fsp/fsp_pr.h" - -namespace Service::FileSystem { - -FSP_PR::FSP_PR(Core::System& system_) : ServiceFramework{system_, "fsp:pr"} { - // clang-format off - static const FunctionInfo functions[] = { - {0, nullptr, "RegisterProgram"}, - {1, nullptr, "UnregisterProgram"}, - {2, nullptr, "SetCurrentProcess"}, - {256, nullptr, "SetEnabledProgramVerification"}, - }; - // clang-format on - - RegisterHandlers(functions); -} - -FSP_PR::~FSP_PR() = default; - -} // namespace Service::FileSystem diff --git a/src/core/hle/service/filesystem/fsp/fsp_pr.h b/src/core/hle/service/filesystem/fsp/fsp_pr.h deleted file mode 100644 index bd4e0a730c..0000000000 --- a/src/core/hle/service/filesystem/fsp/fsp_pr.h +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#pragma once - -#include "core/hle/service/service.h" - -namespace Core { -class System; -} - -namespace Service::FileSystem { - -class FSP_PR final : public ServiceFramework { -public: - explicit FSP_PR(Core::System& system_); - ~FSP_PR() override; -}; - -} // namespace Service::FileSystem