fssrv: skeleton more program registry logic

This commit is contained in:
Michael Scire
2021-12-07 02:04:39 -08:00
committed by SciresM
parent 33701bb387
commit e8d14eb77d
13 changed files with 448 additions and 3 deletions

View File

@@ -31,4 +31,5 @@
#include <stratosphere/fssrv/fssrv_file_system_proxy_server_session_resource_manager.hpp>
#include <stratosphere/fssrv/impl/fssrv_file_system_proxy_service_object.hpp>
#include <stratosphere/fssrv/fssrv_program_registry_impl.hpp>
#include <stratosphere/fssrv/fssrv_program_registry_service.hpp>
#include <stratosphere/fssrv/fssrv_file_system_proxy_api.hpp>

View File

@@ -27,12 +27,16 @@ namespace ams::fssrv {
}
class NcaFileSystemService;
class SaveDataFileSystemService;
class FileSystemProxyImpl {
NON_COPYABLE(FileSystemProxyImpl);
NON_MOVEABLE(FileSystemProxyImpl);
private:
impl::FileSystemProxyCoreImpl *m_impl;
/* TODO: service pointers. */
std::shared_ptr<NcaFileSystemService> m_nca_service;
std::shared_ptr<SaveDataFileSystemService> m_save_data_service;
u64 m_process_id;
public:
FileSystemProxyImpl();

View File

@@ -19,6 +19,8 @@
namespace ams::fssrv {
class ProgramRegistryServiceImpl;
namespace impl {
class ProgramInfo;
@@ -33,6 +35,8 @@ namespace ams::fssrv {
public:
ProgramRegistryImpl();
~ProgramRegistryImpl();
public:
static void Initialize(ProgramRegistryServiceImpl *service);
public:
Result RegisterProgram(u64 process_id, u64 program_id, u8 storage_id, const ams::sf::InBuffer &data, s64 data_size, const ams::sf::InBuffer &desc, s64 desc_size);
Result UnregisterProgram(u64 process_id);

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
#include <stratosphere/fssystem/fssystem_pimpl.hpp>
namespace ams::fssrv {
namespace impl {
class ProgramInfo;
class ProgramRegistryManager;
class ProgramIndexMapInfoManager;
}
class ProgramRegistryServiceImpl {
public:
struct Configuration {
/* ... */
};
private:
Configuration m_config;
fssystem::Pimpl<impl::ProgramRegistryManager, 0x40> m_registry_manager;
fssystem::Pimpl<impl::ProgramIndexMapInfoManager, 0x50> m_index_map_info_manager;
public:
ProgramRegistryServiceImpl(const Configuration &cfg) : m_config(cfg) { /* ... */ }
Result RegisterProgramInfo(u64 process_id, u64 program_id, u8 storage_id, const void *data, s64 data_size, const void *desc, s64 desc_size);
Result UnregisterProgramInfo(u64 process_id);
};
}

View File

@@ -18,6 +18,7 @@
#include <stratosphere/ncm/ncm_ids.hpp>
#include <stratosphere/fs/impl/fs_newable.hpp>
#include <stratosphere/fs/fs_program_index_map_info.hpp>
#include <stratosphere/fssystem/fssystem_pimpl.hpp>
namespace ams::fssrv::impl {
@@ -156,3 +157,5 @@ namespace ams::fssrv::impl {
}
AMS_FSSYSTEM_ENABLE_PIMPL(::ams::fssrv::impl::ProgramIndexMapInfoManager)

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) Atmosphère-NX
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
* version 2, as published by the Free Software Foundation.
*
* This program is distributed in the hope it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <vapours.hpp>
namespace ams::fssystem {
namespace impl {
template<typename T, size_t Size>
struct PimplHelper {
static void Construct(void *);
static void Destroy(void *);
};
}
template<typename T, size_t Size>
class Pimpl {
private:
alignas(0x10) u8 m_storage[Size];
public:
ALWAYS_INLINE Pimpl() { impl::PimplHelper<T, Size>::Construct(m_storage); }
ALWAYS_INLINE ~Pimpl() { impl::PimplHelper<T, Size>::Destroy(m_storage); }
ALWAYS_INLINE T *Get() { return reinterpret_cast<T *>(m_storage + 0); }
ALWAYS_INLINE T *operator->() { return reinterpret_cast<T *>(m_storage + 0); }
};
#define AMS_FSSYSTEM_ENABLE_PIMPL(_CLASSNAME_) \
namespace ams::fssystem::impl { \
\
template<size_t Size> \
struct PimplHelper<_CLASSNAME_, Size> { \
static ALWAYS_INLINE void Construct(void *p) { \
static_assert(sizeof(_CLASSNAME_) <= Size); \
static_assert(alignof(_CLASSNAME_) <= 0x10); \
\
std::construct_at(static_cast<_CLASSNAME_ *>(p)); \
} \
\
static ALWAYS_INLINE void Destroy(void *p) { \
std::destroy_at(static_cast<_CLASSNAME_ *>(p)); \
} \
}; \
\
}
}