Serialize AM services

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

@ -63,7 +63,7 @@
☐ Service @started(19-12-23 12:49)
✔ AC @started(19-12-23 12:48) @done(19-12-24 22:38) @lasted(1d9h50m3s)
✔ ACT @done(19-12-24 23:17)
☐ AM
✔ AM @started(19-12-24 23:17) @done(19-12-24 23:53) @lasted(36m8s)
☐ APT
☐ BOSS
☐ CAM

@ -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) {

@ -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);
}
}

@ -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)

@ -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)

@ -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)

@ -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)

@ -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)

@ -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)

@ -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)

@ -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)

@ -27,6 +27,7 @@
#include "core/file_sys/file_backend.h"
#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
#include "core/core.h"
namespace Service::FS {
@ -90,7 +91,7 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
if (backend.Failed())
return std::make_tuple(backend.Code(), open_timeout_ns);
auto file = std::shared_ptr<File>(new File(system, std::move(backend).Unwrap(), path));
auto file = std::shared_ptr<File>(new File(system.Kernel(), std::move(backend).Unwrap(), path));
return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
}

@ -15,9 +15,9 @@
namespace Service::FS {
File::File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
File::File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend,
const FileSys::Path& path)
: ServiceFramework("", 1), path(path), backend(std::move(backend)), system(system) {
: ServiceFramework("", 1), path(path), backend(std::move(backend)), kernel(kernel) {
static const FunctionInfo functions[] = {
{0x08010100, &File::OpenSubFile, "OpenSubFile"},
{0x080200C2, &File::Read, "Read"},
@ -197,7 +197,7 @@ void File::OpenLinkFile(Kernel::HLERequestContext& ctx) {
using Kernel::ServerSession;
IPC::RequestParser rp(ctx, 0x080C, 0, 0);
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
auto [server, client] = kernel.CreateSessionPair(GetName());
ClientConnected(server);
FileSessionSlot* slot = GetSessionData(server);
@ -243,7 +243,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
using Kernel::ClientSession;
using Kernel::ServerSession;
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
auto [server, client] = kernel.CreateSessionPair(GetName());
ClientConnected(server);
FileSessionSlot* slot = GetSessionData(server);
@ -257,7 +257,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
}
std::shared_ptr<Kernel::ClientSession> File::Connect() {
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
auto [server, client] = kernel.CreateSessionPair(GetName());
ClientConnected(server);
FileSessionSlot* slot = GetSessionData(server);

@ -25,7 +25,7 @@ struct FileSessionSlot : public Kernel::SessionRequestHandler::SessionDataBase {
// Consider splitting ServiceFramework interface.
class File final : public ServiceFramework<File, FileSessionSlot> {
public:
File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
File(Kernel::KernelSystem& kernel, std::unique_ptr<FileSys::FileBackend>&& backend,
const FileSys::Path& path);
~File() = default;
@ -59,7 +59,7 @@ private:
void OpenLinkFile(Kernel::HLERequestContext& ctx);
void OpenSubFile(Kernel::HLERequestContext& ctx);
Core::System& system;
Kernel::KernelSystem& kernel;
};
} // namespace Service::FS