kernel: Move serialization code out of headers. (#7312)

This commit is contained in:
Steveice10 2024-01-14 16:18:31 -08:00 committed by GitHub
parent 9c84721d84
commit a2d1c4a94c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 458 additions and 270 deletions

View File

@ -6,7 +6,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/serialization/version.hpp>
#include "core/hle/applets/mii_selector.h" #include "core/hle/applets/mii_selector.h"
namespace Frontend { namespace Frontend {

View File

@ -3,6 +3,10 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -13,6 +17,9 @@
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/memory.h" #include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter)
SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter::Callback)
namespace Kernel { namespace Kernel {
void AddressArbiter::WaitThread(std::shared_ptr<Thread> thread, VAddr wait_address) { void AddressArbiter::WaitThread(std::shared_ptr<Thread> thread, VAddr wait_address) {
@ -183,6 +190,16 @@ Result AddressArbiter::ArbitrateAddress(std::shared_ptr<Thread> thread, Arbitrat
return ResultSuccess; return ResultSuccess;
} }
template <class Archive>
void AddressArbiter::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this);
ar& name;
ar& waiting_threads;
ar& timeout_callback;
ar& resource_limit;
}
SERIALIZE_IMPL(AddressArbiter)
} // namespace Kernel } // namespace Kernel
namespace boost::serialization { namespace boost::serialization {
@ -201,6 +218,3 @@ void load_construct_data(Archive& ar, Kernel::AddressArbiter::Callback* t, const
} }
} // namespace boost::serialization } // namespace boost::serialization
SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter)
SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter::Callback)

View File

@ -6,12 +6,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/version.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
@ -83,18 +78,11 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<Object>(*this);
ar& name;
ar& waiting_threads;
ar& timeout_callback;
ar& resource_limit;
}
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter) BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter)
BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter::Callback) BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter::Callback)
BOOST_CLASS_VERSION(Kernel::AddressArbiter, 2)
CONSTRUCT_KERNEL_OBJECT(Kernel::AddressArbiter) CONSTRUCT_KERNEL_OBJECT(Kernel::AddressArbiter)

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "core/global.h" #include "core/global.h"
@ -48,4 +50,14 @@ void ClientPort::ConnectionClosed() {
--active_sessions; --active_sessions;
} }
template <class Archive>
void ClientPort::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this);
ar& server_port;
ar& max_sessions;
ar& active_sessions;
ar& name;
}
SERIALIZE_IMPL(ClientPort)
} // namespace Kernel } // namespace Kernel

View File

@ -7,8 +7,6 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/kernel/server_port.h" #include "core/hle/kernel/server_port.h"
@ -66,13 +64,7 @@ private:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<Object>(*this);
ar& server_port;
ar& max_sessions;
ar& active_sessions;
ar& name;
}
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -2,6 +2,9 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "core/hle/kernel/client_session.h" #include "core/hle/kernel/client_session.h"
@ -53,4 +56,12 @@ Result ClientSession::SendSyncRequest(std::shared_ptr<Thread> thread) {
return server->HandleSyncRequest(std::move(thread)); return server->HandleSyncRequest(std::move(thread));
} }
template <class Archive>
void ClientSession::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this);
ar& name;
ar& parent;
}
SERIALIZE_IMPL(ClientSession)
} // namespace Kernel } // namespace Kernel

View File

@ -6,10 +6,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/result.h" #include "core/hle/result.h"
@ -54,11 +51,7 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<Object>(*this);
ar& name;
ar& parent;
}
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <cstring> #include <cstring>
#include <boost/serialization/binary_object.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "core/hle/kernel/config_mem.h" #include "core/hle/kernel/config_mem.h"
@ -31,4 +32,11 @@ ConfigMemDef& Handler::GetConfigMem() {
return config_mem; return config_mem;
} }
template <class Archive>
void Handler::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<BackingMem>(*this);
ar& boost::serialization::make_binary_object(&config_mem, sizeof(config_mem));
}
SERIALIZE_IMPL(Handler)
} // namespace ConfigMem } // namespace ConfigMem

View File

@ -9,7 +9,6 @@
// bootrom. Because we're not emulating this, and essentially just "stubbing" the functionality, I'm // bootrom. Because we're not emulating this, and essentially just "stubbing" the functionality, I'm
// putting this as a subset of HLE for now. // putting this as a subset of HLE for now.
#include <boost/serialization/binary_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include "common/common_funcs.h" #include "common/common_funcs.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -72,10 +71,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<BackingMem>(*this);
ar& boost::serialization::make_binary_object(&config_mem, sizeof(config_mem));
}
}; };
} // namespace ConfigMem } // namespace ConfigMem

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/string.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "core/hle/kernel/event.h" #include "core/hle/kernel/event.h"
@ -58,4 +60,14 @@ void Event::WakeupAllWaitingThreads() {
} }
} }
template <class Archive>
void Event::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<WaitObject>(*this);
ar& reset_type;
ar& signaled;
ar& name;
ar& resource_limit;
}
SERIALIZE_IMPL(Event)
} // namespace Kernel } // namespace Kernel

