fsp: Implement IProgramRegistry

This commit is contained in:
FearlessTobi 2024-02-22 16:34:33 +01:00
parent f9a67ff75d
commit b14f38946c
6 changed files with 92 additions and 47 deletions

View File

@ -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

View File

@ -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<FSP_SRV>(system); };
server_manager->RegisterNamedService("fsp-ldr", std::make_shared<FSP_LDR>(system));
server_manager->RegisterNamedService("fsp:pr", std::make_shared<FSP_PR>(system));
server_manager->RegisterNamedService("fsp:pr", std::make_shared<IProgramRegistry>(system));
server_manager->RegisterNamedService("fsp-srv", std::move(FileSystemProxyFactory));
ServerManager::RunServer(std::move(server_manager));
}

View File

@ -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<BufferAttr_HipcMapAlias> data,
s64 data_size,
const InBuffer<BufferAttr_HipcMapAlias> 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

View File

@ -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<IProgramRegistry> {
public:
explicit IProgramRegistry(Core::System& system_);
~IProgramRegistry() override;
Result RegisterProgram(u8 storage_id, u64 process_id, u64 program_id,
const InBuffer<BufferAttr_HipcMapAlias> data, s64 data_size,
const InBuffer<BufferAttr_HipcMapAlias> 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

View File

@ -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

View File

@ -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<FSP_PR> {
public:
explicit FSP_PR(Core::System& system_);
~FSP_PR() override;
};
} // namespace Service::FileSystem