Serialize kernel/hle/memory

This commit is contained in:
Hamish Milne 2019-12-22 18:35:03 +00:00 committed by zhupengfei
parent 050c3bdee5
commit 8c81500dee
4 changed files with 40 additions and 4 deletions

4
TODO
View file

@ -11,7 +11,7 @@
✔ HW @done(19-08-13 15:41) ✔ HW @done(19-08-13 15:41)
✔ GPU regs @done(19-08-13 15:41) ✔ GPU regs @done(19-08-13 15:41)
✔ LCD regs @done(19-08-13 15:41) ✔ LCD regs @done(19-08-13 15:41)
☐ Video core @started(19-08-13 16:43) ✔ Video core @started(19-08-13 16:43) @done(19-12-22 16:06)
✔ Geometry pipeline @done(19-12-22 15:52) ✔ Geometry pipeline @done(19-12-22 15:52)
Required more use of g_state Required more use of g_state
✔ PICA state @done(19-08-13 15:41) ✔ PICA state @done(19-08-13 15:41)
@ -28,7 +28,7 @@
✔ Handle table @done(19-08-13 16:42) ✔ Handle table @done(19-08-13 16:42)
☐ HLE IPC ☐ HLE IPC
☐ IPC ☐ IPC
☐ Memory @started(19-08-13 16:43) ✔ Memory @started(19-08-13 16:43) @done(19-12-22 18:34)
☐ Mutex @started(19-08-13 16:43) ☐ Mutex @started(19-08-13 16:43)
✔ Object @done(19-08-13 15:41) ✔ Object @done(19-08-13 15:41)
☐ Process @started(19-08-13 16:43) ☐ Process @started(19-08-13 16:43)

View file

@ -0,0 +1,33 @@
#pragma once
#include "common/common_types.h"
#include <boost/icl/discrete_interval.hpp>
namespace boost::serialization {
template <class Archive, class DomainT, ICL_COMPARE Compare>
void save(Archive& ar, const boost::icl::discrete_interval<DomainT, Compare>& obj, const unsigned int file_version)
{
ar << obj.lower();
ar << obj.upper();
ar << obj.bounds()._bits;
}
template <class Archive, class DomainT, ICL_COMPARE Compare>
void load(Archive& ar, boost::icl::discrete_interval<DomainT, Compare>& obj, const unsigned int file_version)
{
DomainT upper, lower;
boost::icl::bound_type bounds;
ar >> upper;
ar >> lower;
ar >> bounds;
obj = boost::icl::discrete_interval(upper, lower, boost::icl::interval_bounds(bounds));
}
template <class Archive, class DomainT, ICL_COMPARE Compare>
void serialize(Archive& ar, boost::icl::discrete_interval<DomainT, Compare>& obj, const unsigned int file_version)
{
boost::serialization::split_free(ar, obj, file_version);
}
}

View file

@ -108,6 +108,7 @@ void KernelSystem::AddNamedPort(std::string name, std::shared_ptr<ClientPort> po
template <class Archive> template <class Archive>
void KernelSystem::serialize(Archive& ar, const unsigned int file_version) void KernelSystem::serialize(Archive& ar, const unsigned int file_version)
{ {
ar & memory_regions;
ar & named_ports; ar & named_ports;
ar & *current_cpu.get(); ar & *current_cpu.get();
// NB: subsystem references and prepare_reschedule_callback are constant // NB: subsystem references and prepare_reschedule_callback are constant
@ -120,7 +121,6 @@ void KernelSystem::serialize(Archive& ar, const unsigned int file_version)
ar & *thread_manager.get(); ar & *thread_manager.get();
ar & *config_mem_handler.get(); ar & *config_mem_handler.get();
// Shared page data is read-only at the moment, so doesn't need serializing // Shared page data is read-only at the moment, so doesn't need serializing
//ar & *shared_page_handler.get();
} }
SERIALIZE_IMPL(KernelSystem) SERIALIZE_IMPL(KernelSystem)

View file

@ -6,6 +6,8 @@
#include <optional> #include <optional>
#include <boost/icl/interval_set.hpp> #include <boost/icl/interval_set.hpp>
#include <boost/serialization/set.hpp>
#include "common/serialization/boost_discrete_interval.hpp"
#include "common/common_types.h" #include "common/common_types.h"
namespace Kernel { namespace Kernel {
@ -69,7 +71,8 @@ private:
ar & base; ar & base;
ar & size; ar & size;
ar & used; ar & used;
// TODO: boost icl / free_blocks // This works because interval_set has exactly one member of type ImplSetT
ar & *(reinterpret_cast<IntervalSet::ImplSetT*>(&free_blocks));
} }
}; };