From a2d1c4a94cdcd328e19d943495dea397fef6dfc9 Mon Sep 17 00:00:00 2001 From: Steveice10 <1269164+Steveice10@users.noreply.github.com> Date: Sun, 14 Jan 2024 16:18:31 -0800 Subject: [PATCH] kernel: Move serialization code out of headers. (#7312) --- src/core/frontend/applets/mii_selector.h | 1 - src/core/hle/kernel/address_arbiter.cpp | 20 +++++++-- src/core/hle/kernel/address_arbiter.h | 14 +------ src/core/hle/kernel/client_port.cpp | 12 ++++++ src/core/hle/kernel/client_port.h | 10 +---- src/core/hle/kernel/client_session.cpp | 11 +++++ src/core/hle/kernel/client_session.h | 9 +--- src/core/hle/kernel/config_mem.cpp | 8 ++++ src/core/hle/kernel/config_mem.h | 6 +-- src/core/hle/kernel/event.cpp | 12 ++++++ src/core/hle/kernel/event.h | 10 +---- src/core/hle/kernel/handle_table.cpp | 14 +++++++ src/core/hle/kernel/handle_table.h | 13 +++--- src/core/hle/kernel/hle_ipc.cpp | 40 +++++++++++++++++- src/core/hle/kernel/hle_ipc.h | 52 ++++++++++-------------- src/core/hle/kernel/ipc.cpp | 15 +++++++ src/core/hle/kernel/ipc.h | 12 ++---- src/core/hle/kernel/kernel.cpp | 13 +++++- src/core/hle/kernel/kernel.h | 11 +++-- src/core/hle/kernel/memory.cpp | 16 ++++++++ src/core/hle/kernel/memory.h | 14 ++----- src/core/hle/kernel/mutex.cpp | 14 +++++++ src/core/hle/kernel/mutex.h | 12 +----- src/core/hle/kernel/object.cpp | 10 +++++ src/core/hle/kernel/object.h | 8 +--- src/core/hle/kernel/process.cpp | 36 +++++++++++++++- src/core/hle/kernel/process.h | 29 +++---------- src/core/hle/kernel/resource_limit.cpp | 20 +++++++++ src/core/hle/kernel/resource_limit.h | 18 +++----- src/core/hle/kernel/semaphore.cpp | 12 ++++++ src/core/hle/kernel/semaphore.h | 10 +---- src/core/hle/kernel/server_port.cpp | 2 +- src/core/hle/kernel/server_port.h | 2 +- src/core/hle/kernel/server_session.cpp | 2 +- src/core/hle/kernel/server_session.h | 2 +- src/core/hle/kernel/session.cpp | 3 +- src/core/hle/kernel/session.h | 6 ++- src/core/hle/kernel/shared_memory.cpp | 20 +++++++++ src/core/hle/kernel/shared_memory.h | 17 +------- src/core/hle/kernel/shared_page.cpp | 9 ++++ src/core/hle/kernel/shared_page.h | 7 +--- src/core/hle/kernel/thread.cpp | 18 +++++++- src/core/hle/kernel/thread.h | 20 +++------ src/core/hle/kernel/timer.cpp | 22 ++++++++++ src/core/hle/kernel/timer.h | 19 ++------- src/core/hle/kernel/vm_manager.cpp | 28 +++++++++++++ src/core/hle/kernel/vm_manager.h | 23 +++-------- src/core/hle/kernel/wait_object.cpp | 7 +++- src/core/hle/kernel/wait_object.h | 7 ++-- src/core/hle/mii.cpp | 17 ++++++++ src/core/hle/mii.h | 14 +++---- src/core/hle/service/soc/soc_u.h | 1 + 52 files changed, 458 insertions(+), 270 deletions(-) diff --git a/src/core/frontend/applets/mii_selector.h b/src/core/frontend/applets/mii_selector.h index 7dc404d37..3c8b3c219 100644 --- a/src/core/frontend/applets/mii_selector.h +++ b/src/core/frontend/applets/mii_selector.h @@ -6,7 +6,6 @@ #include #include -#include #include "core/hle/applets/mii_selector.h" namespace Frontend { diff --git a/src/core/hle/kernel/address_arbiter.cpp b/src/core/hle/kernel/address_arbiter.cpp index 2ccfff318..893492bcd 100644 --- a/src/core/hle/kernel/address_arbiter.cpp +++ b/src/core/hle/kernel/address_arbiter.cpp @@ -3,6 +3,10 @@ // Refer to the license.txt file included. #include +#include +#include +#include +#include #include "common/archives.h" #include "common/common_types.h" #include "common/logging/log.h" @@ -13,6 +17,9 @@ #include "core/hle/kernel/thread.h" #include "core/memory.h" +SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter) +SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter::Callback) + namespace Kernel { void AddressArbiter::WaitThread(std::shared_ptr thread, VAddr wait_address) { @@ -183,6 +190,16 @@ Result AddressArbiter::ArbitrateAddress(std::shared_ptr thread, Arbitrat return ResultSuccess; } +template +void AddressArbiter::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& name; + ar& waiting_threads; + ar& timeout_callback; + ar& resource_limit; +} +SERIALIZE_IMPL(AddressArbiter) + } // namespace Kernel namespace boost::serialization { @@ -201,6 +218,3 @@ void load_construct_data(Archive& ar, Kernel::AddressArbiter::Callback* t, const } } // namespace boost::serialization - -SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter) -SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter::Callback) diff --git a/src/core/hle/kernel/address_arbiter.h b/src/core/hle/kernel/address_arbiter.h index 5c8570a8c..b53a68d9e 100644 --- a/src/core/hle/kernel/address_arbiter.h +++ b/src/core/hle/kernel/address_arbiter.h @@ -6,12 +6,7 @@ #include #include -#include #include -#include -#include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/thread.h" @@ -83,18 +78,11 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& name; - ar& waiting_threads; - ar& timeout_callback; - ar& resource_limit; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter) BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter::Callback) -BOOST_CLASS_VERSION(Kernel::AddressArbiter, 2) CONSTRUCT_KERNEL_OBJECT(Kernel::AddressArbiter) diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp index 4cbe174ac..a2cffe39b 100644 --- a/src/core/hle/kernel/client_port.cpp +++ b/src/core/hle/kernel/client_port.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include #include "common/archives.h" #include "common/assert.h" #include "core/global.h" @@ -48,4 +50,14 @@ void ClientPort::ConnectionClosed() { --active_sessions; } +template +void ClientPort::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& server_port; + ar& max_sessions; + ar& active_sessions; + ar& name; +} +SERIALIZE_IMPL(ClientPort) + } // namespace Kernel diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index 94381a8b0..72ba671b9 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/server_port.h" @@ -66,13 +64,7 @@ private: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& server_port; - ar& max_sessions; - ar& active_sessions; - ar& name; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp index 75917bb85..db21846fb 100644 --- a/src/core/hle/kernel/client_session.cpp +++ b/src/core/hle/kernel/client_session.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "core/hle/kernel/client_session.h" @@ -53,4 +56,12 @@ Result ClientSession::SendSyncRequest(std::shared_ptr thread) { return server->HandleSyncRequest(std::move(thread)); } +template +void ClientSession::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& name; + ar& parent; +} +SERIALIZE_IMPL(ClientSession) + } // namespace Kernel diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 71075de70..9ce9a1e05 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -6,10 +6,7 @@ #include #include -#include #include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/result.h" @@ -54,11 +51,7 @@ public: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& name; - ar& parent; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/config_mem.cpp b/src/core/hle/kernel/config_mem.cpp index 307405f78..e8f612160 100644 --- a/src/core/hle/kernel/config_mem.cpp +++ b/src/core/hle/kernel/config_mem.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include #include "common/archives.h" #include "core/hle/kernel/config_mem.h" @@ -31,4 +32,11 @@ ConfigMemDef& Handler::GetConfigMem() { return config_mem; } +template +void Handler::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& boost::serialization::make_binary_object(&config_mem, sizeof(config_mem)); +} +SERIALIZE_IMPL(Handler) + } // namespace ConfigMem diff --git a/src/core/hle/kernel/config_mem.h b/src/core/hle/kernel/config_mem.h index 196d9d8bf..bcadaad54 100644 --- a/src/core/hle/kernel/config_mem.h +++ b/src/core/hle/kernel/config_mem.h @@ -9,7 +9,6 @@ // bootrom. Because we're not emulating this, and essentially just "stubbing" the functionality, I'm // putting this as a subset of HLE for now. -#include #include #include "common/common_funcs.h" #include "common/common_types.h" @@ -72,10 +71,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)); - } + void serialize(Archive& ar, const unsigned int); }; } // namespace ConfigMem diff --git a/src/core/hle/kernel/event.cpp b/src/core/hle/kernel/event.cpp index b78c17d7d..70b3594f7 100644 --- a/src/core/hle/kernel/event.cpp +++ b/src/core/hle/kernel/event.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include #include "common/archives.h" #include "common/assert.h" #include "core/hle/kernel/event.h" @@ -58,4 +60,14 @@ void Event::WakeupAllWaitingThreads() { } } +template +void Event::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& reset_type; + ar& signaled; + ar& name; + ar& resource_limit; +} +SERIALIZE_IMPL(Event) + } // namespace Kernel diff --git a/src/core/hle/kernel/event.h b/src/core/hle/kernel/event.h index a1fd8876c..1662027f4 100644 --- a/src/core/hle/kernel/event.h +++ b/src/core/hle/kernel/event.h @@ -4,9 +4,7 @@ #pragma once -#include #include -#include #include "core/hle/kernel/object.h" #include "core/hle/kernel/resource_limit.h" #include "core/hle/kernel/wait_object.h" @@ -57,13 +55,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& reset_type; - ar& signaled; - ar& name; - ar& resource_limit; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp index b6510ea4f..081135368 100644 --- a/src/core/hle/kernel/handle_table.cpp +++ b/src/core/hle/kernel/handle_table.cpp @@ -3,6 +3,9 @@ // Refer to the license.txt file included. #include +#include +#include +#include "common/archives.h" #include "common/assert.h" #include "common/logging/log.h" #include "core/hle/kernel/errors.h" @@ -10,6 +13,8 @@ #include "core/hle/kernel/process.h" #include "core/hle/kernel/thread.h" +SERIALIZE_EXPORT_IMPL(Kernel::HandleTable) + namespace Kernel { namespace { constexpr u16 GetSlot(Handle handle) { @@ -94,4 +99,13 @@ void HandleTable::Clear() { next_free_slot = 0; } +template +void HandleTable::serialize(Archive& ar, const unsigned int) { + ar& objects; + ar& generations; + ar& next_generation; + ar& next_free_slot; +} +SERIALIZE_IMPL(HandleTable) + } // namespace Kernel diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h index 1dc032082..5bb34ff18 100644 --- a/src/core/hle/kernel/handle_table.h +++ b/src/core/hle/kernel/handle_table.h @@ -7,8 +7,7 @@ #include #include #include -#include -#include +#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/result.h" @@ -121,12 +120,10 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& objects; - ar& generations; - ar& next_generation; - ar& next_free_slot; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::HandleTable) +CONSTRUCT_KERNEL_OBJECT(Kernel::HandleTable) diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index eeb3dc51b..c0b4c93e7 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -4,6 +4,10 @@ #include #include +#include +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/common_types.h" @@ -15,6 +19,12 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/process.h" +SERIALIZE_EXPORT_IMPL(Kernel::SessionRequestHandler) +SERIALIZE_EXPORT_IMPL(Kernel::SessionRequestHandler::SessionDataBase) +SERIALIZE_EXPORT_IMPL(Kernel::SessionRequestHandler::SessionInfo) +SERIALIZE_EXPORT_IMPL(Kernel::HLERequestContext) +SERIALIZE_EXPORT_IMPL(Kernel::HLERequestContext::ThreadCallback) + namespace Kernel { class HLERequestContext::ThreadCallback : public Kernel::WakeupCallback { @@ -77,6 +87,23 @@ void SessionRequestHandler::ClientDisconnected(std::shared_ptr se connected_sessions.end()); } +template +void SessionRequestHandler::serialize(Archive& ar, const unsigned int) { + ar& connected_sessions; +} +SERIALIZE_IMPL(SessionRequestHandler) + +template +void SessionRequestHandler::SessionDataBase::serialize(Archive& ar, const unsigned int) {} +SERIALIZE_IMPL(SessionRequestHandler::SessionDataBase) + +template +void SessionRequestHandler::SessionInfo::serialize(Archive& ar, const unsigned int) { + ar& session; + ar& data; +} +SERIALIZE_IMPL(SessionRequestHandler::SessionInfo) + std::shared_ptr HLERequestContext::SleepClientThread( const std::string& reason, std::chrono::nanoseconds timeout, std::shared_ptr callback) { @@ -295,6 +322,17 @@ void HLERequestContext::ReportUnimplemented() const { } } +template +void HLERequestContext::serialize(Archive& ar, const unsigned int) { + ar& cmd_buf; + ar& session; + ar& thread; + ar& request_handles; + ar& static_buffers; + ar& request_mapped_buffers; +} +SERIALIZE_IMPL(HLERequestContext) + MappedBuffer::MappedBuffer() : memory(&Core::Global().Memory()) {} MappedBuffer::MappedBuffer(Memory::MemorySystem& memory, std::shared_ptr process, @@ -318,5 +356,3 @@ void MappedBuffer::Write(const void* src_buffer, std::size_t offset, std::size_t } } // namespace Kernel - -SERIALIZE_EXPORT_IMPL(Kernel::HLERequestContext::ThreadCallback) diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 43a03d5e9..5b6ab88b5 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -12,10 +12,7 @@ #include #include #include -#include -#include -#include -#include +#include #include "common/common_types.h" #include "common/serialization/boost_small_vector.hpp" #include "common/swap.h" @@ -77,7 +74,20 @@ public: private: template - void serialize(Archive& ar, const unsigned int file_version) {} + void serialize(Archive& ar, const unsigned int); + friend class boost::serialization::access; + }; + + struct SessionInfo { + SessionInfo(std::shared_ptr session, std::unique_ptr data); + + std::shared_ptr session; + std::unique_ptr data; + + private: + SessionInfo() = default; + template + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; @@ -96,30 +106,13 @@ protected: return static_cast(itr->data.get()); } - struct SessionInfo { - SessionInfo(std::shared_ptr session, std::unique_ptr data); - - std::shared_ptr session; - std::unique_ptr data; - - private: - SessionInfo() = default; - template - void serialize(Archive& ar, const unsigned int file_version) { - ar& session; - ar& data; - } - friend class boost::serialization::access; - }; /// List of sessions that are connected to this handler. A ServerSession whose server endpoint /// is an HLE implementation is kept alive by this list for the duration of the connection. std::vector connected_sessions; private: template - void serialize(Archive& ar, const unsigned int file_version) { - ar& connected_sessions; - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; @@ -388,17 +381,14 @@ private: HLERequestContext(); template - void serialize(Archive& ar, const unsigned int) { - ar& cmd_buf; - ar& session; - ar& thread; - ar& request_handles; - ar& static_buffers; - ar& request_mapped_buffers; - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; } // namespace Kernel +BOOST_CLASS_EXPORT_KEY(Kernel::SessionRequestHandler) +BOOST_CLASS_EXPORT_KEY(Kernel::SessionRequestHandler::SessionDataBase) +BOOST_CLASS_EXPORT_KEY(Kernel::SessionRequestHandler::SessionInfo) +BOOST_CLASS_EXPORT_KEY(Kernel::HLERequestContext) BOOST_CLASS_EXPORT_KEY(Kernel::HLERequestContext::ThreadCallback) diff --git a/src/core/hle/kernel/ipc.cpp b/src/core/hle/kernel/ipc.cpp index 714c8b5e6..dcb8b8acd 100644 --- a/src/core/hle/kernel/ipc.cpp +++ b/src/core/hle/kernel/ipc.cpp @@ -3,7 +3,9 @@ // Refer to the license.txt file included. #include +#include #include "common/alignment.h" +#include "common/archives.h" #include "common/memory_ref.h" #include "core/core.h" #include "core/hle/ipc.h" @@ -16,6 +18,8 @@ #include "core/hle/kernel/thread.h" #include "core/memory.h" +SERIALIZE_EXPORT_IMPL(Kernel::MappedBufferContext) + namespace Kernel { Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, @@ -250,4 +254,15 @@ Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem return ResultSuccess; } + +template +void MappedBufferContext::serialize(Archive& ar, const unsigned int) { + ar& permissions; + ar& size; + ar& source_address; + ar& target_address; + ar& buffer; +} +SERIALIZE_IMPL(MappedBufferContext) + } // namespace Kernel diff --git a/src/core/hle/kernel/ipc.h b/src/core/hle/kernel/ipc.h index dec2fd95a..fd69c3ef8 100644 --- a/src/core/hle/kernel/ipc.h +++ b/src/core/hle/kernel/ipc.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "core/hle/ipc.h" #include "core/hle/kernel/thread.h" @@ -29,13 +29,7 @@ struct MappedBufferContext { private: template - void serialize(Archive& ar, const unsigned int file_version) { - ar& permissions; - ar& size; - ar& source_address; - ar& target_address; - ar& buffer; - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; @@ -46,3 +40,5 @@ Result TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory VAddr dst_address, std::vector& mapped_buffer_context, bool reply); } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::MappedBufferContext) diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 9df6e75dd..7e685b11d 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -19,6 +19,8 @@ #include "core/hle/kernel/thread.h" #include "core/hle/kernel/timer.h" +SERIALIZE_EXPORT_IMPL(Kernel::New3dsHwCapabilities) + namespace Kernel { /// Initialize the kernel @@ -162,7 +164,7 @@ void KernelSystem::ResetThreadIDs() { } template -void KernelSystem::serialize(Archive& ar, const unsigned int file_version) { +void KernelSystem::serialize(Archive& ar, const unsigned int) { ar& memory_regions; ar& named_ports; // current_cpu set externally @@ -195,7 +197,14 @@ void KernelSystem::serialize(Archive& ar, const unsigned int file_version) { } } } - SERIALIZE_IMPL(KernelSystem) +template +void New3dsHwCapabilities::serialize(Archive& ar, const unsigned int) { + ar& enable_l2_cache; + ar& enable_804MHz_cpu; + ar& memory_mode; +} +SERIALIZE_IMPL(New3dsHwCapabilities) + } // namespace Kernel diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h index 8c3f2b35c..8a30abe59 100644 --- a/src/core/hle/kernel/kernel.h +++ b/src/core/hle/kernel/kernel.h @@ -13,6 +13,7 @@ #include #include #include +#include #include "common/common_types.h" #include "core/hle/kernel/memory.h" #include "core/hle/result.h" @@ -124,11 +125,7 @@ struct New3dsHwCapabilities { private: template - void serialize(Archive& ar, const unsigned int) { - ar& enable_l2_cache; - ar& enable_804MHz_cpu; - ar& memory_mode; - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; @@ -407,7 +404,9 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version); + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::New3dsHwCapabilities) diff --git a/src/core/hle/kernel/memory.cpp b/src/core/hle/kernel/memory.cpp index 12fea67a1..006d89804 100644 --- a/src/core/hle/kernel/memory.cpp +++ b/src/core/hle/kernel/memory.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include "common/archives.h" #include "common/assert.h" #include "common/common_types.h" #include "common/logging/log.h" @@ -19,6 +21,8 @@ #include "core/hle/result.h" #include "core/memory.h" +SERIALIZE_EXPORT_IMPL(Kernel::MemoryRegionInfo) + namespace Kernel { /// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system @@ -267,4 +271,16 @@ void MemoryRegionInfo::Unlock() { is_locked = false; } +template +void MemoryRegionInfo::serialize(Archive& ar, const unsigned int) { + ar& base; + ar& size; + ar& used; + ar& free_blocks; + if (Archive::is_loading::value) { + is_locked = true; + } +} +SERIALIZE_IMPL(MemoryRegionInfo) + } // namespace Kernel diff --git a/src/core/hle/kernel/memory.h b/src/core/hle/kernel/memory.h index 0a7ddd166..90b2aeee8 100644 --- a/src/core/hle/kernel/memory.h +++ b/src/core/hle/kernel/memory.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include "common/common_types.h" #include "common/serialization/boost_interval_set.hpp" @@ -83,15 +83,9 @@ struct MemoryRegionInfo { private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& base; - ar& size; - ar& used; - ar& free_blocks; - if (Archive::is_loading::value) { - is_locked = true; - } - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::MemoryRegionInfo) diff --git a/src/core/hle/kernel/mutex.cpp b/src/core/hle/kernel/mutex.cpp index fc6cc9dc7..80b37666b 100644 --- a/src/core/hle/kernel/mutex.cpp +++ b/src/core/hle/kernel/mutex.cpp @@ -2,6 +2,9 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "core/core.h" @@ -127,4 +130,15 @@ void Mutex::UpdatePriority() { } } +template +void Mutex::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& lock_count; + ar& priority; + ar& name; + ar& holding_thread; + ar& resource_limit; +} +SERIALIZE_IMPL(Mutex) + } // namespace Kernel diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index 0ff7ef7cb..d09e5dcb0 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -6,10 +6,7 @@ #include #include -#include #include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/resource_limit.h" @@ -67,14 +64,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& lock_count; - ar& priority; - ar& name; - ar& holding_thread; - ar& resource_limit; - } + void serialize(Archive& ar, const unsigned int); }; /** diff --git a/src/core/hle/kernel/object.cpp b/src/core/hle/kernel/object.cpp index f9ca68218..1e32f6125 100644 --- a/src/core/hle/kernel/object.cpp +++ b/src/core/hle/kernel/object.cpp @@ -6,6 +6,10 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/kernel/object.h" +#include "common/archives.h" + +SERIALIZE_EXPORT_IMPL(Kernel::Object) + namespace Kernel { Object::Object(KernelSystem& kernel) : object_id{kernel.GenerateObjectID()} {} @@ -37,4 +41,10 @@ bool Object::IsWaitable() const { UNREACHABLE(); } +template +void Object::serialize(Archive& ar, const unsigned int) { + ar& object_id; +} +SERIALIZE_IMPL(Object) + } // namespace Kernel diff --git a/src/core/hle/kernel/object.h b/src/core/hle/kernel/object.h index b272366d7..571ecd42f 100644 --- a/src/core/hle/kernel/object.h +++ b/src/core/hle/kernel/object.h @@ -7,8 +7,6 @@ #include #include #include -#include -#include #include #include "common/common_types.h" #include "common/serialization/atomic.h" @@ -72,9 +70,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& object_id; - } + void serialize(Archive& ar, const unsigned int); }; template @@ -99,7 +95,7 @@ inline std::shared_ptr DynamicObjectCast(std::shared_ptr object) { } // namespace Kernel -BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::Object) +BOOST_CLASS_EXPORT_KEY(Kernel::Object) #define CONSTRUCT_KERNEL_OBJECT(T) \ namespace boost::serialization { \ diff --git a/src/core/hle/kernel/process.cpp b/src/core/hle/kernel/process.cpp index a78c5f64c..17f142cfd 100644 --- a/src/core/hle/kernel/process.cpp +++ b/src/core/hle/kernel/process.cpp @@ -5,8 +5,11 @@ #include #include #include +#include #include #include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/common_funcs.h" @@ -23,13 +26,24 @@ #include "core/loader/loader.h" #include "core/memory.h" +SERIALIZE_EXPORT_IMPL(Kernel::AddressMapping) SERIALIZE_EXPORT_IMPL(Kernel::Process) SERIALIZE_EXPORT_IMPL(Kernel::CodeSet) +SERIALIZE_EXPORT_IMPL(Kernel::CodeSet::Segment) namespace Kernel { template -void Process::serialize(Archive& ar, const unsigned int file_version) { +void AddressMapping::serialize(Archive& ar, const unsigned int) { + ar& address; + ar& size; + ar& read_only; + ar& unk_flag; +} +SERIALIZE_IMPL(AddressMapping) + +template +void Process::serialize(Archive& ar, const unsigned int) { ar& boost::serialization::base_object(*this); ar& handle_table; ar& codeset; // TODO: Replace with apploader reference @@ -52,7 +66,6 @@ void Process::serialize(Archive& ar, const unsigned int file_version) { ar& holding_tls_memory; ar& tls_slots; } - SERIALIZE_IMPL(Process) std::shared_ptr KernelSystem::CreateCodeSet(std::string name, u64 program_id) { @@ -67,6 +80,25 @@ std::shared_ptr KernelSystem::CreateCodeSet(std::string name, u64 progr CodeSet::CodeSet(KernelSystem& kernel) : Object(kernel) {} CodeSet::~CodeSet() {} +template +void CodeSet::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& memory; + ar& segments; + ar& entrypoint; + ar& name; + ar& program_id; +} +SERIALIZE_IMPL(CodeSet) + +template +void CodeSet::Segment::serialize(Archive& ar, const unsigned int) { + ar& offset; + ar& addr; + ar& size; +} +SERIALIZE_IMPL(CodeSet::Segment) + std::shared_ptr KernelSystem::CreateProcess(std::shared_ptr code_set) { auto process{std::make_shared(*this)}; diff --git a/src/core/hle/kernel/process.h b/src/core/hle/kernel/process.h index 58703b7a6..7ec1adfbb 100644 --- a/src/core/hle/kernel/process.h +++ b/src/core/hle/kernel/process.h @@ -11,10 +11,7 @@ #include #include #include -#include -#include -#include -#include +#include #include "common/bit_field.h" #include "common/common_types.h" #include "core/hle/kernel/handle_table.h" @@ -33,12 +30,7 @@ struct AddressMapping { private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& address; - ar& size; - ar& read_only; - ar& unk_flag; - } + void serialize(Archive& ar, const unsigned int); }; union ProcessFlags { @@ -77,11 +69,7 @@ public: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& offset; - ar& addr; - ar& size; - } + void serialize(Archive& ar, const unsigned int); }; std::string GetTypeName() const override { @@ -133,14 +121,7 @@ public: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& memory; - ar& segments; - ar& entrypoint; - ar& name; - ar& program_id; - } + void serialize(Archive& ar, const unsigned int); }; class Process final : public Object { @@ -257,7 +238,9 @@ private: } // namespace Kernel +BOOST_CLASS_EXPORT_KEY(Kernel::AddressMapping) BOOST_CLASS_EXPORT_KEY(Kernel::CodeSet) +BOOST_CLASS_EXPORT_KEY(Kernel::CodeSet::Segment) BOOST_CLASS_EXPORT_KEY(Kernel::Process) CONSTRUCT_KERNEL_OBJECT(Kernel::CodeSet) CONSTRUCT_KERNEL_OBJECT(Kernel::Process) diff --git a/src/core/hle/kernel/resource_limit.cpp b/src/core/hle/kernel/resource_limit.cpp index b298c6879..4575cab37 100644 --- a/src/core/hle/kernel/resource_limit.cpp +++ b/src/core/hle/kernel/resource_limit.cpp @@ -2,12 +2,17 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/settings.h" #include "core/hle/kernel/resource_limit.h" SERIALIZE_EXPORT_IMPL(Kernel::ResourceLimit) +SERIALIZE_EXPORT_IMPL(Kernel::ResourceLimitList) namespace Kernel { @@ -61,6 +66,15 @@ bool ResourceLimit::Release(ResourceLimitType type, s32 amount) { return true; } +template +void ResourceLimit::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& m_name; + ar& m_limit_values; + ar& m_current_values; +} +SERIALIZE_IMPL(ResourceLimit) + ResourceLimitList::ResourceLimitList(KernelSystem& kernel) { // PM makes APPMEMALLOC always match app RESLIMIT_COMMIT. // See: https://github.com/LumaTeam/Luma3DS/blob/e2778a45/sysmodules/pm/source/reslimit.c#L275 @@ -138,4 +152,10 @@ std::shared_ptr ResourceLimitList::GetForCategory(ResourceLimitCa } } +template +void ResourceLimitList::serialize(Archive& ar, const unsigned int) { + ar& resource_limits; +} +SERIALIZE_IMPL(ResourceLimitList) + } // namespace Kernel diff --git a/src/core/hle/kernel/resource_limit.h b/src/core/hle/kernel/resource_limit.h index 069175daa..48235411e 100644 --- a/src/core/hle/kernel/resource_limit.h +++ b/src/core/hle/kernel/resource_limit.h @@ -6,10 +6,7 @@ #include #include -#include -#include -#include -#include +#include #include "common/common_types.h" #include "core/hle/kernel/object.h" @@ -76,12 +73,7 @@ private: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& m_name; - ar& m_limit_values; - ar& m_current_values; - } + void serialize(Archive& ar, const unsigned int); }; class ResourceLimitList { @@ -101,12 +93,12 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& resource_limits; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel BOOST_CLASS_EXPORT_KEY(Kernel::ResourceLimit) +BOOST_CLASS_EXPORT_KEY(Kernel::ResourceLimitList) CONSTRUCT_KERNEL_OBJECT(Kernel::ResourceLimit) +CONSTRUCT_KERNEL_OBJECT(Kernel::ResourceLimitList) diff --git a/src/core/hle/kernel/semaphore.cpp b/src/core/hle/kernel/semaphore.cpp index b8c2e0514..5e3129ebb 100644 --- a/src/core/hle/kernel/semaphore.cpp +++ b/src/core/hle/kernel/semaphore.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include #include "common/archives.h" #include "core/hle/kernel/errors.h" #include "core/hle/kernel/kernel.h" @@ -58,4 +60,14 @@ Result Semaphore::Release(s32* out_count, s32 release_count) { return ResultSuccess; } +template +void Semaphore::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& max_count; + ar& available_count; + ar& name; + ar& resource_limit; +} +SERIALIZE_IMPL(Semaphore) + } // namespace Kernel diff --git a/src/core/hle/kernel/semaphore.h b/src/core/hle/kernel/semaphore.h index 1c3a008e1..a7d5f819a 100644 --- a/src/core/hle/kernel/semaphore.h +++ b/src/core/hle/kernel/semaphore.h @@ -5,9 +5,7 @@ #pragma once #include -#include #include -#include #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" @@ -52,13 +50,7 @@ public: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& max_count; - ar& available_count; - ar& name; - ar& resource_limit; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp index f3ac13f7d..827fa0595 100644 --- a/src/core/hle/kernel/server_port.cpp +++ b/src/core/hle/kernel/server_port.cpp @@ -55,7 +55,7 @@ KernelSystem::PortPair KernelSystem::CreatePortPair(u32 max_sessions, std::strin } template -void ServerPort::serialize(Archive& ar, const unsigned int file_version) { +void ServerPort::serialize(Archive& ar, const unsigned int) { ar& boost::serialization::base_object(*this); ar& name; ar& pending_sessions; diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 7f1b0c262..675a80e2b 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -66,7 +66,7 @@ public: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version); + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index e9f872fc8..1a5d39226 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -19,7 +19,7 @@ SERIALIZE_EXPORT_IMPL(Kernel::ServerSession) namespace Kernel { template -void ServerSession::serialize(Archive& ar, const unsigned int file_version) { +void ServerSession::serialize(Archive& ar, const unsigned int) { ar& boost::serialization::base_object(*this); ar& name; ar& parent; diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h index e631c9a1c..666ffe77b 100644 --- a/src/core/hle/kernel/server_session.h +++ b/src/core/hle/kernel/server_session.h @@ -108,7 +108,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version); + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/session.cpp b/src/core/hle/kernel/session.cpp index 8bb846c52..1f79de1f9 100644 --- a/src/core/hle/kernel/session.cpp +++ b/src/core/hle/kernel/session.cpp @@ -9,7 +9,7 @@ #include "core/hle/kernel/server_session.h" #include "core/hle/kernel/session.h" -SERIALIZE_IMPL(Kernel::Session) +SERIALIZE_EXPORT_IMPL(Kernel::Session) namespace Kernel { @@ -19,5 +19,6 @@ void Session::serialize(Archive& ar, const unsigned int file_version) { ar& server; ar& port; } +SERIALIZE_IMPL(Session) } // namespace Kernel diff --git a/src/core/hle/kernel/session.h b/src/core/hle/kernel/session.h index eca1a9252..11e058914 100644 --- a/src/core/hle/kernel/session.h +++ b/src/core/hle/kernel/session.h @@ -5,7 +5,7 @@ #pragma once #include -#include +#include #include "core/hle/kernel/object.h" namespace Kernel { @@ -29,6 +29,8 @@ public: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version); + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::Session) diff --git a/src/core/hle/kernel/shared_memory.cpp b/src/core/hle/kernel/shared_memory.cpp index c68e4a297..73d60a3c0 100644 --- a/src/core/hle/kernel/shared_memory.cpp +++ b/src/core/hle/kernel/shared_memory.cpp @@ -2,6 +2,10 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include +#include +#include #include "common/archives.h" #include "common/logging/log.h" #include "core/hle/kernel/errors.h" @@ -217,4 +221,20 @@ const u8* SharedMemory::GetPointer(u32 offset) const { return backing_blocks[0].first + offset; } +template +void SharedMemory::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& linear_heap_phys_offset; + ar& backing_blocks; + ar& size; + ar& memory_region; + ar& permissions; + ar& other_permissions; + ar& owner_process; + ar& base_address; + ar& name; + ar& holding_memory; +} +SERIALIZE_IMPL(SharedMemory) + } // namespace Kernel diff --git a/src/core/hle/kernel/shared_memory.h b/src/core/hle/kernel/shared_memory.h index f6403fb7d..c2ac11ab3 100644 --- a/src/core/hle/kernel/shared_memory.h +++ b/src/core/hle/kernel/shared_memory.h @@ -6,10 +6,7 @@ #include #include -#include #include -#include -#include #include "common/common_types.h" #include "common/memory_ref.h" #include "core/hle/kernel/object.h" @@ -113,19 +110,7 @@ private: KernelSystem& kernel; 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; - ar& memory_region; - ar& permissions; - ar& other_permissions; - ar& owner_process; - ar& base_address; - ar& name; - ar& holding_memory; - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; diff --git a/src/core/hle/kernel/shared_page.cpp b/src/core/hle/kernel/shared_page.cpp index 10264c4e9..ef7f1690c 100644 --- a/src/core/hle/kernel/shared_page.cpp +++ b/src/core/hle/kernel/shared_page.cpp @@ -4,6 +4,8 @@ #include #include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/settings.h" @@ -172,4 +174,11 @@ SharedPageDef& Handler::GetSharedPage() { return shared_page; } +template +void Handler::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& boost::serialization::make_binary_object(&shared_page, sizeof(shared_page)); +} +SERIALIZE_IMPL(Handler) + } // namespace SharedPage diff --git a/src/core/hle/kernel/shared_page.h b/src/core/hle/kernel/shared_page.h index 7c163bdd3..d39c4c43d 100644 --- a/src/core/hle/kernel/shared_page.h +++ b/src/core/hle/kernel/shared_page.h @@ -13,8 +13,6 @@ #include #include #include -#include -#include #include #include "common/bit_field.h" #include "common/common_funcs.h" @@ -141,10 +139,7 @@ private: SharedPageDef shared_page; 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)); - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 0bcca6177..b531ae97f 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -5,6 +5,9 @@ #include #include #include +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/common_types.h" @@ -24,9 +27,19 @@ #include "core/memory.h" SERIALIZE_EXPORT_IMPL(Kernel::Thread) +SERIALIZE_EXPORT_IMPL(Kernel::WakeupCallback) namespace Kernel { +template +void ThreadManager::serialize(Archive& ar, const unsigned int) { + ar& current_thread; + ar& ready_queue; + ar& wakeup_callback_table; + ar& thread_list; +} +SERIALIZE_IMPL(ThreadManager) + template void Thread::serialize(Archive& ar, const unsigned int file_version) { ar& boost::serialization::base_object(*this); @@ -48,9 +61,12 @@ void Thread::serialize(Archive& ar, const unsigned int file_version) { ar& name; ar& wakeup_callback; } - SERIALIZE_IMPL(Thread) +template +void WakeupCallback::serialize(Archive& ar, const unsigned int) {} +SERIALIZE_IMPL(WakeupCallback) + bool Thread::ShouldWait(const Thread* thread) const { return status != ThreadStatus::Dead; } diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 108611041..65b1cd7e6 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -11,9 +11,6 @@ #include #include #include -#include -#include -#include #include "common/common_types.h" #include "common/thread_queue_list.h" #include "core/arm/arm_interface.h" @@ -72,7 +69,7 @@ public: private: template - void serialize(Archive& ar, const unsigned int) {} + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; @@ -164,12 +161,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& current_thread; - ar& ready_queue; - ar& wakeup_callback_table; - ar& thread_list; - } + void serialize(Archive& ar, const unsigned int); }; class Thread final : public WaitObject { @@ -336,7 +328,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version); + void serialize(Archive& ar, const unsigned int); }; /** @@ -353,17 +345,17 @@ std::shared_ptr SetupMainThread(KernelSystem& kernel, u32 entry_point, u } // namespace Kernel BOOST_CLASS_EXPORT_KEY(Kernel::Thread) +BOOST_CLASS_EXPORT_KEY(Kernel::WakeupCallback) namespace boost::serialization { template -inline void save_construct_data(Archive& ar, const Kernel::Thread* t, - const unsigned int file_version) { +void save_construct_data(Archive& ar, const Kernel::Thread* t, const unsigned int) { ar << t->core_id; } template -inline void load_construct_data(Archive& ar, Kernel::Thread* t, const unsigned int file_version) { +void load_construct_data(Archive& ar, Kernel::Thread* t, const unsigned int) { u32 core_id; ar >> core_id; ::new (t) Kernel::Thread(Core::Global(), core_id); diff --git a/src/core/hle/kernel/timer.cpp b/src/core/hle/kernel/timer.cpp index 41ce6ef1a..4274dbc6a 100644 --- a/src/core/hle/kernel/timer.cpp +++ b/src/core/hle/kernel/timer.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/logging/log.h" @@ -97,6 +99,19 @@ void Timer::Signal(s64 cycles_late) { } } +template +void Timer::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::base_object(*this); + ar& reset_type; + ar& initial_delay; + ar& interval_delay; + ar& signaled; + ar& name; + ar& callback_id; + ar& resource_limit; +} +SERIALIZE_IMPL(Timer) + /// The timer callback event, called when a timer is fired void TimerManager::TimerCallback(u64 callback_id, s64 cycles_late) { std::shared_ptr timer = SharedFrom(timer_callback_table.at(callback_id)); @@ -116,4 +131,11 @@ TimerManager::TimerManager(Core::Timing& timing) : timing(timing) { }); } +template +void TimerManager::serialize(Archive& ar, const unsigned int) { + ar& next_timer_callback_id; + ar& timer_callback_table; +} +SERIALIZE_IMPL(TimerManager) + } // namespace Kernel diff --git a/src/core/hle/kernel/timer.h b/src/core/hle/kernel/timer.h index 9eedb6a85..890d69339 100644 --- a/src/core/hle/kernel/timer.h +++ b/src/core/hle/kernel/timer.h @@ -4,8 +4,7 @@ #pragma once -#include -#include +#include #include "common/common_types.h" #include "core/core_timing.h" #include "core/hle/kernel/object.h" @@ -38,10 +37,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& next_timer_callback_id; - ar& timer_callback_table; - } + void serialize(Archive& ar, const unsigned int); }; class ResourceLimit; @@ -119,16 +115,7 @@ private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& boost::serialization::base_object(*this); - ar& reset_type; - ar& initial_delay; - ar& interval_delay; - ar& signaled; - ar& name; - ar& callback_id; - ar& resource_limit; - } + void serialize(Archive& ar, const unsigned int); }; } // namespace Kernel diff --git a/src/core/hle/kernel/vm_manager.cpp b/src/core/hle/kernel/vm_manager.cpp index ca0a40371..1df94d89e 100644 --- a/src/core/hle/kernel/vm_manager.cpp +++ b/src/core/hle/kernel/vm_manager.cpp @@ -4,6 +4,10 @@ #include #include +#include +#include +#include +#include "common/archives.h" #include "common/assert.h" #include "core/core.h" #include "core/hle/kernel/errors.h" @@ -11,6 +15,8 @@ #include "core/hle/service/plgldr/plgldr.h" #include "core/memory.h" +SERIALIZE_EXPORT_IMPL(Kernel::VirtualMemoryArea) + namespace Kernel { static const char* GetMemoryStateName(MemoryState state) { @@ -35,6 +41,17 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const { return true; } +template +void VirtualMemoryArea::serialize(Archive& ar, const unsigned int) { + ar& base; + ar& size; + ar& type; + ar& permissions; + ar& meminfo_state; + ar& backing_memory; +} +SERIALIZE_IMPL(VirtualMemoryArea) + VMManager::VMManager(Memory::MemorySystem& memory, Kernel::Process& proc) : page_table(std::make_shared()), memory(memory), process(proc) { Reset(); @@ -379,4 +396,15 @@ ResultVal>> VMManager::GetBackingBlocksFor } return backing_blocks; } + +template +void VMManager::serialize(Archive& ar, const unsigned int) { + ar& vma_map; + ar& page_table; + if (Archive::is_loading::value) { + is_locked = true; + } +} +SERIALIZE_IMPL(VMManager) + } // namespace Kernel diff --git a/src/core/hle/kernel/vm_manager.h b/src/core/hle/kernel/vm_manager.h index 37aac9cdf..c1b696664 100644 --- a/src/core/hle/kernel/vm_manager.h +++ b/src/core/hle/kernel/vm_manager.h @@ -6,9 +6,7 @@ #include #include -#include -#include -#include +#include #include "common/common_types.h" #include "common/memory_ref.h" #include "core/hle/kernel/memory.h" @@ -79,14 +77,7 @@ struct VirtualMemoryArea { private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version) { - ar& base; - ar& size; - ar& type; - ar& permissions; - ar& meminfo_state; - ar& backing_memory; - } + void serialize(Archive& ar, const unsigned int); }; /** @@ -238,13 +229,9 @@ private: bool is_locked{}; template - void serialize(Archive& ar, const unsigned int) { - ar& vma_map; - ar& page_table; - if (Archive::is_loading::value) { - is_locked = true; - } - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::VirtualMemoryArea) diff --git a/src/core/hle/kernel/wait_object.cpp b/src/core/hle/kernel/wait_object.cpp index 2cd4331c5..f528d9073 100644 --- a/src/core/hle/kernel/wait_object.cpp +++ b/src/core/hle/kernel/wait_object.cpp @@ -4,6 +4,9 @@ #include #include +#include +#include +#include #include "common/archives.h" #include "common/assert.h" #include "common/logging/log.h" @@ -15,10 +18,12 @@ #include "core/hle/kernel/thread.h" #include "core/hle/kernel/timer.h" +SERIALIZE_EXPORT_IMPL(Kernel::WaitObject) + namespace Kernel { template -void WaitObject::serialize(Archive& ar, const unsigned int file_version) { +void WaitObject::serialize(Archive& ar, const unsigned int) { ar& boost::serialization::base_object(*this); ar& waiting_threads; // NB: hle_notifier *not* serialized since it's a callback! diff --git a/src/core/hle/kernel/wait_object.h b/src/core/hle/kernel/wait_object.h index 7f73eab9f..9215a2ea1 100644 --- a/src/core/hle/kernel/wait_object.h +++ b/src/core/hle/kernel/wait_object.h @@ -7,9 +7,6 @@ #include #include #include -#include -#include -#include #include "common/common_types.h" #include "core/hle/kernel/object.h" @@ -69,7 +66,7 @@ private: private: friend class boost::serialization::access; template - void serialize(Archive& ar, const unsigned int file_version); + void serialize(Archive& ar, const unsigned int); }; // Specialization of DynamicObjectCast for WaitObjects @@ -82,3 +79,5 @@ inline std::shared_ptr DynamicObjectCast(std::shared_ptr } } // namespace Kernel + +BOOST_CLASS_EXPORT_KEY(Kernel::WaitObject) diff --git a/src/core/hle/mii.cpp b/src/core/hle/mii.cpp index 09d4f2f47..8862b491a 100644 --- a/src/core/hle/mii.cpp +++ b/src/core/hle/mii.cpp @@ -3,9 +3,26 @@ // Refer to the license.txt file included. #include +#include +#include "common/archives.h" #include "core/hle/mii.h" +SERIALIZE_EXPORT_IMPL(Mii::MiiData) +SERIALIZE_EXPORT_IMPL(Mii::ChecksummedMiiData) + namespace Mii { +template +void MiiData::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::make_binary_object(this, sizeof(MiiData)); +} +SERIALIZE_IMPL(MiiData) + +template +void ChecksummedMiiData::serialize(Archive& ar, const unsigned int) { + ar& boost::serialization::make_binary_object(this, sizeof(ChecksummedMiiData)); +} +SERIALIZE_IMPL(ChecksummedMiiData) + u16 ChecksummedMiiData::CalculateChecksum() { // Calculate the checksum of the selected Mii, see https://www.3dbrew.org/wiki/Mii#Checksum return boost::crc<16, 0x1021, 0, 0, false, false>(this, offsetof(ChecksummedMiiData, crc16)); diff --git a/src/core/hle/mii.h b/src/core/hle/mii.h index b15fb141c..c7bc0e5ee 100644 --- a/src/core/hle/mii.h +++ b/src/core/hle/mii.h @@ -4,8 +4,7 @@ #pragma once -#include -#include +#include #include "common/bit_field.h" #include "common/common_types.h" @@ -178,9 +177,7 @@ struct MiiData { Nickname author_name; ///< Name of Mii's author (Encoded using UTF16) private: template - void serialize(Archive& ar, const unsigned int) { - ar& boost::serialization::make_binary_object(this, sizeof(MiiData)); - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; @@ -230,9 +227,7 @@ public: private: template - void serialize(Archive& ar, const unsigned int) { - ar& boost::serialization::make_binary_object(this, sizeof(ChecksummedMiiData)); - } + void serialize(Archive& ar, const unsigned int); friend class boost::serialization::access; }; #pragma pack(pop) @@ -242,3 +237,6 @@ static_assert(std::is_trivial_v, "ChecksummedMiiData must be static_assert(std::is_trivially_copyable_v, "ChecksummedMiiData must be trivially copyable."); } // namespace Mii + +BOOST_CLASS_EXPORT_KEY(Mii::MiiData) +BOOST_CLASS_EXPORT_KEY(Mii::ChecksummedMiiData) diff --git a/src/core/hle/service/soc/soc_u.h b/src/core/hle/service/soc/soc_u.h index d6e7ce6c3..2a7cfa8e8 100644 --- a/src/core/hle/service/soc/soc_u.h +++ b/src/core/hle/service/soc/soc_u.h @@ -6,6 +6,7 @@ #include #include +#include #include #include "core/hle/result.h" #include "core/hle/service/service.h"