Merge pull request #4908 from hamish-milne/feature/savestates-2

Save states
This commit is contained in:
Ben 2020-04-17 21:52:51 +02:00 committed by GitHub
commit c605bb42db
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 6100 additions and 604 deletions

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <vector>
#include "common/archives.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/core.h"
@ -179,4 +180,15 @@ void InstallInterfaces(Core::System& system) {
std::make_shared<AC_U>(ac)->InstallAsService(service_manager);
}
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& ac_connected;
ar& close_event;
ar& connect_event;
ar& disconnect_event;
// default_config is never written to
}
} // namespace Service::AC
SERIALIZE_IMPL(Service::AC::Module)

View file

@ -153,6 +153,11 @@ protected:
std::shared_ptr<Kernel::Event> close_event;
std::shared_ptr<Kernel::Event> connect_event;
std::shared_ptr<Kernel::Event> disconnect_event;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version);
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/ac/ac_i.h"
namespace Service::AC {
@ -33,3 +34,5 @@ AC_I::AC_I(std::shared_ptr<Module> ac) : Module::Interface(std::move(ac), "ac:i"
}
} // namespace Service::AC
SERIALIZE_EXPORT_IMPL(Service::AC::AC_I)

View file

@ -12,6 +12,12 @@ namespace Service::AC {
class AC_I final : public Module::Interface {
public:
explicit AC_I(std::shared_ptr<Module> ac);
private:
SERVICE_SERIALIZATION(AC_I, ac, Module)
};
} // namespace Service::AC
BOOST_CLASS_EXPORT_KEY(Service::AC::AC_I)
BOOST_SERIALIZATION_CONSTRUCT(Service::AC::AC_I)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/ac/ac_u.h"
namespace Service::AC {
@ -33,3 +34,5 @@ AC_U::AC_U(std::shared_ptr<Module> ac) : Module::Interface(std::move(ac), "ac:u"
}
} // namespace Service::AC
SERIALIZE_EXPORT_IMPL(Service::AC::AC_U)

View file

@ -12,6 +12,12 @@ namespace Service::AC {
class AC_U final : public Module::Interface {
public:
explicit AC_U(std::shared_ptr<Module> ac);
private:
SERVICE_SERIALIZATION(AC_U, ac, Module)
};
} // namespace Service::AC
BOOST_CLASS_EXPORT_KEY(Service::AC::AC_U)
BOOST_SERIALIZATION_CONSTRUCT(Service::AC::AC_U)

View file

@ -20,9 +20,14 @@ public:
Interface(std::shared_ptr<Module> act, const char* name);
~Interface();
private:
protected:
std::shared_ptr<Module> act;
};
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) {}
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/act/act_a.h"
namespace Service::ACT {
@ -24,3 +25,5 @@ ACT_A::ACT_A(std::shared_ptr<Module> act) : Module::Interface(std::move(act), "a
}
} // namespace Service::ACT
SERIALIZE_EXPORT_IMPL(Service::ACT::ACT_A)

View file

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

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/act/act_u.h"
namespace Service::ACT {
@ -20,3 +21,5 @@ ACT_U::ACT_U(std::shared_ptr<Module> act) : Module::Interface(std::move(act), "a
}
} // namespace Service::ACT
SERIALIZE_EXPORT_IMPL(Service::ACT::ACT_U)

View file

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

View file

@ -1053,7 +1053,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;
@ -1080,7 +1080,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;
@ -1482,11 +1482,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,9 +9,14 @@
#include <memory>
#include <string>
#include <vector>
#include <boost/serialization/array.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/common_types.h"
#include "common/construct.h"
#include "core/file_sys/cia_container.h"
#include "core/file_sys/file_backend.h"
#include "core/global.h"
#include "core/hle/kernel/mutex.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@ -557,11 +562,13 @@ public:
*/
void GetMetaDataFromCia(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> am;
};
private:
explicit Module(Kernel::KernelSystem& kernel);
/**
* Scans the for titles in a storage medium for listing.
* @param media_type the storage medium to scan
@ -573,12 +580,32 @@ 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;
}
template <class Archive>
static void load_construct(Archive& ar, Module* t, const unsigned int file_version) {
::new (t) Module(Core::Global<Kernel::KernelSystem>());
}
template <class Archive>
void save_construct(Archive& ar, const unsigned int file_version) const {}
friend class ::construct_access;
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::AM
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::Module);

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/am/am_app.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,12 @@ 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, Module)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_APP)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_APP)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/am/am_net.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,12 @@ 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, Module)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_NET)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_NET)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/am/am_sys.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,12 @@ 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, Module)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_SYS)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_SYS)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/am/am_u.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,12 @@ 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, Module)
};
} // namespace Service::AM
BOOST_CLASS_EXPORT_KEY(Service::AM::AM_U)
BOOST_SERIALIZATION_CONSTRUCT(Service::AM::AM_U)

View file

@ -10,6 +10,8 @@
#include "core/hle/service/apt/ns.h"
#include "core/hle/service/cfg/cfg.h"
SERVICE_CONSTRUCT_IMPL(Service::APT::AppletManager)
namespace Service::APT {
enum class AppletPos { Application = 0, Library = 1, System = 2, SysLibrary = 3, Resident = 4 };

View file

@ -6,8 +6,12 @@
#include <array>
#include <memory>
#include <optional>
#include <vector>
#include <boost/serialization/array.hpp>
#include <boost/serialization/optional.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "core/global.h"
#include "core/hle/kernel/event.h"
#include "core/hle/result.h"
#include "core/hle/service/fs/archive.h"
@ -84,6 +88,17 @@ struct MessageParameter {
SignalType signal = SignalType::None;
std::shared_ptr<Kernel::Object> object = nullptr;
std::vector<u8> buffer;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& sender_id;
ar& destination_id;
ar& signal;
ar& object;
ar& buffer;
}
friend class boost::serialization::access;
};
/// Holds information about the parameters used in StartLibraryApplet
@ -161,6 +176,16 @@ public:
u64 current_title_id;
FS::MediaType current_media_type;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& next_title_id;
ar& next_media_type;
ar& current_title_id;
ar& current_media_type;
}
friend class boost::serialization::access;
};
ApplicationJumpParameters GetApplicationJumpParameters() const {
@ -169,7 +194,8 @@ public:
private:
/// Parameter data to be returned in the next call to Glance/ReceiveParameter.
std::optional<MessageParameter> next_parameter;
// NOTE: A bug in gcc prevents serializing std::optional
boost::optional<MessageParameter> next_parameter;
static constexpr std::size_t NumAppletSlot = 4;
@ -199,6 +225,20 @@ private:
title_id = 0;
attributes.raw = 0;
}
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& applet_id;
ar& slot;
ar& title_id;
ar& registered;
ar& loaded;
ar& attributes.raw;
ar& notification_event;
ar& parameter_event;
}
friend class boost::serialization::access;
};
ApplicationJumpParameters app_jump_parameters{};
@ -216,6 +256,18 @@ private:
SignalType library_applet_closing_command;
Core::System& system;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& next_parameter;
ar& app_jump_parameters;
ar& applet_slots;
ar& library_applet_closing_command;
}
friend class boost::serialization::access;
};
} // namespace Service::APT
SERVICE_CONSTRUCT(Service::APT::AppletManager)

View file

@ -2,6 +2,9 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/vector.hpp>
#include "common/archives.h"
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/log.h"
@ -26,8 +29,25 @@
#include "core/hw/aes/ccm.h"
#include "core/hw/aes/key.h"
SERVICE_CONSTRUCT_IMPL(Service::APT::Module)
namespace Service::APT {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& shared_font_mem;
ar& shared_font_loaded;
ar& shared_font_relocated;
ar& lock;
ar& cpu_percent;
ar& unknown_ns_state_field;
ar& screen_capture_buffer;
ar& screen_capture_post_permission;
ar& applet_manager;
}
SERIALIZE_IMPL(Module)
Module::NSInterface::NSInterface(std::shared_ptr<Module> apt, const char* name, u32 max_session)
: ServiceFramework(name, max_session), apt(std::move(apt)) {}

View file

@ -6,9 +6,11 @@
#include <memory>
#include <vector>
#include "common/archives.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
#include "common/swap.h"
#include "core/global.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/service/service.h"
@ -65,7 +67,7 @@ public:
NSInterface(std::shared_ptr<Module> apt, const char* name, u32 max_session);
~NSInterface();
private:
protected:
std::shared_ptr<Module> apt;
};
@ -601,9 +603,16 @@ public:
*/
void CheckNew3DS(Kernel::HLERequestContext& ctx);
private:
protected:
bool application_reset_prepared{};
std::shared_ptr<Module> apt;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& application_reset_prepared;
}
friend class boost::serialization::access;
};
private:
@ -630,8 +639,14 @@ private:
ScreencapPostPermission::CleanThePermission; // TODO(JamePeng): verify the initial value
std::shared_ptr<AppletManager> applet_manager;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::APT
SERVICE_CONSTRUCT(Service::APT::Module)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/apt/apt_a.h"
namespace Service::APT {
@ -105,3 +106,5 @@ APT_A::APT_A(std::shared_ptr<Module> apt)
}
} // namespace Service::APT
SERIALIZE_EXPORT_IMPL(Service::APT::APT_A)

