Serialize CECD, CFG services

This commit is contained in:
Hamish Milne 2020-01-02 00:45:58 +00:00 committed by zhupengfei
parent ef2e503281
commit 2d2c7218ef
23 changed files with 135 additions and 16 deletions

23
TODO
View file

@ -7,8 +7,22 @@
Memory only Memory only
✔ Service manager @started(19-12-23 00:36) @done(19-12-23 11:38) @lasted(11h2m3s) ✔ Service manager @started(19-12-23 00:36) @done(19-12-23 11:38) @lasted(11h2m3s)
✔ Fix or ignore inverse map @done(19-12-23 12:46) ✔ Fix or ignore inverse map @done(19-12-23 12:46)
☐ App loader ✘ App loader @cancelled(20-01-01 22:59)
☐ Archive manager No relevant state
☐ Archive manager @started(20-01-01 23:03)
☐ NCCH
☐ Normal
☐ Self
☐ SaveData
☐ Normal
☐ Ext
☐ Other
☐ Source SD
☐ System
☐ SDMC
☐ Normal
☐ Write-only
☐ File refs
☐ Custom texture cache ☐ Custom texture cache
✘ MMIO @cancelled(20-01-01 01:06) ✘ MMIO @cancelled(20-01-01 01:06)
Seems that this whole subsystem is only used in tests Seems that this whole subsystem is only used in tests
@ -76,9 +90,8 @@
✔ BOSS @started(19-12-25 21:48) @done(19-12-25 23:18) @lasted(1h30m14s) ✔ BOSS @started(19-12-25 21:48) @done(19-12-25 23:18) @lasted(1h30m14s)
☐ CAM @started(19-12-26 10:37) ☐ CAM @started(19-12-26 10:37)
Need to check capture_result Need to check capture_result
☐ CECD ✔ CECD @done(20-01-01 23:58)
☐ Archive backend / file handles ✔ CFG @done(20-01-02 00:44)
☐ CFG
Also needs archive backend.. Also needs archive backend..
✔ CSND @started(19-12-26 17:51) @done(19-12-26 17:56) @lasted(5m30s) ✔ CSND @started(19-12-26 17:51) @done(19-12-26 17:56) @lasted(5m30s)
✔ DLP @done(19-12-26 18:02) ✔ DLP @done(19-12-26 18:02)

View file

@ -1,3 +1,4 @@
#pragma once
#include <boost/serialization/serialization.hpp> #include <boost/serialization/serialization.hpp>
class construct_access { class construct_access {

View file

@ -168,7 +168,12 @@ public:
} }
protected: protected:
std::unique_ptr<DelayGenerator> delay_generator; std::unique_ptr<DelayGenerator> delay_generator; // TODO: Replace with virtual GetOpenDelayNs
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
friend class boost::serialization::access;
}; };
class ArchiveFactory : NonCopyable { class ArchiveFactory : NonCopyable {
@ -205,6 +210,10 @@ public:
* @return Format information about the archive or error code * @return Format information about the archive or error code
*/ */
virtual ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const = 0; virtual ResultVal<ArchiveFormatInfo> GetFormatInfo(const Path& path, u64 program_id) const = 0;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
friend class boost::serialization::access;
}; };
} // namespace FileSys } // namespace FileSys

View file

@ -105,13 +105,6 @@ private:
std::chrono::seconds init_time; std::chrono::seconds init_time;
SharedPageDef shared_page; SharedPageDef shared_page;
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) {
auto o_shared_page = boost::serialization::binary_object(&shared_page, sizeof(shared_page));
ar& o_shared_page;
}
}; };
} // namespace SharedPage } // namespace SharedPage

View file

@ -5,6 +5,7 @@
#include <cryptopp/base64.h> #include <cryptopp/base64.h>
#include <cryptopp/hmac.h> #include <cryptopp/hmac.h>
#include <cryptopp/sha.h> #include <cryptopp/sha.h>
#include "common/archives.h"
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -24,8 +25,19 @@
#include "core/hle/service/cfg/cfg.h" #include "core/hle/service/cfg/cfg.h"
#include "fmt/format.h" #include "fmt/format.h"
SERVICE_CONSTRUCT_IMPL(Service::CECD::Module)
SERIALIZE_EXPORT_IMPL(Service::CECD::Module)
namespace Service::CECD { namespace Service::CECD {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& cecd_system_save_data_archive;
ar& cecinfo_event;
ar& change_state_event;
}
SERIALIZE_IMPL(Module)
using CecDataPathType = Module::CecDataPathType; using CecDataPathType = Module::CecDataPathType;
using CecOpenMode = Module::CecOpenMode; using CecOpenMode = Module::CecOpenMode;
using CecSystemInfoType = Module::CecSystemInfoType; using CecSystemInfoType = Module::CecSystemInfoType;
@ -1340,7 +1352,8 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
case CecDataPathType::MboxData: case CecDataPathType::MboxData:
case CecDataPathType::MboxIcon: case CecDataPathType::MboxIcon:
case CecDataPathType::MboxTitle: case CecDataPathType::MboxTitle:
default: {} default: {
}
} }
} }

