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

@ -5,8 +5,11 @@
#include <algorithm>
#include <memory>
#include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/bitset.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/vector.hpp>
#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 <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& 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<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() {}
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) {
auto process{std::make_shared<Process>(*this)};