View file

@ -11,6 +11,12 @@ namespace Service::APT {
class APT_A final : public Module::APTInterface {
public:
explicit APT_A(std::shared_ptr<Module> apt);
private:
SERVICE_SERIALIZATION(APT_A, apt, Module)
};
} // namespace Service::APT
BOOST_CLASS_EXPORT_KEY(Service::APT::APT_A)
BOOST_SERIALIZATION_CONSTRUCT(Service::APT::APT_A)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/apt/apt_s.h"
namespace Service::APT {
@ -105,3 +106,5 @@ APT_S::APT_S(std::shared_ptr<Module> apt)
}
} // namespace Service::APT
SERIALIZE_EXPORT_IMPL(Service::APT::APT_S)

View file

@ -18,6 +18,12 @@ namespace Service::APT {
class APT_S final : public Module::APTInterface {
public:
explicit APT_S(std::shared_ptr<Module> apt);
private:
SERVICE_SERIALIZATION(APT_S, apt, Module)
};
} // namespace Service::APT
BOOST_CLASS_EXPORT_KEY(Service::APT::APT_S)
BOOST_SERIALIZATION_CONSTRUCT(Service::APT::APT_S)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/apt/apt_u.h"
namespace Service::APT {
@ -102,3 +103,5 @@ APT_U::APT_U(std::shared_ptr<Module> apt)
}
} // namespace Service::APT
SERIALIZE_EXPORT_IMPL(Service::APT::APT_U)

View file

@ -18,6 +18,12 @@ namespace Service::APT {
class APT_U final : public Module::APTInterface {
public:
explicit APT_U(std::shared_ptr<Module> apt);
private:
SERVICE_SERIALIZATION(APT_U, apt, Module)
};
} // namespace Service::APT
BOOST_CLASS_EXPORT_KEY(Service::APT::APT_U)
BOOST_SERIALIZATION_CONSTRUCT(Service::APT::APT_U)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/apt/ns_s.h"
namespace Service::NS {
@ -29,3 +30,5 @@ NS_S::NS_S(std::shared_ptr<Service::APT::Module> apt)
}
} // namespace Service::NS
SERIALIZE_EXPORT_IMPL(Service::NS::NS_S)

View file

@ -14,6 +14,12 @@ namespace Service::NS {
class NS_S final : public Service::APT::Module::NSInterface {
public:
explicit NS_S(std::shared_ptr<Service::APT::Module> apt);
private:
SERVICE_SERIALIZATION(NS_S, apt, Service::APT::Module)
};
} // namespace Service::NS
BOOST_CLASS_EXPORT_KEY(Service::NS::NS_S)
BOOST_SERIALIZATION_CONSTRUCT(Service::NS::NS_S)

View file

@ -5,6 +5,8 @@
#pragma once
#include <memory>
#include <boost/serialization/shared_ptr.hpp>
#include "core/global.h"
#include "core/hle/kernel/event.h"
#include "core/hle/service/service.h"
@ -952,19 +954,42 @@ public:
*/
void GetNsDataNewFlagPrivileged(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> boss;
private:
u8 new_arrival_flag;
u8 ns_data_new_flag;
u8 ns_data_new_flag_privileged;
u8 output_flag;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& new_arrival_flag;
ar& ns_data_new_flag;
ar& ns_data_new_flag_privileged;
ar& output_flag;
}
friend class boost::serialization::access;
};
private:
std::shared_ptr<Kernel::Event> task_finish_event;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& task_finish_event;
}
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::BOSS
namespace boost::serialization {
template <class Archive>
void load_construct_data(Archive& ar, Service::BOSS::Module* t, const unsigned int) {
::new (t) Service::BOSS::Module(Core::Global<Core::System>());
}
} // namespace boost::serialization

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/boss/boss_p.h"
namespace Service::BOSS {
@ -84,3 +85,5 @@ BOSS_P::BOSS_P(std::shared_ptr<Module> boss)
}
} // namespace Service::BOSS
SERIALIZE_EXPORT_IMPL(Service::BOSS::BOSS_P)

View file

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

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/boss/boss_u.h"
namespace Service::BOSS {
@ -72,3 +73,5 @@ BOSS_U::BOSS_U(std::shared_ptr<Module> boss)
}
} // namespace Service::BOSS
SERIALIZE_EXPORT_IMPL(Service::BOSS::BOSS_U)

