Added derived kernel objects

This commit is contained in:
Hamish Milne 2019-08-11 15:19:45 +01:00 committed by zhupengfei
parent f79c9668a3
commit 5035e68dad
5 changed files with 29 additions and 4 deletions

2
externals/boost vendored

@ -1 +1 @@
Subproject commit 48130d387975d17aed1b34ef75c21020f2d710a8 Subproject commit 19ccdcc6fbd026f98ed83dea32ff0398120fbb32

View File

@ -12,3 +12,8 @@ template void A::serialize<oarchive>( \
oarchive & ar, \ oarchive & ar, \
const unsigned int file_version \ const unsigned int file_version \
); );
#define SERIALIZE_EXPORT_IMPL(A) \
BOOST_SERIALIZATION_REGISTER_ARCHIVE(iarchive) \
BOOST_SERIALIZATION_REGISTER_ARCHIVE(oarchive) \
BOOST_CLASS_EXPORT_IMPLEMENT(A)

View File

@ -3,6 +3,7 @@
// Refer to the license.txt file included. // Refer to the license.txt file included.
#include <algorithm> #include <algorithm>
#include "common/archives.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/logging/log.h" #include "common/logging/log.h"
#include "core/hle/kernel/address_arbiter.h" #include "core/hle/kernel/address_arbiter.h"
@ -14,6 +15,8 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
// Kernel namespace // Kernel namespace
SERIALIZE_EXPORT_IMPL(Kernel::AddressArbiter)
namespace Kernel { namespace Kernel {
void AddressArbiter::WaitThread(std::shared_ptr<Thread> thread, VAddr wait_address) { void AddressArbiter::WaitThread(std::shared_ptr<Thread> thread, VAddr wait_address) {
@ -65,11 +68,12 @@ std::shared_ptr<Thread> AddressArbiter::ResumeHighestPriorityThread(VAddr addres
return thread; return thread;
} }
AddressArbiter::AddressArbiter(KernelSystem& kernel) : Object(kernel), kernel(kernel) {} AddressArbiter::AddressArbiter() : kernel(*g_kernel) {}
AddressArbiter::~AddressArbiter() {} AddressArbiter::~AddressArbiter() {}
std::shared_ptr<AddressArbiter> KernelSystem::CreateAddressArbiter(std::string name) { std::shared_ptr<AddressArbiter> KernelSystem::CreateAddressArbiter(std::string name) {
auto address_arbiter{std::make_shared<AddressArbiter>(*this)}; auto address_arbiter{std::make_shared<AddressArbiter>()};
address_arbiter->Init(*this);
address_arbiter->name = std::move(name); address_arbiter->name = std::move(name);

View File

@ -6,6 +6,10 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/export.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/object.h" #include "core/hle/kernel/object.h"
#include "core/hle/result.h" #include "core/hle/result.h"
@ -32,7 +36,7 @@ enum class ArbitrationType : u32 {
class AddressArbiter final : public Object { class AddressArbiter final : public Object {
public: public:
explicit AddressArbiter(KernelSystem& kernel); explicit AddressArbiter();
~AddressArbiter() override; ~AddressArbiter() override;
std::string GetTypeName() const override { std::string GetTypeName() const override {
@ -67,6 +71,17 @@ private:
/// Threads waiting for the address arbiter to be signaled. /// Threads waiting for the address arbiter to be signaled.
std::vector<std::shared_ptr<Thread>> waiting_threads; std::vector<std::shared_ptr<Thread>> waiting_threads;
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 & name;
ar & waiting_threads;
}
}; };
} // namespace Kernel } // namespace Kernel
BOOST_CLASS_EXPORT_KEY(Kernel::AddressArbiter)

View File

@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include <string> #include <string>
#include <boost/serialization/access.hpp> #include <boost/serialization/access.hpp>
#include "common/serialization/atomic.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "core/hle/kernel/kernel.h" #include "core/hle/kernel/kernel.h"