More base-derived fixes

This commit is contained in:
Hamish Milne 2020-01-08 23:19:49 +00:00 committed by zhupengfei
parent 996aba39fe
commit 9525d81344
23 changed files with 75 additions and 3 deletions

5
TODO
View file

@ -7,6 +7,11 @@
☐ Review base class serialization everywhere
Make sure that all base/derived relationships are registered
☐ Serialize codeset with an apploader reference instead
☐ Additional stuff to serialize
☐ Self-NCCH archive
☐ File backends
☐ Directory backends
☐ File/directory 'services'
✔ CPU @done(19-08-13 15:41)
✔ Memory @done(19-08-13 15:41)
✔ Page tables @done(20-01-05 16:33)

View file

@ -60,6 +60,7 @@ private:
ArchiveFactory_ExtSaveData() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& shared;
ar& mount_point;
}

View file

@ -116,7 +116,9 @@ public:
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
}
friend class boost::serialization::access;
};

View file

@ -35,6 +35,7 @@ private:
ArchiveFactory_OtherSaveDataPermitted() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& sd_savedata_source;
}
friend class boost::serialization::access;
@ -62,6 +63,7 @@ private:
ArchiveFactory_OtherSaveDataGeneral() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& sd_savedata_source;
}
friend class boost::serialization::access;

View file

@ -34,6 +34,7 @@ private:
ArchiveFactory_SaveData() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& sd_savedata_source;
}
friend class boost::serialization::access;

View file

@ -81,6 +81,7 @@ private:
ArchiveFactory_SDMC() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& sdmc_directory;
}
friend class boost::serialization::access;

View file

@ -67,6 +67,7 @@ private:
ArchiveFactory_SDMCWriteOnly() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& sdmc_directory;
}
friend class boost::serialization::access;

View file

@ -47,6 +47,12 @@ private:
/// Mapping of ProgramId -> NCCHData
std::unordered_map<u64, NCCHData>
ncch_data; // TODO: Remove this, or actually set the values here
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
}
friend class boost::serialization::access;
};
} // namespace FileSys

View file

@ -37,6 +37,7 @@ private:
ArchiveFactory_SystemSaveData() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveFactory>(*this);
ar& base_path;
}
friend class boost::serialization::access;

View file

@ -357,4 +357,5 @@ u64 SaveDataArchive::GetFreeBytes() const {
} // namespace FileSys
SERIALIZE_EXPORT_IMPL(FileSys::SaveDataArchive)
SERIALIZE_EXPORT_IMPL(FileSys::SaveDataDelayGenerator)

View file

@ -38,10 +38,21 @@ public:
protected:
std::string mount_point;
private:
SaveDataArchive() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<ArchiveBackend>(*this);
ar& mount_point;
}
friend class boost::serialization::access;
};
class SaveDataDelayGenerator;
} // namespace FileSys
BOOST_CLASS_EXPORT_KEY(FileSys::SaveDataArchive)
BOOST_CLASS_EXPORT_KEY(FileSys::SaveDataDelayGenerator)

View file

@ -70,6 +70,7 @@ private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) {
ar& boost::serialization::base_object<BackingMem>(*this);
ar& boost::serialization::make_binary_object(&config_mem, sizeof(config_mem));
}
};

View file

@ -50,6 +50,7 @@ private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::WakeupCallback>(*this);
ar& callback;
ar& context;
}

View file

@ -222,6 +222,11 @@ public:
virtual ~WakeupCallback() = default;
virtual void WakeUp(std::shared_ptr<Thread> thread, HLERequestContext& context,
ThreadWakeupReason reason) = 0;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
friend class boost::serialization::access;
};
/**

View file

@ -111,7 +111,7 @@ private:
friend class boost::serialization::access;
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) {
ar& boost::serialization::base_object<Object>(*this);
ar& boost::serialization::base_object<WaitObject>(*this);
ar& name;
ar& parent;
ar& hle_handler;

View file

@ -109,6 +109,7 @@ private:
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) {
ar& boost::serialization::base_object<Object>(*this);
ar& linear_heap_phys_offset;
ar& backing_blocks;
ar& size;

View file

@ -117,6 +117,7 @@ private:
template <class Archive>
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;

View file

@ -434,6 +434,7 @@ private:
SVC_SyncCallback() = default;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::WakeupCallback>(*this);
ar& do_output;
}
friend class boost::serialization::access;
@ -466,7 +467,9 @@ private:
SVC_IPCCallback() : system(Core::Global<Core::System>()) {}
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::WakeupCallback>(*this);
}
friend class boost::serialization::access;
};

View file

@ -32,6 +32,7 @@ namespace Kernel {
template <class Archive>
void Thread::serialize(Archive& ar, const unsigned int file_version) {
ar& boost::serialization::base_object<Object>(*this);
ar&* context.get();
ar& thread_id;
ar& status;

View file

@ -66,6 +66,11 @@ public:
virtual ~WakeupCallback() = default;
virtual void WakeUp(ThreadWakeupReason reason, std::shared_ptr<Thread> thread,
std::shared_ptr<WaitObject> object) = 0;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {}
friend class boost::serialization::access;
};
class ThreadManager {

View file

@ -1189,6 +1189,7 @@ private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::HLERequestContext::WakeupCallback>(*this);
ar& command_id;
}
friend class boost::serialization::access;

View file

@ -3,6 +3,9 @@
// Refer to the license.txt file included.
#include <tuple>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/string.hpp>
#include <boost/serialization/unordered_map.hpp>
#include "common/archives.h"
#include "common/common_types.h"
#include "common/logging/log.h"
@ -21,8 +24,19 @@
#include "core/hle/service/sm/sm.h"
#include "core/hle/service/sm/srv.h"
SERVICE_CONSTRUCT_IMPL(Service::SM::SRV)
SERIALIZE_EXPORT_IMPL(Service::SM::SRV)
namespace Service::SM {
template <class Archive>
void SRV::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& notification_semaphore;
ar& get_service_handle_delayed_map;
}
SERIALIZE_IMPL(SRV)
constexpr int MAX_PENDING_NOTIFICATIONS = 16;
/**
@ -107,6 +121,7 @@ private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::HLERequestContext::WakeupCallback>(*this);
ar& name;
}
friend class boost::serialization::access;

View file

@ -40,8 +40,14 @@ private:
Core::System& system;
std::shared_ptr<Kernel::Semaphore> notification_semaphore;
std::unordered_map<std::string, std::shared_ptr<Kernel::Event>> get_service_handle_delayed_map;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
} // namespace Service::SM
SERVICE_CONSTRUCT(Service::SM::SRV)
BOOST_CLASS_EXPORT_KEY(Service::SM::SRV)
BOOST_CLASS_EXPORT_KEY(Service::SM::SRV::ThreadCallback)