View file

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

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
#include "common/archives.h"
#include "common/bit_set.h"
#include "common/logging/log.h"
#include "core/core.h"
@ -20,8 +21,32 @@
#include "core/memory.h"
#include "core/settings.h"
SERVICE_CONSTRUCT_IMPL(Service::CAM::Module)
namespace Service::CAM {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& cameras;
ar& ports;
ar& is_camera_reload_pending;
if (Archive::is_loading::value) {
for (int i = 0; i < NumCameras; i++) {
LoadCameraImplementation(cameras[i], i);
}
for (std::size_t i = 0; i < ports.size(); i++) {
if (ports[i].is_busy) {
cameras[ports[i].camera_id].impl->StartCapture();
}
if (ports[i].is_receiving) {
StartReceiving(static_cast<int>(i));
}
}
}
}
SERIALIZE_IMPL(Module)
// built-in resolution parameters
constexpr std::array<Resolution, 8> PRESET_RESOLUTION{{
{640, 480, 0, 0, 639, 479}, // VGA

View file

@ -9,8 +9,14 @@
#include <future>
#include <memory>
#include <vector>
#include <boost/serialization/array.hpp>
#include <boost/serialization/deque.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <boost/serialization/version.hpp>
#include "common/common_types.h"
#include "common/swap.h"
#include "core/global.h"
#include "core/hle/result.h"
#include "core/hle/service/service.h"
@ -180,6 +186,18 @@ struct Resolution {
u16 crop_y0;
u16 crop_x1;
u16 crop_y1;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& width;
ar& height;
ar& crop_x0;
ar& crop_y0;
ar& crop_x1;
ar& crop_y1;
}
friend class boost::serialization::access;
};
struct PackageParameterWithoutContext {
@ -726,7 +744,7 @@ public:
*/
void DriverFinalize(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> cam;
};
@ -755,6 +773,16 @@ private:
Effect effect{Effect::None};
OutputFormat format{OutputFormat::YUV422};
Resolution resolution = {0, 0, 0, 0, 0, 0};
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& flip;
ar& effect;
ar& format;
ar& resolution;
}
friend class boost::serialization::access;
};
struct CameraConfig {
@ -762,6 +790,20 @@ private:
std::array<ContextConfig, 2> contexts;
int current_context{0};
FrameRate frame_rate{FrameRate::Rate_15};
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int file_version) {
// For compatibility: put a nullptr here
if (file_version == 0) {
std::unique_ptr<Camera::CameraInterface> x;
ar& x;
}
ar& contexts;
ar& current_context;
ar& frame_rate;
}
friend class boost::serialization::access;
};
struct PortConfig {
@ -798,6 +840,31 @@ private:
u32 dest_size{0}; // the destination size of the receiving process
void Clear();
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& camera_id;
ar& is_active;
ar& is_pending_receiving;
ar& is_busy;
ar& is_receiving;
ar& is_trimming;
ar& x0;
ar& y0;
ar& x1;
ar& y1;
ar& transfer_bytes;
ar& completion_event;
ar& buffer_error_interrupt_event;
ar& vsync_interrupt_event;
ar& vsync_timings;
// Ignore capture_result. In-progress captures might be affected but this is OK.
ar& dest_process;
ar& dest;
ar& dest_size;
}
friend class boost::serialization::access;
};
void LoadCameraImplementation(CameraConfig& camera, int camera_id);
@ -808,6 +875,10 @@ private:
Core::TimingEventType* completion_event_callback;
Core::TimingEventType* vsync_interrupt_event_callback;
std::atomic<bool> is_camera_reload_pending{false};
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
std::shared_ptr<Module> GetModule(Core::System& system);
@ -815,3 +886,6 @@ std::shared_ptr<Module> GetModule(Core::System& system);
void InstallInterfaces(Core::System& system);
} // namespace Service::CAM
SERVICE_CONSTRUCT(Service::CAM::Module)
BOOST_CLASS_VERSION(Service::CAM::Module::CameraConfig, 1)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cam/cam.h"
#include "core/hle/service/cam/cam_c.h"
@ -79,3 +80,5 @@ CAM_C::CAM_C(std::shared_ptr<Module> cam) : Module::Interface(std::move(cam), "c
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_C)

View file

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

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cam/cam_q.h"
namespace Service::CAM {
@ -13,3 +14,5 @@ CAM_Q::CAM_Q() : ServiceFramework("cam:q", 1 /*TODO: find the true value*/) {
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_Q)

View file

@ -11,6 +11,11 @@ namespace Service::CAM {
class CAM_Q : public ServiceFramework<CAM_Q> {
public:
CAM_Q();
private:
SERVICE_SERIALIZATION_SIMPLE
};
} // namespace Service::CAM
BOOST_CLASS_EXPORT_KEY(Service::CAM::CAM_Q)

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cam/cam.h"
#include "core/hle/service/cam/cam_s.h"
@ -79,3 +80,5 @@ CAM_S::CAM_S(std::shared_ptr<Module> cam) : Module::Interface(std::move(cam), "c
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_S)

View file

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

View file

@ -2,6 +2,7 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cam/cam.h"
#include "core/hle/service/cam/cam_u.h"
@ -79,3 +80,5 @@ CAM_U::CAM_U(std::shared_ptr<Module> cam) : Module::Interface(std::move(cam), "c
}
} // namespace Service::CAM
SERIALIZE_EXPORT_IMPL(Service::CAM::CAM_U)

View file

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

View file

