From f5e2f873b003dacaf0b28b92c60beb5d7804e9ee Mon Sep 17 00:00:00 2001 From: Hamish Milne Date: Wed, 1 Jan 2020 21:31:52 +0000 Subject: [PATCH] Serialize NWM service --- TODO | 18 ++++++++++++------ externals/boost | 2 +- src/core/hle/service/nwm/nwm_cec.cpp | 3 +++ src/core/hle/service/nwm/nwm_cec.h | 2 ++ src/core/hle/service/nwm/nwm_ext.cpp | 3 +++ src/core/hle/service/nwm/nwm_ext.h | 2 ++ src/core/hle/service/nwm/nwm_inf.cpp | 3 +++ src/core/hle/service/nwm/nwm_inf.h | 2 ++ src/core/hle/service/nwm/nwm_sap.cpp | 3 +++ src/core/hle/service/nwm/nwm_sap.h | 2 ++ src/core/hle/service/nwm/nwm_soc.cpp | 3 +++ src/core/hle/service/nwm/nwm_soc.h | 2 ++ src/core/hle/service/nwm/nwm_tst.cpp | 3 +++ src/core/hle/service/nwm/nwm_tst.h | 2 ++ src/core/hle/service/nwm/nwm_uds.cpp | 12 ++++++++++++ src/core/hle/service/nwm/nwm_uds.h | 14 ++++++++++++++ src/network/CMakeLists.txt | 2 +- src/network/room_member.h | 12 ++++++++++++ 18 files changed, 82 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 46ba9b2600..1f29a46931 100644 --- a/TODO +++ b/TODO @@ -10,11 +10,16 @@ ☐ App loader ☐ Archive manager ☐ Custom texture cache -☐ MMIO -☐ Movie -☐ Perf stats -☐ Settings -☐ Telemetry session +✘ MMIO @cancelled(20-01-01 01:06) + Seems that this whole subsystem is only used in tests +✘ Movie @cancelled(20-01-01 01:07) + Doesn't need to be serialized here +✘ Perf stats @cancelled(20-01-01 01:09) + Doesn't need to be serialized here +✘ Settings @cancelled(20-01-01 01:11) + For now, let the settings just be whatever they are +✘ Telemetry session @cancelled(20-01-01 01:12) + Doesn't need to be serialized here ☐ Replace SERIALIZE_AS_POD with BOOST_IS_BITWISE_SERIALIZABLE ☐ Review constructor/initialization code ✔ Fix CI @done(19-12-31 21:32) @@ -94,7 +99,8 @@ ✔ NFC @done(19-12-31 20:35) ✔ NIM @done(19-12-31 21:08) ✔ NS @done(20-01-01 00:46) - ☐ NWM + ✔ NWM @done(20-01-01 21:31) + ☐ Fix wifi_packet_received? ☐ PM ✔ PS @done(20-01-01 00:54) ☐ PTM diff --git a/externals/boost b/externals/boost index 65dc954e93..6d7edc593b 160000 --- a/externals/boost +++ b/externals/boost @@ -1 +1 @@ -Subproject commit 65dc954e93b22870b8423701e225147c75e3b31b +Subproject commit 6d7edc593be8e47c8de7bc5f7d6b32971fad0c24 diff --git a/src/core/hle/service/nwm/nwm_cec.cpp b/src/core/hle/service/nwm/nwm_cec.cpp index 7c47c88c70..ecd4f16e19 100644 --- a/src/core/hle/service/nwm/nwm_cec.cpp +++ b/src/core/hle/service/nwm/nwm_cec.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/nwm/nwm_cec.h" +SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_CEC) + namespace Service::NWM { NWM_CEC::NWM_CEC() : ServiceFramework("nwm::CEC") { diff --git a/src/core/hle/service/nwm/nwm_cec.h b/src/core/hle/service/nwm/nwm_cec.h index afdf984776..4f62f32f13 100644 --- a/src/core/hle/service/nwm/nwm_cec.h +++ b/src/core/hle/service/nwm/nwm_cec.h @@ -14,3 +14,5 @@ public: }; } // namespace Service::NWM + +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_CEC) diff --git a/src/core/hle/service/nwm/nwm_ext.cpp b/src/core/hle/service/nwm/nwm_ext.cpp index 4bbac391fc..d69da94ffb 100644 --- a/src/core/hle/service/nwm/nwm_ext.cpp +++ b/src/core/hle/service/nwm/nwm_ext.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/nwm/nwm_ext.h" +SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_EXT) + namespace Service::NWM { NWM_EXT::NWM_EXT() : ServiceFramework("nwm::EXT") { diff --git a/src/core/hle/service/nwm/nwm_ext.h b/src/core/hle/service/nwm/nwm_ext.h index 1711db65ae..a8d43df70d 100644 --- a/src/core/hle/service/nwm/nwm_ext.h +++ b/src/core/hle/service/nwm/nwm_ext.h @@ -14,3 +14,5 @@ public: }; } // namespace Service::NWM + +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_EXT) diff --git a/src/core/hle/service/nwm/nwm_inf.cpp b/src/core/hle/service/nwm/nwm_inf.cpp index 71cf118910..eaabf66673 100644 --- a/src/core/hle/service/nwm/nwm_inf.cpp +++ b/src/core/hle/service/nwm/nwm_inf.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/nwm/nwm_inf.h" +SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_INF) + namespace Service::NWM { NWM_INF::NWM_INF() : ServiceFramework("nwm::INF") { diff --git a/src/core/hle/service/nwm/nwm_inf.h b/src/core/hle/service/nwm/nwm_inf.h index 2c69cfb1e3..f13fd41581 100644 --- a/src/core/hle/service/nwm/nwm_inf.h +++ b/src/core/hle/service/nwm/nwm_inf.h @@ -14,3 +14,5 @@ public: }; } // namespace Service::NWM + +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_INF) diff --git a/src/core/hle/service/nwm/nwm_sap.cpp b/src/core/hle/service/nwm/nwm_sap.cpp index 2ef196ab40..2cedf93718 100644 --- a/src/core/hle/service/nwm/nwm_sap.cpp +++ b/src/core/hle/service/nwm/nwm_sap.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/nwm/nwm_sap.h" +SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_SAP) + namespace Service::NWM { NWM_SAP::NWM_SAP() : ServiceFramework("nwm::SAP") { diff --git a/src/core/hle/service/nwm/nwm_sap.h b/src/core/hle/service/nwm/nwm_sap.h index b6700b8edf..1a289542cc 100644 --- a/src/core/hle/service/nwm/nwm_sap.h +++ b/src/core/hle/service/nwm/nwm_sap.h @@ -14,3 +14,5 @@ public: }; } // namespace Service::NWM + +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_SAP) diff --git a/src/core/hle/service/nwm/nwm_soc.cpp b/src/core/hle/service/nwm/nwm_soc.cpp index 443baaf390..d6ca365aba 100644 --- a/src/core/hle/service/nwm/nwm_soc.cpp +++ b/src/core/hle/service/nwm/nwm_soc.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/nwm/nwm_soc.h" +SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_SOC) + namespace Service::NWM { NWM_SOC::NWM_SOC() : ServiceFramework("nwm::SOC") { diff --git a/src/core/hle/service/nwm/nwm_soc.h b/src/core/hle/service/nwm/nwm_soc.h index 8e1b922bc6..883a20854d 100644 --- a/src/core/hle/service/nwm/nwm_soc.h +++ b/src/core/hle/service/nwm/nwm_soc.h @@ -14,3 +14,5 @@ public: }; } // namespace Service::NWM + +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_SOC) diff --git a/src/core/hle/service/nwm/nwm_tst.cpp b/src/core/hle/service/nwm/nwm_tst.cpp index 3be65200b7..65ffabfd9e 100644 --- a/src/core/hle/service/nwm/nwm_tst.cpp +++ b/src/core/hle/service/nwm/nwm_tst.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/nwm/nwm_tst.h" +SERIALIZE_EXPORT_IMPL(Service::NWM::NWM_TST) + namespace Service::NWM { NWM_TST::NWM_TST() : ServiceFramework("nwm::TST") { diff --git a/src/core/hle/service/nwm/nwm_tst.h b/src/core/hle/service/nwm/nwm_tst.h index 8214e0d1d5..e58fa33714 100644 --- a/src/core/hle/service/nwm/nwm_tst.h +++ b/src/core/hle/service/nwm/nwm_tst.h @@ -14,3 +14,5 @@ public: }; } // namespace Service::NWM + +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_TST) diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index fe8f7635f9..9a3de82fab 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -4,7 +4,10 @@ #include #include +#include +#include #include +#include "common/archives.h" #include "common/common_types.h" #include "common/logging/log.h" #include "core/core.h" @@ -23,6 +26,15 @@ namespace Service::NWM { +template +void NWM_UDS::serialize(Archive& ar, const unsigned int) { + ar& node_map; + ar& connection_event; + ar& received_beacons; + // TODO: Fix wifi_packet_received? +} +SERIALIZE_IMPL(NWM_UDS) + namespace ErrCodes { enum { NotInitialized = 2, diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index 52ca386635..07dd7e9ba1 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -521,6 +521,14 @@ private: struct Node { bool connected; u16 node_id; + + private: + template + void serialize(Archive& ar, const unsigned int) { + ar& connected; + ar& node_id; + } + friend class boost::serialization::access; }; std::map node_map; @@ -543,6 +551,12 @@ private: // List of the last beacons received from the network. std::list received_beacons; + + template + void serialize(Archive& ar, const unsigned int); }; } // namespace Service::NWM + +SERVICE_CONSTRUCT(Service::NWM::NWM_UDS) +BOOST_CLASS_EXPORT_KEY(Service::NWM::NWM_UDS) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 24f7826534..382a69e2f7 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -13,4 +13,4 @@ add_library(network STATIC create_target_directory_groups(network) -target_link_libraries(network PRIVATE common enet) +target_link_libraries(network PRIVATE common enet Boost::boost) diff --git a/src/network/room_member.h b/src/network/room_member.h index ad5d14b445..d582a8552f 100644 --- a/src/network/room_member.h +++ b/src/network/room_member.h @@ -8,6 +8,7 @@ #include #include #include +#include #include "common/common_types.h" #include "network/room.h" @@ -30,6 +31,17 @@ struct WifiPacket { MacAddress transmitter_address; ///< Mac address of the transmitter. MacAddress destination_address; ///< Mac address of the receiver. u8 channel; ///< WiFi channel where this frame was transmitted. + +private: + template + void serialize(Archive& ar, const unsigned int) { + ar& type; + ar& data; + ar& transmitter_address; + ar& destination_address; + ar& channel; + } + friend class boost::serialization::access; }; /// Represents a chat message.