View File

@ -4,9 +4,7 @@
#pragma once #pragma once
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/string.hpp>
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/kernel/resource_limit.h" #include "core/hle/kernel/resource_limit.h"
#include "core/hle/kernel/wait_object.h" #include "core/hle/kernel/wait_object.h"
@ -57,13 +55,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<WaitObject>(*this);
ar& reset_type;
ar& signaled;
ar& name;
ar& resource_limit;
}
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -3,6 +3,9 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <utility> #include <utility>
#include <boost/serialization/array.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/kernel/errors.h" #include "core/hle/kernel/errors.h"
@ -10,6 +13,8 @@
#include "core/hle/kernel/process.h" #include "core/hle/kernel/process.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
SERIALIZE_EXPORT_IMPL(Kernel::HandleTable)
namespace Kernel { namespace Kernel {
namespace { namespace {
constexpr u16 GetSlot(Handle handle) { constexpr u16 GetSlot(Handle handle) {
@ -94,4 +99,13 @@ void HandleTable::Clear() {
next_free_slot = 0; next_free_slot = 0;
} }
template <class Archive>
void HandleTable::serialize(Archive& ar, const unsigned int) {
ar& objects;
ar& generations;
ar& next_generation;
ar& next_free_slot;
}
SERIALIZE_IMPL(HandleTable)
} // namespace Kernel } // namespace Kernel

View File

@ -7,8 +7,7 @@
#include <array> #include <array>
#include <cstddef> #include <cstddef>
#include <memory> #include <memory>
#include <boost/serialization/array.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/result.h" #include "core/hle/result.h"
@ -121,12 +120,10 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& objects;
ar& generations;
ar& next_generation;
ar& next_free_slot;
}
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::HandleTable)
CONSTRUCT_KERNEL_OBJECT(Kernel::HandleTable)

View File

@ -4,6 +4,10 @@
#include <algorithm> #include <algorithm>
#include <vector> #include <vector>
#include <boost/serialization/assume_abstract.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -15,6 +19,12 @@
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/process.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 { namespace Kernel {
class HLERequestContext::ThreadCallback : public Kernel::WakeupCallback { class HLERequestContext::ThreadCallback : public Kernel::WakeupCallback {
@ -77,6 +87,23 @@ void SessionRequestHandler::ClientDisconnected(std::shared_ptr<ServerSession> se
connected_sessions.end()); connected_sessions.end());
} }
template <class Archive>
void SessionRequestHandler::serialize(Archive& ar, const unsigned int) {
ar& connected_sessions;
}
SERIALIZE_IMPL(SessionRequestHandler)
template <class Archive>
void SessionRequestHandler::SessionDataBase::serialize(Archive& ar, const unsigned int) {}
SERIALIZE_IMPL(SessionRequestHandler::SessionDataBase)
template <class Archive>
void SessionRequestHandler::SessionInfo::serialize(Archive& ar, const unsigned int) {
ar& session;
ar& data;
}
SERIALIZE_IMPL(SessionRequestHandler::SessionInfo)
std::shared_ptr<Event> HLERequestContext::SleepClientThread( std::shared_ptr<Event> HLERequestContext::SleepClientThread(
const std::string& reason, std::chrono::nanoseconds timeout, const std::string& reason, std::chrono::nanoseconds timeout,
std::shared_ptr<WakeupCallback> callback) { std::shared_ptr<WakeupCallback> callback) {
@ -295,6 +322,17 @@ void HLERequestContext::ReportUnimplemented() const {
} }
} }
template <class Archive>
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<Core::System>().Memory()) {} MappedBuffer::MappedBuffer() : memory(&Core::Global<Core::System>().Memory()) {}
MappedBuffer::MappedBuffer(Memory::MemorySystem& memory, std::shared_ptr<Process> process, MappedBuffer::MappedBuffer(Memory::MemorySystem& memory, std::shared_ptr<Process> process,
@ -318,5 +356,3 @@ void MappedBuffer::Write(const void* src_buffer, std::size_t offset, std::size_t
} }
} // namespace Kernel } // namespace Kernel
SERIALIZE_EXPORT_IMPL(Kernel::HLERequestContext::ThreadCallback)

View File

@ -12,10 +12,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/container/small_vector.hpp> #include <boost/container/small_vector.hpp>
#include <boost/serialization/assume_abstract.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/serialization/boost_small_vector.hpp" #include "common/serialization/boost_small_vector.hpp"
#include "common/swap.h" #include "common/swap.h"
@ -77,7 +74,20 @@ public:
private: private:
template <class Archive> template <class Archive>
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<ServerSession> session, std::unique_ptr<SessionDataBase> data);
std::shared_ptr<ServerSession> session;
std::unique_ptr<SessionDataBase> data;
private:
SessionInfo() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
@ -96,30 +106,13 @@ protected:
return static_cast<T*>(itr->data.get()); return static_cast<T*>(itr->data.get());
} }
struct SessionInfo {
SessionInfo(std::shared_ptr<ServerSession> session, std::unique_ptr<SessionDataBase> data);
std::shared_ptr<ServerSession> session;
std::unique_ptr<SessionDataBase> data;
private:
SessionInfo() = default;
template <class Archive>
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 /// 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. /// is an HLE implementation is kept alive by this list for the duration of the connection.
std::vector<SessionInfo> connected_sessions; std::vector<SessionInfo> connected_sessions;
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& connected_sessions;
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
@ -388,17 +381,14 @@ private:
HLERequestContext(); HLERequestContext();
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int);
ar& cmd_buf;
ar& session;
ar& thread;
ar& request_handles;
ar& static_buffers;
ar& request_mapped_buffers;
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
} // namespace Kernel } // 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) BOOST_CLASS_EXPORT_KEY(Kernel::HLERequestContext::ThreadCallback)