@ -2,9 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <cryptopp/base64.h>
#include <cryptopp/hmac.h>
#include <cryptopp/sha.h>
#include "common/archives.h"
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/log.h"
@ -24,8 +27,20 @@
#include "core/hle/service/cfg/cfg.h"
#include "fmt/format.h"
SERVICE_CONSTRUCT_IMPL(Service::CECD::Module)
SERIALIZE_EXPORT_IMPL(Service::CECD::Module)
SERIALIZE_EXPORT_IMPL(Service::CECD::Module::SessionData)
namespace Service::CECD {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& cecd_system_save_data_archive;
ar& cecinfo_event;
ar& change_state_event;
}
SERIALIZE_IMPL(Module)
using CecDataPathType = Module::CecDataPathType;
using CecOpenMode = Module::CecOpenMode;
using CecSystemInfoType = Module::CecSystemInfoType;
@ -93,7 +108,7 @@ void Module::Interface::Open(Kernel::HLERequestContext& ctx) {
} else {
session_data->file = std::move(file_result).Unwrap();
rb.Push(RESULT_SUCCESS);
rb.Push<u32>(session_data->file->GetSize()); // Return file size
rb.Push<u32>(static_cast<u32>(session_data->file->GetSize())); // Return file size
}
if (path_type == CecDataPathType::MboxProgramId) {
@ -141,8 +156,8 @@ void Module::Interface::Read(Kernel::HLERequestContext& ctx) {
break;
default: // If not directory, then it is a file
std::vector<u8> buffer(write_buffer_size);
const u32 bytes_read =
session_data->file->Read(0, write_buffer_size, buffer.data()).Unwrap();
const u32 bytes_read = static_cast<u32>(
session_data->file->Read(0, write_buffer_size, buffer.data()).Unwrap());
write_buffer.Write(buffer.data(), 0, write_buffer_size);
session_data->file->Close();
@ -184,7 +199,8 @@ void Module::Interface::ReadMessage(Kernel::HLERequestContext& ctx) {
auto message = std::move(message_result).Unwrap();
std::vector<u8> buffer(buffer_size);
const u32 bytes_read = message->Read(0, buffer_size, buffer.data()).Unwrap();
const u32 bytes_read =
static_cast<u32>(message->Read(0, buffer_size, buffer.data()).Unwrap());
write_buffer.Write(buffer.data(), 0, buffer_size);
message->Close();
@ -253,7 +269,8 @@ void Module::Interface::ReadMessageWithHMAC(Kernel::HLERequestContext& ctx) {
auto message = std::move(message_result).Unwrap();
std::vector<u8> buffer(buffer_size);
const u32 bytes_read = message->Read(0, buffer_size, buffer.data()).Unwrap();
const u32 bytes_read =
static_cast<u32>(message->Read(0, buffer_size, buffer.data()).Unwrap());
write_buffer.Write(buffer.data(), 0, buffer_size);
message->Close();
@ -354,8 +371,8 @@ void Module::Interface::Write(Kernel::HLERequestContext& ctx) {
buffer);
}
const u32 bytes_written =
session_data->file->Write(0, buffer.size(), true, buffer.data()).Unwrap();
const u32 bytes_written = static_cast<u32>(
session_data->file->Write(0, buffer.size(), true, buffer.data()).Unwrap());
session_data->file->Close();
rb.Push(RESULT_SUCCESS);
@ -416,7 +433,8 @@ void Module::Interface::WriteMessage(Kernel::HLERequestContext& ctx) {
msg_header.sender_id, msg_header.sender_id2, msg_header.send_count,
msg_header.forward_count, msg_header.user_data);
const u32 bytes_written = message->Write(0, buffer_size, true, buffer.data()).Unwrap();
const u32 bytes_written =
static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap());
message->Close();
rb.Push(RESULT_SUCCESS);
@ -502,7 +520,8 @@ void Module::Interface::WriteMessageWithHMAC(Kernel::HLERequestContext& ctx) {
hmac.CalculateDigest(hmac_digest.data(), message_body.data(), msg_header.body_size);
std::memcpy(buffer.data() + hmac_offset, hmac_digest.data(), hmac_size);
const u32 bytes_written = message->Write(0, buffer_size, true, buffer.data()).Unwrap();
const u32 bytes_written =
static_cast<u32>(message->Write(0, buffer_size, true, buffer.data()).Unwrap());
message->Close();
rb.Push(RESULT_SUCCESS);
@ -744,7 +763,8 @@ void Module::Interface::OpenAndWrite(Kernel::HLERequestContext& ctx) {
cecd->CheckAndUpdateFile(path_type, ncch_program_id, buffer);
}
const u32 bytes_written = file->Write(0, buffer.size(), true, buffer.data()).Unwrap();
const u32 bytes_written =
static_cast<u32>(file->Write(0, buffer.size(), true, buffer.data()).Unwrap());
file->Close();
rb.Push(RESULT_SUCCESS);
@ -793,7 +813,8 @@ void Module::Interface::OpenAndRead(Kernel::HLERequestContext& ctx) {
auto file = std::move(file_result).Unwrap();
std::vector<u8> buffer(buffer_size);
const u32 bytes_read = file->Read(0, buffer_size, buffer.data()).Unwrap();
const u32 bytes_read =
static_cast<u32>(file->Read(0, buffer_size, buffer.data()).Unwrap());
write_buffer.Write(buffer.data(), 0, buffer_size);
file->Close();
@ -924,7 +945,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
constexpr u32 max_num_boxes = 24;
constexpr u32 name_size = 16; // fixed size 16 characters long
constexpr u32 valid_name_size = 8; // 8 characters are valid, the rest are null
const u32 file_size = file_buffer.size();
const u32 file_size = static_cast<u32>(file_buffer.size());
switch (path_type) {
case CecDataPathType::MboxList: {
@ -1008,7 +1029,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
std::u16string u16_filename;
// Loop through entries but don't add mboxlist____ to itself.
for (auto i = 0; i < entry_count; i++) {
for (u32 i = 0; i < entry_count; i++) {
u16_filename = std::u16string(entries[i].filename);
file_name = Common::UTF16ToUTF8(u16_filename);
@ -1199,7 +1220,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
std::string file_name;
std::u16string u16_filename;
for (auto i = 0; i < entry_count; i++) {
for (u32 i = 0; i < entry_count; i++) {
u16_filename = std::u16string(entries[i].filename);
file_name = Common::UTF16ToUTF8(u16_filename);
@ -1217,7 +1238,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
auto message_result = cecd_system_save_data_archive->OpenFile(message_path, mode);
auto message = std::move(message_result).Unwrap();
const u32 message_size = message->GetSize();
const u32 message_size = static_cast<u32>(message->GetSize());
std::vector<u8> buffer(message_size);
message->Read(0, message_size, buffer.data()).Unwrap();
@ -1291,7 +1312,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
std::string file_name;
std::u16string u16_filename;
for (auto i = 0; i < entry_count; i++) {
for (u32 i = 0; i < entry_count; i++) {
u16_filename = std::u16string(entries[i].filename);
file_name = Common::UTF16ToUTF8(u16_filename);
@ -1307,7 +1328,7 @@ void Module::CheckAndUpdateFile(const CecDataPathType path_type, const u32 ncch_
auto message_result = cecd_system_save_data_archive->OpenFile(message_path, mode);
auto message = std::move(message_result).Unwrap();
const u32 message_size = message->GetSize();
const u32 message_size = static_cast<u32>(message->GetSize());
std::vector<u8> buffer(message_size);
message->Read(0, message_size, buffer.data()).Unwrap();

View file

@ -248,6 +248,19 @@ public:
FileSys::Path path;
std::unique_ptr<FileSys::FileBackend> file;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler::SessionDataBase>(
*this);
ar& ncch_program_id;
ar& data_path_type;
ar& open_mode.raw;
ar& path;
ar& file;
}
friend class boost::serialization::access;
};
class Interface : public ServiceFramework<Interface, SessionData> {
@ -584,7 +597,7 @@ public:
*/
void GetCecInfoEventHandleSys(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> cecd;
};
@ -613,9 +626,17 @@ private:
std::shared_ptr<Kernel::Event> change_state_event;
Core::System& system;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
/// Initialize CECD service(s)
void InstallInterfaces(Core::System& system);
} // namespace Service::CECD
SERVICE_CONSTRUCT(Service::CECD::Module)
BOOST_CLASS_EXPORT_KEY(Service::CECD::Module)
BOOST_CLASS_EXPORT_KEY(Service::CECD::Module::SessionData)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cecd/cecd_ndm.h"
SERIALIZE_EXPORT_IMPL(Service::CECD::CECD_NDM)
namespace Service::CECD {
CECD_NDM::CECD_NDM(std::shared_ptr<Module> cecd)

View file

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

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cecd/cecd_s.h"
SERIALIZE_EXPORT_IMPL(Service::CECD::CECD_S)
namespace Service::CECD {
CECD_S::CECD_S(std::shared_ptr<Module> cecd)

View file

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

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cecd/cecd_u.h"
SERIALIZE_EXPORT_IMPL(Service::CECD::CECD_U)
namespace Service::CECD {
CECD_U::CECD_U(std::shared_ptr<Module> cecd)

View file

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

View file

@ -4,8 +4,11 @@
#include <algorithm>
#include <tuple>
#include <boost/serialization/array.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <cryptopp/osrng.h>
#include <cryptopp/sha.h>
#include "common/archives.h"
#include "common/common_paths.h"
#include "common/file_util.h"
#include "common/logging/log.h"
@ -24,8 +27,18 @@
#include "core/hle/service/cfg/cfg_u.h"
#include "core/settings.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::Module)
namespace Service::CFG {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int) {
ar& cfg_config_file_buffer;
ar& cfg_system_save_data_archive;
ar& preferred_region_code;
}
SERIALIZE_IMPL(Module)
/// The maximum number of block entries that can exist in the config file
static const u32 CONFIG_FILE_MAX_BLOCK_ENTRIES = 1479;

View file

@ -244,7 +244,7 @@ public:
(this->*function)(ctx, id);
}
private:
protected:
std::shared_ptr<Module> cfg;
};
@ -426,6 +426,10 @@ private:
std::array<u8, CONFIG_SAVEFILE_SIZE> cfg_config_file_buffer;
std::unique_ptr<FileSys::ArchiveBackend> cfg_system_save_data_archive;
u32 preferred_region_code = 0;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
std::shared_ptr<Module> GetModule(Core::System& system);
@ -436,3 +440,5 @@ void InstallInterfaces(Core::System& system);
std::string GetConsoleIdHash(Core::System& system);
} // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::Module)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_i.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_I)
namespace Service::CFG {
CFG_I::CFG_I(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:i", 23) {

View file

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

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_nor.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_NOR)
namespace Service::CFG {
CFG_NOR::CFG_NOR() : ServiceFramework("cfg:nor", 23) {

View file

@ -11,6 +11,11 @@ namespace Service::CFG {
class CFG_NOR final : public ServiceFramework<CFG_NOR> {
public:
CFG_NOR();
private:
SERVICE_SERIALIZATION_SIMPLE
};
} // namespace Service::CFG
BOOST_CLASS_EXPORT_KEY(Service::CFG::CFG_NOR)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_s.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_S)
namespace Service::CFG {
CFG_S::CFG_S(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:s", 23) {

View file

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

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/cfg/cfg_u.h"
SERIALIZE_EXPORT_IMPL(Service::CFG::CFG_U)
namespace Service::CFG {
CFG_U::CFG_U(std::shared_ptr<Module> cfg) : Module::Interface(std::move(cfg), "cfg:u", 23) {

View file

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

View file

@ -3,11 +3,15 @@
// Refer to the license.txt file included.
#include "common/alignment.h"
#include "common/archives.h"
#include "core/core.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/result.h"
#include "core/hle/service/csnd/csnd_snd.h"
SERVICE_CONSTRUCT_IMPL(Service::CSND::CSND_SND)
SERIALIZE_EXPORT_IMPL(Service::CSND::CSND_SND)
namespace Service::CSND {
enum class CommandId : u16 {

View file

@ -5,6 +5,8 @@
#pragma once
#include <memory>
#include <boost/serialization/array.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "core/hle/kernel/mutex.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/service.h"
@ -33,6 +35,14 @@ enum class LoopMode : u8 {
struct AdpcmState {
s16 predictor = 0;
u8 step_index = 0;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& predictor;
ar& step_index;
}
friend class boost::serialization::access;
};
struct Channel {
@ -52,6 +62,28 @@ struct Channel {
LoopMode loop_mode = LoopMode::Manual;
Encoding encoding = Encoding::Pcm8;
u8 psg_duty = 0;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& block1_address;
ar& block2_address;
ar& block1_size;
ar& block2_size;
ar& block1_adpcm_state;
ar& block2_adpcm_state;
ar& block2_adpcm_reload;
ar& left_channel_volume;
ar& right_channel_volume;
ar& left_capture_volume;
ar& right_capture_volume;
ar& sample_rate;
ar& linear_interpolation;
ar& loop_mode;
ar& encoding;
ar& psg_duty;
}
friend class boost::serialization::access;
};
class CSND_SND final : public ServiceFramework<CSND_SND> {
@ -222,9 +254,27 @@ private:
u32 type1_command_offset = 0;
u32 acquired_channel_mask = 0;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& mutex;
ar& shared_memory;
ar& capture_units;
ar& channels;
ar& master_state_offset;
ar& channel_state_offset;
ar& capture_state_offset;
ar& type1_command_offset;
ar& acquired_channel_mask;
}
friend class boost::serialization::access;
};
/// Initializes the CSND_SND Service
void InstallInterfaces(Core::System& system);
} // namespace Service::CSND
BOOST_CLASS_EXPORT_KEY(Service::CSND::CSND_SND)
SERVICE_CONSTRUCT(Service::CSND::CSND_SND)

View file

@ -2,9 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/dlp/dlp_clnt.h"
SERIALIZE_EXPORT_IMPL(Service::DLP::DLP_CLNT)
namespace Service::DLP {
DLP_CLNT::DLP_CLNT() : ServiceFramework("dlp:CLNT", 1) {

View file

@ -12,6 +12,11 @@ class DLP_CLNT final : public ServiceFramework<DLP_CLNT> {
public:
DLP_CLNT();
~DLP_CLNT() = default;
private:
SERVICE_SERIALIZATION_SIMPLE
};
} // namespace Service::DLP
BOOST_CLASS_EXPORT_KEY(Service::DLP::DLP_CLNT)

View file

@ -2,9 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/dlp/dlp_fkcl.h"
SERIALIZE_EXPORT_IMPL(Service::DLP::DLP_FKCL)
namespace Service::DLP {
DLP_FKCL::DLP_FKCL() : ServiceFramework("dlp:FKCL", 1) {

View file

@ -12,6 +12,11 @@ class DLP_FKCL final : public ServiceFramework<DLP_FKCL> {
public:
DLP_FKCL();
~DLP_FKCL() = default;
private:
SERVICE_SERIALIZATION_SIMPLE
};
} // namespace Service::DLP
BOOST_CLASS_EXPORT_KEY(Service::DLP::DLP_FKCL)

View file

@ -2,12 +2,15 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "common/common_types.h"
#include "common/logging/log.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/result.h"
#include "core/hle/service/dlp/dlp_srvr.h"
SERIALIZE_EXPORT_IMPL(Service::DLP::DLP_SRVR)
namespace Service::DLP {
void DLP_SRVR::IsChild(Kernel::HLERequestContext& ctx) {

View file

@ -15,6 +15,10 @@ public:
private:
void IsChild(Kernel::HLERequestContext& ctx);
SERVICE_SERIALIZATION_SIMPLE
};
} // namespace Service::DLP
BOOST_CLASS_EXPORT_KEY(Service::DLP::DLP_SRVR)

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include "audio_core/audio_types.h"
#include "common/archives.h"
#include "common/assert.h"
#include "common/logging/log.h"
#include "core/core.h"
@ -13,6 +14,9 @@
using DspPipe = AudioCore::DspPipe;
using InterruptType = Service::DSP::DSP_DSP::InterruptType;
SERIALIZE_EXPORT_IMPL(Service::DSP::DSP_DSP)
SERVICE_CONSTRUCT_IMPL(Service::DSP::DSP_DSP)
namespace AudioCore {
enum class DspPipe;
}

View file

@ -5,6 +5,9 @@
#pragma once
#include <memory>
#include <boost/serialization/array.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "audio_core/dsp_interface.h"
#include "core/hle/kernel/event.h"
#include "core/hle/result.h"
@ -264,8 +267,22 @@ private:
/// Each DSP pipe has an associated interrupt
std::array<std::shared_ptr<Kernel::Event>, AudioCore::num_dsp_pipe> pipes = {{}};
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& semaphore_event;
ar& preset_semaphore;
ar& interrupt_zero;
ar& interrupt_one;
ar& pipes;
}
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::DSP
BOOST_CLASS_EXPORT_KEY(Service::DSP::DSP_DSP)
SERVICE_CONSTRUCT(Service::DSP::DSP_DSP)

View file

@ -6,6 +6,7 @@
#include <chrono>
#include <iomanip>
#include <sstream>
#include "common/archives.h"
#include "common/bit_field.h"
#include "common/common_types.h"
#include "common/logging/log.h"
@ -14,6 +15,20 @@
#include "core/hle/ipc_helpers.h"
#include "core/hle/result.h"
#include "core/hle/service/err_f.h"
#undef exception_info // We use 'exception_info' as a plain identifier, but MSVC defines this in one
// of its many headers.
SERIALIZE_EXPORT_IMPL(Service::ERR::ERR_F)
namespace boost::serialization {
template <class Archive>
void load_construct_data(Archive& ar, Service::ERR::ERR_F* t, const unsigned int) {
::new (t) Service::ERR::ERR_F(Core::Global<Core::System>());
}
template void load_construct_data<iarchive>(iarchive& ar, Service::ERR::ERR_F* t,
const unsigned int);
} // namespace boost::serialization
namespace Service::ERR {

View file

@ -34,8 +34,17 @@ private:
void ThrowFatalError(Kernel::HLERequestContext& ctx);
Core::System& system;
SERVICE_SERIALIZATION_SIMPLE
};
void InstallInterfaces(Core::System& system);
} // namespace Service::ERR
BOOST_CLASS_EXPORT_KEY(Service::ERR::ERR_F)
namespace boost::serialization {
template <class Archive>
void load_construct_data(Archive& ar, Service::ERR::ERR_F* t, const unsigned int);
}

View file

@ -18,10 +18,26 @@ struct FriendKey {
u32 friend_id;
u32 unknown;
u64 friend_code;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& friend_id;
ar& unknown;
ar& friend_code;
}
friend class boost::serialization::access;
};
struct MyPresence {
u8 unknown[0x12C];
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& unknown;
}
friend class boost::serialization::access;
};
struct Profile {
@ -130,13 +146,20 @@ public:
*/
void SetClientSdkVersion(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> frd;
};
private:
FriendKey my_friend_key = {0, 0, 0ull};
MyPresence my_presence = {};
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& my_friend_key;
ar& my_presence;
}
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/frd/frd_a.h"
SERIALIZE_EXPORT_IMPL(Service::FRD::FRD_A)
namespace Service::FRD {
FRD_A::FRD_A(std::shared_ptr<Module> frd) : Module::Interface(std::move(frd), "frd:a", 8) {

View file

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

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/frd/frd_u.h"
SERIALIZE_EXPORT_IMPL(Service::FRD::FRD_U)
namespace Service::FRD {
FRD_U::FRD_U(std::shared_ptr<Module> frd) : Module::Interface(std::move(frd), "frd:u", 8) {

View file

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

View file

@ -13,6 +13,7 @@
#include "common/common_types.h"
#include "common/file_util.h"
#include "common/logging/log.h"
#include "core/core.h"
#include "core/file_sys/archive_backend.h"
#include "core/file_sys/archive_extsavedata.h"
#include "core/file_sys/archive_ncch.h"
@ -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);
}

View file

@ -8,7 +8,8 @@
#include <string>
#include <unordered_map>
#include <vector>
#include <boost/container/flat_map.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <boost/serialization/unordered_map.hpp>
#include "common/common_types.h"
#include "core/file_sys/archive_backend.h"
#include "core/hle/result.h"
@ -253,13 +254,21 @@ private:
* Map of registered archives, identified by id code. Once an archive is registered here, it is
* never removed until UnregisterArchiveTypes is called.
*/
boost::container::flat_map<ArchiveIdCode, std::unique_ptr<ArchiveFactory>> id_code_map;
std::unordered_map<ArchiveIdCode, std::unique_ptr<ArchiveFactory>> id_code_map;
/**
* Map of active archive handles to archive objects
*/
std::unordered_map<ArchiveHandle, std::unique_ptr<ArchiveBackend>> handle_map;
ArchiveHandle next_handle = 1;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& id_code_map;
ar& handle_map;
ar& next_handle;
}
friend class boost::serialization::access;
};
} // namespace Service::FS

View file

@ -2,16 +2,33 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include "common/archives.h"
#include "common/logging/log.h"
#include "core/file_sys/directory_backend.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/fs/directory.h"
SERIALIZE_EXPORT_IMPL(Service::FS::Directory)
namespace Service::FS {
template <class Archive>
void Directory::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& path;
ar& backend;
}
Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend,
const FileSys::Path& path)
: ServiceFramework("", 1), path(path), backend(std::move(backend)) {
: Directory() {
this->backend = std::move(backend);
this->path = path;
}
Directory::Directory() : ServiceFramework("", 1), path(""), backend(nullptr) {
static const FunctionInfo functions[] = {
// clang-format off
{0x08010042, &Directory::Read, "Read"},

View file

@ -25,6 +25,15 @@ public:
protected:
void Read(Kernel::HLERequestContext& ctx);
void Close(Kernel::HLERequestContext& ctx);
private:
Directory();
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
} // namespace Service::FS
BOOST_CLASS_EXPORT_KEY(Service::FS::Directory)

View file

@ -2,6 +2,8 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include <boost/serialization/unique_ptr.hpp>
#include "common/archives.h"
#include "common/logging/log.h"
#include "core/core.h"
#include "core/file_sys/errors.h"
@ -13,11 +15,29 @@
#include "core/hle/kernel/server_session.h"
#include "core/hle/service/fs/file.h"
SERIALIZE_EXPORT_IMPL(Service::FS::File)
SERIALIZE_EXPORT_IMPL(Service::FS::FileSessionSlot)
namespace Service::FS {
File::File(Core::System& system, std::unique_ptr<FileSys::FileBackend>&& backend,
template <class Archive>
void File::serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& path;
ar& backend;
}
File::File() : File(Core::Global<Kernel::KernelSystem>()) {}
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) {
: File(kernel) {
this->backend = std::move(backend);
this->path = path;
}
File::File(Kernel::KernelSystem& kernel)
: ServiceFramework("", 1), path(""), backend(nullptr), kernel(kernel) {
static const FunctionInfo functions[] = {
{0x08010100, &File::OpenSubFile, "OpenSubFile"},
{0x080200C2, &File::Read, "Read"},
@ -71,12 +91,7 @@ void File::Read(Kernel::HLERequestContext& ctx) {
rb.PushMappedBuffer(buffer);
std::chrono::nanoseconds read_timeout_ns{backend->GetReadDelayNs(length)};
ctx.SleepClientThread("file::read", read_timeout_ns,
[](std::shared_ptr<Kernel::Thread> /*thread*/,
Kernel::HLERequestContext& /*ctx*/,
Kernel::ThreadWakeupReason /*reason*/) {
// Nothing to do here
});
ctx.SleepClientThread("file::read", read_timeout_ns, nullptr);
}
void File::Write(Kernel::HLERequestContext& ctx) {
@ -201,7 +216,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);
@ -247,7 +262,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);
@ -261,7 +276,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);

View file

@ -5,7 +5,9 @@
#pragma once
#include <memory>
#include <boost/serialization/base_object.hpp>
#include "core/file_sys/archive_backend.h"
#include "core/global.h"
#include "core/hle/service/service.h"
namespace Core {
@ -19,13 +21,25 @@ struct FileSessionSlot : public Kernel::SessionRequestHandler::SessionDataBase {
u64 offset; ///< Offset that this session will start reading from.
u64 size; ///< Max size of the file that this session is allowed to access
bool subfile; ///< Whether this file was opened via OpenSubFile or not.
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler::SessionDataBase>(
*this);
ar& priority;
ar& offset;
ar& size;
ar& subfile;
}
friend class boost::serialization::access;
};
// TODO: File is not a real service, but it can still utilize ServiceFramework::RegisterHandlers.
// 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 +73,17 @@ private:
void OpenLinkFile(Kernel::HLERequestContext& ctx);
void OpenSubFile(Kernel::HLERequestContext& ctx);
Core::System& system;
Kernel::KernelSystem& kernel;
File(Kernel::KernelSystem& kernel);
File();
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
} // namespace Service::FS
BOOST_CLASS_EXPORT_KEY(Service::FS::FileSessionSlot)
BOOST_CLASS_EXPORT_KEY(Service::FS::File)

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <cinttypes>
#include "common/archives.h"
#include "common/assert.h"
#include "common/common_types.h"
#include "common/file_util.h"
@ -25,6 +26,10 @@
#include "core/hle/service/fs/fs_user.h"
#include "core/settings.h"
SERVICE_CONSTRUCT_IMPL(Service::FS::FS_USER)
SERIALIZE_EXPORT_IMPL(Service::FS::FS_USER)
SERIALIZE_EXPORT_IMPL(Service::FS::ClientSlot)
////////////////////////////////////////////////////////////////////////////////////////////////////
// Namespace FS_User
@ -71,12 +76,7 @@ void FS_USER::OpenFile(Kernel::HLERequestContext& ctx) {
LOG_ERROR(Service_FS, "failed to get a handle for file {}", file_path.DebugStr());
}
ctx.SleepClientThread("fs_user::open", open_timeout_ns,
[](std::shared_ptr<Kernel::Thread> /*thread*/,
Kernel::HLERequestContext& /*ctx*/,
Kernel::ThreadWakeupReason /*reason*/) {
// Nothing to do here
});
ctx.SleepClientThread("fs_user::open", open_timeout_ns, nullptr);
}
void FS_USER::OpenFileDirectly(Kernel::HLERequestContext& ctx) {
@ -129,12 +129,7 @@ void FS_USER::OpenFileDirectly(Kernel::HLERequestContext& ctx) {
file_path.DebugStr(), mode.hex, attributes);
}
ctx.SleepClientThread("fs_user::open_directly", open_timeout_ns,
[](std::shared_ptr<Kernel::Thread> /*thread*/,
Kernel::HLERequestContext& /*ctx*/,
Kernel::ThreadWakeupReason /*reason*/) {
// Nothing to do here
});
ctx.SleepClientThread("fs_user::open_directly", open_timeout_ns, nullptr);
}
void FS_USER::DeleteFile(Kernel::HLERequestContext& ctx) {

View file

@ -4,6 +4,7 @@
#pragma once
#include <boost/serialization/base_object.hpp>
#include "common/common_types.h"
#include "core/hle/service/service.h"
@ -22,6 +23,15 @@ struct ClientSlot : public Kernel::SessionRequestHandler::SessionDataBase {
// behaviour is modified. Since we don't emulate fs:REG mechanism, we assume the program ID is
// the same as codeset ID and fetch from there directly.
u64 program_id = 0;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler::SessionDataBase>(
*this);
ar& program_id;
}
friend class boost::serialization::access;
};
class FS_USER final : public ServiceFramework<FS_USER, ClientSlot> {
@ -545,8 +555,19 @@ private:
Core::System& system;
ArchiveManager& archives;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& priority;
}
friend class boost::serialization::access;
};
void InstallInterfaces(Core::System& system);
} // namespace Service::FS
SERVICE_CONSTRUCT(Service::FS::FS_USER)
BOOST_CLASS_EXPORT_KEY(Service::FS::FS_USER)
BOOST_CLASS_EXPORT_KEY(Service::FS::ClientSlot)

View file

@ -27,4 +27,8 @@ void InstallInterfaces(Core::System& system) {
std::make_shared<GSP_LCD>()->InstallAsService(service_manager);
}
void SetGlobalModule(Core::System& system) {
gsp_gpu = system.ServiceManager().GetService<GSP_GPU>("gsp::Gpu");
}
} // namespace Service::GSP

View file

@ -23,4 +23,6 @@ namespace Service::GSP {
void SignalInterrupt(InterruptId interrupt_id);
void InstallInterfaces(Core::System& system);
void SetGlobalModule(Core::System& system);
} // namespace Service::GSP

View file

@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <vector>
#include "common/archives.h"
#include "common/bit_field.h"
#include "common/microprofile.h"
#include "common/swap.h"
@ -21,6 +22,10 @@
#include "video_core/debug_utils/debug_utils.h"
#include "video_core/gpu_debugger.h"
SERIALIZE_EXPORT_IMPL(Service::GSP::SessionData)
SERIALIZE_EXPORT_IMPL(Service::GSP::GSP_GPU)
SERVICE_CONSTRUCT_IMPL(Service::GSP::GSP_GPU)
// Main graphics debugger object - TODO: Here is probably not the best place for this
GraphicsDebugger g_debugger;
@ -819,10 +824,6 @@ std::unique_ptr<Kernel::SessionRequestHandler::SessionDataBase> GSP_GPU::MakeSes
return std::make_unique<SessionData>(this);
}
SessionData::SessionData() {
UNREACHABLE();
}
SessionData::SessionData(GSP_GPU* gsp) : gsp(gsp) {
// Assign a new thread id to this session when it connects. Note: In the real GSP service this
// is done through a real thread (svcCreateThread) but we have to simulate it since our HLE

View file

@ -7,6 +7,8 @@
#include <cstddef>
#include <memory>
#include <string>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include "common/bit_field.h"
#include "common/common_types.h"
#include "core/hle/kernel/event.h"
@ -187,7 +189,7 @@ class GSP_GPU;
class SessionData : public Kernel::SessionRequestHandler::SessionDataBase {
public:
SessionData();
SessionData() = default;
SessionData(GSP_GPU* gsp);
~SessionData();
@ -199,6 +201,18 @@ public:
u32 thread_id;
/// Whether RegisterInterruptRelayQueue was called for this session
bool registered = false;
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler::SessionDataBase>(
*this);
ar& gsp;
ar& interrupt_event;
ar& thread_id;
ar& registered;
}
friend class boost::serialization::access;
};
class GSP_GPU final : public ServiceFramework<GSP_GPU, SessionData> {
@ -431,8 +445,23 @@ private:
std::array<bool, MaxGSPThreads> used_thread_ids = {false, false, false, false};
friend class SessionData;
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& boost::serialization::base_object<Kernel::SessionRequestHandler>(*this);
ar& shared_memory;
ar& active_thread_id;
ar& first_initialization;
ar& used_thread_ids;
}
friend class boost::serialization::access;
};
ResultCode SetBufferSwap(u32 screen_id, const FrameBufferInfo& info);
} // namespace Service::GSP
BOOST_CLASS_EXPORT_KEY(Service::GSP::SessionData)
BOOST_CLASS_EXPORT_KEY(Service::GSP::GSP_GPU)
SERVICE_CONSTRUCT(Service::GSP::GSP_GPU)

View file

@ -2,9 +2,12 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/ipc_helpers.h"
#include "core/hle/service/gsp/gsp_lcd.h"
SERIALIZE_EXPORT_IMPL(Service::GSP::GSP_LCD)
namespace Service::GSP {
GSP_LCD::GSP_LCD() : ServiceFramework("gsp::Lcd") {

View file

@ -12,6 +12,11 @@ class GSP_LCD final : public ServiceFramework<GSP_LCD> {
public:
GSP_LCD();
~GSP_LCD() = default;
private:
SERVICE_SERIALIZATION_SIMPLE
};
} // namespace Service::GSP
BOOST_CLASS_EXPORT_KEY(Service::GSP::GSP_LCD)

View file

@ -4,6 +4,10 @@
#include <algorithm>
#include <cmath>
#include <boost/serialization/array.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include "common/archives.h"
#include "common/logging/log.h"
#include "core/3ds.h"
#include "core/core.h"
@ -20,8 +24,36 @@
#include "core/movie.h"
#include "video_core/video_core.h"
SERVICE_CONSTRUCT_IMPL(Service::HID::Module)
SERIALIZE_EXPORT_IMPL(Service::HID::Module)
namespace Service::HID {
template <class Archive>
void Module::serialize(Archive& ar, const unsigned int file_version) {
ar& shared_mem;
ar& event_pad_or_touch_1;
ar& event_pad_or_touch_2;
ar& event_accelerometer;
ar& event_gyroscope;
ar& event_debug_pad;
ar& next_pad_index;
ar& next_touch_index;
ar& next_accelerometer_index;
ar& next_gyroscope_index;
ar& enable_accelerometer_count;
ar& enable_gyroscope_count;
if (Archive::is_loading::value) {
LoadInputDevices();
}
if (file_version >= 1) {
ar& state.hex;
}
// Update events are set in the constructor
// Devices are set from the implementation (and are stateless afaik)
}
SERIALIZE_IMPL(Module)
// Updating period for each HID device. These empirical values are measured from a 11.2 3DS.
constexpr u64 pad_update_ticks = BASE_CLOCK_RATE_ARM11 / 234;
constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE_ARM11 / 104;

View file

@ -8,6 +8,7 @@
#include <atomic>
#include <cstddef>
#include <memory>
#include <boost/serialization/version.hpp>
#include "common/bit_field.h"
#include "common/common_funcs.h"
#include "common/common_types.h"
@ -287,7 +288,7 @@ public:
*/
void GetGyroscopeLowCalibrateParam(Kernel::HLERequestContext& ctx);
private:
protected:
std::shared_ptr<Module> hid;
};
@ -335,9 +336,17 @@ private:
std::unique_ptr<Input::AnalogDevice> circle_pad;
std::unique_ptr<Input::MotionDevice> motion_device;
std::unique_ptr<Input::TouchDevice> touch_device;
template <class Archive>
void serialize(Archive& ar, const unsigned int);
friend class boost::serialization::access;
};
std::shared_ptr<Module> GetModule(Core::System& system);
void InstallInterfaces(Core::System& system);
} // namespace Service::HID
SERVICE_CONSTRUCT(Service::HID::Module)
BOOST_CLASS_EXPORT_KEY(Service::HID::Module)
BOOST_CLASS_VERSION(Service::HID::Module, 1)

View file

@ -2,8 +2,11 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/archives.h"
#include "core/hle/service/hid/hid_spvr.h"
SERIALIZE_EXPORT_IMPL(Service::HID::Spvr)
namespace Service::HID {
Spvr::Spvr(std::shared_ptr<Module> hid) : Module::Interface(std::move(hid), "hid:SPVR", 6) {

Some files were not shown because too many files have changed in this diff Show more