View file

@ -584,7 +584,7 @@ public:
*/ */
void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx); void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx);
private: protected:
std::shared_ptr<Module> cecd; std::shared_ptr<Module> cecd;
}; };
@ -613,9 +613,16 @@ private:
std::shared_ptr<Kernel::Event> change_state_event; std::shared_ptr<Kernel::Event> change_state_event;
Core::System& system; Core::System& system;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
}; };
/// Initialize CECD service(s) /// Initialize CECD service(s)
void InstallInterfaces(Core::System& system); void InstallInterfaces(Core::System& system);
} // namespace Service::CECD } // namespace Service::CECD
SERVICE_CONSTRUCT(Service::CECD::Module)
BOOST_CLASS_EXPORT_KEY(Service::CECD::Module)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cecd/cecd_ndm.h" #include "core/hle/service/cecd/cecd_ndm.h"
SERIALIZE_EXPORT_IMPL(Service::CECD::CECD_NDM)
namespace Service::CECD { namespace Service::CECD {
CECD_NDM::CECD_NDM(std::shared_ptr<Module> cecd) CECD_NDM::CECD_NDM(std::shared_ptr<Module> cecd)

View file

@ -11,6 +11,12 @@ namespace Service::CECD {
class CECD_NDM final : public Module::Interface { class CECD_NDM final : public Module::Interface {
public: public:
explicit CECD_NDM(std::shared_ptr<Module> cecd); explicit CECD_NDM(std::shared_ptr<Module> cecd);
private:
SERVICE_SERIALIZATION(CECD_NDM, cecd, Module)
}; };
} // namespace Service::CECD } // namespace Service::CECD
BOOST_CLASS_EXPORT_KEY(Service::CECD::CECD_NDM)
BOOST_SERIALIZATION_CONSTRUCT(Service::CECD::CECD_NDM)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cecd/cecd_s.h" #include "core/hle/service/cecd/cecd_s.h"
SERIALIZE_EXPORT_IMPL(Service::CECD::CECD_S)
namespace Service::CECD { namespace Service::CECD {
CECD_S::CECD_S(std::shared_ptr<Module> cecd) CECD_S::CECD_S(std::shared_ptr<Module> cecd)

View file

@ -11,6 +11,12 @@ namespace Service::CECD {
class CECD_S final : public Module::Interface { class CECD_S final : public Module::Interface {
public: public:
explicit CECD_S(std::shared_ptr<Module> cecd); explicit CECD_S(std::shared_ptr<Module> cecd);
private:
SERVICE_SERIALIZATION(CECD_S, cecd, Module)
}; };
} // namespace Service::CECD } // namespace Service::CECD
BOOST_CLASS_EXPORT_KEY(Service::CECD::CECD_S)
BOOST_SERIALIZATION_CONSTRUCT(Service::CECD::CECD_S)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cecd/cecd_u.h" #include "core/hle/service/cecd/cecd_u.h"
SERIALIZE_EXPORT_IMPL(Service::CECD::CECD_U)
namespace Service::CECD { namespace Service::CECD {
CECD_U::CECD_U(std::shared_ptr<Module> cecd) CECD_U::CECD_U(std::shared_ptr<Module> cecd)

View file

@ -11,6 +11,12 @@ namespace Service::CECD {
class CECD_U final : public Module::Interface { class CECD_U final : public Module::Interface {
public: public:
explicit CECD_U(std::shared_ptr<Module> cecd); explicit CECD_U(std::shared_ptr<Module> cecd);
private:
SERVICE_SERIALIZATION(CECD_U, cecd, Module)
}; };
} // namespace Service::CECD } // namespace Service::CECD
BOOST_CLASS_EXPORT_KEY(Service::CECD::CECD_U)
BOOST_SERIALIZATION_CONSTRUCT(Service::CECD::CECD_U)

View file

@ -6,6 +6,7 @@
#include <tuple> #include <tuple>
#include <cryptopp/osrng.h> #include <cryptopp/osrng.h>
#include <cryptopp/sha.h> #include <cryptopp/sha.h>
#include "common/archives.h"
#include "common/common_paths.h" #include "common/common_paths.h"
#include "common/file_util.h" #include "common/file_util.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -24,8 +25,18 @@
#include "core/hle/service/cfg/cfg_u.h" #include "core/hle/service/cfg/cfg_u.h"
#include "core/settings.h" #include "core/settings.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::Module)
namespace Service::CFG { namespace Service::CFG {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& cfg_config_file_buffer;
ar& cfg_system_save_data_archive;
ar& preferred_region_code;
}
SERIALIZE_IMPL(Module)
/// The maximum number of block entries that can exist in the config file /// The maximum number of block entries that can exist in the config file
static const u32 CONFIG_FILE_MAX_BLOCK_ENTRIES = 1479; static const u32 CONFIG_FILE_MAX_BLOCK_ENTRIES = 1479;

View file

@ -244,7 +244,7 @@ public:
(this->*function)(ctx, id); (this->*function)(ctx, id);
} }
private: protected:
std::shared_ptr<Module> cfg; std::shared_ptr<Module> cfg;
}; };
@ -426,6 +426,10 @@ private:
std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer; std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer;
std::unique_ptr<FileSys::ArchiveBackend> cfg_system_save_data_archive; std::unique_ptr<FileSys::ArchiveBackend> cfg_system_save_data_archive;
u32 preferred_region_code = 0; u32 preferred_region_code = 0;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
}; };
std::shared_ptr<Module> GetModule(Core::System& system); std::shared_ptr<Module> GetModule(Core::System& system);
@ -436,3 +440,5 @@ void InstallInterfaces(Core::System& system);
std::string GetConsoleIdHash(Core::System& system); std::string GetConsoleIdHash(Core::System& system);
} // namespace Service::CFG } // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::Module)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_i.h" #include "core/hle/service/cfg/cfg_i.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_I)
namespace Service::CFG { namespace Service::CFG {
CFG_I::CFG_I(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:i", 23) { CFG_I::CFG_I(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:i", 23) {

View file

@ -11,6 +11,12 @@ namespace Service::CFG {
class CFG_I final : public Module::Interface { class CFG_I final : public Module::Interface {
public: public:
explicit CFG_I(std::shared_ptr<Module> cfg); explicit CFG_I(std::shared_ptr<Module> cfg);
private:
SERVICE_SERIALIZATION(CFG_I, cfg, Module)
}; };
} // namespace Service::CFG } // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::CFG_I)
BOOST_SERIALIZATION_CONSTRUCT(Service::CFG::CFG_I)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_nor.h" #include "core/hle/service/cfg/cfg_nor.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_NOR)
namespace Service::CFG { namespace Service::CFG {
CFG_NOR::CFG_NOR() : ServiceFramework("cfg:nor", 23) { CFG_NOR::CFG_NOR() : ServiceFramework("cfg:nor", 23) {

View file

@ -14,3 +14,5 @@ public:
}; };
} // namespace Service::CFG } // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::CFG_NOR)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_s.h" #include "core/hle/service/cfg/cfg_s.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_S)
namespace Service::CFG { namespace Service::CFG {
CFG_S::CFG_S(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:s", 23) { CFG_S::CFG_S(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:s", 23) {

View file

@ -11,6 +11,12 @@ namespace Service::CFG {
class CFG_S final : public Module::Interface { class CFG_S final : public Module::Interface {
public: public:
explicit CFG_S(std::shared_ptr<Module> cfg); explicit CFG_S(std::shared_ptr<Module> cfg);
private:
SERVICE_SERIALIZATION(CFG_S, cfg, Module)
}; };
} // namespace Service::CFG } // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::CFG_S)
BOOST_SERIALIZATION_CONSTRUCT(Service::CFG::CFG_S)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_u.h" #include "core/hle/service/cfg/cfg_u.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_U)
namespace Service::CFG { namespace Service::CFG {
CFG_U::CFG_U(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:u", 23) { CFG_U::CFG_U(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:u", 23) {

View file

@ -11,6 +11,12 @@ namespace Service::CFG {
class CFG_U final : public Module::Interface { class CFG_U final : public Module::Interface {
public: public:
explicit CFG_U(std::shared_ptr<Module> cfg); explicit CFG_U(std::shared_ptr<Module> cfg);
private:
SERVICE_SERIALIZATION(CFG_U, cfg, Module)
}; };
} // namespace Service::CFG } // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::CFG_U)
BOOST_SERIALIZATION_CONSTRUCT(Service::CFG::CFG_U)

View file

@ -260,6 +260,13 @@ private:
*/ */
std::unordered_map<ArchiveHandle, std::unique_ptr<ArchiveBackend>> handle_map; std::unordered_map<ArchiveHandle, std::unique_ptr<ArchiveBackend>> handle_map;
ArchiveHandle next_handle = 1; ArchiveHandle next_handle = 1;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& id_code_map;
ar& handle_map;
ar& next_handle;
}
}; };
} // namespace Service::FS } // namespace Service::FS