diff --git a/TODO b/TODO index def70ac2b..a8efb78eb 100644 --- a/TODO +++ b/TODO @@ -7,6 +7,11 @@ ☐ Review base class serialization everywhere Make sure that all base/derived relationships are registered ☐ Serialize codeset with an apploader reference instead +☐ Additional stuff to serialize + ☐ Self-NCCH archive + ☐ File backends + ☐ Directory backends + ☐ File/directory 'services' ✔ CPU @done(19-08-13 15:41) ✔ Memory @done(19-08-13 15:41) ✔ Page tables @done(20-01-05 16:33) diff --git a/src/core/file_sys/archive_extsavedata.h b/src/core/file_sys/archive_extsavedata.h index c9b84c984..f33dd1a89 100644 --- a/src/core/file_sys/archive_extsavedata.h +++ b/src/core/file_sys/archive_extsavedata.h @@ -60,6 +60,7 @@ private: ArchiveFactory_ExtSaveData() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& shared; ar& mount_point; } diff --git a/src/core/file_sys/archive_ncch.h b/src/core/file_sys/archive_ncch.h index 0a3f95b5c..d17fbc3a2 100644 --- a/src/core/file_sys/archive_ncch.h +++ b/src/core/file_sys/archive_ncch.h @@ -116,7 +116,9 @@ public: private: template - void serialize(Archive& ar, const unsigned int) {} + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + } friend class boost::serialization::access; }; diff --git a/src/core/file_sys/archive_other_savedata.h b/src/core/file_sys/archive_other_savedata.h index a9deae95a..c5bf98a68 100644 --- a/src/core/file_sys/archive_other_savedata.h +++ b/src/core/file_sys/archive_other_savedata.h @@ -35,6 +35,7 @@ private: ArchiveFactory_OtherSaveDataPermitted() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& sd_savedata_source; } friend class boost::serialization::access; @@ -62,6 +63,7 @@ private: ArchiveFactory_OtherSaveDataGeneral() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& sd_savedata_source; } friend class boost::serialization::access; diff --git a/src/core/file_sys/archive_savedata.h b/src/core/file_sys/archive_savedata.h index 3ebe94a63..6bb22f7a8 100644 --- a/src/core/file_sys/archive_savedata.h +++ b/src/core/file_sys/archive_savedata.h @@ -34,6 +34,7 @@ private: ArchiveFactory_SaveData() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& sd_savedata_source; } friend class boost::serialization::access; diff --git a/src/core/file_sys/archive_sdmc.h b/src/core/file_sys/archive_sdmc.h index 6051abef0..265dd7e93 100644 --- a/src/core/file_sys/archive_sdmc.h +++ b/src/core/file_sys/archive_sdmc.h @@ -81,6 +81,7 @@ private: ArchiveFactory_SDMC() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& sdmc_directory; } friend class boost::serialization::access; diff --git a/src/core/file_sys/archive_sdmcwriteonly.h b/src/core/file_sys/archive_sdmcwriteonly.h index 19982a9db..f4149961c 100644 --- a/src/core/file_sys/archive_sdmcwriteonly.h +++ b/src/core/file_sys/archive_sdmcwriteonly.h @@ -67,6 +67,7 @@ private: ArchiveFactory_SDMCWriteOnly() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& sdmc_directory; } friend class boost::serialization::access; diff --git a/src/core/file_sys/archive_selfncch.h b/src/core/file_sys/archive_selfncch.h index de7fd75e0..571789b9f 100644 --- a/src/core/file_sys/archive_selfncch.h +++ b/src/core/file_sys/archive_selfncch.h @@ -47,6 +47,12 @@ private: /// Mapping of ProgramId -> NCCHData std::unordered_map ncch_data; // TODO: Remove this, or actually set the values here + + template + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + } + friend class boost::serialization::access; }; } // namespace FileSys diff --git a/src/core/file_sys/archive_systemsavedata.h b/src/core/file_sys/archive_systemsavedata.h index cf18cab89..d4f204a66 100644 --- a/src/core/file_sys/archive_systemsavedata.h +++ b/src/core/file_sys/archive_systemsavedata.h @@ -37,6 +37,7 @@ private: ArchiveFactory_SystemSaveData() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& base_path; } friend class boost::serialization::access; diff --git a/src/core/file_sys/savedata_archive.cpp b/src/core/file_sys/savedata_archive.cpp index 1f22b50ab..090dc6fb0 100644 --- a/src/core/file_sys/savedata_archive.cpp +++ b/src/core/file_sys/savedata_archive.cpp @@ -357,4 +357,5 @@ u64 SaveDataArchive::GetFreeBytes() const { } // namespace FileSys +SERIALIZE_EXPORT_IMPL(FileSys::SaveDataArchive) SERIALIZE_EXPORT_IMPL(FileSys::SaveDataDelayGenerator) diff --git a/src/core/file_sys/savedata_archive.h b/src/core/file_sys/savedata_archive.h index 47f2f75e0..c9956e135 100644 --- a/src/core/file_sys/savedata_archive.h +++ b/src/core/file_sys/savedata_archive.h @@ -38,10 +38,21 @@ public: protected: std::string mount_point; + +private: + SaveDataArchive() = default; + + template + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& mount_point; + } + friend class boost::serialization::access; }; class SaveDataDelayGenerator; } // namespace FileSys +BOOST_CLASS_EXPORT_KEY(FileSys::SaveDataArchive) BOOST_CLASS_EXPORT_KEY(FileSys::SaveDataDelayGenerator) diff --git a/src/core/hle/kernel/config_mem.h b/src/core/hle/kernel/config_mem.h index 0ec67fb5e..46595976e 100644 --- a/src/core/hle/kernel/config_mem.h +++ b/src/core/hle/kernel/config_mem.h @@ -70,6 +70,7 @@ private: friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int file_version) { + ar& boost::serialization::base_object(*this); ar& boost::serialization::make_binary_object(&config_mem, sizeof(config_mem)); } }; diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index b1e2f7d8b..23f577490 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -50,6 +50,7 @@ private: template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& callback; ar& context; } diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 01fec190b..046a31e2e 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -222,6 +222,11 @@ public: virtual ~WakeupCallback() = default; virtual void WakeUp(std::shared_ptr thread, HLERequestContext& context, ThreadWakeupReason reason) = 0; + + private: + template + void serialize(Archive& ar, const unsigned int) {} + friend class boost::serialization::access; }; /** diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index 331ac8397..74dbef624 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -111,7 +111,7 @@ private: friend class boost::serialization::access; template void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); + ar& boost::serialization::base_object(*this); ar& name; ar& parent; ar& hle_handler; diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index aa2be05a6..cb2dee685 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -109,6 +109,7 @@ private: template void serialize(Archive& ar, const unsigned int file_version) { + ar& boost::serialization::base_object(*this); ar& linear_heap_phys_offset; ar& backing_blocks; ar& size; diff --git a/src/core/hle/kernel/shared_page.h b/src/core/hle/kernel/shared_page.h index 7b1f7ed16..c94cc079e 100644 --- a/src/core/hle/kernel/shared_page.h +++ b/src/core/hle/kernel/shared_page.h @@ -117,6 +117,7 @@ private: template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& boost::serialization::make_binary_object(&shared_page, sizeof(shared_page)); } friend class boost::serialization::access; diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 7f7cc1272..371bbdfe3 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -434,6 +434,7 @@ private: SVC_SyncCallback() = default; template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& do_output; } friend class boost::serialization::access; @@ -466,7 +467,9 @@ private: SVC_IPCCallback() : system(Core::Global()) {} template - void serialize(Archive& ar, const unsigned int) {} + void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + } friend class boost::serialization::access; }; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 13a3017a5..f7379f50d 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -32,6 +32,7 @@ namespace Kernel { template void Thread::serialize(Archive& ar, const unsigned int file_version) { + ar& boost::serialization::base_object(*this); ar&* context.get(); ar& thread_id; ar& status; diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 9941c76db..c64e24071 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -66,6 +66,11 @@ public: virtual ~WakeupCallback() = default; virtual void WakeUp(ThreadWakeupReason reason, std::shared_ptr thread, std::shared_ptr object) = 0; + +private: + template + void serialize(Archive& ar, const unsigned int) {} + friend class boost::serialization::access; }; class ThreadManager { diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 2aa64f7fc..01bdd821e 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -1189,6 +1189,7 @@ private: template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& command_id; } friend class boost::serialization::access; diff --git a/src/core/hle/service/sm/srv.cpp b/src/core/hle/service/sm/srv.cpp index 10179f416..91b26b497 100644 --- a/src/core/hle/service/sm/srv.cpp +++ b/src/core/hle/service/sm/srv.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include +#include +#include +#include #include "common/archives.h" #include "common/common_types.h" #include "common/logging/log.h" @@ -21,8 +24,19 @@ #include "core/hle/service/sm/sm.h" #include "core/hle/service/sm/srv.h" +SERVICE_CONSTRUCT_IMPL(Service::SM::SRV) +SERIALIZE_EXPORT_IMPL(Service::SM::SRV) + namespace Service::SM { +template +void SRV::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& notification_semaphore; + ar& get_service_handle_delayed_map; +} +SERIALIZE_IMPL(SRV) + constexpr int MAX_PENDING_NOTIFICATIONS = 16; /** @@ -107,6 +121,7 @@ private: template void serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); ar& name; } friend class boost::serialization::access; diff --git a/src/core/hle/service/sm/srv.h b/src/core/hle/service/sm/srv.h index 7d17f87a5..753218dca 100644 --- a/src/core/hle/service/sm/srv.h +++ b/src/core/hle/service/sm/srv.h @@ -40,8 +40,14 @@ private: Core::System& system; std::shared_ptr notification_semaphore; std::unordered_map> get_service_handle_delayed_map; + + template + void serialize(Archive& ar, const unsigned int); + friend class boost::serialization::access; }; } // namespace Service::SM +SERVICE_CONSTRUCT(Service::SM::SRV) +BOOST_CLASS_EXPORT_KEY(Service::SM::SRV) BOOST_CLASS_EXPORT_KEY(Service::SM::SRV::ThreadCallback)