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 2aff6ae689..f9fffa60d7 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 71d16a1ce7..dc9612e624 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 84ad70dfcb..8e17381ad1 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 d76323e914..61618869a7 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 ea150b0825..eaa54c6578 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 2c397f2dd1..43dbde5840 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 6764f6ba89..6e8312e592 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 057e68ede7..936d537996 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 5f48a31824..3339478d1f 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 17eaa5ea8d..94cf68f4c0 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 e4673d22cb..711a0e99bf 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 3d6e87f910..d91b594b8e 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 cb06bad39f..472dd579c8 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 86eb6daeb8..0bd6121a22 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 64bd239acf..2d6b26d832 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 310490b8f1..cd591b9c1b 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 c9fe9b1309..48a9e241b2 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 a6e99ace24..58d1843e42 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 aab408269c..2ed6030e67 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)