View File

@ -3,7 +3,9 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include <boost/serialization/shared_ptr.hpp>
#include "common/alignment.h" #include "common/alignment.h"
#include "common/archives.h"
#include "common/memory_ref.h" #include "common/memory_ref.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
@ -16,6 +18,8 @@
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/memory.h" #include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::MappedBufferContext)
namespace Kernel { namespace Kernel {
Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory, Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem& memory,
@ -250,4 +254,15 @@ Result TranslateCommandBuffer(Kernel::KernelSystem& kernel, Memory::MemorySystem
return ResultSuccess; return ResultSuccess;
} }
template <class Archive>
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 } // namespace Kernel

View File

@ -6,7 +6,7 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/export.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/ipc.h" #include "core/hle/ipc.h"
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
@ -29,13 +29,7 @@ struct MappedBufferContext {
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& permissions;
ar& size;
ar& source_address;
ar& target_address;
ar& buffer;
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
@ -46,3 +40,5 @@ Result TranslateCommandBuffer(KernelSystem& system, Memory::MemorySystem& memory
VAddr dst_address, VAddr dst_address,
std::vector<MappedBufferContext>& mapped_buffer_context, bool reply); std::vector<MappedBufferContext>& mapped_buffer_context, bool reply);
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::MappedBufferContext)

View File

@ -19,6 +19,8 @@
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/hle/kernel/timer.h" #include "core/hle/kernel/timer.h"
SERIALIZE_EXPORT_IMPL(Kernel::New3dsHwCapabilities)
namespace Kernel { namespace Kernel {
/// Initialize the kernel /// Initialize the kernel
@ -162,7 +164,7 @@ void KernelSystem::ResetThreadIDs() {
} }
template <class Archive> template <class Archive>
void KernelSystem::serialize(Archive& ar, const unsigned int file_version) { void KernelSystem::serialize(Archive& ar, const unsigned int) {
ar& memory_regions; ar& memory_regions;
ar& named_ports; ar& named_ports;
// current_cpu set externally // current_cpu set externally
@ -195,7 +197,14 @@ void KernelSystem::serialize(Archive& ar, const unsigned int file_version) {
} }
} }
} }
SERIALIZE_IMPL(KernelSystem) SERIALIZE_IMPL(KernelSystem)
template <class Archive>
void New3dsHwCapabilities::serialize(Archive& ar, const unsigned int) {
ar& enable_l2_cache;
ar& enable_804MHz_cpu;
ar& memory_mode;
}
SERIALIZE_IMPL(New3dsHwCapabilities)
} // namespace Kernel } // namespace Kernel

View File

@ -13,6 +13,7 @@
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include <vector> #include <vector>
#include <boost/serialization/export.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/memory.h" #include "core/hle/kernel/memory.h"
#include "core/hle/result.h" #include "core/hle/result.h"
@ -124,11 +125,7 @@ struct New3dsHwCapabilities {
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int);
ar& enable_l2_cache;
ar& enable_804MHz_cpu;
ar& memory_mode;
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
@ -407,7 +404,9 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int);
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::New3dsHwCapabilities)

View File

@ -6,6 +6,8 @@
#include <memory> #include <memory>
#include <utility> #include <utility>
#include <vector> #include <vector>
#include <boost/serialization/set.hpp>
#include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -19,6 +21,8 @@
#include "core/hle/result.h" #include "core/hle/result.h"
#include "core/memory.h" #include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::MemoryRegionInfo)
namespace Kernel { namespace Kernel {
/// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system /// Size of the APPLICATION, SYSTEM and BASE memory regions (respectively) for each system
@ -267,4 +271,16 @@ void MemoryRegionInfo::Unlock() {
is_locked = false; is_locked = false;
} }
template <class Archive>
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 } // namespace Kernel

View File

@ -6,7 +6,7 @@
#include <optional> #include <optional>
#include <boost/icl/interval_set.hpp> #include <boost/icl/interval_set.hpp>
#include <boost/serialization/set.hpp> #include <boost/serialization/export.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/serialization/boost_interval_set.hpp" #include "common/serialization/boost_interval_set.hpp"
@ -83,15 +83,9 @@ struct MemoryRegionInfo {
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& base;
ar& size;
ar& used;
ar& free_blocks;
if (Archive::is_loading::value) {
is_locked = true;
}
}
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::MemoryRegionInfo)

