Serialize AM services

This commit is contained in:
Hamish Milne 2019-12-24 23:53:51 +00:00 committed by zhupengfei
parent 89e4e49a63
commit e707685c2a
14 changed files with 71 additions and 14 deletions

View file

@ -1021,7 +1021,7 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
// Citra will store contents out to sdmc/nand
const FileSys::Path cia_path = {};
auto file = std::make_shared<Service::FS::File>(
am->system, std::make_unique<CIAFile>(media_type), cia_path);
am->kernel, std::make_unique<CIAFile>(media_type), cia_path);
am->cia_installing = true;
@ -1048,7 +1048,7 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
// contents out to sdmc/nand
const FileSys::Path cia_path = {};
auto file = std::make_shared<Service::FS::File>(
am->system, std::make_unique<CIAFile>(FS::MediaType::NAND), cia_path);
am->kernel, std::make_unique<CIAFile>(FS::MediaType::NAND), cia_path);
am->cia_installing = true;
@ -1450,11 +1450,13 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
rb.PushMappedBuffer(output_buffer);
}
Module::Module(Core::System& system) : system(system) {
Module::Module(Core::System& system) : kernel(system.Kernel()) {
ScanForAllTitles();
system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex");
}
Module::Module(Kernel::KernelSystem& kernel) : kernel(kernel) { }
Module::~Module() = default;
void InstallInterfaces(Core::System& system) {

View file

@ -9,6 +9,9 @@
#include <memory>
#include <string>
#include <vector>
#include <boost/serialization/array.hpp>
#include <boost/serialization/vector.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "common/common_types.h"
#include "core/file_sys/cia_container.h"
#include "core/file_sys/file_backend.h"
@ -150,6 +153,8 @@ std::string GetMediaTitlePath(Service::FS::MediaType media_type);
class Module final {
public:
explicit Module(Core::System& system);
explicit Module(Kernel::KernelSystem& kernel);
Module() = default;
~Module();
class Interface : public ServiceFramework<Interface> {
@ -557,7 +562,7 @@ public:
*/
void GetMetaDataFromCia(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> am;
};
@ -573,12 +578,29 @@ private:
*/
void ScanForAllTitles();
Core::System& system;
Kernel::KernelSystem& kernel;
bool cia_installing = false;
std::array<std::vector<u64_le>, 3> am_title_list;
std::shared_ptr<Kernel::Mutex> system_updater_mutex;
template <class Archive>
void serialize(Archive& ar, const unsigned int)
{
ar & cia_installing;
ar & am_title_list;
ar & system_updater_mutex;
}
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::AM
namespace boost::serialization {
template <class Archive>
inline void load_construct_data(Archive& ar, Service::AM::Module* t, const unsigned int)
{
::new(t)Service::AM::Module(*Kernel::g_kernel);
}
}

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "core/hle/service/am/am_app.h"
#include "common/archives.h"
namespace Service::AM {
@ -26,3 +27,5 @@ AM_APP::AM_APP(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "a
}
} // namespace Service::AM
SERIALIZE_EXPORT_IMPL(Service::AM::AM_APP)

View file

@ -11,6 +11,11 @@ namespace Service::AM {
class AM_APP final : public Module::Interface {
public:
explicit AM_APP(std::shared_ptr<Module> am);
private:
SERVICE_SERIALIZATION(AM_APP, am)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_APP)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_APP)

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "core/hle/service/am/am_net.h"
#include "common/archives.h"
namespace Service::AM {
@ -123,3 +124,5 @@ AM_NET::AM_NET(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "a
}
} // namespace Service::AM
SERIALIZE_EXPORT_IMPL(Service::AM::AM_NET)

View file

@ -11,6 +11,11 @@ namespace Service::AM {
class AM_NET final : public Module::Interface {
public:
explicit AM_NET(std::shared_ptr<Module> am);
private:
SERVICE_SERIALIZATION(AM_NET, am)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_NET)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_NET)

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "core/hle/service/am/am_sys.h"
#include "common/archives.h"
namespace Service::AM {
@ -71,3 +72,5 @@ AM_SYS::AM_SYS(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "a
}
} // namespace Service::AM
SERIALIZE_EXPORT_IMPL(Service::AM::AM_SYS)

View file

@ -11,6 +11,11 @@ namespace Service::AM {
class AM_SYS final : public Module::Interface {
public:
explicit AM_SYS(std::shared_ptr<Module> am);
private:
SERVICE_SERIALIZATION(AM_SYS, am)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_SYS)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_SYS)

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "core/hle/service/am/am_u.h"
#include "common/archives.h"
namespace Service::AM {
@ -83,3 +84,5 @@ AM_U::AM_U(std::shared_ptr<Module> am) : Module::Interface(std::move(am), "am:u"
}
} // namespace Service::AM
SERIALIZE_EXPORT_IMPL(Service::AM::AM_U)

View file

@ -11,6 +11,11 @@ namespace Service::AM {
class AM_U final : public Module::Interface {
public:
explicit AM_U(std::shared_ptr<Module> am);
private:
SERVICE_SERIALIZATION(AM_U, am)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_U)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_U)