From 2409ee39cbafd6631a5ed1f45f8d0f9c2ccd94ee Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Tue, 31 Dec 2019 20:39:38 +0000 Subject: [PATCH] Serialize IR, MVD, NDM, NEWS, NFC --- TODO | 8 ++++---- src/core/hle/service/ir/ir_rst.cpp | 17 +++++++++++++++++ src/core/hle/service/ir/ir_rst.h | 7 +++++++ src/core/hle/service/ir/ir_u.cpp | 3 +++ src/core/hle/service/ir/ir_u.h | 2 ++ src/core/hle/service/mvd/mvd_std.cpp | 3 +++ src/core/hle/service/mvd/mvd_std.h | 9 +++++++++ src/core/hle/service/ndm/ndm_u.cpp | 3 +++ src/core/hle/service/ndm/ndm_u.h | 15 +++++++++++++++ src/core/hle/service/news/news_s.cpp | 3 +++ src/core/hle/service/news/news_s.h | 2 ++ src/core/hle/service/news/news_u.cpp | 3 +++ src/core/hle/service/news/news_u.h | 2 ++ src/core/hle/service/nfc/nfc.cpp | 13 +++++++++++++ src/core/hle/service/nfc/nfc.h | 9 ++++++++- src/core/hle/service/nfc/nfc_m.cpp | 3 +++ src/core/hle/service/nfc/nfc_m.h | 6 ++++++ src/core/hle/service/nfc/nfc_u.cpp | 3 +++ src/core/hle/service/nfc/nfc_u.h | 6 ++++++ 19 files changed, 112 insertions(+), 5 deletions(-) diff --git a/TODO b/TODO index 2aff6ae68..f9fffa60d 100644 --- a/TODO +++ b/TODO @@ -88,10 +88,10 @@ ✔ IR @done(19-12-30 16:06) ✔ LDR_RO @done(19-12-30 16:25) ✔ MIC @done(19-12-30 16:53) - ☐ MVD - ☐ NDM - ☐ NEWS - ☐ NFC + ✔ MVD @done(19-12-31 18:26) + ✔ NDM @done(19-12-31 18:26) + ✔ NEWS @done(19-12-31 18:29) + ✔ NFC @done(19-12-31 20:35) ☐ NIM ☐ NS ☐ NWM diff --git a/src/core/hle/service/ir/ir_rst.cpp b/src/core/hle/service/ir/ir_rst.cpp index 71d16a1ce..dc9612e62 100644 --- a/src/core/hle/service/ir/ir_rst.cpp +++ b/src/core/hle/service/ir/ir_rst.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/core.h" #include "core/core_timing.h" #include "core/hle/ipc_helpers.h" @@ -12,8 +13,24 @@ #include "core/movie.h" #include "core/settings.h" +SERIALIZE_EXPORT_IMPL(Service::IR::IR_RST) +SERVICE_CONSTRUCT_IMPL(Service::IR::IR_RST) + namespace Service::IR { +template +void IR_RST::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& update_event; + ar& shared_memory; + ar& next_pad_index; + ar& raw_c_stick; + ar& update_period; + // update_callback_id and input devices are set separately + ReloadInputDevices(); +} +SERIALIZE_IMPL(IR_RST) + struct PadDataEntry { PadState current_state; PadState delta_additions; diff --git a/src/core/hle/service/ir/ir_rst.h b/src/core/hle/service/ir/ir_rst.h index 84ad70dfc..8e17381ad 100644 --- a/src/core/hle/service/ir/ir_rst.h +++ b/src/core/hle/service/ir/ir_rst.h @@ -87,6 +87,13 @@ private: std::atomic is_device_reload_pending{false}; bool raw_c_stick{false}; int update_period{0}; + + template + void serialize(Archive& ar, const unsigned int); + friend class boost::serialization::access; }; } // namespace Service::IR + +BOOST_CLASS_EXPORT_KEY(Service::IR::IR_RST) +SERVICE_CONSTRUCT(Service::IR::IR_RST) diff --git a/src/core/hle/service/ir/ir_u.cpp b/src/core/hle/service/ir/ir_u.cpp index d76323e91..61618869a 100644 --- a/src/core/hle/service/ir/ir_u.cpp +++ b/src/core/hle/service/ir/ir_u.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/service/ir/ir_u.h" +SERIALIZE_EXPORT_IMPL(Service::IR::IR_U) + namespace Service::IR { IR_U::IR_U() : ServiceFramework("ir:u", 1) { diff --git a/src/core/hle/service/ir/ir_u.h b/src/core/hle/service/ir/ir_u.h index ea150b082..eaa54c657 100644 --- a/src/core/hle/service/ir/ir_u.h +++ b/src/core/hle/service/ir/ir_u.h @@ -15,3 +15,5 @@ public: }; } // namespace Service::IR + +BOOST_CLASS_EXPORT_KEY(Service::IR::IR_U) diff --git a/src/core/hle/service/mvd/mvd_std.cpp b/src/core/hle/service/mvd/mvd_std.cpp index 2c397f2dd..43dbde584 100644 --- a/src/core/hle/service/mvd/mvd_std.cpp +++ b/src/core/hle/service/mvd/mvd_std.cpp @@ -2,9 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/mvd/mvd_std.h" +SERIALIZE_EXPORT_IMPL(Service::MVD::MVD_STD) + namespace Service::MVD { MVD_STD::MVD_STD() : ServiceFramework("mvd:std", 1) { diff --git a/src/core/hle/service/mvd/mvd_std.h b/src/core/hle/service/mvd/mvd_std.h index 6764f6ba8..6e8312e59 100644 --- a/src/core/hle/service/mvd/mvd_std.h +++ b/src/core/hle/service/mvd/mvd_std.h @@ -12,6 +12,15 @@ class MVD_STD final : public ServiceFramework { public: MVD_STD(); ~MVD_STD() = default; + +private: + template + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + } + friend class boost::serialization::access; }; } // namespace Service::MVD + +BOOST_CLASS_EXPORT_KEY(Service::MVD::MVD_STD) diff --git a/src/core/hle/service/ndm/ndm_u.cpp b/src/core/hle/service/ndm/ndm_u.cpp index 057e68ede..936d53799 100644 --- a/src/core/hle/service/ndm/ndm_u.cpp +++ b/src/core/hle/service/ndm/ndm_u.cpp @@ -2,10 +2,13 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/ndm/ndm_u.h" +SERIALIZE_EXPORT_IMPL(Service::NDM::NDM_U) + namespace Service::NDM { void NDM_U::EnterExclusiveState(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/ndm/ndm_u.h b/src/core/hle/service/ndm/ndm_u.h index 5f48a3182..3339478d1 100644 --- a/src/core/hle/service/ndm/ndm_u.h +++ b/src/core/hle/service/ndm/ndm_u.h @@ -270,8 +270,23 @@ private: u32 scan_interval = DEFAULT_SCAN_INTERVAL; u32 retry_interval = DEFAULT_RETRY_INTERVAL; bool daemon_lock_enabled = false; + + template + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& daemon_bit_mask; + ar& default_daemon_bit_mask; + ar& daemon_status; + ar& exclusive_state; + ar& scan_interval; + ar& retry_interval; + ar& daemon_lock_enabled; + } + friend class boost::serialization::access; }; void InstallInterfaces(Core::System& system); } // namespace Service::NDM + +BOOST_CLASS_EXPORT_KEY(Service::NDM::NDM_U) diff --git a/src/core/hle/service/news/news_s.cpp b/src/core/hle/service/news/news_s.cpp index 17eaa5ea8..94cf68f4c 100644 --- a/src/core/hle/service/news/news_s.cpp +++ b/src/core/hle/service/news/news_s.cpp @@ -2,9 +2,12 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/news/news_s.h" +SERIALIZE_EXPORT_IMPL(Service::NEWS::NEWS_S) + namespace Service::NEWS { void NEWS_S::GetTotalNotifications(Kernel::HLERequestContext& ctx) { diff --git a/src/core/hle/service/news/news_s.h b/src/core/hle/service/news/news_s.h index e4673d22c..711a0e99b 100644 --- a/src/core/hle/service/news/news_s.h +++ b/src/core/hle/service/news/news_s.h @@ -27,3 +27,5 @@ private: }; } // namespace Service::NEWS + +BOOST_CLASS_EXPORT_KEY(Service::NEWS::NEWS_S) diff --git a/src/core/hle/service/news/news_u.cpp b/src/core/hle/service/news/news_u.cpp index 3d6e87f91..d91b594b8 100644 --- a/src/core/hle/service/news/news_u.cpp +++ b/src/core/hle/service/news/news_u.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/service/news/news_u.h" +SERIALIZE_EXPORT_IMPL(Service::NEWS::NEWS_U) + namespace Service::NEWS { NEWS_U::NEWS_U() : ServiceFramework("news:u", 1) { diff --git a/src/core/hle/service/news/news_u.h b/src/core/hle/service/news/news_u.h index cb06bad39..472dd579c 100644 --- a/src/core/hle/service/news/news_u.h +++ b/src/core/hle/service/news/news_u.h @@ -15,3 +15,5 @@ public: }; } // namespace Service::NEWS + +BOOST_CLASS_EXPORT_KEY(Service::NEWS::NEWS_U) diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index 86eb6daeb..0bd6121a2 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" @@ -10,8 +11,20 @@ #include "core/hle/service/nfc/nfc_m.h" #include "core/hle/service/nfc/nfc_u.h" +SERVICE_CONSTRUCT_IMPL(Service::NFC::Module) +SERIALIZE_EXPORT_IMPL(Service::NFC::Module) + namespace Service::NFC { +template +void Module::serialize(Archive& ar, const unsigned int) { + ar& tag_in_range_event; + ar& tag_out_of_range_event; + ar& nfc_tag_state; + ar& nfc_status; +} +SERIALIZE_IMPL(Module) + struct TagInfo { u16_le id_offset_size; u8 unk1; diff --git a/src/core/hle/service/nfc/nfc.h b/src/core/hle/service/nfc/nfc.h index 64bd239ac..2d6b26d83 100644 --- a/src/core/hle/service/nfc/nfc.h +++ b/src/core/hle/service/nfc/nfc.h @@ -226,7 +226,7 @@ public: */ void GetIdentificationBlock(Kernel::HLERequestContext& ctx); - private: + protected: std::shared_ptr nfc; }; @@ -241,8 +241,15 @@ private: AmiiboData amiibo_data{}; bool amiibo_in_range = false; + + template + void serialize(Archive& ar, const unsigned int); + friend class boost::serialization::access; }; void InstallInterfaces(Core::System& system); } // namespace Service::NFC + +SERVICE_CONSTRUCT(Service::NFC::Module) +BOOST_CLASS_EXPORT_KEY(Service::NFC::Module) diff --git a/src/core/hle/service/nfc/nfc_m.cpp b/src/core/hle/service/nfc/nfc_m.cpp index 310490b8f..cd591b9c1 100644 --- a/src/core/hle/service/nfc/nfc_m.cpp +++ b/src/core/hle/service/nfc/nfc_m.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/service/nfc/nfc_m.h" +SERIALIZE_EXPORT_IMPL(Service::NFC::NFC_M) + namespace Service::NFC { NFC_M::NFC_M(std::shared_ptr nfc) : Module::Interface(std::move(nfc), "nfc:m", 1) { diff --git a/src/core/hle/service/nfc/nfc_m.h b/src/core/hle/service/nfc/nfc_m.h index c9fe9b130..48a9e241b 100644 --- a/src/core/hle/service/nfc/nfc_m.h +++ b/src/core/hle/service/nfc/nfc_m.h @@ -11,6 +11,12 @@ namespace Service::NFC { class NFC_M final : public Module::Interface { public: explicit NFC_M(std::shared_ptr nfc); + +private: + SERVICE_SERIALIZATION(NFC_M, nfc, Module) }; } // namespace Service::NFC + +BOOST_CLASS_EXPORT_KEY(Service::NFC::NFC_M) +BOOST_SERIALIZATION_CONSTRUCT(Service::NFC::NFC_M) diff --git a/src/core/hle/service/nfc/nfc_u.cpp b/src/core/hle/service/nfc/nfc_u.cpp index a6e99ace2..58d1843e4 100644 --- a/src/core/hle/service/nfc/nfc_u.cpp +++ b/src/core/hle/service/nfc/nfc_u.cpp @@ -2,8 +2,11 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "common/archives.h" #include "core/hle/service/nfc/nfc_u.h" +SERIALIZE_EXPORT_IMPL(Service::NFC::NFC_U) + namespace Service::NFC { NFC_U::NFC_U(std::shared_ptr nfc) : Module::Interface(std::move(nfc), "nfc:u", 1) { diff --git a/src/core/hle/service/nfc/nfc_u.h b/src/core/hle/service/nfc/nfc_u.h index aab408269..2ed6030e6 100644 --- a/src/core/hle/service/nfc/nfc_u.h +++ b/src/core/hle/service/nfc/nfc_u.h @@ -11,6 +11,12 @@ namespace Service::NFC { class NFC_U final : public Module::Interface { public: explicit NFC_U(std::shared_ptr nfc); + +private: + SERVICE_SERIALIZATION(NFC_U, nfc, Module) }; } // namespace Service::NFC + +BOOST_CLASS_EXPORT_KEY(Service::NFC::NFC_U) +BOOST_SERIALIZATION_CONSTRUCT(Service::NFC::NFC_U)