Serialize some more kernel objects

This commit is contained in:
Hamish Milne 2019-12-22 23:37:17 +00:00 committed by zhupengfei
parent 8c81500dee
commit 4f95575d41
15 changed files with 66 additions and 12 deletions

21
TODO
View File

@ -2,6 +2,10 @@
✔ CPU @done(19-08-13 15:41)
✔ Memory @done(19-08-13 15:41)
✔ DSP @done(19-08-13 15:41)
☐ Service manager
☐ App loader
☐ Archive manager
☐ Custom texture cache
☐ MMIO
☐ Movie
☐ Perf stats
@ -24,27 +28,32 @@
✔ Client port @done(19-08-13 16:40)
✔ Client session @done(19-08-13 16:40)
✔ Config mem @done(19-08-13 16:40)
☐ Event
✔ Event @done(19-12-22 18:44)
✔ Handle table @done(19-08-13 16:42)
☐ HLE IPC
☐ IPC
✔ Memory @started(19-08-13 16:43) @done(19-12-22 18:34)
☐ Mutex @started(19-08-13 16:43)
✔ Mutex @done(19-08-13 16:43)
✔ Object @done(19-08-13 15:41)
☐ Process @started(19-08-13 16:43)
✔ Process @started(19-08-13 16:43) @done(19-12-22 18:41)
☐ Code set @started(19-12-22 18:41)
Needs a way to reference loaded images (so we don't serialize the entire ROM as well)
✔ Resource limit @done(19-08-13 16:43)
☐ Semaphore @started(19-08-13 16:44)
✔ Semaphore @done(19-08-13 16:44)
✔ Server port @done(19-08-13 16:44)
✔ Server session @done(19-08-13 16:44)
✔ Session @done(19-08-13 16:44)
☐ Shared memory
☐ Shared memory @started(19-12-22 21:20)
Need to figure out backing memory (a u8*)
✘ Shared page @started(19-08-13 16:44) @cancelled(19-12-22 11:19)
Not needed right now as shared_page is read-only and derived from other data
☐ SVC
✔ SVC @done(19-12-22 21:32)
Nothing to do - all data is constant
☐ Thread @started(19-08-13 16:45)
This requires refactoring wakeup_callback to be an object ref
✔ Timer @done(19-08-13 16:45)
☐ VM Manager @started(19-08-13 16:46)
Just need to figure out backing_mem (a u8*)
✔ Wait object @done(19-08-13 16:46)
☐ Service
☐ AC

View File

@ -1,5 +1,6 @@
#include "boost/archive/binary_iarchive.hpp"
#include "boost/archive/binary_oarchive.hpp"
#include "boost/serialization/export.hpp"
using iarchive = boost::archive::binary_iarchive;
using oarchive = boost::archive::binary_oarchive;

View File

@ -398,6 +398,8 @@ void System::Reset() {
template<class Archive>
void System::serialize(Archive & ar, const unsigned int file_version)
{
ar & *cpu_core.get();
//ar & *service_manager.get();
ar & GPU::g_regs;
ar & LCD::g_regs;
ar & dsp_core->GetDspMemory();

View File

@ -6,17 +6,20 @@
#include <map>
#include <vector>
#include "common/assert.h"
#include "common/archives.h"
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/thread.h"
SERIALIZE_EXPORT_IMPL(Kernel::Event)
namespace Kernel {
Event::Event(KernelSystem& kernel) : WaitObject(kernel) {}
Event::Event() : WaitObject() {}
Event::~Event() {}
std::shared_ptr<Event> KernelSystem::CreateEvent(ResetType reset_type, std::string name) {
auto evt{std::make_shared<Event>(*this)};
auto evt{std::make_shared<Event>()};
evt->signaled = false;
evt->reset_type = reset_type;

View File

@ -4,6 +4,7 @@
#pragma once
#include <boost/serialization/export.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/wait_object.h"
@ -12,7 +13,7 @@ namespace Kernel {
class Event final : public WaitObject {
public:
explicit Event(KernelSystem& kernel);
explicit Event();
~Event() override;
std::string GetTypeName() const override {
@ -62,3 +63,5 @@ private:
};
} // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::Event)

View File

@ -121,6 +121,7 @@ void KernelSystem::serialize(Archive& ar, const unsigned int file_version)
ar & *thread_manager.get();
ar & *config_mem_handler.get();
// Shared page data is read-only at the moment, so doesn't need serializing
// Deliberately don't include debugger info to allow debugging through loads
}
SERIALIZE_IMPL(KernelSystem)

View File

@ -4,6 +4,7 @@
#include <map>
#include <vector>
#include "common/archives.h"
#include "common/assert.h"
#include "core/core.h"
#include "core/hle/kernel/errors.h"
@ -12,6 +13,8 @@
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/thread.h"
SERIALIZE_EXPORT_IMPL(Kernel::Mutex)
namespace Kernel {
void ReleaseThreadMutexes(Thread* thread) {

View File

@ -6,6 +6,7 @@
#include <memory>
#include <string>
#include <boost/serialization/export.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/wait_object.h"
@ -78,3 +79,5 @@ private:
void ReleaseThreadMutexes(Thread* thread);
} // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::Mutex)

View File

@ -34,6 +34,7 @@ void Process::serialize(Archive& ar, const unsigned int file_version)
ar & flags.raw;
ar & kernel_version;
ar & ideal_processor;
ar & status;
ar & process_id;
ar & vm_manager;
ar & memory_used;

View File

@ -3,14 +3,17 @@
// Refer to the license.txt file included.
#include "common/assert.h"
#include "common/archives.h"
#include "core/hle/kernel/errors.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/semaphore.h"
#include "core/hle/kernel/thread.h"
SERIALIZE_EXPORT_IMPL(Kernel::Semaphore)
namespace Kernel {
Semaphore::Semaphore(KernelSystem& kernel) : WaitObject(kernel) {}
Semaphore::Semaphore() : WaitObject() {}
Semaphore::~Semaphore() {}
ResultVal<std::shared_ptr<Semaphore>> KernelSystem::CreateSemaphore(s32 initial_count,
@ -20,7 +23,7 @@ ResultVal<std::shared_ptr<Semaphore>> KernelSystem::CreateSemaphore(s32 initial_
if (initial_count > max_count)
return ERR_INVALID_COMBINATION_KERNEL;
auto semaphore{std::make_shared<Semaphore>(*this)};
auto semaphore{std::make_shared<Semaphore>()};
// When the semaphore is created, some slots are reserved for other threads,
// and the rest is reserved for the caller thread

View File

@ -6,6 +6,7 @@
#include <string>
#include <queue>
#include <boost/serialization/export.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/wait_object.h"
@ -15,7 +16,7 @@ namespace Kernel {
class Semaphore final : public WaitObject {
public:
explicit Semaphore(KernelSystem& kernel);
explicit Semaphore();
~Semaphore() override;
std::string GetTypeName() const override {
@ -57,3 +58,5 @@ private:
};
} // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::Semaphore)

View File

@ -6,6 +6,7 @@
#include <string>
#include <utility>
#include <boost/serialization/export.hpp>
#include "common/common_types.h"
#include "core/hle/kernel/object.h"
#include "core/hle/kernel/process.h"
@ -104,6 +105,21 @@ private:
friend class KernelSystem;
KernelSystem& kernel;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version)
{
ar & linear_heap_phys_offset;
// TODO: backing blocks u8* (this is always FCRAM I think)
ar & size;
ar & permissions;
ar & other_permissions;
ar & owner_process;
ar & base_address;
ar & name;
ar & *(reinterpret_cast<MemoryRegionInfo::IntervalSet::ImplSetT*>(&holding_memory));;
}
friend class boost::serialization::access;
};
} // namespace Kernel

View File

@ -25,6 +25,8 @@
#include "core/hle/result.h"
#include "core/memory.h"
SERIALIZE_EXPORT_IMPL(Kernel::Thread)
namespace Kernel {
template <class Archive>

View File

@ -12,6 +12,7 @@
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unordered_map.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/export.hpp>
#include "common/common_types.h"
#include "common/thread_queue_list.h"
#include "core/arm/arm_interface.h"
@ -337,3 +338,5 @@ std::shared_ptr<Thread> SetupMainThread(KernelSystem& kernel, u32 entry_point, u
std::shared_ptr<Process> owner_process);
} // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::Thread)

View File

@ -94,6 +94,7 @@ private:
ar & permissions;
ar & meminfo_state;
// TODO: backing memory ref
// backing memory can be: Physical/FCRAM pointer, config mem, shared page
ar & paddr;
ar & mmio_handler;
}