diff --git a/src/core/core.cpp b/src/core/core.cpp index 9fb520fe5..f16e083a8 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp @@ -194,7 +194,7 @@ System::ResultStatus System::Init(EmuWindow& emu_window, u32 system_mode) { HW::Init(); Kernel::Init(system_mode); - Service::Init(service_manager); + Service::Init(*this, service_manager); GDBStub::Init(); ResultStatus result = VideoCore::Init(emu_window); diff --git a/src/core/hle/service/ac/ac.cpp b/src/core/hle/service/ac/ac.cpp index e0340c1f1..9d40b9661 100644 --- a/src/core/hle/service/ac/ac.cpp +++ b/src/core/hle/service/ac/ac.cpp @@ -5,6 +5,7 @@ #include #include "common/common_types.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" @@ -171,7 +172,8 @@ void Module::Interface::SetClientVersion(Kernel::HLERequestContext& ctx) { Module::Interface::Interface(std::shared_ptr ac, const char* name, u32 max_session) : ServiceFramework(name, max_session), ac(std::move(ac)) {} -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto ac = std::make_shared(); std::make_shared(ac)->InstallAsService(service_manager); std::make_shared(ac)->InstallAsService(service_manager); diff --git a/src/core/hle/service/ac/ac.h b/src/core/hle/service/ac/ac.h index 805e0840e..6721ec8de 100644 --- a/src/core/hle/service/ac/ac.h +++ b/src/core/hle/service/ac/ac.h @@ -9,6 +9,10 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class Event; } @@ -152,6 +156,6 @@ protected: Kernel::SharedPtr disconnect_event; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::AC diff --git a/src/core/hle/service/act/act.cpp b/src/core/hle/service/act/act.cpp index 9827aa8dc..c2d295636 100644 --- a/src/core/hle/service/act/act.cpp +++ b/src/core/hle/service/act/act.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/act/act.h" #include "core/hle/service/act/act_a.h" #include "core/hle/service/act/act_u.h" @@ -13,7 +14,8 @@ Module::Interface::Interface(std::shared_ptr act, const char* name) Module::Interface::~Interface() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto act = std::make_shared(); std::make_shared(act)->InstallAsService(service_manager); std::make_shared(act)->InstallAsService(service_manager); diff --git a/src/core/hle/service/act/act.h b/src/core/hle/service/act/act.h index 357496b59..884678890 100644 --- a/src/core/hle/service/act/act.h +++ b/src/core/hle/service/act/act.h @@ -6,6 +6,10 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::ACT { /// Initializes all ACT services @@ -21,6 +25,6 @@ public: }; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::ACT diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 05be6ef32..5e22d8280 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp @@ -12,6 +12,7 @@ #include "common/file_util.h" #include "common/logging/log.h" #include "common/string_util.h" +#include "core/core.h" #include "core/file_sys/errors.h" #include "core/file_sys/ncch_container.h" #include "core/file_sys/title_metadata.h" @@ -1462,7 +1463,8 @@ Module::Module() { Module::~Module() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto am = std::make_shared(); std::make_shared(am)->InstallAsService(service_manager); std::make_shared(am)->InstallAsService(service_manager); diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index dc10af0db..543dbd8fe 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h @@ -16,6 +16,10 @@ #include "core/hle/result.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::FS { enum class MediaType : u32; } @@ -574,6 +578,6 @@ private: Kernel::SharedPtr system_updater_mutex; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::AM diff --git a/src/core/hle/service/apt/apt.cpp b/src/core/hle/service/apt/apt.cpp index 682a57597..a642cefb9 100644 --- a/src/core/hle/service/apt/apt.cpp +++ b/src/core/hle/service/apt/apt.cpp @@ -182,7 +182,8 @@ void Module::Interface::GetSharedFont(Kernel::HLERequestContext& ctx) { IPC::RequestBuilder rb = rp.MakeBuilder(2, 2); // Log in telemetry if the game uses the shared font - Core::Telemetry().AddField(Telemetry::FieldType::Session, "RequiresSharedFont", true); + apt->system.TelemetrySession().AddField(Telemetry::FieldType::Session, "RequiresSharedFont", + true); if (!apt->shared_font_loaded) { // On real 3DS, font loading happens on booting. However, we load it on demand to coordinate @@ -197,8 +198,7 @@ void Module::Interface::GetSharedFont(Kernel::HLERequestContext& ctx) { rb.Push(-1); // TODO: Find the right error code rb.Push(0); rb.PushCopyObjects(nullptr); - Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorSystemFiles, - "Shared fonts"); + apt->system.SetStatus(Core::System::ResultStatus::ErrorSystemFiles, "Shared fonts"); return; } } @@ -544,7 +544,7 @@ void Module::Interface::CloseApplication(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_APT, "called"); - Core::System::GetInstance().RequestShutdown(); + apt->system.RequestShutdown(); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); @@ -584,11 +584,11 @@ void Module::Interface::DoApplicationJump(Kernel::HLERequestContext& ctx) { if (application_reset_prepared) { // Reset system - Core::System::GetInstance().RequestReset(); + apt->system.RequestReset(); } else { // After the jump, the application should shutdown // TODO: Actually implement the jump - Core::System::GetInstance().RequestShutdown(); + apt->system.RequestShutdown(); } IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); @@ -843,7 +843,7 @@ Module::Interface::Interface(std::shared_ptr apt, const char* name, u32 Module::Interface::~Interface() = default; -Module::Module() { +Module::Module(Core::System& system) : system(system) { applet_manager = std::make_shared(); using Kernel::MemoryPermission; @@ -857,8 +857,9 @@ Module::Module() { Module::~Module() {} -void InstallInterfaces(SM::ServiceManager& service_manager) { - auto apt = std::make_shared(); +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); + auto apt = std::make_shared(system); std::make_shared(apt)->InstallAsService(service_manager); std::make_shared(apt)->InstallAsService(service_manager); std::make_shared(apt)->InstallAsService(service_manager); diff --git a/src/core/hle/service/apt/apt.h b/src/core/hle/service/apt/apt.h index bd4008e6e..a54025ad3 100644 --- a/src/core/hle/service/apt/apt.h +++ b/src/core/hle/service/apt/apt.h @@ -11,6 +11,10 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class Mutex; class SharedMemory; @@ -52,7 +56,7 @@ enum class ScreencapPostPermission : u32 { class Module final { public: - Module(); + explicit Module(Core::System& system); ~Module(); class Interface : public ServiceFramework { @@ -582,6 +586,8 @@ private: bool LoadSharedFont(); bool LoadLegacySharedFont(); + Core::System& system; + /// Handle to shared memory region designated to for shared system font Kernel::SharedPtr shared_font_mem; bool shared_font_loaded = false; @@ -602,6 +608,6 @@ private: std::shared_ptr applet_manager; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::APT diff --git a/src/core/hle/service/boss/boss.cpp b/src/core/hle/service/boss/boss.cpp index a417fe008..8dd21ab3b 100644 --- a/src/core/hle/service/boss/boss.cpp +++ b/src/core/hle/service/boss/boss.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/result.h" #include "core/hle/service/boss/boss.h" @@ -908,7 +909,8 @@ Module::Module() { task_finish_event = Event::Create(Kernel::ResetType::OneShot, "BOSS::task_finish_event"); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto boss = std::make_shared(); std::make_shared(boss)->InstallAsService(service_manager); std::make_shared(boss)->InstallAsService(service_manager); diff --git a/src/core/hle/service/boss/boss.h b/src/core/hle/service/boss/boss.h index 873170b03..222f88066 100644 --- a/src/core/hle/service/boss/boss.h +++ b/src/core/hle/service/boss/boss.h @@ -7,6 +7,10 @@ #include "core/hle/kernel/event.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::BOSS { class Module final { @@ -960,6 +964,6 @@ private: Kernel::SharedPtr task_finish_event; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::BOSS diff --git a/src/core/hle/service/cam/cam.cpp b/src/core/hle/service/cam/cam.cpp index 3cf3bf755..af027bd85 100644 --- a/src/core/hle/service/cam/cam.cpp +++ b/src/core/hle/service/cam/cam.cpp @@ -5,6 +5,7 @@ #include #include "common/bit_set.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/core_timing.h" #include "core/frontend/camera/factory.h" #include "core/hle/ipc.h" @@ -1054,7 +1055,8 @@ void ReloadCameraDevices() { cam->ReloadCameraDevices(); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto cam = std::make_shared(); current_cam = cam; diff --git a/src/core/hle/service/cam/cam.h b/src/core/hle/service/cam/cam.h index b0145dead..319debfdb 100644 --- a/src/core/hle/service/cam/cam.h +++ b/src/core/hle/service/cam/cam.h @@ -13,6 +13,10 @@ #include "core/hle/result.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Camera { class CameraInterface; } @@ -782,6 +786,6 @@ private: /// Reload camera devices. Used when input configuration changed void ReloadCameraDevices(); -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::CAM diff --git a/src/core/hle/service/cecd/cecd.cpp b/src/core/hle/service/cecd/cecd.cpp index 6e338dd54..451a5ce84 100644 --- a/src/core/hle/service/cecd/cecd.cpp +++ b/src/core/hle/service/cecd/cecd.cpp @@ -9,6 +9,7 @@ #include "common/file_util.h" #include "common/logging/log.h" #include "common/string_util.h" +#include "core/core.h" #include "core/file_sys/archive_systemsavedata.h" #include "core/file_sys/directory_backend.h" #include "core/file_sys/errors.h" @@ -1430,7 +1431,8 @@ Module::Module() { Module::~Module() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto cecd = std::make_shared(); std::make_shared(cecd)->InstallAsService(service_manager); std::make_shared(cecd)->InstallAsService(service_manager); diff --git a/src/core/hle/service/cecd/cecd.h b/src/core/hle/service/cecd/cecd.h index 079589a0e..929f0f397 100644 --- a/src/core/hle/service/cecd/cecd.h +++ b/src/core/hle/service/cecd/cecd.h @@ -15,6 +15,10 @@ class ArchiveBackend; class FileBackend; } // namespace FileSys +namespace Core { +class System; +} + namespace Service::CECD { class Module final { @@ -609,6 +613,6 @@ private: }; /// Initialize CECD service(s) -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::CECD diff --git a/src/core/hle/service/cfg/cfg.cpp b/src/core/hle/service/cfg/cfg.cpp index ebdd190b5..c07fb6bd4 100644 --- a/src/core/hle/service/cfg/cfg.cpp +++ b/src/core/hle/service/cfg/cfg.cpp @@ -11,6 +11,7 @@ #include "common/logging/log.h" #include "common/string_util.h" #include "common/swap.h" +#include "core/core.h" #include "core/file_sys/archive_systemsavedata.h" #include "core/file_sys/errors.h" #include "core/file_sys/file_backend.h" @@ -721,7 +722,8 @@ u64 Module::GetConsoleUniqueId() { return console_id_le; } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto cfg = std::make_shared(); std::make_shared(cfg)->InstallAsService(service_manager); std::make_shared(cfg)->InstallAsService(service_manager); diff --git a/src/core/hle/service/cfg/cfg.h b/src/core/hle/service/cfg/cfg.h index 568e27853..02342711f 100644 --- a/src/core/hle/service/cfg/cfg.h +++ b/src/core/hle/service/cfg/cfg.h @@ -15,6 +15,10 @@ namespace FileSys { class ArchiveBackend; } +namespace Core { +class System; +} + namespace Service::CFG { enum SystemModel { @@ -407,7 +411,7 @@ private: u32 preferred_region_code = 0; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); std::shared_ptr GetCurrentModule(); } // namespace Service::CFG diff --git a/src/core/hle/service/csnd/csnd_snd.cpp b/src/core/hle/service/csnd/csnd_snd.cpp index 2b42cba3f..6e0488b3a 100644 --- a/src/core/hle/service/csnd/csnd_snd.cpp +++ b/src/core/hle/service/csnd/csnd_snd.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "common/alignment.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/result.h" #include "core/hle/service/csnd/csnd_snd.h" @@ -193,7 +194,8 @@ CSND_SND::CSND_SND() : ServiceFramework("csnd:SND", 4) { RegisterHandlers(functions); }; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/csnd/csnd_snd.h b/src/core/hle/service/csnd/csnd_snd.h index b8d19e116..909034e6d 100644 --- a/src/core/hle/service/csnd/csnd_snd.h +++ b/src/core/hle/service/csnd/csnd_snd.h @@ -8,6 +8,10 @@ #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::CSND { class CSND_SND final : public ServiceFramework { @@ -178,6 +182,6 @@ private: }; /// Initializes the CSND_SND Service -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::CSND diff --git a/src/core/hle/service/dlp/dlp.cpp b/src/core/hle/service/dlp/dlp.cpp index 87d428423..edbd22321 100644 --- a/src/core/hle/service/dlp/dlp.cpp +++ b/src/core/hle/service/dlp/dlp.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/dlp/dlp.h" #include "core/hle/service/dlp/dlp_clnt.h" #include "core/hle/service/dlp/dlp_fkcl.h" @@ -9,7 +10,8 @@ namespace Service::DLP { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); diff --git a/src/core/hle/service/dlp/dlp.h b/src/core/hle/service/dlp/dlp.h index f2c925f70..28fb73718 100644 --- a/src/core/hle/service/dlp/dlp.h +++ b/src/core/hle/service/dlp/dlp.h @@ -6,9 +6,13 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::DLP { /// Initializes the DLP services. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::DLP diff --git a/src/core/hle/service/dsp/dsp_dsp.cpp b/src/core/hle/service/dsp/dsp_dsp.cpp index 6b4157ae0..fa1ddd4c9 100644 --- a/src/core/hle/service/dsp/dsp_dsp.cpp +++ b/src/core/hle/service/dsp/dsp_dsp.cpp @@ -399,7 +399,8 @@ DSP_DSP::~DSP_DSP() { pipes = {}; } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto dsp = std::make_shared(); dsp->InstallAsService(service_manager); Core::DSP().SetServiceToInterrupt(std::move(dsp)); diff --git a/src/core/hle/service/dsp/dsp_dsp.h b/src/core/hle/service/dsp/dsp_dsp.h index b030c8ff3..506a1f9f4 100644 --- a/src/core/hle/service/dsp/dsp_dsp.h +++ b/src/core/hle/service/dsp/dsp_dsp.h @@ -9,6 +9,10 @@ #include "core/hle/result.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::DSP { class DSP_DSP final : public ServiceFramework { @@ -250,6 +254,6 @@ private: std::array, AudioCore::num_dsp_pipe> pipes = {{}}; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::DSP diff --git a/src/core/hle/service/err_f.cpp b/src/core/hle/service/err_f.cpp index e76a21a6a..9a914ee7b 100644 --- a/src/core/hle/service/err_f.cpp +++ b/src/core/hle/service/err_f.cpp @@ -154,7 +154,7 @@ void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) { LOG_CRITICAL(Service_ERR, "Fatal error"); const ErrInfo errinfo = rp.PopRaw(); LOG_CRITICAL(Service_ERR, "Fatal error type: {}", GetErrType(errinfo.errinfo_common.specifier)); - Core::System::GetInstance().SetStatus(Core::System::ResultStatus::ErrorUnknown); + system.SetStatus(Core::System::ResultStatus::ErrorUnknown); // Generic Info LogGenericInfo(errinfo.errinfo_common); @@ -232,7 +232,7 @@ void ERR_F::ThrowFatalError(Kernel::HLERequestContext& ctx) { rb.Push(RESULT_SUCCESS); } -ERR_F::ERR_F() : ServiceFramework("err:f", 1) { +ERR_F::ERR_F(Core::System& system) : ServiceFramework("err:f", 1), system(system) { static const FunctionInfo functions[] = { {0x00010800, &ERR_F::ThrowFatalError, "ThrowFatalError"}, {0x00020042, nullptr, "SetUserString"}, @@ -242,8 +242,8 @@ ERR_F::ERR_F() : ServiceFramework("err:f", 1) { ERR_F::~ERR_F() = default; -void InstallInterfaces() { - auto errf = std::make_shared(); +void InstallInterfaces(Core::System& system) { + auto errf = std::make_shared(system); errf->InstallAsNamedPort(); } diff --git a/src/core/hle/service/err_f.h b/src/core/hle/service/err_f.h index 1f4f3808e..4a1684caf 100644 --- a/src/core/hle/service/err_f.h +++ b/src/core/hle/service/err_f.h @@ -6,6 +6,10 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class HLERequestContext; } @@ -15,7 +19,7 @@ namespace Service::ERR { /// Interface to "err:f" service class ERR_F final : public ServiceFramework { public: - ERR_F(); + explicit ERR_F(Core::System& system); ~ERR_F(); private: @@ -28,8 +32,10 @@ private: * 1 : Result code */ void ThrowFatalError(Kernel::HLERequestContext& ctx); + + Core::System& system; }; -void InstallInterfaces(); +void InstallInterfaces(Core::System& system); } // namespace Service::ERR diff --git a/src/core/hle/service/frd/frd.cpp b/src/core/hle/service/frd/frd.cpp index 37ac87c41..69f2a4462 100644 --- a/src/core/hle/service/frd/frd.cpp +++ b/src/core/hle/service/frd/frd.cpp @@ -7,6 +7,7 @@ #include "common/assert.h" #include "common/logging/log.h" #include "common/string_util.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/result.h" #include "core/hle/service/frd/frd.h" @@ -149,7 +150,8 @@ void Module::Interface::SetClientSdkVersion(Kernel::HLERequestContext& ctx) { Module::Module() = default; Module::~Module() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto frd = std::make_shared(); std::make_shared(frd)->InstallAsService(service_manager); std::make_shared(frd)->InstallAsService(service_manager); diff --git a/src/core/hle/service/frd/frd.h b/src/core/hle/service/frd/frd.h index 87a5e1972..200b51ebe 100644 --- a/src/core/hle/service/frd/frd.h +++ b/src/core/hle/service/frd/frd.h @@ -8,6 +8,10 @@ #include "common/common_types.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::FRD { struct FriendKey { @@ -135,6 +139,6 @@ private: MyPresence my_presence = {}; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::FRD diff --git a/src/core/hle/service/fs/fs_user.cpp b/src/core/hle/service/fs/fs_user.cpp index 4c5d53bc7..daa7bb237 100644 --- a/src/core/hle/service/fs/fs_user.cpp +++ b/src/core/hle/service/fs/fs_user.cpp @@ -853,7 +853,8 @@ FS_USER::FS_USER() : ServiceFramework("fs:USER", 30) { RegisterHandlers(functions); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } } // namespace Service::FS diff --git a/src/core/hle/service/fs/fs_user.h b/src/core/hle/service/fs/fs_user.h index 728c4ef0f..d8a044dd9 100644 --- a/src/core/hle/service/fs/fs_user.h +++ b/src/core/hle/service/fs/fs_user.h @@ -7,6 +7,10 @@ #include "common/common_types.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::FS { class FS_USER final : public ServiceFramework { @@ -517,6 +521,6 @@ private: u32 priority = -1; ///< For SetPriority and GetPriority service functions }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::FS diff --git a/src/core/hle/service/gsp/gsp.cpp b/src/core/hle/service/gsp/gsp.cpp index f5fe99f5d..27a14ff52 100644 --- a/src/core/hle/service/gsp/gsp.cpp +++ b/src/core/hle/service/gsp/gsp.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "core/core.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/gsp/gsp.h" @@ -23,8 +24,9 @@ void SignalInterrupt(InterruptId interrupt_id) { return gpu->SignalInterrupt(interrupt_id); } -void InstallInterfaces(SM::ServiceManager& service_manager) { - auto gpu = std::make_shared(); +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); + auto gpu = std::make_shared(system); gpu->InstallAsService(service_manager); gsp_gpu = gpu; diff --git a/src/core/hle/service/gsp/gsp.h b/src/core/hle/service/gsp/gsp.h index 0e1017b5d..2b565bc7e 100644 --- a/src/core/hle/service/gsp/gsp.h +++ b/src/core/hle/service/gsp/gsp.h @@ -11,6 +11,10 @@ #include "core/hle/service/gsp/gsp_gpu.h" #include "core/hle/service/gsp/gsp_lcd.h" +namespace Core { +class System; +} + namespace Service::GSP { /** * Retrieves the framebuffer info stored in the GSP shared memory for the @@ -27,5 +31,5 @@ FrameBufferUpdate* GetFrameBufferInfo(u32 thread_id, u32 screen_index); */ void SignalInterrupt(InterruptId interrupt_id); -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::GSP diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index d9aad5ea5..be2a7ca64 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -731,7 +731,7 @@ void GSP_GPU::SetLedForceOff(Kernel::HLERequestContext& ctx) { u8 state = rp.Pop(); - Core::System::GetInstance().GetSharedPageHandler()->Set3DLed(state); + system.GetSharedPageHandler()->Set3DLed(state); IPC::RequestBuilder rb = rp.MakeBuilder(1, 0); rb.Push(RESULT_SUCCESS); @@ -749,7 +749,7 @@ SessionData* GSP_GPU::FindRegisteredThreadData(u32 thread_id) { return nullptr; } -GSP_GPU::GSP_GPU() : ServiceFramework("gsp::Gpu", 2) { +GSP_GPU::GSP_GPU(Core::System& system) : ServiceFramework("gsp::Gpu", 2), system(system) { static const FunctionInfo functions[] = { {0x00010082, &GSP_GPU::WriteHWRegs, "WriteHWRegs"}, {0x00020084, &GSP_GPU::WriteHWRegsWithMask, "WriteHWRegsWithMask"}, diff --git a/src/core/hle/service/gsp/gsp_gpu.h b/src/core/hle/service/gsp/gsp_gpu.h index da36a5f09..593d05ea2 100644 --- a/src/core/hle/service/gsp/gsp_gpu.h +++ b/src/core/hle/service/gsp/gsp_gpu.h @@ -13,6 +13,10 @@ #include "core/hle/result.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class SharedMemory; } // namespace Kernel @@ -192,7 +196,7 @@ struct SessionData : public Kernel::SessionRequestHandler::SessionDataBase { class GSP_GPU final : public ServiceFramework { public: - GSP_GPU(); + explicit GSP_GPU(Core::System& system); ~GSP_GPU() = default; void ClientDisconnected(Kernel::SharedPtr server_session) override; @@ -399,6 +403,8 @@ private: /// Returns the session data for the specified registered thread id, or nullptr if not found. SessionData* FindRegisteredThreadData(u32 thread_id); + Core::System& system; + /// GSP shared memory Kernel::SharedPtr shared_memory; diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 32837a870..4d183c014 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -219,7 +219,7 @@ void Module::UpdateGyroscopeCallback(u64 userdata, s64 cycles_late) { Math::Vec3 gyro; std::tie(std::ignore, gyro) = motion_device->GetStatus(); - double stretch = Core::System::GetInstance().perf_stats.GetLastFrameTimeScale(); + double stretch = system.perf_stats.GetLastFrameTimeScale(); gyro *= gyroscope_coef * static_cast(stretch); gyroscope_entry.x = static_cast(gyro.x); gyroscope_entry.y = static_cast(gyro.y); @@ -354,7 +354,7 @@ void Module::Interface::GetSoundVolume(Kernel::HLERequestContext& ctx) { Module::Interface::Interface(std::shared_ptr hid, const char* name, u32 max_session) : ServiceFramework(name, max_session), hid(std::move(hid)) {} -Module::Module() { +Module::Module(Core::System& system) : system(system) { using namespace Kernel; shared_mem = @@ -393,8 +393,9 @@ void ReloadInputDevices() { hid->ReloadInputDevices(); } -void InstallInterfaces(SM::ServiceManager& service_manager) { - auto hid = std::make_shared(); +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); + auto hid = std::make_shared(system); std::make_shared(hid)->InstallAsService(service_manager); std::make_shared(hid)->InstallAsService(service_manager); current_module = hid; diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 286189df0..ecdb02f21 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -18,6 +18,10 @@ #include "core/hle/service/service.h" #include "core/settings.h" +namespace Core { +class System; +} + namespace Kernel { class Event; class SharedMemory; @@ -198,7 +202,7 @@ DirectionState GetStickDirectionState(s16 circle_pad_x, s16 circle_pad_y); class Module final { public: - Module(); + explicit Module(Core::System& system); class Interface : public ServiceFramework { public: @@ -299,6 +303,8 @@ private: void UpdateAccelerometerCallback(u64 userdata, s64 cycles_late); void UpdateGyroscopeCallback(u64 userdata, s64 cycles_late); + Core::System& system; + // Handle to shared memory region designated to HID_User service Kernel::SharedPtr shared_mem; @@ -329,7 +335,7 @@ private: std::unique_ptr touch_device; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); /// Reload input devices. Used when input configuration changed void ReloadInputDevices(); diff --git a/src/core/hle/service/http_c.cpp b/src/core/hle/service/http_c.cpp index 9f8a20fd9..be12faaa3 100644 --- a/src/core/hle/service/http_c.cpp +++ b/src/core/hle/service/http_c.cpp @@ -4,6 +4,7 @@ #include #include +#include "core/core.h" #include "core/file_sys/archive_ncch.h" #include "core/file_sys/file_backend.h" #include "core/hle/ipc_helpers.h" @@ -581,7 +582,8 @@ HTTP_C::HTTP_C() : ServiceFramework("http:C", 32) { DecryptClCertA(); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } } // namespace Service::HTTP diff --git a/src/core/hle/service/http_c.h b/src/core/hle/service/http_c.h index 2c452cc71..009c5288d 100644 --- a/src/core/hle/service/http_c.h +++ b/src/core/hle/service/http_c.h @@ -12,6 +12,10 @@ #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::HTTP { enum class RequestMethod : u8 { @@ -262,6 +266,6 @@ private: } ClCertA; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::HTTP diff --git a/src/core/hle/service/ir/ir.cpp b/src/core/hle/service/ir/ir.cpp index b9803f0fd..481ef123c 100644 --- a/src/core/hle/service/ir/ir.cpp +++ b/src/core/hle/service/ir/ir.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "core/core.h" #include "core/hle/service/ir/ir.h" #include "core/hle/service/ir/ir_rst.h" #include "core/hle/service/ir/ir_u.h" @@ -22,7 +23,8 @@ void ReloadInputDevices() { ir_rst->ReloadInputDevices(); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); auto ir_user = std::make_shared(); diff --git a/src/core/hle/service/ir/ir.h b/src/core/hle/service/ir/ir.h index 931be77e7..0666ed0b6 100644 --- a/src/core/hle/service/ir/ir.h +++ b/src/core/hle/service/ir/ir.h @@ -4,6 +4,10 @@ #pragma once +namespace Core { +class System; +} + namespace SM { class ServiceManager; } @@ -13,6 +17,6 @@ namespace Service::IR { /// Reload input devices. Used when input configuration changed void ReloadInputDevices(); -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::IR diff --git a/src/core/hle/service/ldr_ro/ldr_ro.cpp b/src/core/hle/service/ldr_ro/ldr_ro.cpp index 07cf68cc8..ceae8be20 100644 --- a/src/core/hle/service/ldr_ro/ldr_ro.cpp +++ b/src/core/hle/service/ldr_ro/ldr_ro.cpp @@ -586,7 +586,8 @@ RO::RO() : ServiceFramework("ldr:ro", 2) { RegisterHandlers(functions); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/ldr_ro/ldr_ro.h b/src/core/hle/service/ldr_ro/ldr_ro.h index 4d3fd5c91..34800f2c7 100644 --- a/src/core/hle/service/ldr_ro/ldr_ro.h +++ b/src/core/hle/service/ldr_ro/ldr_ro.h @@ -7,6 +7,10 @@ #include "core/hle/service/ldr_ro/memory_synchronizer.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::LDR { struct ClientSlot : public Kernel::SessionRequestHandler::SessionDataBase { @@ -149,6 +153,6 @@ private: void Shutdown(Kernel::HLERequestContext& self); }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::LDR diff --git a/src/core/hle/service/mic_u.cpp b/src/core/hle/service/mic_u.cpp index 096d4c862..34e68099f 100644 --- a/src/core/hle/service/mic_u.cpp +++ b/src/core/hle/service/mic_u.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" @@ -290,7 +291,8 @@ MIC_U::MIC_U() : ServiceFramework{"mic:u", 1}, impl{std::make_unique()} { MIC_U::~MIC_U() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/mic_u.h b/src/core/hle/service/mic_u.h index 2f46a277e..8fd835f0a 100644 --- a/src/core/hle/service/mic_u.h +++ b/src/core/hle/service/mic_u.h @@ -8,6 +8,10 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::MIC { class MIC_U final : public ServiceFramework { @@ -186,6 +190,6 @@ private: std::unique_ptr impl; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::MIC diff --git a/src/core/hle/service/mvd/mvd.cpp b/src/core/hle/service/mvd/mvd.cpp index d62e267f2..c865a528b 100644 --- a/src/core/hle/service/mvd/mvd.cpp +++ b/src/core/hle/service/mvd/mvd.cpp @@ -2,12 +2,14 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/mvd/mvd.h" #include "core/hle/service/mvd/mvd_std.h" namespace Service::MVD { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/mvd/mvd.h b/src/core/hle/service/mvd/mvd.h index dc2a6632c..4c4bb06ad 100644 --- a/src/core/hle/service/mvd/mvd.h +++ b/src/core/hle/service/mvd/mvd.h @@ -6,9 +6,13 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::MVD { /// Initializes all MVD services. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::MVD diff --git a/src/core/hle/service/ndm/ndm_u.cpp b/src/core/hle/service/ndm/ndm_u.cpp index 7e2ed79ea..057e68ede 100644 --- a/src/core/hle/service/ndm/ndm_u.cpp +++ b/src/core/hle/service/ndm/ndm_u.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/ndm/ndm_u.h" @@ -236,7 +237,8 @@ NDM_U::NDM_U() : ServiceFramework("ndm:u", 6) { RegisterHandlers(functions); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/ndm/ndm_u.h b/src/core/hle/service/ndm/ndm_u.h index ff348b9f6..5f48a3182 100644 --- a/src/core/hle/service/ndm/ndm_u.h +++ b/src/core/hle/service/ndm/ndm_u.h @@ -7,6 +7,10 @@ #include #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::NDM { class NDM_U final : public ServiceFramework { @@ -268,6 +272,6 @@ private: bool daemon_lock_enabled = false; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::NDM diff --git a/src/core/hle/service/news/news.cpp b/src/core/hle/service/news/news.cpp index b4cb7c8cf..957f05212 100644 --- a/src/core/hle/service/news/news.cpp +++ b/src/core/hle/service/news/news.cpp @@ -3,13 +3,15 @@ // Refer to the license.txt file included. #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/service/news/news_s.h" #include "core/hle/service/news/news_u.h" #include "core/hle/service/service.h" namespace Service::NEWS { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/news/news.h b/src/core/hle/service/news/news.h index f7afc5226..98f3b1583 100644 --- a/src/core/hle/service/news/news.h +++ b/src/core/hle/service/news/news.h @@ -4,8 +4,12 @@ #pragma once +namespace Core { +class System; +} + namespace Service::NEWS { -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::NEWS diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index 40399382a..80bd6aa72 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/service/nfc/nfc.h" @@ -148,7 +149,8 @@ Module::Module() { Module::~Module() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto nfc = std::make_shared(); std::make_shared(nfc)->InstallAsService(service_manager); std::make_shared(nfc)->InstallAsService(service_manager); diff --git a/src/core/hle/service/nfc/nfc.h b/src/core/hle/service/nfc/nfc.h index af296662a..d942e4b63 100644 --- a/src/core/hle/service/nfc/nfc.h +++ b/src/core/hle/service/nfc/nfc.h @@ -9,6 +9,10 @@ #include "core/hle/kernel/kernel.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class Event; } // namespace Kernel @@ -174,6 +178,6 @@ private: CommunicationStatus nfc_status = CommunicationStatus::NfcInitialized; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::NFC diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index 9d393f59f..25dafaa6e 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/nim/nim.h" #include "core/hle/service/nim/nim_aoc.h" #include "core/hle/service/nim/nim_s.h" @@ -9,7 +10,8 @@ namespace Service::NIM { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); diff --git a/src/core/hle/service/nim/nim.h b/src/core/hle/service/nim/nim.h index ec118ff6d..ada03e053 100644 --- a/src/core/hle/service/nim/nim.h +++ b/src/core/hle/service/nim/nim.h @@ -6,8 +6,12 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::NIM { -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::NIM diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index 1ea1f6615..c0fac1d55 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include +#include "core/core.h" #include "core/hle/service/am/am.h" #include "core/hle/service/ns/ns.h" #include "core/hle/service/ns/ns_s.h" @@ -30,7 +31,8 @@ Kernel::SharedPtr LaunchTitle(FS::MediaType media_type, u64 tit return process; } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h index 3175cb74f..f6328dc3a 100644 --- a/src/core/hle/service/ns/ns.h +++ b/src/core/hle/service/ns/ns.h @@ -8,12 +8,16 @@ #include "core/hle/service/fs/archive.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::NS { /// Loads and launches the title identified by title_id in the specified media type. Kernel::SharedPtr LaunchTitle(FS::MediaType media_type, u64 title_id); /// Registers all NS services with the specified service manager. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::NS diff --git a/src/core/hle/service/nwm/nwm.cpp b/src/core/hle/service/nwm/nwm.cpp index 8b1fa2b89..dd984b2b9 100644 --- a/src/core/hle/service/nwm/nwm.cpp +++ b/src/core/hle/service/nwm/nwm.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/nwm/nwm.h" #include "core/hle/service/nwm/nwm_cec.h" #include "core/hle/service/nwm/nwm_ext.h" @@ -13,14 +14,15 @@ namespace Service::NWM { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); - std::make_shared()->InstallAsService(service_manager); + std::make_shared(system)->InstallAsService(service_manager); } } // namespace Service::NWM diff --git a/src/core/hle/service/nwm/nwm.h b/src/core/hle/service/nwm/nwm.h index b0e95621f..d9036803e 100644 --- a/src/core/hle/service/nwm/nwm.h +++ b/src/core/hle/service/nwm/nwm.h @@ -6,9 +6,13 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::NWM { /// Initialize all NWM services -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::NWM diff --git a/src/core/hle/service/nwm/nwm_uds.cpp b/src/core/hle/service/nwm/nwm_uds.cpp index 19527f8ab..c08b9626e 100644 --- a/src/core/hle/service/nwm/nwm_uds.cpp +++ b/src/core/hle/service/nwm/nwm_uds.cpp @@ -1283,7 +1283,7 @@ static void BeaconBroadcastCallback(u64 userdata, s64 cycles_late) { beacon_broadcast_event, 0); } -NWM_UDS::NWM_UDS() : ServiceFramework("nwm::UDS") { +NWM_UDS::NWM_UDS(Core::System& system) : ServiceFramework("nwm::UDS") { static const FunctionInfo functions[] = { {0x000102C2, nullptr, "Initialize (deprecated)"}, {0x00020000, nullptr, "Scrap"}, @@ -1334,9 +1334,8 @@ NWM_UDS::NWM_UDS() : ServiceFramework("nwm::UDS") { } } - Core::System::GetInstance().GetSharedPageHandler()->SetMacAddress(mac); - Core::System::GetInstance().GetSharedPageHandler()->SetWifiLinkLevel( - SharedPage::WifiLinkLevel::BEST); + system.GetSharedPageHandler()->SetMacAddress(mac); + system.GetSharedPageHandler()->SetWifiLinkLevel(SharedPage::WifiLinkLevel::BEST); } NWM_UDS::~NWM_UDS() { diff --git a/src/core/hle/service/nwm/nwm_uds.h b/src/core/hle/service/nwm/nwm_uds.h index d19bd4a1c..d10b99fc9 100644 --- a/src/core/hle/service/nwm/nwm_uds.h +++ b/src/core/hle/service/nwm/nwm_uds.h @@ -11,6 +11,10 @@ #include "common/swap.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + // Local-WLAN service namespace Service::NWM { @@ -98,7 +102,7 @@ enum class TagId : u8 { class NWM_UDS final : public ServiceFramework { public: - NWM_UDS(); + explicit NWM_UDS(Core::System& system); ~NWM_UDS(); private: diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index fedf00efc..6c9ddc7d9 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp @@ -2,13 +2,15 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/pm/pm.h" #include "core/hle/service/pm/pm_app.h" #include "core/hle/service/pm/pm_dbg.h" namespace Service::PM { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/pm/pm.h b/src/core/hle/service/pm/pm.h index 63f832598..d405c58cf 100644 --- a/src/core/hle/service/pm/pm.h +++ b/src/core/hle/service/pm/pm.h @@ -6,9 +6,13 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::PM { /// Initializes the PM services. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::PM diff --git a/src/core/hle/service/ps/ps_ps.cpp b/src/core/hle/service/ps/ps_ps.cpp index 62ddf9c12..e8d4d733c 100644 --- a/src/core/hle/service/ps/ps_ps.cpp +++ b/src/core/hle/service/ps/ps_ps.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/ps/ps_ps.h" @@ -32,7 +33,8 @@ PS_PS::PS_PS() : ServiceFramework("ps:ps", DefaultMaxSessions) { RegisterHandlers(functions); }; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/ps/ps_ps.h b/src/core/hle/service/ps/ps_ps.h index 09bf4f54c..6e8b3ad0a 100644 --- a/src/core/hle/service/ps/ps_ps.h +++ b/src/core/hle/service/ps/ps_ps.h @@ -6,6 +6,10 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::PS { class PS_PS final : public ServiceFramework { @@ -224,6 +228,6 @@ private: }; /// Initializes the PS_PS Service -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::PS diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index b9df66e3b..8d6dc6cad 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp @@ -6,6 +6,7 @@ #include "common/common_paths.h" #include "common/file_util.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/file_sys/archive_extsavedata.h" #include "core/file_sys/errors.h" #include "core/file_sys/file_backend.h" @@ -226,7 +227,8 @@ void Module::SetPlayCoins(u16 play_coins) { Module::Interface::Interface(std::shared_ptr ptm, const char* name, u32 max_session) : ServiceFramework(name, max_session), ptm(std::move(ptm)) {} -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); auto ptm = std::make_shared(); std::make_shared(ptm)->InstallAsService(service_manager); std::make_shared(ptm)->InstallAsService(service_manager); diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index 7da9189e0..e56a66972 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h @@ -9,6 +9,10 @@ #include "core/hle/ipc_helpers.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::PTM { /// Charge levels used by PTM functions @@ -140,6 +144,6 @@ private: bool pedometer_is_counting = false; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::PTM diff --git a/src/core/hle/service/pxi/pxi.cpp b/src/core/hle/service/pxi/pxi.cpp index d7eff7a5f..68e7d8737 100644 --- a/src/core/hle/service/pxi/pxi.cpp +++ b/src/core/hle/service/pxi/pxi.cpp @@ -2,12 +2,14 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/pxi/dev.h" #include "core/hle/service/pxi/pxi.h" namespace Service::PXI { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/pxi/pxi.h b/src/core/hle/service/pxi/pxi.h index f0ca55e35..c3ae62912 100644 --- a/src/core/hle/service/pxi/pxi.h +++ b/src/core/hle/service/pxi/pxi.h @@ -6,9 +6,13 @@ #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::PXI { /// Registers all PXI services with the specified service manager. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::PXI diff --git a/src/core/hle/service/qtm/qtm.cpp b/src/core/hle/service/qtm/qtm.cpp index c0e545541..68fe6e132 100644 --- a/src/core/hle/service/qtm/qtm.cpp +++ b/src/core/hle/service/qtm/qtm.cpp @@ -2,6 +2,7 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#include "core/core.h" #include "core/hle/service/qtm/qtm.h" #include "core/hle/service/qtm/qtm_c.h" #include "core/hle/service/qtm/qtm_s.h" @@ -10,7 +11,8 @@ namespace Service::QTM { -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); std::make_shared()->InstallAsService(service_manager); diff --git a/src/core/hle/service/qtm/qtm.h b/src/core/hle/service/qtm/qtm.h index 31d8eee82..79f95b36c 100644 --- a/src/core/hle/service/qtm/qtm.h +++ b/src/core/hle/service/qtm/qtm.h @@ -5,10 +5,13 @@ #pragma once #include "core/hle/service/service.h" +namespace Core { +class System; +} namespace Service::QTM { /// Initializes all QTM services. -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::QTM diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index d99d07aac..7d6b25d0f 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp @@ -69,15 +69,15 @@ const std::array service_module_map{ {"LDR", 0x00040130'00003702, LDR::InstallInterfaces}, {"PXI", 0x00040130'00001402, PXI::InstallInterfaces}, - {"ERR", 0x00040030'00008A02, [](SM::ServiceManager& sm) { ERR::InstallInterfaces(); }}, + {"ERR", 0x00040030'00008A02, ERR::InstallInterfaces}, {"AC", 0x00040130'00002402, AC::InstallInterfaces}, {"ACT", 0x00040130'00003802, ACT::InstallInterfaces}, {"AM", 0x00040130'00001502, AM::InstallInterfaces}, {"BOSS", 0x00040130'00003402, BOSS::InstallInterfaces}, {"CAM", 0x00040130'00001602, - [](SM::ServiceManager& sm) { - CAM::InstallInterfaces(sm); - Y2R::InstallInterfaces(sm); + [](Core::System& system) { + CAM::InstallInterfaces(system); + Y2R::InstallInterfaces(system); }}, {"CECD", 0x00040130'00002602, CECD::InstallInterfaces}, {"CFG", 0x00040130'00001702, CFG::InstallInterfaces}, @@ -94,9 +94,9 @@ const std::array service_module_map{ {"NFC", 0x00040130'00004002, NFC::InstallInterfaces}, {"NIM", 0x00040130'00002C02, NIM::InstallInterfaces}, {"NS", 0x00040130'00008002, - [](SM::ServiceManager& sm) { - NS::InstallInterfaces(sm); - APT::InstallInterfaces(sm); + [](Core::System& system) { + NS::InstallInterfaces(system); + APT::InstallInterfaces(system); }}, {"NWM", 0x00040130'00002D02, NWM::InstallInterfaces}, {"PTM", 0x00040130'00002202, PTM::InstallInterfaces}, @@ -235,13 +235,13 @@ static bool AttemptLLE(const ServiceModuleInfo& service_module) { } /// Initialize ServiceManager -void Init(std::shared_ptr& sm) { +void Init(Core::System& core, std::shared_ptr& sm) { FS::ArchiveInit(); SM::ServiceManager::InstallInterfaces(sm); for (const auto& service_module : service_module_map) { if (!AttemptLLE(service_module) && service_module.init_function != nullptr) - service_module.init_function(*sm); + service_module.init_function(core); } LOG_DEBUG(Service, "initialized OK"); } diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 11ceef2be..3a8634251 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h @@ -15,8 +15,9 @@ #include "core/hle/kernel/object.h" #include "core/hle/service/sm/sm.h" -//////////////////////////////////////////////////////////////////////////////////////////////////// -// Namespace Service +namespace Core { +class System; +} namespace Kernel { class ClientPort; @@ -183,7 +184,7 @@ private: }; /// Initialize ServiceManager -void Init(std::shared_ptr& sm); +void Init(Core::System& system, std::shared_ptr& sm); /// Shutdown ServiceManager void Shutdown(); @@ -194,7 +195,7 @@ extern std::unordered_map> g_ struct ServiceModuleInfo { std::string name; u64 title_id; - std::function init_function; + std::function init_function; }; extern const std::array service_module_map; diff --git a/src/core/hle/service/soc_u.cpp b/src/core/hle/service/soc_u.cpp index 5ffd28f47..c0995f192 100644 --- a/src/core/hle/service/soc_u.cpp +++ b/src/core/hle/service/soc_u.cpp @@ -10,6 +10,7 @@ #include "common/common_types.h" #include "common/logging/log.h" #include "common/scope_exit.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/result.h" @@ -909,7 +910,8 @@ SOC_U::~SOC_U() { #endif } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/soc_u.h b/src/core/hle/service/soc_u.h index 54106ef0a..cb650c82c 100644 --- a/src/core/hle/service/soc_u.h +++ b/src/core/hle/service/soc_u.h @@ -7,6 +7,10 @@ #include #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::SOC { /// Holds information about a particular socket @@ -48,6 +52,6 @@ private: std::unordered_map open_sockets; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::SOC diff --git a/src/core/hle/service/ssl_c.cpp b/src/core/hle/service/ssl_c.cpp index 0a9107796..b862c41f1 100644 --- a/src/core/hle/service/ssl_c.cpp +++ b/src/core/hle/service/ssl_c.cpp @@ -3,6 +3,7 @@ // Refer to the license.txt file included. #include "common/common_types.h" +#include "core/core.h" #include "core/hle/ipc.h" #include "core/hle/ipc_helpers.h" #include "core/hle/service/ssl_c.h" @@ -86,7 +87,8 @@ SSL_C::SSL_C() : ServiceFramework("ssl:C") { RegisterHandlers(functions); } -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/ssl_c.h b/src/core/hle/service/ssl_c.h index 34cbe0655..807f7c725 100644 --- a/src/core/hle/service/ssl_c.h +++ b/src/core/hle/service/ssl_c.h @@ -7,6 +7,10 @@ #include #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Service::SSL { class SSL_C final : public ServiceFramework { @@ -21,6 +25,6 @@ private: std::mt19937 rand_gen; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::SSL diff --git a/src/core/hle/service/y2r_u.cpp b/src/core/hle/service/y2r_u.cpp index e73a4abab..cd20b57bd 100644 --- a/src/core/hle/service/y2r_u.cpp +++ b/src/core/hle/service/y2r_u.cpp @@ -5,6 +5,7 @@ #include #include "common/common_funcs.h" #include "common/logging/log.h" +#include "core/core.h" #include "core/hle/ipc_helpers.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/process.h" @@ -686,7 +687,8 @@ Y2R_U::Y2R_U() : ServiceFramework("y2r:u", 1) { Y2R_U::~Y2R_U() = default; -void InstallInterfaces(SM::ServiceManager& service_manager) { +void InstallInterfaces(Core::System& system) { + auto& service_manager = system.ServiceManager(); std::make_shared()->InstallAsService(service_manager); } diff --git a/src/core/hle/service/y2r_u.h b/src/core/hle/service/y2r_u.h index 81b38e642..e32763925 100644 --- a/src/core/hle/service/y2r_u.h +++ b/src/core/hle/service/y2r_u.h @@ -12,6 +12,10 @@ #include "core/hle/result.h" #include "core/hle/service/service.h" +namespace Core { +class System; +} + namespace Kernel { class Event; } @@ -298,6 +302,6 @@ private: bool spacial_dithering_enabled = false; }; -void InstallInterfaces(SM::ServiceManager& service_manager); +void InstallInterfaces(Core::System& system); } // namespace Service::Y2R