Added core serialization

This commit is contained in:
Hamish Milne 2019-08-07 02:53:56 +01:00 committed by zhupengfei
parent dc04774ece
commit ee2cae2093
5 changed files with 47 additions and 9 deletions

View file

@ -6,6 +6,7 @@
#include <memory>
#include <vector>
#include "boost/serialization/array.hpp"
#include "audio_core/audio_types.h"
#include "audio_core/time_stretch.h"
#include "common/common_types.h"

View file

@ -4,9 +4,12 @@
#include <memory>
#include <utility>
#include "boost/serialization/array.hpp"
#include "boost/serialization/unique_ptr.hpp"
#include "audio_core/dsp_interface.h"
#include "audio_core/hle/hle.h"
#include "audio_core/lle/lle.h"
#include "common/archives.h"
#include "common/logging/log.h"
#include "common/texture.h"
#include "core/arm/arm_interface.h"
@ -30,7 +33,9 @@
#include "core/hle/service/fs/archive.h"
#include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"
#include "core/hw/gpu.h"
#include "core/hw/hw.h"
#include "core/hw/lcd.h"
#include "core/loader/loader.h"
#include "core/movie.h"
#include "core/rpc/rpc_server.h"
@ -389,4 +394,25 @@ void System::Reset() {
Load(*m_emu_window, m_filepath);
}
template<class Archive>
void System::serialize(Archive & ar, const unsigned int file_version)
{
ar & memory;
ar & GPU::g_regs;
ar & LCD::g_regs;
ar & dsp_core->GetDspMemory();
}
void System::Save(std::ostream &stream) const
{
boost::archive::binary_oarchive oa{stream};
oa & *this;
}
void System::Load(std::istream &stream)
{
boost::archive::binary_iarchive ia{stream};
ia & *this;
}
} // namespace Core

View file

@ -6,6 +6,7 @@
#include <memory>
#include <string>
#include "boost/serialization/access.hpp"
#include "common/common_types.h"
#include "core/custom_tex_cache.h"
#include "core/frontend/applets/mii_selector.h"
@ -15,7 +16,6 @@
#include "core/memory.h"
#include "core/perf_stats.h"
#include "core/telemetry_session.h"
class boost::serialization::access;
class ARM_Interface;
@ -272,6 +272,10 @@ public:
return registered_image_interface;
}
void Save(std::ostream &stream) const;
void Load(std::istream &stream);
private:
/**
* Initialize the emulated system.
@ -342,11 +346,7 @@ private:
friend class boost::serialization::access;
template<typename Archive>
void serialize(Archive & ar, const unsigned int file_version)
{
ar & GPU::g_regs;
ar & LCD::g_regs;
}
void serialize(Archive & ar, const unsigned int file_version);
};
inline ARM_Interface& CPU() {

View file

@ -6,6 +6,7 @@
#include <cstring>
#include "boost/serialization/array.hpp"
#include "boost/serialization/nvp.hpp"
#include "boost/serialization/unique_ptr.hpp"
#include "audio_core/dsp_interface.h"
#include "common/archives.h"
#include "common/assert.h"
@ -107,11 +108,17 @@ private:
}
};
SERIALIZE_IMPL(MemorySystem::Impl)
MemorySystem::MemorySystem() : impl(std::make_unique<Impl>()) {}
MemorySystem::~MemorySystem() = default;
template<class Archive>
void MemorySystem::serialize(Archive & ar, const unsigned int file_version)
{
ar & impl;
}
SERIALIZE_IMPL(MemorySystem)
void MemorySystem::SetCurrentPageTable(PageTable* page_table) {
impl->current_page_table = page_table;
}

View file

@ -9,7 +9,7 @@
#include <memory>
#include <string>
#include <vector>
#include "boost/serialization/split_member.hpp"
#include "boost/serialization/access.hpp"
#include "common/common_types.h"
#include "core/mmio.h"
@ -324,6 +324,10 @@ private:
class Impl;
std::unique_ptr<Impl> impl;
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int file_version);
};
/// Determines if the given VAddr is valid for the specified process.