Serialize AM services
This commit is contained in:
parent
89e4e49a63
commit
e707685c2a
14 changed files with 71 additions and 14 deletions
2
TODO
2
TODO
|
@ -63,7 +63,7 @@
|
||||||
☐ Service @started(19-12-23 12:49)
|
☐ Service @started(19-12-23 12:49)
|
||||||
✔ AC @started(19-12-23 12:48) @done(19-12-24 22:38) @lasted(1d9h50m3s)
|
✔ AC @started(19-12-23 12:48) @done(19-12-24 22:38) @lasted(1d9h50m3s)
|
||||||
✔ ACT @done(19-12-24 23:17)
|
✔ ACT @done(19-12-24 23:17)
|
||||||
☐ AM
|
✔ AM @started(19-12-24 23:17) @done(19-12-24 23:53) @lasted(36m8s)
|
||||||
☐ APT
|
☐ APT
|
||||||
☐ BOSS
|
☐ BOSS
|
||||||
☐ CAM
|
☐ CAM
|
||||||
|
|
|
@ -1021,7 +1021,7 @@ void Module::Interface::BeginImportProgram(Kernel::HLERequestContext& ctx) {
|
||||||
// Citra will store contents out to sdmc/nand
|
// Citra will store contents out to sdmc/nand
|
||||||
const FileSys::Path cia_path = {};
|
const FileSys::Path cia_path = {};
|
||||||
auto file = std::make_shared<Service::FS::File>(
|
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;
|
am->cia_installing = true;
|
||||||
|
|
||||||
|
@ -1048,7 +1048,7 @@ void Module::Interface::BeginImportProgramTemporarily(Kernel::HLERequestContext&
|
||||||
// contents out to sdmc/nand
|
// contents out to sdmc/nand
|
||||||
const FileSys::Path cia_path = {};
|
const FileSys::Path cia_path = {};
|
||||||
auto file = std::make_shared<Service::FS::File>(
|
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;
|
am->cia_installing = true;
|
||||||
|
|
||||||
|
@ -1450,11 +1450,13 @@ void Module::Interface::GetMetaDataFromCia(Kernel::HLERequestContext& ctx) {
|
||||||
rb.PushMappedBuffer(output_buffer);
|
rb.PushMappedBuffer(output_buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
Module::Module(Core::System& system) : system(system) {
|
Module::Module(Core::System& system) : kernel(system.Kernel()) {
|
||||||
ScanForAllTitles();
|
ScanForAllTitles();
|
||||||
system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex");
|
system_updater_mutex = system.Kernel().CreateMutex(false, "AM::SystemUpdaterMutex");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Module::Module(Kernel::KernelSystem& kernel) : kernel(kernel) { }
|
||||||
|
|
||||||
Module::~Module() = default;
|
Module::~Module() = default;
|
||||||
|
|
||||||
void InstallInterfaces(Core::System& system) {
|
void InstallInterfaces(Core::System& system) {
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <boost/serialization/array.hpp>
|
||||||
|
#include <boost/serialization/vector.hpp>
|
||||||
|
#include <boost/serialization/shared_ptr.hpp>
|
||||||
#include "common/common_types.h"
|
#include "common/common_types.h"
|
||||||
#include "core/file_sys/cia_container.h"
|
#include "core/file_sys/cia_container.h"
|
||||||
#include "core/file_sys/file_backend.h"
|
#include "core/file_sys/file_backend.h"
|
||||||
|
@ -150,6 +153,8 @@ std::string GetMediaTitlePath(Service::FS::MediaType media_type);
|
||||||
class Module final {
|
class Module final {
|
||||||
public:
|
public:
|
||||||
explicit Module(Core::System& system);
|
explicit Module(Core::System& system);
|
||||||
|
explicit Module(Kernel::KernelSystem& kernel);
|
||||||
|
Module() = default;
|
||||||
~Module();
|
~Module();
|
||||||
|
|
||||||
class Interface : public ServiceFramework<Interface> {
|
class Interface : public ServiceFramework<Interface> {
|
||||||
|
@ -557,7 +562,7 @@ public:
|
||||||
*/
|
*/
|
||||||
void GetMetaDataFromCia(Kernel::HLERequestContext& ctx);
|
void GetMetaDataFromCia(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
private:
|
protected:
|
||||||
std::shared_ptr<Module> am;
|
std::shared_ptr<Module> am;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -573,12 +578,29 @@ private:
|
||||||
*/
|
*/
|
||||||
void ScanForAllTitles();
|
void ScanForAllTitles();
|
||||||
|
|
||||||
Core::System& system;
|
Kernel::KernelSystem& kernel;
|
||||||
bool cia_installing = false;
|
bool cia_installing = false;
|
||||||
std::array<std::vector<u64_le>, 3> am_title_list;
|
std::array<std::vector<u64_le>, 3> am_title_list;
|
||||||
std::shared_ptr<Kernel::Mutex> system_updater_mutex;
|
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);
|
void InstallInterfaces(Core::System& system);
|
||||||
|
|
||||||
} // namespace Service::AM
|
} // 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.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/hle/service/am/am_app.h"
|
#include "core/hle/service/am/am_app.h"
|
||||||
|
#include "common/archives.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
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
|
} // namespace Service::AM
|
||||||
|
|
||||||
|
SERIALIZE_EXPORT_IMPL(Service::AM::AM_APP)
|
||||||
|
|
|
@ -11,6 +11,11 @@ namespace Service::AM {
|
||||||
class AM_APP final : public Module::Interface {
|
class AM_APP final : public Module::Interface {
|
||||||
public:
|
public:
|
||||||
explicit AM_APP(std::shared_ptr<Module> am);
|
explicit AM_APP(std::shared_ptr<Module> am);
|
||||||
|
private:
|
||||||
|
SERVICE_SERIALIZATION(AM_APP, am)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::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.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/hle/service/am/am_net.h"
|
#include "core/hle/service/am/am_net.h"
|
||||||
|
#include "common/archives.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
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
|
} // namespace Service::AM
|
||||||
|
|
||||||
|
SERIALIZE_EXPORT_IMPL(Service::AM::AM_NET)
|
||||||
|
|
|
@ -11,6 +11,11 @@ namespace Service::AM {
|
||||||
class AM_NET final : public Module::Interface {
|
class AM_NET final : public Module::Interface {
|
||||||
public:
|
public:
|
||||||
explicit AM_NET(std::shared_ptr<Module> am);
|
explicit AM_NET(std::shared_ptr<Module> am);
|
||||||
|
private:
|
||||||
|
SERVICE_SERIALIZATION(AM_NET, am)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::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.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/hle/service/am/am_sys.h"
|
#include "core/hle/service/am/am_sys.h"
|
||||||
|
#include "common/archives.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
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
|
} // namespace Service::AM
|
||||||
|
|
||||||
|
SERIALIZE_EXPORT_IMPL(Service::AM::AM_SYS)
|
||||||
|
|
|
@ -11,6 +11,11 @@ namespace Service::AM {
|
||||||
class AM_SYS final : public Module::Interface {
|
class AM_SYS final : public Module::Interface {
|
||||||
public:
|
public:
|
||||||
explicit AM_SYS(std::shared_ptr<Module> am);
|
explicit AM_SYS(std::shared_ptr<Module> am);
|
||||||
|
private:
|
||||||
|
SERVICE_SERIALIZATION(AM_SYS, am)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::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.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#include "core/hle/service/am/am_u.h"
|
#include "core/hle/service/am/am_u.h"
|
||||||
|
#include "common/archives.h"
|
||||||
|
|
||||||
namespace Service::AM {
|
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
|
} // namespace Service::AM
|
||||||
|
|
||||||
|
SERIALIZE_EXPORT_IMPL(Service::AM::AM_U)
|
||||||
|
|
|
@ -11,6 +11,11 @@ namespace Service::AM {
|
||||||
class AM_U final : public Module::Interface {
|
class AM_U final : public Module::Interface {
|
||||||
public:
|
public:
|
||||||
explicit AM_U(std::shared_ptr<Module> am);
|
explicit AM_U(std::shared_ptr<Module> am);
|
||||||
|
private:
|
||||||
|
SERVICE_SERIALIZATION(AM_U, am)
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::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/file_sys/file_backend.h"
|
||||||
#include "core/hle/result.h"
|
#include "core/hle/result.h"
|
||||||
#include "core/hle/service/fs/archive.h"
|
#include "core/hle/service/fs/archive.h"
|
||||||
|
#include "core/core.h"
|
||||||
|
|
||||||
namespace Service::FS {
|
namespace Service::FS {
|
||||||
|
|
||||||
|
@ -90,7 +91,7 @@ ArchiveManager::OpenFileFromArchive(ArchiveHandle archive_handle, const FileSys:
|
||||||
if (backend.Failed())
|
if (backend.Failed())
|
||||||
return std::make_tuple(backend.Code(), open_timeout_ns);
|
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);
|
return std::make_tuple(MakeResult<std::shared_ptr<File>>(std::move(file)), open_timeout_ns);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,9 +15,9 @@
|
||||||
|
|
||||||
namespace Service::FS {
|
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)
|
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[] = {
|
static const FunctionInfo functions[] = {
|
||||||
{0x08010100, &File::OpenSubFile, "OpenSubFile"},
|
{0x08010100, &File::OpenSubFile, "OpenSubFile"},
|
||||||
{0x080200C2, &File::Read, "Read"},
|
{0x080200C2, &File::Read, "Read"},
|
||||||
|
@ -197,7 +197,7 @@ void File::OpenLinkFile(Kernel::HLERequestContext& ctx) {
|
||||||
using Kernel::ServerSession;
|
using Kernel::ServerSession;
|
||||||
IPC::RequestParser rp(ctx, 0x080C, 0, 0);
|
IPC::RequestParser rp(ctx, 0x080C, 0, 0);
|
||||||
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
IPC::RequestBuilder rb = rp.MakeBuilder(1, 2);
|
||||||
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
|
auto [server, client] = kernel.CreateSessionPair(GetName());
|
||||||
ClientConnected(server);
|
ClientConnected(server);
|
||||||
|
|
||||||
FileSessionSlot* slot = GetSessionData(server);
|
FileSessionSlot* slot = GetSessionData(server);
|
||||||
|
@ -243,7 +243,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
|
||||||
|
|
||||||
using Kernel::ClientSession;
|
using Kernel::ClientSession;
|
||||||
using Kernel::ServerSession;
|
using Kernel::ServerSession;
|
||||||
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
|
auto [server, client] = kernel.CreateSessionPair(GetName());
|
||||||
ClientConnected(server);
|
ClientConnected(server);
|
||||||
|
|
||||||
FileSessionSlot* slot = GetSessionData(server);
|
FileSessionSlot* slot = GetSessionData(server);
|
||||||
|
@ -257,7 +257,7 @@ void File::OpenSubFile(Kernel::HLERequestContext& ctx) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<Kernel::ClientSession> File::Connect() {
|
std::shared_ptr<Kernel::ClientSession> File::Connect() {
|
||||||
auto [server, client] = system.Kernel().CreateSessionPair(GetName());
|
auto [server, client] = kernel.CreateSessionPair(GetName());
|
||||||
ClientConnected(server);
|
ClientConnected(server);
|
||||||
|
|
||||||
FileSessionSlot* slot = GetSessionData(server);
|
FileSessionSlot* slot = GetSessionData(server);
|
||||||
|
|
|
@ -25,7 +25,7 @@ struct FileSessionSlot : public Kernel::SessionRequestHandler::SessionDataBase {
|
||||||
// Consider splitting ServiceFramework interface.
|
// Consider splitting ServiceFramework interface.
|
||||||
class File final : public ServiceFramework<File, FileSessionSlot> {
|
class File final : public ServiceFramework<File, FileSessionSlot> {
|
||||||
public:
|
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);
|
const FileSys::Path& path);
|
||||||
~File() = default;
|
~File() = default;
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ private:
|
||||||
void OpenLinkFile(Kernel::HLERequestContext& ctx);
|
void OpenLinkFile(Kernel::HLERequestContext& ctx);
|
||||||
void OpenSubFile(Kernel::HLERequestContext& ctx);
|
void OpenSubFile(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
Core::System& system;
|
Kernel::KernelSystem& kernel;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Service::FS
|
} // namespace Service::FS
|
||||||
|
|
Loading…
Reference in a new issue