View File

@ -2,6 +2,9 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "core/core.h" #include "core/core.h"
@ -127,4 +130,15 @@ void Mutex::UpdatePriority() {
} }
} }
template <class Archive>
void Mutex::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<WaitObject>(*this);
ar& lock_count;
ar& priority;
ar& name;
ar& holding_thread;
ar& resource_limit;
}
SERIALIZE_IMPL(Mutex)
} // namespace Kernel } // namespace Kernel

View File

@ -6,10 +6,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/resource_limit.h" #include "core/hle/kernel/resource_limit.h"
@ -67,14 +64,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<WaitObject>(*this);
ar& lock_count;
ar& priority;
ar& name;
ar& holding_thread;
ar& resource_limit;
}
}; };
/** /**

View File

@ -6,6 +6,10 @@
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "common/archives.h"
SERIALIZE_EXPORT_IMPL(Kernel::Object)
namespace Kernel { namespace Kernel {
Object::Object(KernelSystem& kernel) : object_id{kernel.GenerateObjectID()} {} Object::Object(KernelSystem& kernel) : object_id{kernel.GenerateObjectID()} {}
@ -37,4 +41,10 @@ bool Object::IsWaitable() const {
UNREACHABLE(); UNREACHABLE();
} }
template <class Archive>
void Object::serialize(Archive& ar, const unsigned int) {
ar& object_id;
}
SERIALIZE_IMPL(Object)
} // namespace Kernel } // namespace Kernel

View File

@ -7,8 +7,6 @@
#include <atomic> #include <atomic>
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/serialization/access.hpp>
#include <boost/serialization/assume_abstract.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/serialization/atomic.h" #include "common/serialization/atomic.h"
@ -72,9 +70,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& object_id;
}
}; };
template <typename T> template <typename T>
@ -99,7 +95,7 @@ inline std::shared_ptr<T> DynamicObjectCast(std::shared_ptr<Object> object) {
} // namespace Kernel } // namespace Kernel
BOOST_SERIALIZATION_ASSUME_ABSTRACT(Kernel::Object) BOOST_CLASS_EXPORT_KEY(Kernel::Object)
#define CONSTRUCT_KERNEL_OBJECT(T) \ #define CONSTRUCT_KERNEL_OBJECT(T) \
namespace boost::serialization { \ namespace boost::serialization { \

View File

@ -5,8 +5,11 @@
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <boost/serialization/array.hpp> #include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/bitset.hpp> #include <boost/serialization/bitset.hpp>
#include <boost/serialization/shared_ptr.hpp> #include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
@ -23,13 +26,24 @@
#include "core/loader/loader.h" #include "core/loader/loader.h"
#include "core/memory.h" #include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::AddressMapping)
SERIALIZE_EXPORT_IMPL(Kernel::Process) SERIALIZE_EXPORT_IMPL(Kernel::Process)
SERIALIZE_EXPORT_IMPL(Kernel::CodeSet) SERIALIZE_EXPORT_IMPL(Kernel::CodeSet)
SERIALIZE_EXPORT_IMPL(Kernel::CodeSet::Segment)
namespace Kernel { namespace Kernel {
template <class Archive> template <class Archive>
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 <class Archive>
void Process::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this); ar& boost::serialization::base_object<Object>(*this);
ar& handle_table; ar& handle_table;
ar& codeset; // TODO: Replace with apploader reference 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& holding_tls_memory;
ar& tls_slots; ar& tls_slots;
} }
SERIALIZE_IMPL(Process) SERIALIZE_IMPL(Process)
std::shared_ptr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 program_id) { std::shared_ptr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 program_id) {
@ -67,6 +80,25 @@ std::shared_ptr<CodeSet> KernelSystem::CreateCodeSet(std::string name, u64 progr
CodeSet::CodeSet(KernelSystem& kernel) : Object(kernel) {} CodeSet::CodeSet(KernelSystem& kernel) : Object(kernel) {}
CodeSet::~CodeSet() {} CodeSet::~CodeSet() {}
template <class Archive>
void CodeSet::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this);
ar& memory;
ar& segments;
ar& entrypoint;
ar& name;
ar& program_id;
}
SERIALIZE_IMPL(CodeSet)
template <class Archive>
void CodeSet::Segment::serialize(Archive& ar, const unsigned int) {
ar& offset;
ar& addr;
ar& size;
}
SERIALIZE_IMPL(CodeSet::Segment)
std::shared_ptr<Process> KernelSystem::CreateProcess(std::shared_ptr<CodeSet> code_set) { std::shared_ptr<Process> KernelSystem::CreateProcess(std::shared_ptr<CodeSet> code_set) {
auto process{std::make_shared<Process>(*this)}; auto process{std::make_shared<Process>(*this)};

View File

@ -11,10 +11,7 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include <boost/container/static_vector.hpp> #include <boost/container/static_vector.hpp>
#include <boost/serialization/array.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/handle_table.h" #include "core/hle/kernel/handle_table.h"
@ -33,12 +30,7 @@ struct AddressMapping {
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& address;
ar& size;
ar& read_only;
ar& unk_flag;
}
}; };
union ProcessFlags { union ProcessFlags {
@ -77,11 +69,7 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& offset;
ar& addr;
ar& size;
}
}; };
std::string GetTypeName() const override { std::string GetTypeName() const override {
@ -133,14 +121,7 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<Object>(*this);
ar& memory;
ar& segments;
ar& entrypoint;
ar& name;
ar& program_id;
}
}; };
class Process final : public Object { class Process final : public Object {
@ -257,7 +238,9 @@ private:
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::AddressMapping)
BOOST_CLASS_EXPORT_KEY(Kernel::CodeSet) BOOST_CLASS_EXPORT_KEY(Kernel::CodeSet)
BOOST_CLASS_EXPORT_KEY(Kernel::CodeSet::Segment)
BOOST_CLASS_EXPORT_KEY(Kernel::Process) BOOST_CLASS_EXPORT_KEY(Kernel::Process)
CONSTRUCT_KERNEL_OBJECT(Kernel::CodeSet) CONSTRUCT_KERNEL_OBJECT(Kernel::CodeSet)
CONSTRUCT_KERNEL_OBJECT(Kernel::Process) CONSTRUCT_KERNEL_OBJECT(Kernel::Process)

View File

@ -2,12 +2,17 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/settings.h" #include "common/settings.h"
#include "core/hle/kernel/resource_limit.h" #include "core/hle/kernel/resource_limit.h"
SERIALIZE_EXPORT_IMPL(Kernel::ResourceLimit) SERIALIZE_EXPORT_IMPL(Kernel::ResourceLimit)
SERIALIZE_EXPORT_IMPL(Kernel::ResourceLimitList)
namespace Kernel { namespace Kernel {
@ -61,6 +66,15 @@ bool ResourceLimit::Release(ResourceLimitType type, s32 amount) {
return true; return true;
} }
template <class Archive>
void ResourceLimit::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this);
ar& m_name;
ar& m_limit_values;
ar& m_current_values;
}
SERIALIZE_IMPL(ResourceLimit)
ResourceLimitList::ResourceLimitList(KernelSystem& kernel) { ResourceLimitList::ResourceLimitList(KernelSystem& kernel) {
// PM makes APPMEMALLOC always match app RESLIMIT_COMMIT. // PM makes APPMEMALLOC always match app RESLIMIT_COMMIT.
// See: https://github.com/LumaTeam/Luma3DS/blob/e2778a45/sysmodules/pm/source/reslimit.c#L275 // See: https://github.com/LumaTeam/Luma3DS/blob/e2778a45/sysmodules/pm/source/reslimit.c#L275
@ -138,4 +152,10 @@ std::shared_ptr<ResourceLimit> ResourceLimitList::GetForCategory(ResourceLimitCa
} }
} }
template <class Archive>
void ResourceLimitList::serialize(Archive& ar, const unsigned int) {
ar& resource_limits;
}
SERIALIZE_IMPL(ResourceLimitList)
} // namespace Kernel } // namespace Kernel

View File

@ -6,10 +6,7 @@
#include <array> #include <array>
#include <memory> #include <memory>
#include <boost/serialization/array.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
@ -76,12 +73,7 @@ private:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<Object>(*this);
ar& m_name;
ar& m_limit_values;
ar& m_current_values;
}
}; };
class ResourceLimitList { class ResourceLimitList {
@ -101,12 +93,12 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& resource_limits;
}
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::ResourceLimit) BOOST_CLASS_EXPORT_KEY(Kernel::ResourceLimit)
BOOST_CLASS_EXPORT_KEY(Kernel::ResourceLimitList)
CONSTRUCT_KERNEL_OBJECT(Kernel::ResourceLimit) CONSTRUCT_KERNEL_OBJECT(Kernel::ResourceLimit)
CONSTRUCT_KERNEL_OBJECT(Kernel::ResourceLimitList)

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/string.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "core/hle/kernel/errors.h" #include "core/hle/kernel/errors.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"
@ -58,4 +60,14 @@ Result Semaphore::Release(s32* out_count, s32 release_count) {
return ResultSuccess; return ResultSuccess;
} }
template <class Archive>
void Semaphore::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<WaitObject>(*this);
ar& max_count;
ar& available_count;
ar& name;
ar& resource_limit;
}
SERIALIZE_IMPL(Semaphore)
} // namespace Kernel } // namespace Kernel

View File

@ -5,9 +5,7 @@
#pragma once #pragma once
#include <string> #include <string>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/string.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/kernel/wait_object.h" #include "core/hle/kernel/wait_object.h"
@ -52,13 +50,7 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<WaitObject>(*this);
ar& max_count;
ar& available_count;
ar& name;
ar& resource_limit;
}
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -55,7 +55,7 @@ KernelSystem::PortPair KernelSystem::CreatePortPair(u32 max_sessions, std::strin
} }
template <class Archive> template <class Archive>
void ServerPort::serialize(Archive& ar, const unsigned int file_version) { void ServerPort::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<WaitObject>(*this); ar& boost::serialization::base_object<WaitObject>(*this);
ar& name; ar& name;
ar& pending_sessions; ar& pending_sessions;

View File

@ -66,7 +66,7 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int);
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -19,7 +19,7 @@ SERIALIZE_EXPORT_IMPL(Kernel::ServerSession)
namespace Kernel { namespace Kernel {
template <class Archive> template <class Archive>
void ServerSession::serialize(Archive& ar, const unsigned int file_version) { void ServerSession::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<WaitObject>(*this); ar& boost::serialization::base_object<WaitObject>(*this);
ar& name; ar& name;
ar& parent; ar& parent;

View File

@ -108,7 +108,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int);
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -9,7 +9,7 @@
#include "core/hle/kernel/server_session.h" #include "core/hle/kernel/server_session.h"
#include "core/hle/kernel/session.h" #include "core/hle/kernel/session.h"
SERIALIZE_IMPL(Kernel::Session) SERIALIZE_EXPORT_IMPL(Kernel::Session)
namespace Kernel { namespace Kernel {
@ -19,5 +19,6 @@ void Session::serialize(Archive& ar, const unsigned int file_version) {
ar& server; ar& server;
ar& port; ar& port;
} }
SERIALIZE_IMPL(Session)
} // namespace Kernel } // namespace Kernel

View File

@ -5,7 +5,7 @@
#pragma once #pragma once
#include <memory> #include <memory>
#include <boost/serialization/access.hpp> #include <boost/serialization/export.hpp>
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
namespace Kernel { namespace Kernel {
@ -29,6 +29,8 @@ public:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int);
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::Session)

View File

@ -2,6 +2,10 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/utility.hpp>
#include <boost/serialization/weak_ptr.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/kernel/errors.h" #include "core/hle/kernel/errors.h"
@ -217,4 +221,20 @@ const u8* SharedMemory::GetPointer(u32 offset) const {
return backing_blocks[0].first + offset; return backing_blocks[0].first + offset;
} }
template <class Archive>
void SharedMemory::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<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 } // namespace Kernel

View File

@ -6,10 +6,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/weak_ptr.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/memory_ref.h" #include "common/memory_ref.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
@ -113,19 +110,7 @@ private:
KernelSystem& kernel; KernelSystem& kernel;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<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;
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };

View File

@ -4,6 +4,8 @@
#include <chrono> #include <chrono>
#include <cstring> #include <cstring>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/binary_object.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/settings.h" #include "common/settings.h"
@ -172,4 +174,11 @@ SharedPageDef& Handler::GetSharedPage() {
return shared_page; return shared_page;
} }
template <class Archive>
void Handler::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<BackingMem>(*this);
ar& boost::serialization::make_binary_object(&shared_page, sizeof(shared_page));
}
SERIALIZE_IMPL(Handler)
} // namespace SharedPage } // namespace SharedPage

View File

@ -13,8 +13,6 @@
#include <chrono> #include <chrono>
#include <ctime> #include <ctime>
#include <memory> #include <memory>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/binary_object.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_funcs.h" #include "common/common_funcs.h"
@ -141,10 +139,7 @@ private:
SharedPageDef shared_page; SharedPageDef shared_page;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<BackingMem>(*this);
ar& boost::serialization::make_binary_object(&shared_page, sizeof(shared_page));
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };

View File

@ -5,6 +5,9 @@
#include <algorithm> #include <algorithm>
#include <climits> #include <climits>
#include <boost/serialization/string.hpp> #include <boost/serialization/string.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/weak_ptr.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -24,9 +27,19 @@
#include "core/memory.h" #include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::Thread) SERIALIZE_EXPORT_IMPL(Kernel::Thread)
SERIALIZE_EXPORT_IMPL(Kernel::WakeupCallback)
namespace Kernel { namespace Kernel {
template <class Archive>
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 <class Archive> template <class Archive>
void Thread::serialize(Archive& ar, const unsigned int file_version) { void Thread::serialize(Archive& ar, const unsigned int file_version) {
ar& boost::serialization::base_object<WaitObject>(*this); ar& boost::serialization::base_object<WaitObject>(*this);
@ -48,9 +61,12 @@ void Thread::serialize(Archive& ar, const unsigned int file_version) {
ar& name; ar& name;
ar& wakeup_callback; ar& wakeup_callback;
} }
SERIALIZE_IMPL(Thread) SERIALIZE_IMPL(Thread)
template <class Archive>
void WakeupCallback::serialize(Archive& ar, const unsigned int) {}
SERIALIZE_IMPL(WakeupCallback)
bool Thread::ShouldWait(const Thread* thread) const { bool Thread::ShouldWait(const Thread* thread) const {
return status != ThreadStatus::Dead; return status != ThreadStatus::Dead;
} }

View File

@ -11,9 +11,6 @@
#include <vector> #include <vector>
#include <boost/container/flat_set.hpp> #include <boost/container/flat_set.hpp>
#include <boost/serialization/export.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/weak_ptr.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/thread_queue_list.h" #include "common/thread_queue_list.h"
#include "core/arm/arm_interface.h" #include "core/arm/arm_interface.h"
@ -72,7 +69,7 @@ public:
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) {} void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
@ -164,12 +161,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& current_thread;
ar& ready_queue;
ar& wakeup_callback_table;
ar& thread_list;
}
}; };
class Thread final : public WaitObject { class Thread final : public WaitObject {
@ -336,7 +328,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int);
}; };
/** /**
@ -353,17 +345,17 @@ std::shared_ptr<Thread> SetupMainThread(KernelSystem& kernel, u32 entry_point, u
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::Thread) BOOST_CLASS_EXPORT_KEY(Kernel::Thread)
BOOST_CLASS_EXPORT_KEY(Kernel::WakeupCallback)
namespace boost::serialization { namespace boost::serialization {
template <class Archive> template <class Archive>
inline void save_construct_data(Archive& ar, const Kernel::Thread* t, void save_construct_data(Archive& ar, const Kernel::Thread* t, const unsigned int) {
const unsigned int file_version) {
ar << t->core_id; ar << t->core_id;
} }
template <class Archive> template <class Archive>
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; u32 core_id;
ar >> core_id; ar >> core_id;
::new (t) Kernel::Thread(Core::Global<Kernel::KernelSystem>(), core_id); ::new (t) Kernel::Thread(Core::Global<Kernel::KernelSystem>(), core_id);

View File

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version // Licensed under GPLv2 or any later version
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/serialization/string.hpp>
#include <boost/serialization/unordered_map.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -97,6 +99,19 @@ void Timer::Signal(s64 cycles_late) {
} }
} }
template <class Archive>
void Timer::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<WaitObject>(*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 /// The timer callback event, called when a timer is fired
void TimerManager::TimerCallback(u64 callback_id, s64 cycles_late) { void TimerManager::TimerCallback(u64 callback_id, s64 cycles_late) {
std::shared_ptr<Timer> timer = SharedFrom(timer_callback_table.at(callback_id)); std::shared_ptr<Timer> timer = SharedFrom(timer_callback_table.at(callback_id));
@ -116,4 +131,11 @@ TimerManager::TimerManager(Core::Timing& timing) : timing(timing) {
}); });
} }
template <class Archive>
void TimerManager::serialize(Archive& ar, const unsigned int) {
ar& next_timer_callback_id;
ar& timer_callback_table;
}
SERIALIZE_IMPL(TimerManager)
} // namespace Kernel } // namespace Kernel

View File

@ -4,8 +4,7 @@
#pragma once #pragma once
#include <boost/serialization/string.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/unordered_map.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/core_timing.h" #include "core/core_timing.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
@ -38,10 +37,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& next_timer_callback_id;
ar& timer_callback_table;
}
}; };
class ResourceLimit; class ResourceLimit;
@ -119,16 +115,7 @@ private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::base_object<WaitObject>(*this);
ar& reset_type;
ar& initial_delay;
ar& interval_delay;
ar& signaled;
ar& name;
ar& callback_id;
ar& resource_limit;
}
}; };
} // namespace Kernel } // namespace Kernel

View File

@ -4,6 +4,10 @@
#include <algorithm> #include <algorithm>
#include <iterator> #include <iterator>
#include <boost/serialization/map.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/split_member.hpp>
#include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "core/core.h" #include "core/core.h"
#include "core/hle/kernel/errors.h" #include "core/hle/kernel/errors.h"
@ -11,6 +15,8 @@
#include "core/hle/service/plgldr/plgldr.h" #include "core/hle/service/plgldr/plgldr.h"
#include "core/memory.h" #include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::VirtualMemoryArea)
namespace Kernel { namespace Kernel {
static const char* GetMemoryStateName(MemoryState state) { static const char* GetMemoryStateName(MemoryState state) {
@ -35,6 +41,17 @@ bool VirtualMemoryArea::CanBeMergedWith(const VirtualMemoryArea& next) const {
return true; return true;
} }
template <class Archive>
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) VMManager::VMManager(Memory::MemorySystem& memory, Kernel::Process& proc)
: page_table(std::make_shared<Memory::PageTable>()), memory(memory), process(proc) { : page_table(std::make_shared<Memory::PageTable>()), memory(memory), process(proc) {
Reset(); Reset();
@ -379,4 +396,15 @@ ResultVal<std::vector<std::pair<MemoryRef, u32>>> VMManager::GetBackingBlocksFor
} }
return backing_blocks; return backing_blocks;
} }
template <class Archive>
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 } // namespace Kernel

View File

@ -6,9 +6,7 @@
#include <map> #include <map>
#include <memory> #include <memory>
#include <boost/serialization/map.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/split_member.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "common/memory_ref.h" #include "common/memory_ref.h"
#include "core/hle/kernel/memory.h" #include "core/hle/kernel/memory.h"
@ -79,14 +77,7 @@ struct VirtualMemoryArea {
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) { void serialize(Archive& ar, const unsigned int);
ar& base;
ar& size;
ar& type;
ar& permissions;
ar& meminfo_state;
ar& backing_memory;
}
}; };
/** /**
@ -238,13 +229,9 @@ private:
bool is_locked{}; bool is_locked{};
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int);
ar& vma_map;
ar& page_table;
if (Archive::is_loading::value) {
is_locked = true;
}
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::VirtualMemoryArea)

View File

@ -4,6 +4,9 @@
#include <algorithm> #include <algorithm>
#include <utility> #include <utility>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/archives.h" #include "common/archives.h"
#include "common/assert.h" #include "common/assert.h"
#include "common/logging/log.h" #include "common/logging/log.h"
@ -15,10 +18,12 @@
#include "core/hle/kernel/thread.h" #include "core/hle/kernel/thread.h"
#include "core/hle/kernel/timer.h" #include "core/hle/kernel/timer.h"
SERIALIZE_EXPORT_IMPL(Kernel::WaitObject)
namespace Kernel { namespace Kernel {
template <class Archive> template <class Archive>
void WaitObject::serialize(Archive& ar, const unsigned int file_version) { void WaitObject::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Object>(*this); ar& boost::serialization::base_object<Object>(*this);
ar& waiting_threads; ar& waiting_threads;
// NB: hle_notifier *not* serialized since it's a callback! // NB: hle_notifier *not* serialized since it's a callback!

View File

@ -7,9 +7,6 @@
#include <functional> #include <functional>
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
@ -69,7 +66,7 @@ private:
private: private:
friend class boost::serialization::access; friend class boost::serialization::access;
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int file_version); void serialize(Archive& ar, const unsigned int);
}; };
// Specialization of DynamicObjectCast for WaitObjects // Specialization of DynamicObjectCast for WaitObjects
@ -82,3 +79,5 @@ inline std::shared_ptr<WaitObject> DynamicObjectCast<WaitObject>(std::shared_ptr
} }
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::WaitObject)

View File

@ -3,9 +3,26 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <boost/crc.hpp> #include <boost/crc.hpp>
#include <boost/serialization/binary_object.hpp>
#include "common/archives.h"
#include "core/hle/mii.h" #include "core/hle/mii.h"
SERIALIZE_EXPORT_IMPL(Mii::MiiData)
SERIALIZE_EXPORT_IMPL(Mii::ChecksummedMiiData)
namespace Mii { namespace Mii {
template <class Archive>
void MiiData::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::make_binary_object(this, sizeof(MiiData));
}
SERIALIZE_IMPL(MiiData)
template <class Archive>
void ChecksummedMiiData::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::make_binary_object(this, sizeof(ChecksummedMiiData));
}
SERIALIZE_IMPL(ChecksummedMiiData)
u16 ChecksummedMiiData::CalculateChecksum() { u16 ChecksummedMiiData::CalculateChecksum() {
// Calculate the checksum of the selected Mii, see https://www.3dbrew.org/wiki/Mii#Checksum // 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)); return boost::crc<16, 0x1021, 0, 0, false, false>(this, offsetof(ChecksummedMiiData, crc16));

View File

@ -4,8 +4,7 @@
#pragma once #pragma once
#include <boost/serialization/base_object.hpp> #include <boost/serialization/export.hpp>
#include <boost/serialization/binary_object.hpp>
#include "common/bit_field.h" #include "common/bit_field.h"
#include "common/common_types.h" #include "common/common_types.h"
@ -178,9 +177,7 @@ struct MiiData {
Nickname author_name; ///< Name of Mii's author (Encoded using UTF16) Nickname author_name; ///< Name of Mii's author (Encoded using UTF16)
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::make_binary_object(this, sizeof(MiiData));
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
@ -230,9 +227,7 @@ public:
private: private:
template <class Archive> template <class Archive>
void serialize(Archive& ar, const unsigned int) { void serialize(Archive& ar, const unsigned int);
ar& boost::serialization::make_binary_object(this, sizeof(ChecksummedMiiData));
}
friend class boost::serialization::access; friend class boost::serialization::access;
}; };
#pragma pack(pop) #pragma pack(pop)
@ -242,3 +237,6 @@ static_assert(std::is_trivial_v<ChecksummedMiiData>, "ChecksummedMiiData must be
static_assert(std::is_trivially_copyable_v<ChecksummedMiiData>, static_assert(std::is_trivially_copyable_v<ChecksummedMiiData>,
"ChecksummedMiiData must be trivially copyable."); "ChecksummedMiiData must be trivially copyable.");
} // namespace Mii } // namespace Mii
BOOST_CLASS_EXPORT_KEY(Mii::MiiData)
BOOST_CLASS_EXPORT_KEY(Mii::ChecksummedMiiData)

View File

@ -6,6 +6,7 @@
#include <unordered_map> #include <unordered_map>
#include <utility> #include <utility>
#include <boost/serialization/set.hpp>
#include <boost/serialization/unordered_map.hpp> #include <boost/serialization/unordered_map.hpp>
#include "core/hle/result.h" #include "core/hle/result.h"
#include "core/hle/service/service.h" #include "core/hle/service/service.h"