core: Make ProgramRegistry part of the system instance
This commit is contained in:
parent
ade3a79bde
commit
0cac10aa19
@ -22,6 +22,7 @@
|
||||
#include "core/device_memory.h"
|
||||
#include "core/file_sys/bis_factory.h"
|
||||
#include "core/file_sys/fs_filesystem.h"
|
||||
#include "core/file_sys/fssrv/fssrv_program_registry_impl.h"
|
||||
#include "core/file_sys/patch_manager.h"
|
||||
#include "core/file_sys/registered_cache.h"
|
||||
#include "core/file_sys/romfs_factory.h"
|
||||
@ -137,8 +138,9 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
|
||||
|
||||
struct System::Impl {
|
||||
explicit Impl(System& system)
|
||||
: kernel{system}, fs_controller{system}, hid_core{}, room_network{}, cpu_manager{system},
|
||||
reporter{system}, applet_manager{system}, frontend_applets{system}, profile_manager{} {}
|
||||
: kernel{system}, fs_controller{system}, program_registry{system}, hid_core{},
|
||||
room_network{}, cpu_manager{system}, reporter{system}, applet_manager{system},
|
||||
frontend_applets{system}, profile_manager{} {}
|
||||
|
||||
void Initialize(System& system) {
|
||||
device_memory = std::make_unique<Core::DeviceMemory>();
|
||||
@ -470,6 +472,7 @@ struct System::Impl {
|
||||
services.reset();
|
||||
service_manager.reset();
|
||||
fs_controller.Reset();
|
||||
program_registry.Reset();
|
||||
cheat_engine.reset();
|
||||
telemetry_session.reset();
|
||||
core_timing.ClearPendingEvents();
|
||||
@ -556,6 +559,7 @@ struct System::Impl {
|
||||
/// ContentProviderUnion instance
|
||||
std::unique_ptr<FileSys::ContentProviderUnion> content_provider;
|
||||
Service::FileSystem::FileSystemController fs_controller;
|
||||
FileSys::FsSrv::ProgramRegistryImpl program_registry;
|
||||
/// AppLoader used to load the current executing application
|
||||
std::unique_ptr<Loader::AppLoader> app_loader;
|
||||
std::unique_ptr<Tegra::GPU> gpu_core;
|
||||
@ -939,6 +943,14 @@ void System::ClearContentProvider(FileSys::ContentProviderUnionSlot slot) {
|
||||
impl->content_provider->ClearSlot(slot);
|
||||
}
|
||||
|
||||
FileSys::FsSrv::ProgramRegistryImpl& System::GetProgramRegistry() {
|
||||
return impl->program_registry;
|
||||
}
|
||||
|
||||
const FileSys::FsSrv::ProgramRegistryImpl& System::GetProgramRegistry() const {
|
||||
return impl->program_registry;
|
||||
}
|
||||
|
||||
const Reporter& System::GetReporter() const {
|
||||
return impl->reporter;
|
||||
}
|
||||
|
@ -24,6 +24,10 @@ class ContentProvider;
|
||||
class ContentProviderUnion;
|
||||
enum class ContentProviderUnionSlot;
|
||||
class VfsFilesystem;
|
||||
|
||||
namespace FsSrv {
|
||||
class ProgramRegistryImpl;
|
||||
}
|
||||
} // namespace FileSys
|
||||
|
||||
namespace Kernel {
|
||||
@ -373,6 +377,9 @@ public:
|
||||
|
||||
void ClearContentProvider(FileSys::ContentProviderUnionSlot slot);
|
||||
|
||||
[[nodiscard]] FileSys::FsSrv::ProgramRegistryImpl& GetProgramRegistry();
|
||||
[[nodiscard]] const FileSys::FsSrv::ProgramRegistryImpl& GetProgramRegistry() const;
|
||||
|
||||
[[nodiscard]] const Reporter& GetReporter() const;
|
||||
|
||||
[[nodiscard]] Service::Glue::ARPManager& GetARPManager();
|
||||
|
@ -9,35 +9,21 @@
|
||||
|
||||
namespace FileSys::FsSrv {
|
||||
|
||||
namespace {
|
||||
constinit ProgramRegistryServiceImpl* g_impl = nullptr;
|
||||
}
|
||||
|
||||
// TODO: Move this to a common types file
|
||||
constexpr u64 InvalidProcessIdProgramRegistry = 0xffffffffffffffffULL;
|
||||
|
||||
ProgramRegistryImpl::ProgramRegistryImpl(Core::System& system_)
|
||||
: m_process_id(InvalidProcessIdProgramRegistry), system{system_} {}
|
||||
: m_process_id(InvalidProcessIdProgramRegistry), system{system_},
|
||||
service_impl{std::make_unique<ProgramRegistryServiceImpl>(
|
||||
system, ProgramRegistryServiceImpl::Configuration{})} {}
|
||||
|
||||
ProgramRegistryImpl::~ProgramRegistryImpl() {}
|
||||
|
||||
void ProgramRegistryImpl::Initialize(ProgramRegistryServiceImpl* service) {
|
||||
// Check pre-conditions
|
||||
ASSERT(service != nullptr);
|
||||
ASSERT(g_impl == nullptr);
|
||||
|
||||
// Set the global service
|
||||
g_impl = service;
|
||||
}
|
||||
|
||||
Result ProgramRegistryImpl::RegisterProgram(u64 process_id, u64 program_id, u8 storage_id,
|
||||
const InBuffer<BufferAttr_HipcMapAlias> data,
|
||||
s64 data_size,
|
||||
const InBuffer<BufferAttr_HipcMapAlias> desc,
|
||||
s64 desc_size) {
|
||||
// Check pre-conditions
|
||||
ASSERT(g_impl != nullptr);
|
||||
|
||||
// Check that we're allowed to register
|
||||
R_UNLESS(FsSrv::Impl::IsInitialProgram(system, m_process_id), ResultPermissionDenied);
|
||||
|
||||
@ -46,19 +32,16 @@ Result ProgramRegistryImpl::RegisterProgram(u64 process_id, u64 program_id, u8 s
|
||||
R_UNLESS(desc.size() >= static_cast<size_t>(desc_size), ResultInvalidSize);
|
||||
|
||||
// Register the program
|
||||
R_RETURN(g_impl->RegisterProgramInfo(process_id, program_id, storage_id, data.data(), data_size,
|
||||
desc.data(), desc_size));
|
||||
R_RETURN(service_impl->RegisterProgramInfo(process_id, program_id, storage_id, data.data(),
|
||||
data_size, desc.data(), desc_size));
|
||||
}
|
||||
|
||||
Result ProgramRegistryImpl::UnregisterProgram(u64 process_id) {
|
||||
// Check pre-conditions
|
||||
ASSERT(g_impl != nullptr);
|
||||
|
||||
// Check that we're allowed to register
|
||||
R_UNLESS(FsSrv::Impl::IsInitialProgram(system, m_process_id), ResultPermissionDenied);
|
||||
|
||||
// Unregister the program
|
||||
R_RETURN(g_impl->UnregisterProgramInfo(process_id));
|
||||
R_RETURN(service_impl->UnregisterProgramInfo(process_id));
|
||||
}
|
||||
|
||||
Result ProgramRegistryImpl::SetCurrentProcess(const Service::ClientProcessId& client_pid) {
|
||||
@ -74,4 +57,9 @@ Result ProgramRegistryImpl::SetEnabledProgramVerification(bool enabled) {
|
||||
R_THROW(ResultNotImplemented);
|
||||
}
|
||||
|
||||
void ProgramRegistryImpl::Reset() {
|
||||
service_impl = std::make_unique<ProgramRegistryServiceImpl>(
|
||||
system, ProgramRegistryServiceImpl::Configuration{});
|
||||
}
|
||||
|
||||
} // namespace FileSys::FsSrv
|
||||
|
@ -29,8 +29,6 @@ public:
|
||||
ProgramRegistryImpl(Core::System& system_);
|
||||
~ProgramRegistryImpl();
|
||||
|
||||
static void Initialize(ProgramRegistryServiceImpl* service);
|
||||
|
||||
Result RegisterProgram(u64 process_id, u64 program_id, u8 storage_id,
|
||||
const InBuffer<BufferAttr_HipcMapAlias> data, s64 data_size,
|
||||
const InBuffer<BufferAttr_HipcMapAlias> desc, s64 desc_size);
|
||||
@ -38,9 +36,13 @@ public:
|
||||
Result SetCurrentProcess(const Service::ClientProcessId& client_pid);
|
||||
Result SetEnabledProgramVerification(bool enabled);
|
||||
|
||||
void Reset();
|
||||
|
||||
private:
|
||||
u64 m_process_id;
|
||||
Core::System& system;
|
||||
|
||||
std::unique_ptr<ProgramRegistryServiceImpl> service_impl;
|
||||
};
|
||||
|
||||
} // namespace FileSys::FsSrv
|
||||
|
@ -3,9 +3,7 @@
|
||||
|
||||
#include "core/core.h"
|
||||
#include "core/file_sys/fssrv/fssrv_program_registry_service.h"
|
||||
#include "core/file_sys/fssrv/impl/fssrv_program_index_map_info_manager.h"
|
||||
#include "core/file_sys/fssrv/impl/fssrv_program_info.h"
|
||||
#include "core/file_sys/fssrv/impl/fssrv_program_registry_manager.h"
|
||||
|
||||
namespace FileSys::FsSrv {
|
||||
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include <optional>
|
||||
#include "core/file_sys/fs_program_index_map_info.h"
|
||||
#include "core/file_sys/fssrv/impl/fssrv_program_index_map_info_manager.h"
|
||||
#include "core/file_sys/fssrv/impl/fssrv_program_registry_manager.h"
|
||||
#include "core/hle/result.h"
|
||||
|
||||
namespace Core {
|
||||
@ -15,8 +17,6 @@ namespace FileSys::FsSrv {
|
||||
|
||||
namespace Impl {
|
||||
class ProgramInfo;
|
||||
class ProgramRegistryManager;
|
||||
class ProgramIndexMapInfoManager;
|
||||
} // namespace Impl
|
||||
|
||||
class ProgramRegistryServiceImpl {
|
||||
|
@ -7,7 +7,7 @@
|
||||
namespace Service::FileSystem {
|
||||
|
||||
IProgramRegistry::IProgramRegistry(Core::System& system_)
|
||||
: ServiceFramework{system_, "fsp:pr"}, registry{system_} {
|
||||
: ServiceFramework{system_, "fsp:pr"}, registry{system_.GetProgramRegistry()} {
|
||||
// clang-format off
|
||||
static const FunctionInfo functions[] = {
|
||||
{0, C<&IProgramRegistry::RegisterProgram>, "RegisterProgram"},
|
||||
|
@ -30,7 +30,7 @@ public:
|
||||
Result SetEnabledProgramVerification(bool enabled);
|
||||
|
||||
private:
|
||||
FileSys::FsSrv::ProgramRegistryImpl registry;
|
||||
FileSys::FsSrv::ProgramRegistryImpl& registry;
|
||||
};
|
||||
|
||||
} // namespace Service::FileSystem
|
||||
|
Loading…
Reference in New Issue
Block a user