diff options
Diffstat (limited to 'src/core/hle/service')
123 files changed, 1328 insertions, 658 deletions
diff --git a/src/core/hle/service/acc/acc.cpp b/src/core/hle/service/acc/acc.cpp index 1241fcdff..c3e5c4462 100644 --- a/src/core/hle/service/acc/acc.cpp +++ b/src/core/hle/service/acc/acc.cpp | |||
| @@ -25,6 +25,7 @@ | |||
| 25 | #include "core/hle/service/acc/errors.h" | 25 | #include "core/hle/service/acc/errors.h" |
| 26 | #include "core/hle/service/acc/profile_manager.h" | 26 | #include "core/hle/service/acc/profile_manager.h" |
| 27 | #include "core/hle/service/glue/glue_manager.h" | 27 | #include "core/hle/service/glue/glue_manager.h" |
| 28 | #include "core/hle/service/server_manager.h" | ||
| 28 | #include "core/loader/loader.h" | 29 | #include "core/loader/loader.h" |
| 29 | 30 | ||
| 30 | namespace Service::Account { | 31 | namespace Service::Account { |
| @@ -950,18 +951,20 @@ Module::Interface::Interface(std::shared_ptr<Module> module_, | |||
| 950 | 951 | ||
| 951 | Module::Interface::~Interface() = default; | 952 | Module::Interface::~Interface() = default; |
| 952 | 953 | ||
| 953 | void InstallInterfaces(Core::System& system) { | 954 | void LoopProcess(Core::System& system) { |
| 954 | auto module = std::make_shared<Module>(); | 955 | auto module = std::make_shared<Module>(); |
| 955 | auto profile_manager = std::make_shared<ProfileManager>(); | 956 | auto profile_manager = std::make_shared<ProfileManager>(); |
| 956 | 957 | auto server_manager = std::make_unique<ServerManager>(system); | |
| 957 | std::make_shared<ACC_AA>(module, profile_manager, system) | 958 | |
| 958 | ->InstallAsService(system.ServiceManager()); | 959 | server_manager->RegisterNamedService("acc:aa", |
| 959 | std::make_shared<ACC_SU>(module, profile_manager, system) | 960 | std::make_shared<ACC_AA>(module, profile_manager, system)); |
| 960 | ->InstallAsService(system.ServiceManager()); | 961 | server_manager->RegisterNamedService("acc:su", |
| 961 | std::make_shared<ACC_U0>(module, profile_manager, system) | 962 | std::make_shared<ACC_SU>(module, profile_manager, system)); |
| 962 | ->InstallAsService(system.ServiceManager()); | 963 | server_manager->RegisterNamedService("acc:u0", |
| 963 | std::make_shared<ACC_U1>(module, profile_manager, system) | 964 | std::make_shared<ACC_U0>(module, profile_manager, system)); |
| 964 | ->InstallAsService(system.ServiceManager()); | 965 | server_manager->RegisterNamedService("acc:u1", |
| 966 | std::make_shared<ACC_U1>(module, profile_manager, system)); | ||
| 967 | ServerManager::RunServer(std::move(server_manager)); | ||
| 965 | } | 968 | } |
| 966 | 969 | ||
| 967 | } // namespace Service::Account | 970 | } // namespace Service::Account |
diff --git a/src/core/hle/service/acc/acc.h b/src/core/hle/service/acc/acc.h index 9411b0b92..a2fdafd82 100644 --- a/src/core/hle/service/acc/acc.h +++ b/src/core/hle/service/acc/acc.h | |||
| @@ -67,7 +67,6 @@ public: | |||
| 67 | }; | 67 | }; |
| 68 | }; | 68 | }; |
| 69 | 69 | ||
| 70 | /// Registers all ACC services with the specified service manager. | 70 | void LoopProcess(Core::System& system); |
| 71 | void InstallInterfaces(Core::System& system); | ||
| 72 | 71 | ||
| 73 | } // namespace Service::Account | 72 | } // namespace Service::Account |
diff --git a/src/core/hle/service/am/am.cpp b/src/core/hle/service/am/am.cpp index 9a7316e27..3cd772b83 100644 --- a/src/core/hle/service/am/am.cpp +++ b/src/core/hle/service/am/am.cpp | |||
| @@ -32,6 +32,7 @@ | |||
| 32 | #include "core/hle/service/ns/ns.h" | 32 | #include "core/hle/service/ns/ns.h" |
| 33 | #include "core/hle/service/nvflinger/nvflinger.h" | 33 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 34 | #include "core/hle/service/pm/pm.h" | 34 | #include "core/hle/service/pm/pm.h" |
| 35 | #include "core/hle/service/server_manager.h" | ||
| 35 | #include "core/hle/service/sm/sm.h" | 36 | #include "core/hle/service/sm/sm.h" |
| 36 | #include "core/hle/service/vi/vi.h" | 37 | #include "core/hle/service/vi/vi.h" |
| 37 | #include "core/memory.h" | 38 | #include "core/memory.h" |
| @@ -1830,17 +1831,21 @@ void IApplicationFunctions::PrepareForJit(Kernel::HLERequestContext& ctx) { | |||
| 1830 | rb.Push(ResultSuccess); | 1831 | rb.Push(ResultSuccess); |
| 1831 | } | 1832 | } |
| 1832 | 1833 | ||
| 1833 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | 1834 | void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) { |
| 1834 | Core::System& system) { | ||
| 1835 | auto message_queue = std::make_shared<AppletMessageQueue>(system); | 1835 | auto message_queue = std::make_shared<AppletMessageQueue>(system); |
| 1836 | // Needed on game boot | 1836 | // Needed on game boot |
| 1837 | message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); | 1837 | message_queue->PushMessage(AppletMessageQueue::AppletMessage::FocusStateChanged); |
| 1838 | 1838 | ||
| 1839 | std::make_shared<AppletAE>(nvflinger, message_queue, system)->InstallAsService(service_manager); | 1839 | auto server_manager = std::make_unique<ServerManager>(system); |
| 1840 | std::make_shared<AppletOE>(nvflinger, message_queue, system)->InstallAsService(service_manager); | 1840 | |
| 1841 | std::make_shared<IdleSys>(system)->InstallAsService(service_manager); | 1841 | server_manager->RegisterNamedService( |
| 1842 | std::make_shared<OMM>(system)->InstallAsService(service_manager); | 1842 | "appletAE", std::make_shared<AppletAE>(nvflinger, message_queue, system)); |
| 1843 | std::make_shared<SPSM>(system)->InstallAsService(service_manager); | 1843 | server_manager->RegisterNamedService( |
| 1844 | "appletOE", std::make_shared<AppletOE>(nvflinger, message_queue, system)); | ||
| 1845 | server_manager->RegisterNamedService("idle:sys", std::make_shared<IdleSys>(system)); | ||
| 1846 | server_manager->RegisterNamedService("omm", std::make_shared<OMM>(system)); | ||
| 1847 | server_manager->RegisterNamedService("spsm", std::make_shared<SPSM>(system)); | ||
| 1848 | ServerManager::RunServer(std::move(server_manager)); | ||
| 1844 | } | 1849 | } |
| 1845 | 1850 | ||
| 1846 | IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) | 1851 | IHomeMenuFunctions::IHomeMenuFunctions(Core::System& system_) |
diff --git a/src/core/hle/service/am/am.h b/src/core/hle/service/am/am.h index a0fbfcfc5..79e2263d7 100644 --- a/src/core/hle/service/am/am.h +++ b/src/core/hle/service/am/am.h | |||
| @@ -396,8 +396,6 @@ public: | |||
| 396 | ~IProcessWindingController() override; | 396 | ~IProcessWindingController() override; |
| 397 | }; | 397 | }; |
| 398 | 398 | ||
| 399 | /// Registers all AM services with the specified service manager. | 399 | void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system); |
| 400 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | ||
| 401 | Core::System& system); | ||
| 402 | 400 | ||
| 403 | } // namespace Service::AM | 401 | } // namespace Service::AM |
diff --git a/src/core/hle/service/aoc/aoc_u.cpp b/src/core/hle/service/aoc/aoc_u.cpp index 1bbf057cb..fed51cfd6 100644 --- a/src/core/hle/service/aoc/aoc_u.cpp +++ b/src/core/hle/service/aoc/aoc_u.cpp | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #include "core/hle/ipc_helpers.h" | 17 | #include "core/hle/ipc_helpers.h" |
| 18 | #include "core/hle/kernel/k_event.h" | 18 | #include "core/hle/kernel/k_event.h" |
| 19 | #include "core/hle/service/aoc/aoc_u.h" | 19 | #include "core/hle/service/aoc/aoc_u.h" |
| 20 | #include "core/hle/service/server_manager.h" | ||
| 20 | #include "core/loader/loader.h" | 21 | #include "core/loader/loader.h" |
| 21 | 22 | ||
| 22 | namespace Service::AOC { | 23 | namespace Service::AOC { |
| @@ -314,8 +315,10 @@ void AOC_U::CreatePermanentEcPurchasedEventManager(Kernel::HLERequestContext& ct | |||
| 314 | rb.PushIpcInterface<IPurchaseEventManager>(system); | 315 | rb.PushIpcInterface<IPurchaseEventManager>(system); |
| 315 | } | 316 | } |
| 316 | 317 | ||
| 317 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 318 | void LoopProcess(Core::System& system) { |
| 318 | std::make_shared<AOC_U>(system)->InstallAsService(service_manager); | 319 | auto server_manager = std::make_unique<ServerManager>(system); |
| 320 | server_manager->RegisterNamedService("aoc:u", std::make_shared<AOC_U>(system)); | ||
| 321 | ServerManager::RunServer(std::move(server_manager)); | ||
| 319 | } | 322 | } |
| 320 | 323 | ||
| 321 | } // namespace Service::AOC | 324 | } // namespace Service::AOC |
diff --git a/src/core/hle/service/aoc/aoc_u.h b/src/core/hle/service/aoc/aoc_u.h index 6c1ce601a..5e7087e50 100644 --- a/src/core/hle/service/aoc/aoc_u.h +++ b/src/core/hle/service/aoc/aoc_u.h | |||
| @@ -40,7 +40,6 @@ private: | |||
| 40 | Kernel::KEvent* aoc_change_event; | 40 | Kernel::KEvent* aoc_change_event; |
| 41 | }; | 41 | }; |
| 42 | 42 | ||
| 43 | /// Registers all AOC services with the specified service manager. | 43 | void LoopProcess(Core::System& system); |
| 44 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 45 | 44 | ||
| 46 | } // namespace Service::AOC | 45 | } // namespace Service::AOC |
diff --git a/src/core/hle/service/apm/apm.cpp b/src/core/hle/service/apm/apm.cpp index 44b2927a6..c23ff293d 100644 --- a/src/core/hle/service/apm/apm.cpp +++ b/src/core/hle/service/apm/apm.cpp | |||
| @@ -4,20 +4,24 @@ | |||
| 4 | #include "core/core.h" | 4 | #include "core/core.h" |
| 5 | #include "core/hle/service/apm/apm.h" | 5 | #include "core/hle/service/apm/apm.h" |
| 6 | #include "core/hle/service/apm/apm_interface.h" | 6 | #include "core/hle/service/apm/apm_interface.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | 8 | ||
| 8 | namespace Service::APM { | 9 | namespace Service::APM { |
| 9 | 10 | ||
| 10 | Module::Module() = default; | 11 | Module::Module() = default; |
| 11 | Module::~Module() = default; | 12 | Module::~Module() = default; |
| 12 | 13 | ||
| 13 | void InstallInterfaces(Core::System& system) { | 14 | void LoopProcess(Core::System& system) { |
| 14 | auto module_ = std::make_shared<Module>(); | 15 | auto module = std::make_shared<Module>(); |
| 15 | std::make_shared<APM>(system, module_, system.GetAPMController(), "apm") | 16 | auto server_manager = std::make_unique<ServerManager>(system); |
| 16 | ->InstallAsService(system.ServiceManager()); | 17 | |
| 17 | std::make_shared<APM>(system, module_, system.GetAPMController(), "apm:am") | 18 | server_manager->RegisterNamedService( |
| 18 | ->InstallAsService(system.ServiceManager()); | 19 | "apm", std::make_shared<APM>(system, module, system.GetAPMController(), "apm")); |
| 19 | std::make_shared<APM_Sys>(system, system.GetAPMController()) | 20 | server_manager->RegisterNamedService( |
| 20 | ->InstallAsService(system.ServiceManager()); | 21 | "apm:am", std::make_shared<APM>(system, module, system.GetAPMController(), "apm:am")); |
| 22 | server_manager->RegisterNamedService( | ||
| 23 | "apm:sys", std::make_shared<APM_Sys>(system, system.GetAPMController())); | ||
| 24 | ServerManager::RunServer(std::move(server_manager)); | ||
| 21 | } | 25 | } |
| 22 | 26 | ||
| 23 | } // namespace Service::APM | 27 | } // namespace Service::APM |
diff --git a/src/core/hle/service/apm/apm.h b/src/core/hle/service/apm/apm.h index 0fecc766a..e188b4e44 100644 --- a/src/core/hle/service/apm/apm.h +++ b/src/core/hle/service/apm/apm.h | |||
| @@ -15,7 +15,6 @@ public: | |||
| 15 | ~Module(); | 15 | ~Module(); |
| 16 | }; | 16 | }; |
| 17 | 17 | ||
| 18 | /// Registers all AM services with the specified service manager. | 18 | void LoopProcess(Core::System& system); |
| 19 | void InstallInterfaces(Core::System& system); | ||
| 20 | 19 | ||
| 21 | } // namespace Service::APM | 20 | } // namespace Service::APM |
diff --git a/src/core/hle/service/audio/audin_u.cpp b/src/core/hle/service/audio/audin_u.cpp index 053e8f9dd..26dec7147 100644 --- a/src/core/hle/service/audio/audin_u.cpp +++ b/src/core/hle/service/audio/audin_u.cpp | |||
| @@ -203,9 +203,8 @@ private: | |||
| 203 | }; | 203 | }; |
| 204 | 204 | ||
| 205 | AudInU::AudInU(Core::System& system_) | 205 | AudInU::AudInU(Core::System& system_) |
| 206 | : ServiceFramework{system_, "audin:u", ServiceThreadType::CreateNew}, | 206 | : ServiceFramework{system_, "audin:u"}, service_context{system_, "AudInU"}, |
| 207 | service_context{system_, "AudInU"}, impl{std::make_unique<AudioCore::AudioIn::Manager>( | 207 | impl{std::make_unique<AudioCore::AudioIn::Manager>(system_)} { |
| 208 | system_)} { | ||
| 209 | // clang-format off | 208 | // clang-format off |
| 210 | static const FunctionInfo functions[] = { | 209 | static const FunctionInfo functions[] = { |
| 211 | {0, &AudInU::ListAudioIns, "ListAudioIns"}, | 210 | {0, &AudInU::ListAudioIns, "ListAudioIns"}, |
diff --git a/src/core/hle/service/audio/audio.cpp b/src/core/hle/service/audio/audio.cpp index ed36e3448..dccd16309 100644 --- a/src/core/hle/service/audio/audio.cpp +++ b/src/core/hle/service/audio/audio.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/core.h" | ||
| 4 | #include "core/hle/service/audio/audctl.h" | 5 | #include "core/hle/service/audio/audctl.h" |
| 5 | #include "core/hle/service/audio/audin_u.h" | 6 | #include "core/hle/service/audio/audin_u.h" |
| 6 | #include "core/hle/service/audio/audio.h" | 7 | #include "core/hle/service/audio/audio.h" |
| @@ -9,18 +10,22 @@ | |||
| 9 | #include "core/hle/service/audio/audrec_u.h" | 10 | #include "core/hle/service/audio/audrec_u.h" |
| 10 | #include "core/hle/service/audio/audren_u.h" | 11 | #include "core/hle/service/audio/audren_u.h" |
| 11 | #include "core/hle/service/audio/hwopus.h" | 12 | #include "core/hle/service/audio/hwopus.h" |
| 13 | #include "core/hle/service/server_manager.h" | ||
| 12 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 13 | 15 | ||
| 14 | namespace Service::Audio { | 16 | namespace Service::Audio { |
| 15 | 17 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 18 | void LoopProcess(Core::System& system) { |
| 17 | std::make_shared<AudCtl>(system)->InstallAsService(service_manager); | 19 | auto server_manager = std::make_unique<ServerManager>(system); |
| 18 | std::make_shared<AudOutU>(system)->InstallAsService(service_manager); | 20 | |
| 19 | std::make_shared<AudInU>(system)->InstallAsService(service_manager); | 21 | server_manager->RegisterNamedService("audctl", std::make_shared<AudCtl>(system)); |
| 20 | std::make_shared<AudRecA>(system)->InstallAsService(service_manager); | 22 | server_manager->RegisterNamedService("audout:u", std::make_shared<AudOutU>(system)); |
| 21 | std::make_shared<AudRecU>(system)->InstallAsService(service_manager); | 23 | server_manager->RegisterNamedService("audin:u", std::make_shared<AudInU>(system)); |
| 22 | std::make_shared<AudRenU>(system)->InstallAsService(service_manager); | 24 | server_manager->RegisterNamedService("audrec:a", std::make_shared<AudRecA>(system)); |
| 23 | std::make_shared<HwOpus>(system)->InstallAsService(service_manager); | 25 | server_manager->RegisterNamedService("audrec:u", std::make_shared<AudRecU>(system)); |
| 26 | server_manager->RegisterNamedService("audren:u", std::make_shared<AudRenU>(system)); | ||
| 27 | server_manager->RegisterNamedService("hwopus", std::make_shared<HwOpus>(system)); | ||
| 28 | ServerManager::RunServer(std::move(server_manager)); | ||
| 24 | } | 29 | } |
| 25 | 30 | ||
| 26 | } // namespace Service::Audio | 31 | } // namespace Service::Audio |
diff --git a/src/core/hle/service/audio/audio.h b/src/core/hle/service/audio/audio.h index bbb2214e4..d70f022c7 100644 --- a/src/core/hle/service/audio/audio.h +++ b/src/core/hle/service/audio/audio.h | |||
| @@ -13,7 +13,6 @@ class ServiceManager; | |||
| 13 | 13 | ||
| 14 | namespace Service::Audio { | 14 | namespace Service::Audio { |
| 15 | 15 | ||
| 16 | /// Registers all Audio services with the specified service manager. | 16 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 17 | ||
| 19 | } // namespace Service::Audio | 18 | } // namespace Service::Audio |
diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 29751f075..991e30ba1 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -26,9 +26,8 @@ public: | |||
| 26 | explicit IAudioOut(Core::System& system_, AudioCore::AudioOut::Manager& manager, | 26 | explicit IAudioOut(Core::System& system_, AudioCore::AudioOut::Manager& manager, |
| 27 | size_t session_id, const std::string& device_name, | 27 | size_t session_id, const std::string& device_name, |
| 28 | const AudioOutParameter& in_params, u32 handle, u64 applet_resource_user_id) | 28 | const AudioOutParameter& in_params, u32 handle, u64 applet_resource_user_id) |
| 29 | : ServiceFramework{system_, "IAudioOut", ServiceThreadType::CreateNew}, | 29 | : ServiceFramework{system_, "IAudioOut"}, service_context{system_, "IAudioOut"}, |
| 30 | service_context{system_, "IAudioOut"}, event{service_context.CreateEvent( | 30 | event{service_context.CreateEvent("AudioOutEvent")}, |
| 31 | "AudioOutEvent")}, | ||
| 32 | impl{std::make_shared<AudioCore::AudioOut::Out>(system_, manager, event, session_id)} { | 31 | impl{std::make_shared<AudioCore::AudioOut::Out>(system_, manager, event, session_id)} { |
| 33 | 32 | ||
| 34 | // clang-format off | 33 | // clang-format off |
| @@ -221,9 +220,8 @@ private: | |||
| 221 | }; | 220 | }; |
| 222 | 221 | ||
| 223 | AudOutU::AudOutU(Core::System& system_) | 222 | AudOutU::AudOutU(Core::System& system_) |
| 224 | : ServiceFramework{system_, "audout:u", ServiceThreadType::CreateNew}, | 223 | : ServiceFramework{system_, "audout:u"}, service_context{system_, "AudOutU"}, |
| 225 | service_context{system_, "AudOutU"}, impl{std::make_unique<AudioCore::AudioOut::Manager>( | 224 | impl{std::make_unique<AudioCore::AudioOut::Manager>(system_)} { |
| 226 | system_)} { | ||
| 227 | // clang-format off | 225 | // clang-format off |
| 228 | static const FunctionInfo functions[] = { | 226 | static const FunctionInfo functions[] = { |
| 229 | {0, &AudOutU::ListAudioOuts, "ListAudioOuts"}, | 227 | {0, &AudOutU::ListAudioOuts, "ListAudioOuts"}, |
diff --git a/src/core/hle/service/audio/audren_u.cpp b/src/core/hle/service/audio/audren_u.cpp index 7d730421d..6c12f00a1 100644 --- a/src/core/hle/service/audio/audren_u.cpp +++ b/src/core/hle/service/audio/audren_u.cpp | |||
| @@ -35,10 +35,9 @@ public: | |||
| 35 | AudioCore::AudioRendererParameterInternal& params, | 35 | AudioCore::AudioRendererParameterInternal& params, |
| 36 | Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, | 36 | Kernel::KTransferMemory* transfer_memory, u64 transfer_memory_size, |
| 37 | u32 process_handle, u64 applet_resource_user_id, s32 session_id) | 37 | u32 process_handle, u64 applet_resource_user_id, s32 session_id) |
| 38 | : ServiceFramework{system_, "IAudioRenderer", ServiceThreadType::CreateNew}, | 38 | : ServiceFramework{system_, "IAudioRenderer"}, service_context{system_, "IAudioRenderer"}, |
| 39 | service_context{system_, "IAudioRenderer"}, rendered_event{service_context.CreateEvent( | 39 | rendered_event{service_context.CreateEvent("IAudioRendererEvent")}, manager{manager_}, |
| 40 | "IAudioRendererEvent")}, | 40 | impl{std::make_unique<Renderer>(system_, manager, rendered_event)} { |
| 41 | manager{manager_}, impl{std::make_unique<Renderer>(system_, manager, rendered_event)} { | ||
| 42 | // clang-format off | 41 | // clang-format off |
| 43 | static const FunctionInfo functions[] = { | 42 | static const FunctionInfo functions[] = { |
| 44 | {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, | 43 | {0, &IAudioRenderer::GetSampleRate, "GetSampleRate"}, |
| @@ -243,10 +242,8 @@ class IAudioDevice final : public ServiceFramework<IAudioDevice> { | |||
| 243 | public: | 242 | public: |
| 244 | explicit IAudioDevice(Core::System& system_, u64 applet_resource_user_id, u32 revision, | 243 | explicit IAudioDevice(Core::System& system_, u64 applet_resource_user_id, u32 revision, |
| 245 | u32 device_num) | 244 | u32 device_num) |
| 246 | : ServiceFramework{system_, "IAudioDevice", ServiceThreadType::CreateNew}, | 245 | : ServiceFramework{system_, "IAudioDevice"}, service_context{system_, "IAudioDevice"}, |
| 247 | service_context{system_, "IAudioDevice"}, impl{std::make_unique<AudioDevice>( | 246 | impl{std::make_unique<AudioDevice>(system_, applet_resource_user_id, revision)}, |
| 248 | system_, applet_resource_user_id, | ||
| 249 | revision)}, | ||
| 250 | event{service_context.CreateEvent(fmt::format("IAudioDeviceEvent-{}", device_num))} { | 247 | event{service_context.CreateEvent(fmt::format("IAudioDeviceEvent-{}", device_num))} { |
| 251 | static const FunctionInfo functions[] = { | 248 | static const FunctionInfo functions[] = { |
| 252 | {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, | 249 | {0, &IAudioDevice::ListAudioDeviceName, "ListAudioDeviceName"}, |
| @@ -421,7 +418,7 @@ private: | |||
| 421 | }; | 418 | }; |
| 422 | 419 | ||
| 423 | AudRenU::AudRenU(Core::System& system_) | 420 | AudRenU::AudRenU(Core::System& system_) |
| 424 | : ServiceFramework{system_, "audren:u", ServiceThreadType::CreateNew}, | 421 | : ServiceFramework{system_, "audren:u"}, |
| 425 | service_context{system_, "audren:u"}, impl{std::make_unique<Manager>(system_)} { | 422 | service_context{system_, "audren:u"}, impl{std::make_unique<Manager>(system_)} { |
| 426 | // clang-format off | 423 | // clang-format off |
| 427 | static const FunctionInfo functions[] = { | 424 | static const FunctionInfo functions[] = { |
diff --git a/src/core/hle/service/bcat/bcat_module.cpp b/src/core/hle/service/bcat/bcat_module.cpp index 6e6fed227..1db3f026b 100644 --- a/src/core/hle/service/bcat/bcat_module.cpp +++ b/src/core/hle/service/bcat/bcat_module.cpp | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | #include "core/hle/service/bcat/bcat.h" | 15 | #include "core/hle/service/bcat/bcat.h" |
| 16 | #include "core/hle/service/bcat/bcat_module.h" | 16 | #include "core/hle/service/bcat/bcat_module.h" |
| 17 | #include "core/hle/service/filesystem/filesystem.h" | 17 | #include "core/hle/service/filesystem/filesystem.h" |
| 18 | #include "core/hle/service/server_manager.h" | ||
| 18 | 19 | ||
| 19 | namespace Service::BCAT { | 20 | namespace Service::BCAT { |
| 20 | 21 | ||
| @@ -585,16 +586,23 @@ Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> modu | |||
| 585 | 586 | ||
| 586 | Module::Interface::~Interface() = default; | 587 | Module::Interface::~Interface() = default; |
| 587 | 588 | ||
| 588 | void InstallInterfaces(Core::System& system) { | 589 | void LoopProcess(Core::System& system) { |
| 590 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 589 | auto module = std::make_shared<Module>(); | 591 | auto module = std::make_shared<Module>(); |
| 590 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:a") | 592 | |
| 591 | ->InstallAsService(system.ServiceManager()); | 593 | server_manager->RegisterNamedService( |
| 592 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:m") | 594 | "bcat:a", |
| 593 | ->InstallAsService(system.ServiceManager()); | 595 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:a")); |
| 594 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:u") | 596 | server_manager->RegisterNamedService( |
| 595 | ->InstallAsService(system.ServiceManager()); | 597 | "bcat:m", |
| 596 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:s") | 598 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:m")); |
| 597 | ->InstallAsService(system.ServiceManager()); | 599 | server_manager->RegisterNamedService( |
| 600 | "bcat:u", | ||
| 601 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:u")); | ||
| 602 | server_manager->RegisterNamedService( | ||
| 603 | "bcat:s", | ||
| 604 | std::make_shared<BCAT>(system, module, system.GetFileSystemController(), "bcat:s")); | ||
| 605 | ServerManager::RunServer(std::move(server_manager)); | ||
| 598 | } | 606 | } |
| 599 | 607 | ||
| 600 | } // namespace Service::BCAT | 608 | } // namespace Service::BCAT |
diff --git a/src/core/hle/service/bcat/bcat_module.h b/src/core/hle/service/bcat/bcat_module.h index b2fcf9bfb..0c134d1ff 100644 --- a/src/core/hle/service/bcat/bcat_module.h +++ b/src/core/hle/service/bcat/bcat_module.h | |||
| @@ -39,8 +39,7 @@ public: | |||
| 39 | }; | 39 | }; |
| 40 | }; | 40 | }; |
| 41 | 41 | ||
| 42 | /// Registers all BCAT services with the specified service manager. | 42 | void LoopProcess(Core::System& system); |
| 43 | void InstallInterfaces(Core::System& system); | ||
| 44 | 43 | ||
| 45 | } // namespace BCAT | 44 | } // namespace BCAT |
| 46 | 45 | ||
diff --git a/src/core/hle/service/bpc/bpc.cpp b/src/core/hle/service/bpc/bpc.cpp index 466163538..91b15e256 100644 --- a/src/core/hle/service/bpc/bpc.cpp +++ b/src/core/hle/service/bpc/bpc.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/bpc/bpc.h" | 6 | #include "core/hle/service/bpc/bpc.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::BPC { | 10 | namespace Service::BPC { |
| 11 | 11 | ||
| @@ -54,9 +54,12 @@ public: | |||
| 54 | } | 54 | } |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 57 | void LoopProcess(Core::System& system) { |
| 58 | std::make_shared<BPC>(system)->InstallAsService(sm); | 58 | auto server_manager = std::make_unique<ServerManager>(system); |
| 59 | std::make_shared<BPC_R>(system)->InstallAsService(sm); | 59 | |
| 60 | server_manager->RegisterNamedService("bpc", std::make_shared<BPC>(system)); | ||
| 61 | server_manager->RegisterNamedService("bpc:r", std::make_shared<BPC_R>(system)); | ||
| 62 | ServerManager::RunServer(std::move(server_manager)); | ||
| 60 | } | 63 | } |
| 61 | 64 | ||
| 62 | } // namespace Service::BPC | 65 | } // namespace Service::BPC |
diff --git a/src/core/hle/service/bpc/bpc.h b/src/core/hle/service/bpc/bpc.h index 8adc2f962..524391ddb 100644 --- a/src/core/hle/service/bpc/bpc.h +++ b/src/core/hle/service/bpc/bpc.h | |||
| @@ -13,6 +13,6 @@ class ServiceManager; | |||
| 13 | 13 | ||
| 14 | namespace Service::BPC { | 14 | namespace Service::BPC { |
| 15 | 15 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 16 | void LoopProcess(Core::System& system); |
| 17 | 17 | ||
| 18 | } // namespace Service::BPC | 18 | } // namespace Service::BPC |
diff --git a/src/core/hle/service/btdrv/btdrv.cpp b/src/core/hle/service/btdrv/btdrv.cpp index ec7e5320c..ed020d03f 100644 --- a/src/core/hle/service/btdrv/btdrv.cpp +++ b/src/core/hle/service/btdrv/btdrv.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "core/hle/kernel/k_event.h" | 7 | #include "core/hle/kernel/k_event.h" |
| 8 | #include "core/hle/service/btdrv/btdrv.h" | 8 | #include "core/hle/service/btdrv/btdrv.h" |
| 9 | #include "core/hle/service/kernel_helpers.h" | 9 | #include "core/hle/service/kernel_helpers.h" |
| 10 | #include "core/hle/service/server_manager.h" | ||
| 10 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 11 | #include "core/hle/service/sm/sm.h" | 12 | #include "core/hle/service/sm/sm.h" |
| 12 | 13 | ||
| @@ -196,9 +197,12 @@ public: | |||
| 196 | } | 197 | } |
| 197 | }; | 198 | }; |
| 198 | 199 | ||
| 199 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 200 | void LoopProcess(Core::System& system) { |
| 200 | std::make_shared<BtDrv>(system)->InstallAsService(sm); | 201 | auto server_manager = std::make_unique<ServerManager>(system); |
| 201 | std::make_shared<Bt>(system)->InstallAsService(sm); | 202 | |
| 203 | server_manager->RegisterNamedService("btdrv", std::make_shared<BtDrv>(system)); | ||
| 204 | server_manager->RegisterNamedService("bt", std::make_shared<Bt>(system)); | ||
| 205 | ServerManager::RunServer(std::move(server_manager)); | ||
| 202 | } | 206 | } |
| 203 | 207 | ||
| 204 | } // namespace Service::BtDrv | 208 | } // namespace Service::BtDrv |
diff --git a/src/core/hle/service/btdrv/btdrv.h b/src/core/hle/service/btdrv/btdrv.h index 9cbe2926f..42713860e 100644 --- a/src/core/hle/service/btdrv/btdrv.h +++ b/src/core/hle/service/btdrv/btdrv.h | |||
| @@ -13,7 +13,6 @@ class System; | |||
| 13 | 13 | ||
| 14 | namespace Service::BtDrv { | 14 | namespace Service::BtDrv { |
| 15 | 15 | ||
| 16 | /// Registers all BtDrv services with the specified service manager. | 16 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 18 | 17 | ||
| 19 | } // namespace Service::BtDrv | 18 | } // namespace Service::BtDrv |
diff --git a/src/core/hle/service/btm/btm.cpp b/src/core/hle/service/btm/btm.cpp index 419da36c4..dbd9d6a88 100644 --- a/src/core/hle/service/btm/btm.cpp +++ b/src/core/hle/service/btm/btm.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/hle/kernel/k_event.h" | 9 | #include "core/hle/kernel/k_event.h" |
| 10 | #include "core/hle/service/btm/btm.h" | 10 | #include "core/hle/service/btm/btm.h" |
| 11 | #include "core/hle/service/kernel_helpers.h" | 11 | #include "core/hle/service/kernel_helpers.h" |
| 12 | #include "core/hle/service/server_manager.h" | ||
| 12 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 13 | 14 | ||
| 14 | namespace Service::BTM { | 15 | namespace Service::BTM { |
| @@ -315,11 +316,14 @@ private: | |||
| 315 | } | 316 | } |
| 316 | }; | 317 | }; |
| 317 | 318 | ||
| 318 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 319 | void LoopProcess(Core::System& system) { |
| 319 | std::make_shared<BTM>(system)->InstallAsService(sm); | 320 | auto server_manager = std::make_unique<ServerManager>(system); |
| 320 | std::make_shared<BTM_DBG>(system)->InstallAsService(sm); | 321 | |
| 321 | std::make_shared<BTM_SYS>(system)->InstallAsService(sm); | 322 | server_manager->RegisterNamedService("btm", std::make_shared<BTM>(system)); |
| 322 | std::make_shared<BTM_USR>(system)->InstallAsService(sm); | 323 | server_manager->RegisterNamedService("btm:dbg", std::make_shared<BTM_DBG>(system)); |
| 324 | server_manager->RegisterNamedService("btm:sys", std::make_shared<BTM_SYS>(system)); | ||
| 325 | server_manager->RegisterNamedService("btm:u", std::make_shared<BTM_USR>(system)); | ||
| 326 | ServerManager::RunServer(std::move(server_manager)); | ||
| 323 | } | 327 | } |
| 324 | 328 | ||
| 325 | } // namespace Service::BTM | 329 | } // namespace Service::BTM |
diff --git a/src/core/hle/service/btm/btm.h b/src/core/hle/service/btm/btm.h index 9dcda1848..a99b34364 100644 --- a/src/core/hle/service/btm/btm.h +++ b/src/core/hle/service/btm/btm.h | |||
| @@ -13,6 +13,6 @@ class System; | |||
| 13 | 13 | ||
| 14 | namespace Service::BTM { | 14 | namespace Service::BTM { |
| 15 | 15 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 16 | void LoopProcess(Core::System& system); |
| 17 | 17 | ||
| 18 | } // namespace Service::BTM | 18 | } // namespace Service::BTM |
diff --git a/src/core/hle/service/caps/caps.cpp b/src/core/hle/service/caps/caps.cpp index 13940a8c9..610fe9940 100644 --- a/src/core/hle/service/caps/caps.cpp +++ b/src/core/hle/service/caps/caps.cpp | |||
| @@ -8,17 +8,21 @@ | |||
| 8 | #include "core/hle/service/caps/caps_ss.h" | 8 | #include "core/hle/service/caps/caps_ss.h" |
| 9 | #include "core/hle/service/caps/caps_su.h" | 9 | #include "core/hle/service/caps/caps_su.h" |
| 10 | #include "core/hle/service/caps/caps_u.h" | 10 | #include "core/hle/service/caps/caps_u.h" |
| 11 | #include "core/hle/service/server_manager.h" | ||
| 11 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 12 | 13 | ||
| 13 | namespace Service::Capture { | 14 | namespace Service::Capture { |
| 14 | 15 | ||
| 15 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 16 | void LoopProcess(Core::System& system) { |
| 16 | std::make_shared<CAPS_A>(system)->InstallAsService(sm); | 17 | auto server_manager = std::make_unique<ServerManager>(system); |
| 17 | std::make_shared<CAPS_C>(system)->InstallAsService(sm); | 18 | |
| 18 | std::make_shared<CAPS_U>(system)->InstallAsService(sm); | 19 | server_manager->RegisterNamedService("caps:a", std::make_shared<CAPS_A>(system)); |
| 19 | std::make_shared<CAPS_SC>(system)->InstallAsService(sm); | 20 | server_manager->RegisterNamedService("caps:c", std::make_shared<CAPS_C>(system)); |
| 20 | std::make_shared<CAPS_SS>(system)->InstallAsService(sm); | 21 | server_manager->RegisterNamedService("caps:u", std::make_shared<CAPS_U>(system)); |
| 21 | std::make_shared<CAPS_SU>(system)->InstallAsService(sm); | 22 | server_manager->RegisterNamedService("caps:sc", std::make_shared<CAPS_SC>(system)); |
| 23 | server_manager->RegisterNamedService("caps:ss", std::make_shared<CAPS_SS>(system)); | ||
| 24 | server_manager->RegisterNamedService("caps:su", std::make_shared<CAPS_SU>(system)); | ||
| 25 | ServerManager::RunServer(std::move(server_manager)); | ||
| 22 | } | 26 | } |
| 23 | 27 | ||
| 24 | } // namespace Service::Capture | 28 | } // namespace Service::Capture |
diff --git a/src/core/hle/service/caps/caps.h b/src/core/hle/service/caps/caps.h index 3e89c82cb..15f0ecfaa 100644 --- a/src/core/hle/service/caps/caps.h +++ b/src/core/hle/service/caps/caps.h | |||
| @@ -90,7 +90,6 @@ struct ApplicationAlbumFileEntry { | |||
| 90 | static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30, | 90 | static_assert(sizeof(ApplicationAlbumFileEntry) == 0x30, |
| 91 | "ApplicationAlbumFileEntry has incorrect size."); | 91 | "ApplicationAlbumFileEntry has incorrect size."); |
| 92 | 92 | ||
| 93 | /// Registers all Capture services with the specified service manager. | 93 | void LoopProcess(Core::System& system); |
| 94 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 95 | 94 | ||
| 96 | } // namespace Service::Capture | 95 | } // namespace Service::Capture |
diff --git a/src/core/hle/service/erpt/erpt.cpp b/src/core/hle/service/erpt/erpt.cpp index 923c0022a..3ea862fad 100644 --- a/src/core/hle/service/erpt/erpt.cpp +++ b/src/core/hle/service/erpt/erpt.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/erpt/erpt.h" | 6 | #include "core/hle/service/erpt/erpt.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | 9 | #include "core/hle/service/sm/sm.h" |
| 9 | 10 | ||
| @@ -52,9 +53,13 @@ public: | |||
| 52 | } | 53 | } |
| 53 | }; | 54 | }; |
| 54 | 55 | ||
| 55 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 56 | void LoopProcess(Core::System& system) { |
| 56 | std::make_shared<ErrorReportContext>(system)->InstallAsService(sm); | 57 | auto server_manager = std::make_unique<ServerManager>(system); |
| 57 | std::make_shared<ErrorReportSession>(system)->InstallAsService(sm); | 58 | |
| 59 | server_manager->RegisterNamedService("erpt:c", std::make_shared<ErrorReportContext>(system)); | ||
| 60 | server_manager->RegisterNamedService("erpt:r", std::make_shared<ErrorReportSession>(system)); | ||
| 61 | |||
| 62 | ServerManager::RunServer(std::move(server_manager)); | ||
| 58 | } | 63 | } |
| 59 | 64 | ||
| 60 | } // namespace Service::ERPT | 65 | } // namespace Service::ERPT |
diff --git a/src/core/hle/service/erpt/erpt.h b/src/core/hle/service/erpt/erpt.h index 507d626ec..60094f556 100644 --- a/src/core/hle/service/erpt/erpt.h +++ b/src/core/hle/service/erpt/erpt.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::ERPT { | 10 | namespace Service::ERPT { |
| 15 | 11 | ||
| 16 | /// Registers all ERPT services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::ERPT | 14 | } // namespace Service::ERPT |
diff --git a/src/core/hle/service/es/es.cpp b/src/core/hle/service/es/es.cpp index fb8686859..d9736af4e 100644 --- a/src/core/hle/service/es/es.cpp +++ b/src/core/hle/service/es/es.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "core/crypto/key_manager.h" | 4 | #include "core/crypto/key_manager.h" |
| 5 | #include "core/hle/ipc_helpers.h" | 5 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/service/es/es.h" | 6 | #include "core/hle/service/es/es.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | 9 | ||
| 9 | namespace Service::ES { | 10 | namespace Service::ES { |
| @@ -307,8 +308,11 @@ private: | |||
| 307 | Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance(); | 308 | Core::Crypto::KeyManager& keys = Core::Crypto::KeyManager::Instance(); |
| 308 | }; | 309 | }; |
| 309 | 310 | ||
| 310 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 311 | void LoopProcess(Core::System& system) { |
| 311 | std::make_shared<ETicket>(system)->InstallAsService(service_manager); | 312 | auto server_manager = std::make_unique<ServerManager>(system); |
| 313 | |||
| 314 | server_manager->RegisterNamedService("es", std::make_shared<ETicket>(system)); | ||
| 315 | ServerManager::RunServer(std::move(server_manager)); | ||
| 312 | } | 316 | } |
| 313 | 317 | ||
| 314 | } // namespace Service::ES | 318 | } // namespace Service::ES |
diff --git a/src/core/hle/service/es/es.h b/src/core/hle/service/es/es.h index 530563550..317680625 100644 --- a/src/core/hle/service/es/es.h +++ b/src/core/hle/service/es/es.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::ES { | 10 | namespace Service::ES { |
| 15 | 11 | ||
| 16 | /// Registers all ES services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::ES | 14 | } // namespace Service::ES |
diff --git a/src/core/hle/service/eupld/eupld.cpp b/src/core/hle/service/eupld/eupld.cpp index d1553ace0..3cf27513a 100644 --- a/src/core/hle/service/eupld/eupld.cpp +++ b/src/core/hle/service/eupld/eupld.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/eupld/eupld.h" | 6 | #include "core/hle/service/eupld/eupld.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::EUPLD { | 10 | namespace Service::EUPLD { |
| 11 | 11 | ||
| @@ -44,9 +44,12 @@ public: | |||
| 44 | } | 44 | } |
| 45 | }; | 45 | }; |
| 46 | 46 | ||
| 47 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 47 | void LoopProcess(Core::System& system) { |
| 48 | std::make_shared<ErrorUploadContext>(system)->InstallAsService(sm); | 48 | auto server_manager = std::make_unique<ServerManager>(system); |
| 49 | std::make_shared<ErrorUploadRequest>(system)->InstallAsService(sm); | 49 | |
| 50 | server_manager->RegisterNamedService("eupld:c", std::make_shared<ErrorUploadContext>(system)); | ||
| 51 | server_manager->RegisterNamedService("eupld:r", std::make_shared<ErrorUploadRequest>(system)); | ||
| 52 | ServerManager::RunServer(std::move(server_manager)); | ||
| 50 | } | 53 | } |
| 51 | 54 | ||
| 52 | } // namespace Service::EUPLD | 55 | } // namespace Service::EUPLD |
diff --git a/src/core/hle/service/eupld/eupld.h b/src/core/hle/service/eupld/eupld.h index 5de8219be..8eb0a5b4f 100644 --- a/src/core/hle/service/eupld/eupld.h +++ b/src/core/hle/service/eupld/eupld.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::EUPLD { | 10 | namespace Service::EUPLD { |
| 15 | 11 | ||
| 16 | /// Registers all EUPLD services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::EUPLD | 14 | } // namespace Service::EUPLD |
diff --git a/src/core/hle/service/fatal/fatal.cpp b/src/core/hle/service/fatal/fatal.cpp index 2e5919330..3b7b636f3 100644 --- a/src/core/hle/service/fatal/fatal.cpp +++ b/src/core/hle/service/fatal/fatal.cpp | |||
| @@ -13,6 +13,7 @@ | |||
| 13 | #include "core/hle/service/fatal/fatal.h" | 13 | #include "core/hle/service/fatal/fatal.h" |
| 14 | #include "core/hle/service/fatal/fatal_p.h" | 14 | #include "core/hle/service/fatal/fatal_p.h" |
| 15 | #include "core/hle/service/fatal/fatal_u.h" | 15 | #include "core/hle/service/fatal/fatal_u.h" |
| 16 | #include "core/hle/service/server_manager.h" | ||
| 16 | #include "core/reporter.h" | 17 | #include "core/reporter.h" |
| 17 | 18 | ||
| 18 | namespace Service::Fatal { | 19 | namespace Service::Fatal { |
| @@ -163,10 +164,13 @@ void Module::Interface::ThrowFatalWithCpuContext(Kernel::HLERequestContext& ctx) | |||
| 163 | rb.Push(ResultSuccess); | 164 | rb.Push(ResultSuccess); |
| 164 | } | 165 | } |
| 165 | 166 | ||
| 166 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 167 | void LoopProcess(Core::System& system) { |
| 168 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 167 | auto module = std::make_shared<Module>(); | 169 | auto module = std::make_shared<Module>(); |
| 168 | std::make_shared<Fatal_P>(module, system)->InstallAsService(service_manager); | 170 | |
| 169 | std::make_shared<Fatal_U>(module, system)->InstallAsService(service_manager); | 171 | server_manager->RegisterNamedService("fatal:p", std::make_shared<Fatal_P>(module, system)); |
| 172 | server_manager->RegisterNamedService("fatal:u", std::make_shared<Fatal_U>(module, system)); | ||
| 173 | ServerManager::RunServer(std::move(server_manager)); | ||
| 170 | } | 174 | } |
| 171 | 175 | ||
| 172 | } // namespace Service::Fatal | 176 | } // namespace Service::Fatal |
diff --git a/src/core/hle/service/fatal/fatal.h b/src/core/hle/service/fatal/fatal.h index a7a310f7b..2e4e4c2f6 100644 --- a/src/core/hle/service/fatal/fatal.h +++ b/src/core/hle/service/fatal/fatal.h | |||
| @@ -28,6 +28,6 @@ public: | |||
| 28 | }; | 28 | }; |
| 29 | }; | 29 | }; |
| 30 | 30 | ||
| 31 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | 31 | void LoopProcess(Core::System& system); |
| 32 | 32 | ||
| 33 | } // namespace Service::Fatal | 33 | } // namespace Service::Fatal |
diff --git a/src/core/hle/service/fgm/fgm.cpp b/src/core/hle/service/fgm/fgm.cpp index 7e9fb0385..612491270 100644 --- a/src/core/hle/service/fgm/fgm.cpp +++ b/src/core/hle/service/fgm/fgm.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/service/fgm/fgm.h" | 7 | #include "core/hle/service/fgm/fgm.h" |
| 8 | #include "core/hle/service/server_manager.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | #include "core/hle/service/sm/sm.h" | 10 | #include "core/hle/service/sm/sm.h" |
| 10 | 11 | ||
| @@ -63,11 +64,14 @@ public: | |||
| 63 | } | 64 | } |
| 64 | }; | 65 | }; |
| 65 | 66 | ||
| 66 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 67 | void LoopProcess(Core::System& system) { |
| 67 | std::make_shared<FGM>(system, "fgm")->InstallAsService(sm); | 68 | auto server_manager = std::make_unique<ServerManager>(system); |
| 68 | std::make_shared<FGM>(system, "fgm:0")->InstallAsService(sm); | 69 | |
| 69 | std::make_shared<FGM>(system, "fgm:9")->InstallAsService(sm); | 70 | server_manager->RegisterNamedService("fgm", std::make_shared<FGM>(system, "fgm")); |
| 70 | std::make_shared<FGM_DBG>(system)->InstallAsService(sm); | 71 | server_manager->RegisterNamedService("fgm:0", std::make_shared<FGM>(system, "fgm:0")); |
| 72 | server_manager->RegisterNamedService("fgm:9", std::make_shared<FGM>(system, "fgm:9")); | ||
| 73 | server_manager->RegisterNamedService("fgm:dbg", std::make_shared<FGM_DBG>(system)); | ||
| 74 | ServerManager::RunServer(std::move(server_manager)); | ||
| 71 | } | 75 | } |
| 72 | 76 | ||
| 73 | } // namespace Service::FGM | 77 | } // namespace Service::FGM |
diff --git a/src/core/hle/service/fgm/fgm.h b/src/core/hle/service/fgm/fgm.h index 077e48812..9d2465c0f 100644 --- a/src/core/hle/service/fgm/fgm.h +++ b/src/core/hle/service/fgm/fgm.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::FGM { | 10 | namespace Service::FGM { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::FGM | 14 | } // namespace Service::FGM |
diff --git a/src/core/hle/service/filesystem/filesystem.cpp b/src/core/hle/service/filesystem/filesystem.cpp index 177447bc1..dfcdd3ada 100644 --- a/src/core/hle/service/filesystem/filesystem.cpp +++ b/src/core/hle/service/filesystem/filesystem.cpp | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include "core/hle/service/filesystem/fsp_ldr.h" | 23 | #include "core/hle/service/filesystem/fsp_ldr.h" |
| 24 | #include "core/hle/service/filesystem/fsp_pr.h" | 24 | #include "core/hle/service/filesystem/fsp_pr.h" |
| 25 | #include "core/hle/service/filesystem/fsp_srv.h" | 25 | #include "core/hle/service/filesystem/fsp_srv.h" |
| 26 | #include "core/hle/service/server_manager.h" | ||
| 26 | #include "core/loader/loader.h" | 27 | #include "core/loader/loader.h" |
| 27 | 28 | ||
| 28 | namespace Service::FileSystem { | 29 | namespace Service::FileSystem { |
| @@ -796,10 +797,13 @@ void FileSystemController::CreateFactories(FileSys::VfsFilesystem& vfs, bool ove | |||
| 796 | } | 797 | } |
| 797 | } | 798 | } |
| 798 | 799 | ||
| 799 | void InstallInterfaces(Core::System& system) { | 800 | void LoopProcess(Core::System& system) { |
| 800 | std::make_shared<FSP_LDR>(system)->InstallAsService(system.ServiceManager()); | 801 | auto server_manager = std::make_unique<ServerManager>(system); |
| 801 | std::make_shared<FSP_PR>(system)->InstallAsService(system.ServiceManager()); | 802 | |
| 802 | std::make_shared<FSP_SRV>(system)->InstallAsService(system.ServiceManager()); | 803 | server_manager->RegisterNamedService("fsp-ldr", std::make_shared<FSP_LDR>(system)); |
| 804 | server_manager->RegisterNamedService("fsp:pr", std::make_shared<FSP_PR>(system)); | ||
| 805 | server_manager->RegisterNamedService("fsp-srv", std::make_shared<FSP_SRV>(system)); | ||
| 806 | ServerManager::RunServer(std::move(server_manager)); | ||
| 803 | } | 807 | } |
| 804 | 808 | ||
| 805 | } // namespace Service::FileSystem | 809 | } // namespace Service::FileSystem |
diff --git a/src/core/hle/service/filesystem/filesystem.h b/src/core/hle/service/filesystem/filesystem.h index 5b27de9fa..a5c1c9d3e 100644 --- a/src/core/hle/service/filesystem/filesystem.h +++ b/src/core/hle/service/filesystem/filesystem.h | |||
| @@ -139,7 +139,7 @@ private: | |||
| 139 | Core::System& system; | 139 | Core::System& system; |
| 140 | }; | 140 | }; |
| 141 | 141 | ||
| 142 | void InstallInterfaces(Core::System& system); | 142 | void LoopProcess(Core::System& system); |
| 143 | 143 | ||
| 144 | // A class that wraps a VfsDirectory with methods that return ResultVal and Result instead of | 144 | // A class that wraps a VfsDirectory with methods that return ResultVal and Result instead of |
| 145 | // pointers and booleans. This makes using a VfsDirectory with switch services much easier and | 145 | // pointers and booleans. This makes using a VfsDirectory with switch services much easier and |
diff --git a/src/core/hle/service/filesystem/fsp_srv.cpp b/src/core/hle/service/filesystem/fsp_srv.cpp index e76346ca9..89eddb510 100644 --- a/src/core/hle/service/filesystem/fsp_srv.cpp +++ b/src/core/hle/service/filesystem/fsp_srv.cpp | |||
| @@ -57,8 +57,7 @@ enum class FileSystemType : u8 { | |||
| 57 | class IStorage final : public ServiceFramework<IStorage> { | 57 | class IStorage final : public ServiceFramework<IStorage> { |
| 58 | public: | 58 | public: |
| 59 | explicit IStorage(Core::System& system_, FileSys::VirtualFile backend_) | 59 | explicit IStorage(Core::System& system_, FileSys::VirtualFile backend_) |
| 60 | : ServiceFramework{system_, "IStorage", ServiceThreadType::CreateNew}, | 60 | : ServiceFramework{system_, "IStorage"}, backend(std::move(backend_)) { |
| 61 | backend(std::move(backend_)) { | ||
| 62 | static const FunctionInfo functions[] = { | 61 | static const FunctionInfo functions[] = { |
| 63 | {0, &IStorage::Read, "Read"}, | 62 | {0, &IStorage::Read, "Read"}, |
| 64 | {1, nullptr, "Write"}, | 63 | {1, nullptr, "Write"}, |
| @@ -116,8 +115,7 @@ private: | |||
| 116 | class IFile final : public ServiceFramework<IFile> { | 115 | class IFile final : public ServiceFramework<IFile> { |
| 117 | public: | 116 | public: |
| 118 | explicit IFile(Core::System& system_, FileSys::VirtualFile backend_) | 117 | explicit IFile(Core::System& system_, FileSys::VirtualFile backend_) |
| 119 | : ServiceFramework{system_, "IFile", ServiceThreadType::CreateNew}, | 118 | : ServiceFramework{system_, "IFile"}, backend(std::move(backend_)) { |
| 120 | backend(std::move(backend_)) { | ||
| 121 | static const FunctionInfo functions[] = { | 119 | static const FunctionInfo functions[] = { |
| 122 | {0, &IFile::Read, "Read"}, | 120 | {0, &IFile::Read, "Read"}, |
| 123 | {1, &IFile::Write, "Write"}, | 121 | {1, &IFile::Write, "Write"}, |
| @@ -254,8 +252,7 @@ static void BuildEntryIndex(std::vector<FileSys::Entry>& entries, const std::vec | |||
| 254 | class IDirectory final : public ServiceFramework<IDirectory> { | 252 | class IDirectory final : public ServiceFramework<IDirectory> { |
| 255 | public: | 253 | public: |
| 256 | explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_) | 254 | explicit IDirectory(Core::System& system_, FileSys::VirtualDir backend_) |
| 257 | : ServiceFramework{system_, "IDirectory", ServiceThreadType::CreateNew}, | 255 | : ServiceFramework{system_, "IDirectory"}, backend(std::move(backend_)) { |
| 258 | backend(std::move(backend_)) { | ||
| 259 | static const FunctionInfo functions[] = { | 256 | static const FunctionInfo functions[] = { |
| 260 | {0, &IDirectory::Read, "Read"}, | 257 | {0, &IDirectory::Read, "Read"}, |
| 261 | {1, &IDirectory::GetEntryCount, "GetEntryCount"}, | 258 | {1, &IDirectory::GetEntryCount, "GetEntryCount"}, |
| @@ -311,8 +308,8 @@ private: | |||
| 311 | class IFileSystem final : public ServiceFramework<IFileSystem> { | 308 | class IFileSystem final : public ServiceFramework<IFileSystem> { |
| 312 | public: | 309 | public: |
| 313 | explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_) | 310 | explicit IFileSystem(Core::System& system_, FileSys::VirtualDir backend_, SizeGetter size_) |
| 314 | : ServiceFramework{system_, "IFileSystem", ServiceThreadType::CreateNew}, | 311 | : ServiceFramework{system_, "IFileSystem"}, backend{std::move(backend_)}, size{std::move( |
| 315 | backend{std::move(backend_)}, size{std::move(size_)} { | 312 | size_)} { |
| 316 | static const FunctionInfo functions[] = { | 313 | static const FunctionInfo functions[] = { |
| 317 | {0, &IFileSystem::CreateFile, "CreateFile"}, | 314 | {0, &IFileSystem::CreateFile, "CreateFile"}, |
| 318 | {1, &IFileSystem::DeleteFile, "DeleteFile"}, | 315 | {1, &IFileSystem::DeleteFile, "DeleteFile"}, |
diff --git a/src/core/hle/service/friend/friend.cpp b/src/core/hle/service/friend/friend.cpp index fad532115..fcf10bfeb 100644 --- a/src/core/hle/service/friend/friend.cpp +++ b/src/core/hle/service/friend/friend.cpp | |||
| @@ -11,6 +11,7 @@ | |||
| 11 | #include "core/hle/service/friend/friend.h" | 11 | #include "core/hle/service/friend/friend.h" |
| 12 | #include "core/hle/service/friend/friend_interface.h" | 12 | #include "core/hle/service/friend/friend_interface.h" |
| 13 | #include "core/hle/service/kernel_helpers.h" | 13 | #include "core/hle/service/kernel_helpers.h" |
| 14 | #include "core/hle/service/server_manager.h" | ||
| 14 | 15 | ||
| 15 | namespace Service::Friend { | 16 | namespace Service::Friend { |
| 16 | 17 | ||
| @@ -335,13 +336,22 @@ Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& syst | |||
| 335 | 336 | ||
| 336 | Module::Interface::~Interface() = default; | 337 | Module::Interface::~Interface() = default; |
| 337 | 338 | ||
| 338 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 339 | void LoopProcess(Core::System& system) { |
| 340 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 339 | auto module = std::make_shared<Module>(); | 341 | auto module = std::make_shared<Module>(); |
| 340 | std::make_shared<Friend>(module, system, "friend:a")->InstallAsService(service_manager); | 342 | |
| 341 | std::make_shared<Friend>(module, system, "friend:m")->InstallAsService(service_manager); | 343 | server_manager->RegisterNamedService("friend:a", |
| 342 | std::make_shared<Friend>(module, system, "friend:s")->InstallAsService(service_manager); | 344 | std::make_shared<Friend>(module, system, "friend:a")); |
| 343 | std::make_shared<Friend>(module, system, "friend:u")->InstallAsService(service_manager); | 345 | server_manager->RegisterNamedService("friend:m", |
| 344 | std::make_shared<Friend>(module, system, "friend:v")->InstallAsService(service_manager); | 346 | std::make_shared<Friend>(module, system, "friend:m")); |
| 347 | server_manager->RegisterNamedService("friend:s", | ||
| 348 | std::make_shared<Friend>(module, system, "friend:s")); | ||
| 349 | server_manager->RegisterNamedService("friend:u", | ||
| 350 | std::make_shared<Friend>(module, system, "friend:u")); | ||
| 351 | server_manager->RegisterNamedService("friend:v", | ||
| 352 | std::make_shared<Friend>(module, system, "friend:v")); | ||
| 353 | |||
| 354 | ServerManager::RunServer(std::move(server_manager)); | ||
| 345 | } | 355 | } |
| 346 | 356 | ||
| 347 | } // namespace Service::Friend | 357 | } // namespace Service::Friend |
diff --git a/src/core/hle/service/friend/friend.h b/src/core/hle/service/friend/friend.h index 444da8b35..41be06a4f 100644 --- a/src/core/hle/service/friend/friend.h +++ b/src/core/hle/service/friend/friend.h | |||
| @@ -27,7 +27,6 @@ public: | |||
| 27 | }; | 27 | }; |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | /// Registers all Friend services with the specified service manager. | 30 | void LoopProcess(Core::System& system); |
| 31 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 32 | 31 | ||
| 33 | } // namespace Service::Friend | 32 | } // namespace Service::Friend |
diff --git a/src/core/hle/service/glue/glue.cpp b/src/core/hle/service/glue/glue.cpp index 717f2562b..993c3d21d 100644 --- a/src/core/hle/service/glue/glue.cpp +++ b/src/core/hle/service/glue/glue.cpp | |||
| @@ -8,25 +8,30 @@ | |||
| 8 | #include "core/hle/service/glue/ectx.h" | 8 | #include "core/hle/service/glue/ectx.h" |
| 9 | #include "core/hle/service/glue/glue.h" | 9 | #include "core/hle/service/glue/glue.h" |
| 10 | #include "core/hle/service/glue/notif.h" | 10 | #include "core/hle/service/glue/notif.h" |
| 11 | #include "core/hle/service/server_manager.h" | ||
| 11 | 12 | ||
| 12 | namespace Service::Glue { | 13 | namespace Service::Glue { |
| 13 | 14 | ||
| 14 | void InstallInterfaces(Core::System& system) { | 15 | void LoopProcess(Core::System& system) { |
| 16 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 17 | |||
| 15 | // ARP | 18 | // ARP |
| 16 | std::make_shared<ARP_R>(system, system.GetARPManager()) | 19 | server_manager->RegisterNamedService("arp:r", |
| 17 | ->InstallAsService(system.ServiceManager()); | 20 | std::make_shared<ARP_R>(system, system.GetARPManager())); |
| 18 | std::make_shared<ARP_W>(system, system.GetARPManager()) | 21 | server_manager->RegisterNamedService("arp:w", |
| 19 | ->InstallAsService(system.ServiceManager()); | 22 | std::make_shared<ARP_W>(system, system.GetARPManager())); |
| 20 | 23 | ||
| 21 | // BackGround Task Controller | 24 | // BackGround Task Controller |
| 22 | std::make_shared<BGTC_T>(system)->InstallAsService(system.ServiceManager()); | 25 | server_manager->RegisterNamedService("bgtc:t", std::make_shared<BGTC_T>(system)); |
| 23 | std::make_shared<BGTC_SC>(system)->InstallAsService(system.ServiceManager()); | 26 | server_manager->RegisterNamedService("bgtc:sc", std::make_shared<BGTC_SC>(system)); |
| 24 | 27 | ||
| 25 | // Error Context | 28 | // Error Context |
| 26 | std::make_shared<ECTX_AW>(system)->InstallAsService(system.ServiceManager()); | 29 | server_manager->RegisterNamedService("ectx:aw", std::make_shared<ECTX_AW>(system)); |
| 27 | 30 | ||
| 28 | // Notification Services for application | 31 | // Notification Services for application |
| 29 | std::make_shared<NOTIF_A>(system)->InstallAsService(system.ServiceManager()); | 32 | server_manager->RegisterNamedService("notif:a", std::make_shared<NOTIF_A>(system)); |
| 33 | |||
| 34 | ServerManager::RunServer(std::move(server_manager)); | ||
| 30 | } | 35 | } |
| 31 | 36 | ||
| 32 | } // namespace Service::Glue | 37 | } // namespace Service::Glue |
diff --git a/src/core/hle/service/glue/glue.h b/src/core/hle/service/glue/glue.h index ae7c6d235..2a906f5ad 100644 --- a/src/core/hle/service/glue/glue.h +++ b/src/core/hle/service/glue/glue.h | |||
| @@ -9,7 +9,6 @@ class System; | |||
| 9 | 9 | ||
| 10 | namespace Service::Glue { | 10 | namespace Service::Glue { |
| 11 | 11 | ||
| 12 | /// Registers all Glue services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 13 | void InstallInterfaces(Core::System& system); | ||
| 14 | 13 | ||
| 15 | } // namespace Service::Glue | 14 | } // namespace Service::Glue |
diff --git a/src/core/hle/service/grc/grc.cpp b/src/core/hle/service/grc/grc.cpp index 4b684f6d0..64275da36 100644 --- a/src/core/hle/service/grc/grc.cpp +++ b/src/core/hle/service/grc/grc.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/grc/grc.h" | 6 | #include "core/hle/service/grc/grc.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::GRC { | 10 | namespace Service::GRC { |
| 11 | 11 | ||
| @@ -26,8 +26,11 @@ public: | |||
| 26 | } | 26 | } |
| 27 | }; | 27 | }; |
| 28 | 28 | ||
| 29 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 29 | void LoopProcess(Core::System& system) { |
| 30 | std::make_shared<GRC>(system)->InstallAsService(sm); | 30 | auto server_manager = std::make_unique<ServerManager>(system); |
| 31 | |||
| 32 | server_manager->RegisterNamedService("grc:c", std::make_shared<GRC>(system)); | ||
| 33 | ServerManager::RunServer(std::move(server_manager)); | ||
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | } // namespace Service::GRC | 36 | } // namespace Service::GRC |
diff --git a/src/core/hle/service/grc/grc.h b/src/core/hle/service/grc/grc.h index f8c2f8dab..a3f8a5b90 100644 --- a/src/core/hle/service/grc/grc.h +++ b/src/core/hle/service/grc/grc.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::GRC { | 10 | namespace Service::GRC { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::GRC | 14 | } // namespace Service::GRC |
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index 0da67235f..4b5130469 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp | |||
| @@ -18,6 +18,7 @@ | |||
| 18 | #include "core/hle/service/hid/hidbus.h" | 18 | #include "core/hle/service/hid/hidbus.h" |
| 19 | #include "core/hle/service/hid/irs.h" | 19 | #include "core/hle/service/hid/irs.h" |
| 20 | #include "core/hle/service/hid/xcd.h" | 20 | #include "core/hle/service/hid/xcd.h" |
| 21 | #include "core/hle/service/server_manager.h" | ||
| 21 | #include "core/memory.h" | 22 | #include "core/memory.h" |
| 22 | 23 | ||
| 23 | #include "core/hle/service/hid/controllers/console_sixaxis.h" | 24 | #include "core/hle/service/hid/controllers/console_sixaxis.h" |
| @@ -2739,16 +2740,20 @@ private: | |||
| 2739 | } | 2740 | } |
| 2740 | }; | 2741 | }; |
| 2741 | 2742 | ||
| 2742 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 2743 | void LoopProcess(Core::System& system) { |
| 2743 | std::make_shared<Hid>(system)->InstallAsService(service_manager); | 2744 | auto server_manager = std::make_unique<ServerManager>(system); |
| 2744 | std::make_shared<HidBus>(system)->InstallAsService(service_manager); | ||
| 2745 | std::make_shared<HidDbg>(system)->InstallAsService(service_manager); | ||
| 2746 | std::make_shared<HidSys>(system)->InstallAsService(service_manager); | ||
| 2747 | 2745 | ||
| 2748 | std::make_shared<Service::IRS::IRS>(system)->InstallAsService(service_manager); | 2746 | server_manager->RegisterNamedService("hid", std::make_shared<Hid>(system)); |
| 2749 | std::make_shared<Service::IRS::IRS_SYS>(system)->InstallAsService(service_manager); | 2747 | server_manager->RegisterNamedService("hidbus", std::make_shared<HidBus>(system)); |
| 2748 | server_manager->RegisterNamedService("hid:dbg", std::make_shared<HidDbg>(system)); | ||
| 2749 | server_manager->RegisterNamedService("hid:sys", std::make_shared<HidSys>(system)); | ||
| 2750 | 2750 | ||
| 2751 | std::make_shared<XCD_SYS>(system)->InstallAsService(service_manager); | 2751 | server_manager->RegisterNamedService("irs", std::make_shared<Service::IRS::IRS>(system)); |
| 2752 | server_manager->RegisterNamedService("irs:sys", | ||
| 2753 | std::make_shared<Service::IRS::IRS_SYS>(system)); | ||
| 2754 | |||
| 2755 | server_manager->RegisterNamedService("xcd:sys", std::make_shared<XCD_SYS>(system)); | ||
| 2756 | system.RunServer(std::move(server_manager)); | ||
| 2752 | } | 2757 | } |
| 2753 | 2758 | ||
| 2754 | } // namespace Service::HID | 2759 | } // namespace Service::HID |
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 9ace83129..9563654b6 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h | |||
| @@ -216,7 +216,6 @@ private: | |||
| 216 | KernelHelpers::ServiceContext service_context; | 216 | KernelHelpers::ServiceContext service_context; |
| 217 | }; | 217 | }; |
| 218 | 218 | ||
| 219 | /// Registers all HID services with the specified service manager. | 219 | void LoopProcess(Core::System& system); |
| 220 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 221 | 220 | ||
| 222 | } // namespace Service::HID | 221 | } // namespace Service::HID |
diff --git a/src/core/hle/service/jit/jit.cpp b/src/core/hle/service/jit/jit.cpp index 47a1277ea..005c212dc 100644 --- a/src/core/hle/service/jit/jit.cpp +++ b/src/core/hle/service/jit/jit.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "core/hle/result.h" | 9 | #include "core/hle/result.h" |
| 10 | #include "core/hle/service/jit/jit.h" | 10 | #include "core/hle/service/jit/jit.h" |
| 11 | #include "core/hle/service/jit/jit_context.h" | 11 | #include "core/hle/service/jit/jit_context.h" |
| 12 | #include "core/hle/service/server_manager.h" | ||
| 12 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 13 | #include "core/memory.h" | 14 | #include "core/memory.h" |
| 14 | 15 | ||
| @@ -23,8 +24,8 @@ class IJitEnvironment final : public ServiceFramework<IJitEnvironment> { | |||
| 23 | public: | 24 | public: |
| 24 | explicit IJitEnvironment(Core::System& system_, Kernel::KProcess& process_, CodeRange user_rx, | 25 | explicit IJitEnvironment(Core::System& system_, Kernel::KProcess& process_, CodeRange user_rx, |
| 25 | CodeRange user_ro) | 26 | CodeRange user_ro) |
| 26 | : ServiceFramework{system_, "IJitEnvironment", ServiceThreadType::CreateNew}, | 27 | : ServiceFramework{system_, "IJitEnvironment"}, process{&process_}, context{ |
| 27 | process{&process_}, context{system_.Memory()} { | 28 | system_.Memory()} { |
| 28 | // clang-format off | 29 | // clang-format off |
| 29 | static const FunctionInfo functions[] = { | 30 | static const FunctionInfo functions[] = { |
| 30 | {0, &IJitEnvironment::GenerateCode, "GenerateCode"}, | 31 | {0, &IJitEnvironment::GenerateCode, "GenerateCode"}, |
| @@ -397,8 +398,11 @@ public: | |||
| 397 | } | 398 | } |
| 398 | }; | 399 | }; |
| 399 | 400 | ||
| 400 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 401 | void LoopProcess(Core::System& system) { |
| 401 | std::make_shared<JITU>(system)->InstallAsService(sm); | 402 | auto server_manager = std::make_unique<ServerManager>(system); |
| 403 | |||
| 404 | server_manager->RegisterNamedService("jit:u", std::make_shared<JITU>(system)); | ||
| 405 | ServerManager::RunServer(std::move(server_manager)); | ||
| 402 | } | 406 | } |
| 403 | 407 | ||
| 404 | } // namespace Service::JIT | 408 | } // namespace Service::JIT |
diff --git a/src/core/hle/service/jit/jit.h b/src/core/hle/service/jit/jit.h index af0f5b4f3..19014c75a 100644 --- a/src/core/hle/service/jit/jit.h +++ b/src/core/hle/service/jit/jit.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::JIT { | 10 | namespace Service::JIT { |
| 15 | 11 | ||
| 16 | /// Registers all JIT services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::JIT | 14 | } // namespace Service::JIT |
diff --git a/src/core/hle/service/kernel_helpers.cpp b/src/core/hle/service/kernel_helpers.cpp index 42991928e..a39ce5212 100644 --- a/src/core/hle/service/kernel_helpers.cpp +++ b/src/core/hle/service/kernel_helpers.cpp | |||
| @@ -15,17 +15,24 @@ namespace Service::KernelHelpers { | |||
| 15 | 15 | ||
| 16 | ServiceContext::ServiceContext(Core::System& system_, std::string name_) | 16 | ServiceContext::ServiceContext(Core::System& system_, std::string name_) |
| 17 | : kernel(system_.Kernel()) { | 17 | : kernel(system_.Kernel()) { |
| 18 | if (process = Kernel::GetCurrentProcessPointer(kernel); process != nullptr) { | ||
| 19 | return; | ||
| 20 | } | ||
| 21 | |||
| 18 | // Create the process. | 22 | // Create the process. |
| 19 | process = Kernel::KProcess::Create(kernel); | 23 | process = Kernel::KProcess::Create(kernel); |
| 20 | ASSERT(Kernel::KProcess::Initialize(process, system_, std::move(name_), | 24 | ASSERT(Kernel::KProcess::Initialize(process, system_, std::move(name_), |
| 21 | Kernel::KProcess::ProcessType::KernelInternal, | 25 | Kernel::KProcess::ProcessType::KernelInternal, |
| 22 | kernel.GetSystemResourceLimit()) | 26 | kernel.GetSystemResourceLimit()) |
| 23 | .IsSuccess()); | 27 | .IsSuccess()); |
| 28 | process_created = true; | ||
| 24 | } | 29 | } |
| 25 | 30 | ||
| 26 | ServiceContext::~ServiceContext() { | 31 | ServiceContext::~ServiceContext() { |
| 27 | process->Close(); | 32 | if (process_created) { |
| 28 | process = nullptr; | 33 | process->Close(); |
| 34 | process = nullptr; | ||
| 35 | } | ||
| 29 | } | 36 | } |
| 30 | 37 | ||
| 31 | Kernel::KEvent* ServiceContext::CreateEvent(std::string&& name) { | 38 | Kernel::KEvent* ServiceContext::CreateEvent(std::string&& name) { |
diff --git a/src/core/hle/service/kernel_helpers.h b/src/core/hle/service/kernel_helpers.h index 6415838e5..eca9aefb5 100644 --- a/src/core/hle/service/kernel_helpers.h +++ b/src/core/hle/service/kernel_helpers.h | |||
| @@ -29,6 +29,7 @@ public: | |||
| 29 | private: | 29 | private: |
| 30 | Kernel::KernelCore& kernel; | 30 | Kernel::KernelCore& kernel; |
| 31 | Kernel::KProcess* process{}; | 31 | Kernel::KProcess* process{}; |
| 32 | bool process_created{false}; | ||
| 32 | }; | 33 | }; |
| 33 | 34 | ||
| 34 | } // namespace Service::KernelHelpers | 35 | } // namespace Service::KernelHelpers |
diff --git a/src/core/hle/service/lbl/lbl.cpp b/src/core/hle/service/lbl/lbl.cpp index c8415e0bf..3f3c68d80 100644 --- a/src/core/hle/service/lbl/lbl.cpp +++ b/src/core/hle/service/lbl/lbl.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "common/logging/log.h" | 7 | #include "common/logging/log.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/service/lbl/lbl.h" | 9 | #include "core/hle/service/lbl/lbl.h" |
| 10 | #include "core/hle/service/server_manager.h" | ||
| 10 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 11 | #include "core/hle/service/sm/sm.h" | 12 | #include "core/hle/service/sm/sm.h" |
| 12 | 13 | ||
| @@ -319,8 +320,11 @@ private: | |||
| 319 | bool auto_brightness = false; // TODO(ogniK): Move to system settings | 320 | bool auto_brightness = false; // TODO(ogniK): Move to system settings |
| 320 | }; | 321 | }; |
| 321 | 322 | ||
| 322 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 323 | void LoopProcess(Core::System& system) { |
| 323 | std::make_shared<LBL>(system)->InstallAsService(sm); | 324 | auto server_manager = std::make_unique<ServerManager>(system); |
| 325 | |||
| 326 | server_manager->RegisterNamedService("lbl", std::make_shared<LBL>(system)); | ||
| 327 | ServerManager::RunServer(std::move(server_manager)); | ||
| 324 | } | 328 | } |
| 325 | 329 | ||
| 326 | } // namespace Service::LBL | 330 | } // namespace Service::LBL |
diff --git a/src/core/hle/service/lbl/lbl.h b/src/core/hle/service/lbl/lbl.h index 6484105c2..e47759c01 100644 --- a/src/core/hle/service/lbl/lbl.h +++ b/src/core/hle/service/lbl/lbl.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::LBL { | 10 | namespace Service::LBL { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::LBL | 14 | } // namespace Service::LBL |
diff --git a/src/core/hle/service/ldn/ldn.cpp b/src/core/hle/service/ldn/ldn.cpp index e5099d61f..4c2abe7d3 100644 --- a/src/core/hle/service/ldn/ldn.cpp +++ b/src/core/hle/service/ldn/ldn.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "core/hle/service/ldn/ldn.h" | 8 | #include "core/hle/service/ldn/ldn.h" |
| 9 | #include "core/hle/service/ldn/ldn_results.h" | 9 | #include "core/hle/service/ldn/ldn_results.h" |
| 10 | #include "core/hle/service/ldn/ldn_types.h" | 10 | #include "core/hle/service/ldn/ldn_types.h" |
| 11 | #include "core/hle/service/server_manager.h" | ||
| 11 | #include "core/internal_network/network.h" | 12 | #include "core/internal_network/network.h" |
| 12 | #include "core/internal_network/network_interface.h" | 13 | #include "core/internal_network/network_interface.h" |
| 13 | #include "network/network.h" | 14 | #include "network/network.h" |
| @@ -106,7 +107,7 @@ class IUserLocalCommunicationService final | |||
| 106 | : public ServiceFramework<IUserLocalCommunicationService> { | 107 | : public ServiceFramework<IUserLocalCommunicationService> { |
| 107 | public: | 108 | public: |
| 108 | explicit IUserLocalCommunicationService(Core::System& system_) | 109 | explicit IUserLocalCommunicationService(Core::System& system_) |
| 109 | : ServiceFramework{system_, "IUserLocalCommunicationService", ServiceThreadType::CreateNew}, | 110 | : ServiceFramework{system_, "IUserLocalCommunicationService"}, |
| 110 | service_context{system, "IUserLocalCommunicationService"}, | 111 | service_context{system, "IUserLocalCommunicationService"}, |
| 111 | room_network{system_.GetRoomNetwork()}, lan_discovery{room_network} { | 112 | room_network{system_.GetRoomNetwork()}, lan_discovery{room_network} { |
| 112 | // clang-format off | 113 | // clang-format off |
| @@ -730,12 +731,15 @@ public: | |||
| 730 | } | 731 | } |
| 731 | }; | 732 | }; |
| 732 | 733 | ||
| 733 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 734 | void LoopProcess(Core::System& system) { |
| 734 | std::make_shared<LDNM>(system)->InstallAsService(sm); | 735 | auto server_manager = std::make_unique<ServerManager>(system); |
| 735 | std::make_shared<LDNS>(system)->InstallAsService(sm); | 736 | |
| 736 | std::make_shared<LDNU>(system)->InstallAsService(sm); | 737 | server_manager->RegisterNamedService("ldn:m", std::make_shared<LDNM>(system)); |
| 737 | std::make_shared<LP2PAPP>(system)->InstallAsService(sm); | 738 | server_manager->RegisterNamedService("ldn:s", std::make_shared<LDNS>(system)); |
| 738 | std::make_shared<LP2PSYS>(system)->InstallAsService(sm); | 739 | server_manager->RegisterNamedService("ldn:u", std::make_shared<LDNU>(system)); |
| 740 | server_manager->RegisterNamedService("lp2p:app", std::make_shared<LP2PAPP>(system)); | ||
| 741 | server_manager->RegisterNamedService("lp2p:sys", std::make_shared<LP2PSYS>(system)); | ||
| 742 | ServerManager::RunServer(std::move(server_manager)); | ||
| 739 | } | 743 | } |
| 740 | 744 | ||
| 741 | } // namespace Service::LDN | 745 | } // namespace Service::LDN |
diff --git a/src/core/hle/service/ldn/ldn.h b/src/core/hle/service/ldn/ldn.h index 6afe2ea6f..fa869fa89 100644 --- a/src/core/hle/service/ldn/ldn.h +++ b/src/core/hle/service/ldn/ldn.h | |||
| @@ -13,13 +13,8 @@ namespace Core { | |||
| 13 | class System; | 13 | class System; |
| 14 | } | 14 | } |
| 15 | 15 | ||
| 16 | namespace Service::SM { | ||
| 17 | class ServiceManager; | ||
| 18 | } | ||
| 19 | |||
| 20 | namespace Service::LDN { | 16 | namespace Service::LDN { |
| 21 | 17 | ||
| 22 | /// Registers all LDN services with the specified service manager. | 18 | void LoopProcess(Core::System& system); |
| 23 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 24 | 19 | ||
| 25 | } // namespace Service::LDN | 20 | } // namespace Service::LDN |
diff --git a/src/core/hle/service/ldr/ldr.cpp b/src/core/hle/service/ldr/ldr.cpp index 2d4d6fe3e..c82e189f4 100644 --- a/src/core/hle/service/ldr/ldr.cpp +++ b/src/core/hle/service/ldr/ldr.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "core/hle/kernel/svc_results.h" | 14 | #include "core/hle/kernel/svc_results.h" |
| 15 | #include "core/hle/kernel/svc_types.h" | 15 | #include "core/hle/kernel/svc_types.h" |
| 16 | #include "core/hle/service/ldr/ldr.h" | 16 | #include "core/hle/service/ldr/ldr.h" |
| 17 | #include "core/hle/service/server_manager.h" | ||
| 17 | #include "core/hle/service/service.h" | 18 | #include "core/hle/service/service.h" |
| 18 | #include "core/loader/nro.h" | 19 | #include "core/loader/nro.h" |
| 19 | #include "core/memory.h" | 20 | #include "core/memory.h" |
| @@ -159,8 +160,7 @@ public: | |||
| 159 | 160 | ||
| 160 | class RelocatableObject final : public ServiceFramework<RelocatableObject> { | 161 | class RelocatableObject final : public ServiceFramework<RelocatableObject> { |
| 161 | public: | 162 | public: |
| 162 | explicit RelocatableObject(Core::System& system_) | 163 | explicit RelocatableObject(Core::System& system_) : ServiceFramework{system_, "ldr:ro"} { |
| 163 | : ServiceFramework{system_, "ldr:ro", ServiceThreadType::CreateNew} { | ||
| 164 | // clang-format off | 164 | // clang-format off |
| 165 | static const FunctionInfo functions[] = { | 165 | static const FunctionInfo functions[] = { |
| 166 | {0, &RelocatableObject::LoadModule, "LoadModule"}, | 166 | {0, &RelocatableObject::LoadModule, "LoadModule"}, |
| @@ -682,11 +682,15 @@ private: | |||
| 682 | } | 682 | } |
| 683 | }; | 683 | }; |
| 684 | 684 | ||
| 685 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 685 | void LoopProcess(Core::System& system) { |
| 686 | std::make_shared<DebugMonitor>(system)->InstallAsService(sm); | 686 | auto server_manager = std::make_unique<ServerManager>(system); |
| 687 | std::make_shared<ProcessManager>(system)->InstallAsService(sm); | 687 | |
| 688 | std::make_shared<Shell>(system)->InstallAsService(sm); | 688 | server_manager->RegisterNamedService("ldr:dmnt", std::make_shared<DebugMonitor>(system)); |
| 689 | std::make_shared<RelocatableObject>(system)->InstallAsService(sm); | 689 | server_manager->RegisterNamedService("ldr:pm", std::make_shared<ProcessManager>(system)); |
| 690 | server_manager->RegisterNamedService("ldr:shel", std::make_shared<Shell>(system)); | ||
| 691 | server_manager->RegisterNamedService("ldr:ro", std::make_shared<RelocatableObject>(system)); | ||
| 692 | |||
| 693 | ServerManager::RunServer(std::move(server_manager)); | ||
| 690 | } | 694 | } |
| 691 | 695 | ||
| 692 | } // namespace Service::LDR | 696 | } // namespace Service::LDR |
diff --git a/src/core/hle/service/ldr/ldr.h b/src/core/hle/service/ldr/ldr.h index 25ffd8442..c9281dbfb 100644 --- a/src/core/hle/service/ldr/ldr.h +++ b/src/core/hle/service/ldr/ldr.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::LDR { | 10 | namespace Service::LDR { |
| 15 | 11 | ||
| 16 | /// Registers all LDR services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::LDR | 14 | } // namespace Service::LDR |
diff --git a/src/core/hle/service/lm/lm.cpp b/src/core/hle/service/lm/lm.cpp index ef4b54046..7efd8e0ab 100644 --- a/src/core/hle/service/lm/lm.cpp +++ b/src/core/hle/service/lm/lm.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "core/core.h" | 10 | #include "core/core.h" |
| 11 | #include "core/hle/ipc_helpers.h" | 11 | #include "core/hle/ipc_helpers.h" |
| 12 | #include "core/hle/service/lm/lm.h" | 12 | #include "core/hle/service/lm/lm.h" |
| 13 | #include "core/hle/service/server_manager.h" | ||
| 13 | #include "core/hle/service/service.h" | 14 | #include "core/hle/service/service.h" |
| 14 | 15 | ||
| 15 | namespace Service::LM { | 16 | namespace Service::LM { |
| @@ -351,8 +352,11 @@ private: | |||
| 351 | } | 352 | } |
| 352 | }; | 353 | }; |
| 353 | 354 | ||
| 354 | void InstallInterfaces(Core::System& system) { | 355 | void LoopProcess(Core::System& system) { |
| 355 | std::make_shared<LM>(system)->InstallAsService(system.ServiceManager()); | 356 | auto server_manager = std::make_unique<ServerManager>(system); |
| 357 | |||
| 358 | server_manager->RegisterNamedService("lm", std::make_shared<LM>(system)); | ||
| 359 | ServerManager::RunServer(std::move(server_manager)); | ||
| 356 | } | 360 | } |
| 357 | 361 | ||
| 358 | } // namespace Service::LM | 362 | } // namespace Service::LM |
diff --git a/src/core/hle/service/lm/lm.h b/src/core/hle/service/lm/lm.h index 266019c30..0d7c39cbc 100644 --- a/src/core/hle/service/lm/lm.h +++ b/src/core/hle/service/lm/lm.h | |||
| @@ -9,7 +9,6 @@ class System; | |||
| 9 | 9 | ||
| 10 | namespace Service::LM { | 10 | namespace Service::LM { |
| 11 | 11 | ||
| 12 | /// Registers all LM services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 13 | void InstallInterfaces(Core::System& system); | ||
| 14 | 13 | ||
| 15 | } // namespace Service::LM | 14 | } // namespace Service::LM |
diff --git a/src/core/hle/service/mig/mig.cpp b/src/core/hle/service/mig/mig.cpp index b9fe0cecd..082e470ab 100644 --- a/src/core/hle/service/mig/mig.cpp +++ b/src/core/hle/service/mig/mig.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/mig/mig.h" | 6 | #include "core/hle/service/mig/mig.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::Migration { | 10 | namespace Service::Migration { |
| 11 | 11 | ||
| @@ -32,8 +32,11 @@ public: | |||
| 32 | } | 32 | } |
| 33 | }; | 33 | }; |
| 34 | 34 | ||
| 35 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 35 | void LoopProcess(Core::System& system) { |
| 36 | std::make_shared<MIG_USR>(system)->InstallAsService(sm); | 36 | auto server_manager = std::make_unique<ServerManager>(system); |
| 37 | |||
| 38 | server_manager->RegisterNamedService("mig:user", std::make_shared<MIG_USR>(system)); | ||
| 39 | ServerManager::RunServer(std::move(server_manager)); | ||
| 37 | } | 40 | } |
| 38 | 41 | ||
| 39 | } // namespace Service::Migration | 42 | } // namespace Service::Migration |
diff --git a/src/core/hle/service/mig/mig.h b/src/core/hle/service/mig/mig.h index f1641a521..c8ed732a5 100644 --- a/src/core/hle/service/mig/mig.h +++ b/src/core/hle/service/mig/mig.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Migration { | 10 | namespace Service::Migration { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::Migration | 14 | } // namespace Service::Migration |
diff --git a/src/core/hle/service/mii/mii.cpp b/src/core/hle/service/mii/mii.cpp index 390514fdc..50dc0ac64 100644 --- a/src/core/hle/service/mii/mii.cpp +++ b/src/core/hle/service/mii/mii.cpp | |||
| @@ -7,8 +7,8 @@ | |||
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/service/mii/mii.h" | 8 | #include "core/hle/service/mii/mii.h" |
| 9 | #include "core/hle/service/mii/mii_manager.h" | 9 | #include "core/hle/service/mii/mii_manager.h" |
| 10 | #include "core/hle/service/server_manager.h" | ||
| 10 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 11 | #include "core/hle/service/sm/sm.h" | ||
| 12 | 12 | ||
| 13 | namespace Service::Mii { | 13 | namespace Service::Mii { |
| 14 | 14 | ||
| @@ -310,11 +310,13 @@ public: | |||
| 310 | } | 310 | } |
| 311 | }; | 311 | }; |
| 312 | 312 | ||
| 313 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 313 | void LoopProcess(Core::System& system) { |
| 314 | std::make_shared<MiiDBModule>(system, "mii:e")->InstallAsService(sm); | 314 | auto server_manager = std::make_unique<ServerManager>(system); |
| 315 | std::make_shared<MiiDBModule>(system, "mii:u")->InstallAsService(sm); | ||
| 316 | 315 | ||
| 317 | std::make_shared<MiiImg>(system)->InstallAsService(sm); | 316 | server_manager->RegisterNamedService("mii:e", std::make_shared<MiiDBModule>(system, "mii:e")); |
| 317 | server_manager->RegisterNamedService("mii:u", std::make_shared<MiiDBModule>(system, "mii:u")); | ||
| 318 | server_manager->RegisterNamedService("miiimg", std::make_shared<MiiImg>(system)); | ||
| 319 | ServerManager::RunServer(std::move(server_manager)); | ||
| 318 | } | 320 | } |
| 319 | 321 | ||
| 320 | } // namespace Service::Mii | 322 | } // namespace Service::Mii |
diff --git a/src/core/hle/service/mii/mii.h b/src/core/hle/service/mii/mii.h index 009d80d58..ed4e3f62b 100644 --- a/src/core/hle/service/mii/mii.h +++ b/src/core/hle/service/mii/mii.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Mii { | 10 | namespace Service::Mii { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::Mii | 14 | } // namespace Service::Mii |
diff --git a/src/core/hle/service/mm/mm_u.cpp b/src/core/hle/service/mm/mm_u.cpp index ba8c0e230..bee72fa1b 100644 --- a/src/core/hle/service/mm/mm_u.cpp +++ b/src/core/hle/service/mm/mm_u.cpp | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "common/logging/log.h" | 4 | #include "common/logging/log.h" |
| 5 | #include "core/hle/ipc_helpers.h" | 5 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/service/mm/mm_u.h" | 6 | #include "core/hle/service/mm/mm_u.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/sm/sm.h" | 8 | #include "core/hle/service/sm/sm.h" |
| 8 | 9 | ||
| 9 | namespace Service::MM { | 10 | namespace Service::MM { |
| @@ -103,8 +104,11 @@ private: | |||
| 103 | u32 id{1}; | 104 | u32 id{1}; |
| 104 | }; | 105 | }; |
| 105 | 106 | ||
| 106 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 107 | void LoopProcess(Core::System& system) { |
| 107 | std::make_shared<MM_U>(system)->InstallAsService(service_manager); | 108 | auto server_manager = std::make_unique<ServerManager>(system); |
| 109 | |||
| 110 | server_manager->RegisterNamedService("mm:u", std::make_shared<MM_U>(system)); | ||
| 111 | ServerManager::RunServer(std::move(server_manager)); | ||
| 108 | } | 112 | } |
| 109 | 113 | ||
| 110 | } // namespace Service::MM | 114 | } // namespace Service::MM |
diff --git a/src/core/hle/service/mm/mm_u.h b/src/core/hle/service/mm/mm_u.h index b40941e35..43117c9b1 100644 --- a/src/core/hle/service/mm/mm_u.h +++ b/src/core/hle/service/mm/mm_u.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::MM { | 10 | namespace Service::MM { |
| 15 | 11 | ||
| 16 | /// Registers all MM services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::MM | 14 | } // namespace Service::MM |
diff --git a/src/core/hle/service/mnpp/mnpp_app.cpp b/src/core/hle/service/mnpp/mnpp_app.cpp index c3aad5714..4ce4672b7 100644 --- a/src/core/hle/service/mnpp/mnpp_app.cpp +++ b/src/core/hle/service/mnpp/mnpp_app.cpp | |||
| @@ -4,7 +4,8 @@ | |||
| 4 | #include "common/logging/log.h" | 4 | #include "common/logging/log.h" |
| 5 | #include "core/hle/ipc_helpers.h" | 5 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/service/mnpp/mnpp_app.h" | 6 | #include "core/hle/service/mnpp/mnpp_app.h" |
| 7 | #include "core/hle/service/sm/sm.h" | 7 | #include "core/hle/service/server_manager.h" |
| 8 | #include "core/hle/service/service.h" | ||
| 8 | 9 | ||
| 9 | namespace Service::MNPP { | 10 | namespace Service::MNPP { |
| 10 | 11 | ||
| @@ -37,8 +38,11 @@ private: | |||
| 37 | } | 38 | } |
| 38 | }; | 39 | }; |
| 39 | 40 | ||
| 40 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 41 | void LoopProcess(Core::System& system) { |
| 41 | std::make_shared<MNPP_APP>(system)->InstallAsService(service_manager); | 42 | auto server_manager = std::make_unique<ServerManager>(system); |
| 43 | |||
| 44 | server_manager->RegisterNamedService("mnpp:app", std::make_shared<MNPP_APP>(system)); | ||
| 45 | ServerManager::RunServer(std::move(server_manager)); | ||
| 42 | } | 46 | } |
| 43 | 47 | ||
| 44 | } // namespace Service::MNPP | 48 | } // namespace Service::MNPP |
diff --git a/src/core/hle/service/mnpp/mnpp_app.h b/src/core/hle/service/mnpp/mnpp_app.h index eec75fe0e..40d0395bd 100644 --- a/src/core/hle/service/mnpp/mnpp_app.h +++ b/src/core/hle/service/mnpp/mnpp_app.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::MNPP { | 10 | namespace Service::MNPP { |
| 15 | 11 | ||
| 16 | /// Registers all MNPP services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::MNPP | 14 | } // namespace Service::MNPP |
diff --git a/src/core/hle/service/mutex.cpp b/src/core/hle/service/mutex.cpp new file mode 100644 index 000000000..07589a0f0 --- /dev/null +++ b/src/core/hle/service/mutex.cpp | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "core/core.h" | ||
| 5 | #include "core/hle/kernel/k_event.h" | ||
| 6 | #include "core/hle/kernel/k_synchronization_object.h" | ||
| 7 | #include "core/hle/service/mutex.h" | ||
| 8 | |||
| 9 | namespace Service { | ||
| 10 | |||
| 11 | Mutex::Mutex(Core::System& system) : m_system(system) { | ||
| 12 | m_event = Kernel::KEvent::Create(system.Kernel()); | ||
| 13 | m_event->Initialize(nullptr); | ||
| 14 | |||
| 15 | ASSERT(R_SUCCEEDED(m_event->Signal())); | ||
| 16 | } | ||
| 17 | |||
| 18 | Mutex::~Mutex() { | ||
| 19 | m_event->GetReadableEvent().Close(); | ||
| 20 | m_event->Close(); | ||
| 21 | } | ||
| 22 | |||
| 23 | void Mutex::lock() { | ||
| 24 | // Infinitely retry until we successfully clear the event. | ||
| 25 | while (R_FAILED(m_event->GetReadableEvent().Reset())) { | ||
| 26 | s32 index; | ||
| 27 | Kernel::KSynchronizationObject* obj = &m_event->GetReadableEvent(); | ||
| 28 | |||
| 29 | // The event was already cleared! | ||
| 30 | // Wait for it to become signaled again. | ||
| 31 | ASSERT(R_SUCCEEDED( | ||
| 32 | Kernel::KSynchronizationObject::Wait(m_system.Kernel(), &index, &obj, 1, -1))); | ||
| 33 | } | ||
| 34 | |||
| 35 | // We successfully cleared the event, and now have exclusive ownership. | ||
| 36 | } | ||
| 37 | |||
| 38 | void Mutex::unlock() { | ||
| 39 | // Unlock. | ||
| 40 | ASSERT(R_SUCCEEDED(m_event->Signal())); | ||
| 41 | } | ||
| 42 | |||
| 43 | } // namespace Service | ||
diff --git a/src/core/hle/service/mutex.h b/src/core/hle/service/mutex.h new file mode 100644 index 000000000..95ac9b117 --- /dev/null +++ b/src/core/hle/service/mutex.h | |||
| @@ -0,0 +1,31 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include "common/common_types.h" | ||
| 7 | |||
| 8 | namespace Core { | ||
| 9 | class System; | ||
| 10 | } | ||
| 11 | |||
| 12 | namespace Kernel { | ||
| 13 | class KEvent; | ||
| 14 | } | ||
| 15 | |||
| 16 | namespace Service { | ||
| 17 | |||
| 18 | class Mutex { | ||
| 19 | public: | ||
| 20 | explicit Mutex(Core::System& system); | ||
| 21 | ~Mutex(); | ||
| 22 | |||
| 23 | void lock(); | ||
| 24 | void unlock(); | ||
| 25 | |||
| 26 | private: | ||
| 27 | Core::System& m_system; | ||
| 28 | Kernel::KEvent* m_event{}; | ||
| 29 | }; | ||
| 30 | |||
| 31 | } // namespace Service | ||
diff --git a/src/core/hle/service/ncm/ncm.cpp b/src/core/hle/service/ncm/ncm.cpp index 4c66cfeba..5ab24dc34 100644 --- a/src/core/hle/service/ncm/ncm.cpp +++ b/src/core/hle/service/ncm/ncm.cpp | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | #include "core/file_sys/romfs_factory.h" | 6 | #include "core/file_sys/romfs_factory.h" |
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/service/ncm/ncm.h" | 8 | #include "core/hle/service/ncm/ncm.h" |
| 9 | #include "core/hle/service/server_manager.h" | ||
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | #include "core/hle/service/sm/sm.h" | ||
| 11 | 11 | ||
| 12 | namespace Service::NCM { | 12 | namespace Service::NCM { |
| 13 | 13 | ||
| @@ -132,9 +132,12 @@ public: | |||
| 132 | } | 132 | } |
| 133 | }; | 133 | }; |
| 134 | 134 | ||
| 135 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 135 | void LoopProcess(Core::System& system) { |
| 136 | std::make_shared<LR>(system)->InstallAsService(sm); | 136 | auto server_manager = std::make_unique<ServerManager>(system); |
| 137 | std::make_shared<NCM>(system)->InstallAsService(sm); | 137 | |
| 138 | server_manager->RegisterNamedService("lr", std::make_shared<LR>(system)); | ||
| 139 | server_manager->RegisterNamedService("ncm", std::make_shared<NCM>(system)); | ||
| 140 | ServerManager::RunServer(std::move(server_manager)); | ||
| 138 | } | 141 | } |
| 139 | 142 | ||
| 140 | } // namespace Service::NCM | 143 | } // namespace Service::NCM |
diff --git a/src/core/hle/service/ncm/ncm.h b/src/core/hle/service/ncm/ncm.h index de3971437..b78efdcd7 100644 --- a/src/core/hle/service/ncm/ncm.h +++ b/src/core/hle/service/ncm/ncm.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::NCM { | 10 | namespace Service::NCM { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::NCM | 14 | } // namespace Service::NCM |
diff --git a/src/core/hle/service/nfc/nfc.cpp b/src/core/hle/service/nfc/nfc.cpp index b17b18ab9..34612b9df 100644 --- a/src/core/hle/service/nfc/nfc.cpp +++ b/src/core/hle/service/nfc/nfc.cpp | |||
| @@ -9,8 +9,8 @@ | |||
| 9 | #include "core/hle/service/nfc/mifare_user.h" | 9 | #include "core/hle/service/nfc/mifare_user.h" |
| 10 | #include "core/hle/service/nfc/nfc.h" | 10 | #include "core/hle/service/nfc/nfc.h" |
| 11 | #include "core/hle/service/nfc/nfc_user.h" | 11 | #include "core/hle/service/nfc/nfc_user.h" |
| 12 | #include "core/hle/service/server_manager.h" | ||
| 12 | #include "core/hle/service/service.h" | 13 | #include "core/hle/service/service.h" |
| 13 | #include "core/hle/service/sm/sm.h" | ||
| 14 | 14 | ||
| 15 | namespace Service::NFC { | 15 | namespace Service::NFC { |
| 16 | 16 | ||
| @@ -154,11 +154,14 @@ private: | |||
| 154 | } | 154 | } |
| 155 | }; | 155 | }; |
| 156 | 156 | ||
| 157 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 157 | void LoopProcess(Core::System& system) { |
| 158 | std::make_shared<NFC_AM>(system)->InstallAsService(sm); | 158 | auto server_manager = std::make_unique<ServerManager>(system); |
| 159 | std::make_shared<NFC_MF_U>(system)->InstallAsService(sm); | 159 | |
| 160 | std::make_shared<NFC_U>(system)->InstallAsService(sm); | 160 | server_manager->RegisterNamedService("nfc:am", std::make_shared<NFC_AM>(system)); |
| 161 | std::make_shared<NFC_SYS>(system)->InstallAsService(sm); | 161 | server_manager->RegisterNamedService("nfc:mf:u", std::make_shared<NFC_MF_U>(system)); |
| 162 | server_manager->RegisterNamedService("nfc:user", std::make_shared<NFC_U>(system)); | ||
| 163 | server_manager->RegisterNamedService("nfc:sys", std::make_shared<NFC_SYS>(system)); | ||
| 164 | ServerManager::RunServer(std::move(server_manager)); | ||
| 162 | } | 165 | } |
| 163 | 166 | ||
| 164 | } // namespace Service::NFC | 167 | } // namespace Service::NFC |
diff --git a/src/core/hle/service/nfc/nfc.h b/src/core/hle/service/nfc/nfc.h index 0107b696c..d15955b75 100644 --- a/src/core/hle/service/nfc/nfc.h +++ b/src/core/hle/service/nfc/nfc.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::NFC { | 10 | namespace Service::NFC { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::NFC | 14 | } // namespace Service::NFC |
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp index 0cb55ca49..1b59aba8e 100644 --- a/src/core/hle/service/nfp/nfp.cpp +++ b/src/core/hle/service/nfp/nfp.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "core/hle/ipc_helpers.h" | 5 | #include "core/hle/ipc_helpers.h" |
| 6 | #include "core/hle/service/nfp/nfp.h" | 6 | #include "core/hle/service/nfp/nfp.h" |
| 7 | #include "core/hle/service/nfp/nfp_user.h" | 7 | #include "core/hle/service/nfp/nfp_user.h" |
| 8 | #include "core/hle/service/server_manager.h" | ||
| 8 | 9 | ||
| 9 | namespace Service::NFP { | 10 | namespace Service::NFP { |
| 10 | 11 | ||
| @@ -36,8 +37,11 @@ private: | |||
| 36 | std::shared_ptr<IUser> user_interface; | 37 | std::shared_ptr<IUser> user_interface; |
| 37 | }; | 38 | }; |
| 38 | 39 | ||
| 39 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 40 | void LoopProcess(Core::System& system) { |
| 40 | std::make_shared<IUserManager>(system)->InstallAsService(service_manager); | 41 | auto server_manager = std::make_unique<ServerManager>(system); |
| 42 | |||
| 43 | server_manager->RegisterNamedService("nfp:user", std::make_shared<IUserManager>(system)); | ||
| 44 | ServerManager::RunServer(std::move(server_manager)); | ||
| 41 | } | 45 | } |
| 42 | 46 | ||
| 43 | } // namespace Service::NFP | 47 | } // namespace Service::NFP |
diff --git a/src/core/hle/service/nfp/nfp.h b/src/core/hle/service/nfp/nfp.h index a25c362b8..a5aac710b 100644 --- a/src/core/hle/service/nfp/nfp.h +++ b/src/core/hle/service/nfp/nfp.h | |||
| @@ -7,6 +7,6 @@ | |||
| 7 | 7 | ||
| 8 | namespace Service::NFP { | 8 | namespace Service::NFP { |
| 9 | 9 | ||
| 10 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | 10 | void LoopProcess(Core::System& system); |
| 11 | 11 | ||
| 12 | } // namespace Service::NFP | 12 | } // namespace Service::NFP |
diff --git a/src/core/hle/service/ngct/ngct.cpp b/src/core/hle/service/ngct/ngct.cpp index 8af8a835d..76897d05c 100644 --- a/src/core/hle/service/ngct/ngct.cpp +++ b/src/core/hle/service/ngct/ngct.cpp | |||
| @@ -5,6 +5,7 @@ | |||
| 5 | #include "core/core.h" | 5 | #include "core/core.h" |
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/service/ngct/ngct.h" | 7 | #include "core/hle/service/ngct/ngct.h" |
| 8 | #include "core/hle/service/server_manager.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | 10 | ||
| 10 | namespace Service::NGCT { | 11 | namespace Service::NGCT { |
| @@ -51,8 +52,11 @@ private: | |||
| 51 | } | 52 | } |
| 52 | }; | 53 | }; |
| 53 | 54 | ||
| 54 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 55 | void LoopProcess(Core::System& system) { |
| 55 | std::make_shared<IService>(system)->InstallAsService(system.ServiceManager()); | 56 | auto server_manager = std::make_unique<ServerManager>(system); |
| 57 | |||
| 58 | server_manager->RegisterNamedService("ngct:u", std::make_shared<IService>(system)); | ||
| 59 | ServerManager::RunServer(std::move(server_manager)); | ||
| 56 | } | 60 | } |
| 57 | 61 | ||
| 58 | } // namespace Service::NGCT | 62 | } // namespace Service::NGCT |
diff --git a/src/core/hle/service/ngct/ngct.h b/src/core/hle/service/ngct/ngct.h index 370bd4a25..27c34dad4 100644 --- a/src/core/hle/service/ngct/ngct.h +++ b/src/core/hle/service/ngct/ngct.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::NGCT { | 10 | namespace Service::NGCT { |
| 15 | 11 | ||
| 16 | /// Registers all NGCT services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::NGCT | 14 | } // namespace Service::NGCT |
diff --git a/src/core/hle/service/nifm/nifm.cpp b/src/core/hle/service/nifm/nifm.cpp index 5d32adf64..3d176b3c2 100644 --- a/src/core/hle/service/nifm/nifm.cpp +++ b/src/core/hle/service/nifm/nifm.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "core/hle/kernel/k_event.h" | 6 | #include "core/hle/kernel/k_event.h" |
| 7 | #include "core/hle/service/kernel_helpers.h" | 7 | #include "core/hle/service/kernel_helpers.h" |
| 8 | #include "core/hle/service/nifm/nifm.h" | 8 | #include "core/hle/service/nifm/nifm.h" |
| 9 | #include "core/hle/service/server_manager.h" | ||
| 9 | 10 | ||
| 10 | namespace { | 11 | namespace { |
| 11 | 12 | ||
| @@ -626,10 +627,16 @@ private: | |||
| 626 | } | 627 | } |
| 627 | }; | 628 | }; |
| 628 | 629 | ||
| 629 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 630 | void LoopProcess(Core::System& system) { |
| 630 | std::make_shared<NetworkInterface>("nifm:a", system)->InstallAsService(service_manager); | 631 | auto server_manager = std::make_unique<ServerManager>(system); |
| 631 | std::make_shared<NetworkInterface>("nifm:s", system)->InstallAsService(service_manager); | 632 | |
| 632 | std::make_shared<NetworkInterface>("nifm:u", system)->InstallAsService(service_manager); | 633 | server_manager->RegisterNamedService("nifm:a", |
| 634 | std::make_shared<NetworkInterface>("nifm:a", system)); | ||
| 635 | server_manager->RegisterNamedService("nifm:s", | ||
| 636 | std::make_shared<NetworkInterface>("nifm:s", system)); | ||
| 637 | server_manager->RegisterNamedService("nifm:u", | ||
| 638 | std::make_shared<NetworkInterface>("nifm:u", system)); | ||
| 639 | ServerManager::RunServer(std::move(server_manager)); | ||
| 633 | } | 640 | } |
| 634 | 641 | ||
| 635 | } // namespace Service::NIFM | 642 | } // namespace Service::NIFM |
diff --git a/src/core/hle/service/nifm/nifm.h b/src/core/hle/service/nifm/nifm.h index 48161be28..b5da7ae12 100644 --- a/src/core/hle/service/nifm/nifm.h +++ b/src/core/hle/service/nifm/nifm.h | |||
| @@ -12,14 +12,9 @@ namespace Core { | |||
| 12 | class System; | 12 | class System; |
| 13 | } | 13 | } |
| 14 | 14 | ||
| 15 | namespace Service::SM { | ||
| 16 | class ServiceManager; | ||
| 17 | } | ||
| 18 | |||
| 19 | namespace Service::NIFM { | 15 | namespace Service::NIFM { |
| 20 | 16 | ||
| 21 | /// Registers all NIFM services with the specified service manager. | 17 | void LoopProcess(Core::System& system); |
| 22 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 23 | 18 | ||
| 24 | class IGeneralService final : public ServiceFramework<IGeneralService> { | 19 | class IGeneralService final : public ServiceFramework<IGeneralService> { |
| 25 | public: | 20 | public: |
diff --git a/src/core/hle/service/nim/nim.cpp b/src/core/hle/service/nim/nim.cpp index 5a8a91e0b..aff7cc5bd 100644 --- a/src/core/hle/service/nim/nim.cpp +++ b/src/core/hle/service/nim/nim.cpp | |||
| @@ -8,8 +8,8 @@ | |||
| 8 | #include "core/hle/kernel/k_event.h" | 8 | #include "core/hle/kernel/k_event.h" |
| 9 | #include "core/hle/service/kernel_helpers.h" | 9 | #include "core/hle/service/kernel_helpers.h" |
| 10 | #include "core/hle/service/nim/nim.h" | 10 | #include "core/hle/service/nim/nim.h" |
| 11 | #include "core/hle/service/server_manager.h" | ||
| 11 | #include "core/hle/service/service.h" | 12 | #include "core/hle/service/service.h" |
| 12 | #include "core/hle/service/sm/sm.h" | ||
| 13 | 13 | ||
| 14 | namespace Service::NIM { | 14 | namespace Service::NIM { |
| 15 | 15 | ||
| @@ -418,11 +418,14 @@ private: | |||
| 418 | } | 418 | } |
| 419 | }; | 419 | }; |
| 420 | 420 | ||
| 421 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 421 | void LoopProcess(Core::System& system) { |
| 422 | std::make_shared<NIM>(system)->InstallAsService(sm); | 422 | auto server_manager = std::make_unique<ServerManager>(system); |
| 423 | std::make_shared<NIM_ECA>(system)->InstallAsService(sm); | 423 | |
| 424 | std::make_shared<NIM_SHP>(system)->InstallAsService(sm); | 424 | server_manager->RegisterNamedService("nim", std::make_shared<NIM>(system)); |
| 425 | std::make_shared<NTC>(system)->InstallAsService(sm); | 425 | server_manager->RegisterNamedService("nim:eca", std::make_shared<NIM_ECA>(system)); |
| 426 | server_manager->RegisterNamedService("nim:shp", std::make_shared<NIM_SHP>(system)); | ||
| 427 | server_manager->RegisterNamedService("ntc", std::make_shared<NTC>(system)); | ||
| 428 | ServerManager::RunServer(std::move(server_manager)); | ||
| 426 | } | 429 | } |
| 427 | 430 | ||
| 428 | } // namespace Service::NIM | 431 | } // namespace Service::NIM |
diff --git a/src/core/hle/service/nim/nim.h b/src/core/hle/service/nim/nim.h index 8f6ff28e8..e7d599908 100644 --- a/src/core/hle/service/nim/nim.h +++ b/src/core/hle/service/nim/nim.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::NIM { | 10 | namespace Service::NIM { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::NIM | 14 | } // namespace Service::NIM |
diff --git a/src/core/hle/service/npns/npns.cpp b/src/core/hle/service/npns/npns.cpp index 8133711c2..a162e5c54 100644 --- a/src/core/hle/service/npns/npns.cpp +++ b/src/core/hle/service/npns/npns.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/npns/npns.h" | 6 | #include "core/hle/service/npns/npns.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::NPNS { | 10 | namespace Service::NPNS { |
| 11 | 11 | ||
| @@ -94,9 +94,12 @@ public: | |||
| 94 | } | 94 | } |
| 95 | }; | 95 | }; |
| 96 | 96 | ||
| 97 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 97 | void LoopProcess(Core::System& system) { |
| 98 | std::make_shared<NPNS_S>(system)->InstallAsService(sm); | 98 | auto server_manager = std::make_unique<ServerManager>(system); |
| 99 | std::make_shared<NPNS_U>(system)->InstallAsService(sm); | 99 | |
| 100 | server_manager->RegisterNamedService("npns:s", std::make_shared<NPNS_S>(system)); | ||
| 101 | server_manager->RegisterNamedService("npns:u", std::make_shared<NPNS_U>(system)); | ||
| 102 | ServerManager::RunServer(std::move(server_manager)); | ||
| 100 | } | 103 | } |
| 101 | 104 | ||
| 102 | } // namespace Service::NPNS | 105 | } // namespace Service::NPNS |
diff --git a/src/core/hle/service/npns/npns.h b/src/core/hle/service/npns/npns.h index 84e6ec437..0019fca76 100644 --- a/src/core/hle/service/npns/npns.h +++ b/src/core/hle/service/npns/npns.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::NPNS { | 10 | namespace Service::NPNS { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::NPNS | 14 | } // namespace Service::NPNS |
diff --git a/src/core/hle/service/ns/ns.cpp b/src/core/hle/service/ns/ns.cpp index e53bdde52..062e96ef9 100644 --- a/src/core/hle/service/ns/ns.cpp +++ b/src/core/hle/service/ns/ns.cpp | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | #include "core/hle/service/ns/language.h" | 14 | #include "core/hle/service/ns/language.h" |
| 15 | #include "core/hle/service/ns/ns.h" | 15 | #include "core/hle/service/ns/ns.h" |
| 16 | #include "core/hle/service/ns/pdm_qry.h" | 16 | #include "core/hle/service/ns/pdm_qry.h" |
| 17 | #include "core/hle/service/server_manager.h" | ||
| 17 | #include "core/hle/service/set/set.h" | 18 | #include "core/hle/service/set/set.h" |
| 18 | 19 | ||
| 19 | namespace Service::NS { | 20 | namespace Service::NS { |
| @@ -785,23 +786,26 @@ private: | |||
| 785 | } | 786 | } |
| 786 | }; | 787 | }; |
| 787 | 788 | ||
| 788 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 789 | void LoopProcess(Core::System& system) { |
| 789 | 790 | auto server_manager = std::make_unique<ServerManager>(system); | |
| 790 | std::make_shared<NS>("ns:am2", system)->InstallAsService(service_manager); | 791 | |
| 791 | std::make_shared<NS>("ns:ec", system)->InstallAsService(service_manager); | 792 | server_manager->RegisterNamedService("ns:am2", std::make_shared<NS>("ns:am2", system)); |
| 792 | std::make_shared<NS>("ns:rid", system)->InstallAsService(service_manager); | 793 | server_manager->RegisterNamedService("ns:ec", std::make_shared<NS>("ns:ec", system)); |
| 793 | std::make_shared<NS>("ns:rt", system)->InstallAsService(service_manager); | 794 | server_manager->RegisterNamedService("ns:rid", std::make_shared<NS>("ns:rid", system)); |
| 794 | std::make_shared<NS>("ns:web", system)->InstallAsService(service_manager); | 795 | server_manager->RegisterNamedService("ns:rt", std::make_shared<NS>("ns:rt", system)); |
| 795 | std::make_shared<NS>("ns:ro", system)->InstallAsService(service_manager); | 796 | server_manager->RegisterNamedService("ns:web", std::make_shared<NS>("ns:web", system)); |
| 796 | 797 | server_manager->RegisterNamedService("ns:ro", std::make_shared<NS>("ns:ro", system)); | |
| 797 | std::make_shared<NS_DEV>(system)->InstallAsService(service_manager); | 798 | |
| 798 | std::make_shared<NS_SU>(system)->InstallAsService(service_manager); | 799 | server_manager->RegisterNamedService("ns:dev", std::make_shared<NS_DEV>(system)); |
| 799 | std::make_shared<NS_VM>(system)->InstallAsService(service_manager); | 800 | server_manager->RegisterNamedService("ns:su", std::make_shared<NS_SU>(system)); |
| 800 | 801 | server_manager->RegisterNamedService("ns:vm", std::make_shared<NS_VM>(system)); | |
| 801 | std::make_shared<PDM_QRY>(system)->InstallAsService(service_manager); | 802 | server_manager->RegisterNamedService("pdm:qry", std::make_shared<PDM_QRY>(system)); |
| 802 | 803 | ||
| 803 | std::make_shared<IPlatformServiceManager>(system, "pl:s")->InstallAsService(service_manager); | 804 | server_manager->RegisterNamedService("pl:s", |
| 804 | std::make_shared<IPlatformServiceManager>(system, "pl:u")->InstallAsService(service_manager); | 805 | std::make_shared<IPlatformServiceManager>(system, "pl:s")); |
| 806 | server_manager->RegisterNamedService("pl:u", | ||
| 807 | std::make_shared<IPlatformServiceManager>(system, "pl:u")); | ||
| 808 | ServerManager::RunServer(std::move(server_manager)); | ||
| 805 | } | 809 | } |
| 806 | 810 | ||
| 807 | } // namespace Service::NS | 811 | } // namespace Service::NS |
diff --git a/src/core/hle/service/ns/ns.h b/src/core/hle/service/ns/ns.h index 9c18e935c..797e69a13 100644 --- a/src/core/hle/service/ns/ns.h +++ b/src/core/hle/service/ns/ns.h | |||
| @@ -117,8 +117,7 @@ private: | |||
| 117 | } | 117 | } |
| 118 | }; | 118 | }; |
| 119 | 119 | ||
| 120 | /// Registers all NS services with the specified service manager. | 120 | void LoopProcess(Core::System& system); |
| 121 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 122 | 121 | ||
| 123 | } // namespace NS | 122 | } // namespace NS |
| 124 | } // namespace Service | 123 | } // namespace Service |
diff --git a/src/core/hle/service/nvdrv/nvdrv.cpp b/src/core/hle/service/nvdrv/nvdrv.cpp index 52d27e755..a70ea9385 100644 --- a/src/core/hle/service/nvdrv/nvdrv.cpp +++ b/src/core/hle/service/nvdrv/nvdrv.cpp | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include "core/hle/service/nvdrv/nvdrv_interface.h" | 24 | #include "core/hle/service/nvdrv/nvdrv_interface.h" |
| 25 | #include "core/hle/service/nvdrv/nvmemp.h" | 25 | #include "core/hle/service/nvdrv/nvmemp.h" |
| 26 | #include "core/hle/service/nvflinger/nvflinger.h" | 26 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 27 | #include "core/hle/service/server_manager.h" | ||
| 27 | #include "video_core/gpu.h" | 28 | #include "video_core/gpu.h" |
| 28 | 29 | ||
| 29 | namespace Service::Nvidia { | 30 | namespace Service::Nvidia { |
| @@ -41,15 +42,19 @@ void EventInterface::FreeEvent(Kernel::KEvent* event) { | |||
| 41 | module.service_context.CloseEvent(event); | 42 | module.service_context.CloseEvent(event); |
| 42 | } | 43 | } |
| 43 | 44 | ||
| 44 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | 45 | void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system) { |
| 45 | Core::System& system) { | 46 | auto server_manager = std::make_unique<ServerManager>(system); |
| 46 | auto module_ = std::make_shared<Module>(system); | 47 | auto module = std::make_shared<Module>(system); |
| 47 | std::make_shared<NVDRV>(system, module_, "nvdrv")->InstallAsService(service_manager); | 48 | server_manager->RegisterNamedService("nvdrv", std::make_shared<NVDRV>(system, module, "nvdrv")); |
| 48 | std::make_shared<NVDRV>(system, module_, "nvdrv:a")->InstallAsService(service_manager); | 49 | server_manager->RegisterNamedService("nvdrv:a", |
| 49 | std::make_shared<NVDRV>(system, module_, "nvdrv:s")->InstallAsService(service_manager); | 50 | std::make_shared<NVDRV>(system, module, "nvdrv:a")); |
| 50 | std::make_shared<NVDRV>(system, module_, "nvdrv:t")->InstallAsService(service_manager); | 51 | server_manager->RegisterNamedService("nvdrv:s", |
| 51 | std::make_shared<NVMEMP>(system)->InstallAsService(service_manager); | 52 | std::make_shared<NVDRV>(system, module, "nvdrv:s")); |
| 52 | nvflinger.SetNVDrvInstance(module_); | 53 | server_manager->RegisterNamedService("nvdrv:t", |
| 54 | std::make_shared<NVDRV>(system, module, "nvdrv:t")); | ||
| 55 | server_manager->RegisterNamedService("nvmemp", std::make_shared<NVMEMP>(system)); | ||
| 56 | nvflinger.SetNVDrvInstance(module); | ||
| 57 | ServerManager::RunServer(std::move(server_manager)); | ||
| 53 | } | 58 | } |
| 54 | 59 | ||
| 55 | Module::Module(Core::System& system) | 60 | Module::Module(Core::System& system) |
diff --git a/src/core/hle/service/nvdrv/nvdrv.h b/src/core/hle/service/nvdrv/nvdrv.h index b09b6e585..b2270cf76 100644 --- a/src/core/hle/service/nvdrv/nvdrv.h +++ b/src/core/hle/service/nvdrv/nvdrv.h | |||
| @@ -114,8 +114,6 @@ private: | |||
| 114 | std::unordered_map<std::string, std::function<FilesContainerType::iterator(DeviceFD)>> builders; | 114 | std::unordered_map<std::string, std::function<FilesContainerType::iterator(DeviceFD)>> builders; |
| 115 | }; | 115 | }; |
| 116 | 116 | ||
| 117 | /// Registers all NVDRV services with the specified service manager. | 117 | void LoopProcess(NVFlinger::NVFlinger& nvflinger, Core::System& system); |
| 118 | void InstallInterfaces(SM::ServiceManager& service_manager, NVFlinger::NVFlinger& nvflinger, | ||
| 119 | Core::System& system); | ||
| 120 | 118 | ||
| 121 | } // namespace Service::Nvidia | 119 | } // namespace Service::Nvidia |
diff --git a/src/core/hle/service/nvdrv/nvdrv_interface.cpp b/src/core/hle/service/nvdrv/nvdrv_interface.cpp index edbdfee43..396fa7ed5 100644 --- a/src/core/hle/service/nvdrv/nvdrv_interface.cpp +++ b/src/core/hle/service/nvdrv/nvdrv_interface.cpp | |||
| @@ -222,7 +222,7 @@ void NVDRV::DumpGraphicsMemoryInfo(Kernel::HLERequestContext& ctx) { | |||
| 222 | } | 222 | } |
| 223 | 223 | ||
| 224 | NVDRV::NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name) | 224 | NVDRV::NVDRV(Core::System& system_, std::shared_ptr<Module> nvdrv_, const char* name) |
| 225 | : ServiceFramework{system_, name, ServiceThreadType::CreateNew}, nvdrv{std::move(nvdrv_)} { | 225 | : ServiceFramework{system_, name}, nvdrv{std::move(nvdrv_)} { |
| 226 | static const FunctionInfo functions[] = { | 226 | static const FunctionInfo functions[] = { |
| 227 | {0, &NVDRV::Open, "Open"}, | 227 | {0, &NVDRV::Open, "Open"}, |
| 228 | {1, &NVDRV::Ioctl1, "Ioctl"}, | 228 | {1, &NVDRV::Ioctl1, "Ioctl"}, |
diff --git a/src/core/hle/service/olsc/olsc.cpp b/src/core/hle/service/olsc/olsc.cpp index 530e1be3b..3493f8272 100644 --- a/src/core/hle/service/olsc/olsc.cpp +++ b/src/core/hle/service/olsc/olsc.cpp | |||
| @@ -3,8 +3,8 @@ | |||
| 3 | 3 | ||
| 4 | #include "core/hle/ipc_helpers.h" | 4 | #include "core/hle/ipc_helpers.h" |
| 5 | #include "core/hle/service/olsc/olsc.h" | 5 | #include "core/hle/service/olsc/olsc.h" |
| 6 | #include "core/hle/service/server_manager.h" | ||
| 6 | #include "core/hle/service/service.h" | 7 | #include "core/hle/service/service.h" |
| 7 | #include "core/hle/service/sm/sm.h" | ||
| 8 | 8 | ||
| 9 | namespace Service::OLSC { | 9 | namespace Service::OLSC { |
| 10 | 10 | ||
| @@ -72,8 +72,11 @@ private: | |||
| 72 | bool initialized{}; | 72 | bool initialized{}; |
| 73 | }; | 73 | }; |
| 74 | 74 | ||
| 75 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 75 | void LoopProcess(Core::System& system) { |
| 76 | std::make_shared<OLSC>(system)->InstallAsService(service_manager); | 76 | auto server_manager = std::make_unique<ServerManager>(system); |
| 77 | |||
| 78 | server_manager->RegisterNamedService("olsc:u", std::make_shared<OLSC>(system)); | ||
| 79 | ServerManager::RunServer(std::move(server_manager)); | ||
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | } // namespace Service::OLSC | 82 | } // namespace Service::OLSC |
diff --git a/src/core/hle/service/olsc/olsc.h b/src/core/hle/service/olsc/olsc.h index 1522d8d32..620b634fa 100644 --- a/src/core/hle/service/olsc/olsc.h +++ b/src/core/hle/service/olsc/olsc.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::OLSC { | 10 | namespace Service::OLSC { |
| 15 | 11 | ||
| 16 | /// Registers all SSL services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::OLSC | 14 | } // namespace Service::OLSC |
diff --git a/src/core/hle/service/pcie/pcie.cpp b/src/core/hle/service/pcie/pcie.cpp index 79501b9f9..c6da6eb51 100644 --- a/src/core/hle/service/pcie/pcie.cpp +++ b/src/core/hle/service/pcie/pcie.cpp | |||
| @@ -4,8 +4,8 @@ | |||
| 4 | #include <memory> | 4 | #include <memory> |
| 5 | 5 | ||
| 6 | #include "core/hle/service/pcie/pcie.h" | 6 | #include "core/hle/service/pcie/pcie.h" |
| 7 | #include "core/hle/service/server_manager.h" | ||
| 7 | #include "core/hle/service/service.h" | 8 | #include "core/hle/service/service.h" |
| 8 | #include "core/hle/service/sm/sm.h" | ||
| 9 | 9 | ||
| 10 | namespace Service::PCIe { | 10 | namespace Service::PCIe { |
| 11 | 11 | ||
| @@ -59,8 +59,11 @@ public: | |||
| 59 | } | 59 | } |
| 60 | }; | 60 | }; |
| 61 | 61 | ||
| 62 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 62 | void LoopProcess(Core::System& system) { |
| 63 | std::make_shared<PCIe>(system)->InstallAsService(sm); | 63 | auto server_manager = std::make_unique<ServerManager>(system); |
| 64 | |||
| 65 | server_manager->RegisterNamedService("pcie", std::make_shared<PCIe>(system)); | ||
| 66 | ServerManager::RunServer(std::move(server_manager)); | ||
| 64 | } | 67 | } |
| 65 | 68 | ||
| 66 | } // namespace Service::PCIe | 69 | } // namespace Service::PCIe |
diff --git a/src/core/hle/service/pcie/pcie.h b/src/core/hle/service/pcie/pcie.h index cebfd9042..5c2d4b805 100644 --- a/src/core/hle/service/pcie/pcie.h +++ b/src/core/hle/service/pcie/pcie.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::PCIe { | 10 | namespace Service::PCIe { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::PCIe | 14 | } // namespace Service::PCIe |
diff --git a/src/core/hle/service/pctl/pctl_module.cpp b/src/core/hle/service/pctl/pctl_module.cpp index 083609b34..a4a12a78c 100644 --- a/src/core/hle/service/pctl/pctl_module.cpp +++ b/src/core/hle/service/pctl/pctl_module.cpp | |||
| @@ -8,6 +8,7 @@ | |||
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/service/pctl/pctl.h" | 9 | #include "core/hle/service/pctl/pctl.h" |
| 10 | #include "core/hle/service/pctl/pctl_module.h" | 10 | #include "core/hle/service/pctl/pctl_module.h" |
| 11 | #include "core/hle/service/server_manager.h" | ||
| 11 | 12 | ||
| 12 | namespace Service::PCTL { | 13 | namespace Service::PCTL { |
| 13 | 14 | ||
| @@ -393,19 +394,22 @@ Module::Interface::Interface(Core::System& system_, std::shared_ptr<Module> modu | |||
| 393 | 394 | ||
| 394 | Module::Interface::~Interface() = default; | 395 | Module::Interface::~Interface() = default; |
| 395 | 396 | ||
| 396 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 397 | void LoopProcess(Core::System& system) { |
| 398 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 399 | |||
| 397 | auto module = std::make_shared<Module>(); | 400 | auto module = std::make_shared<Module>(); |
| 398 | std::make_shared<PCTL>(system, module, "pctl", | 401 | server_manager->RegisterNamedService( |
| 399 | Capability::Application | Capability::SnsPost | Capability::Status | | 402 | "pctl", std::make_shared<PCTL>(system, module, "pctl", |
| 400 | Capability::StereoVision) | 403 | Capability::Application | Capability::SnsPost | |
| 401 | ->InstallAsService(service_manager); | 404 | Capability::Status | Capability::StereoVision)); |
| 402 | // TODO(ogniK): Implement remaining capabilities | 405 | // TODO(ogniK): Implement remaining capabilities |
| 403 | std::make_shared<PCTL>(system, module, "pctl:a", Capability::None) | 406 | server_manager->RegisterNamedService( |
| 404 | ->InstallAsService(service_manager); | 407 | "pctl:a", std::make_shared<PCTL>(system, module, "pctl:a", Capability::None)); |
| 405 | std::make_shared<PCTL>(system, module, "pctl:r", Capability::None) | 408 | server_manager->RegisterNamedService( |
| 406 | ->InstallAsService(service_manager); | 409 | "pctl:r", std::make_shared<PCTL>(system, module, "pctl:r", Capability::None)); |
| 407 | std::make_shared<PCTL>(system, module, "pctl:s", Capability::None) | 410 | server_manager->RegisterNamedService( |
| 408 | ->InstallAsService(service_manager); | 411 | "pctl:s", std::make_shared<PCTL>(system, module, "pctl:s", Capability::None)); |
| 412 | ServerManager::RunServer(std::move(server_manager)); | ||
| 409 | } | 413 | } |
| 410 | 414 | ||
| 411 | } // namespace Service::PCTL | 415 | } // namespace Service::PCTL |
diff --git a/src/core/hle/service/pctl/pctl_module.h b/src/core/hle/service/pctl/pctl_module.h index 6f584530d..4ea77ab21 100644 --- a/src/core/hle/service/pctl/pctl_module.h +++ b/src/core/hle/service/pctl/pctl_module.h | |||
| @@ -42,7 +42,6 @@ public: | |||
| 42 | }; | 42 | }; |
| 43 | }; | 43 | }; |
| 44 | 44 | ||
| 45 | /// Registers all PCTL services with the specified service manager. | 45 | void LoopProcess(Core::System& system); |
| 46 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 47 | 46 | ||
| 48 | } // namespace Service::PCTL | 47 | } // namespace Service::PCTL |
diff --git a/src/core/hle/service/pcv/pcv.cpp b/src/core/hle/service/pcv/pcv.cpp index 98037a8d4..be64b94ea 100644 --- a/src/core/hle/service/pcv/pcv.cpp +++ b/src/core/hle/service/pcv/pcv.cpp | |||
| @@ -5,8 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include "core/hle/ipc_helpers.h" | 6 | #include "core/hle/ipc_helpers.h" |
| 7 | #include "core/hle/service/pcv/pcv.h" | 7 | #include "core/hle/service/pcv/pcv.h" |
| 8 | #include "core/hle/service/server_manager.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 10 | 10 | ||
| 11 | namespace Service::PCV { | 11 | namespace Service::PCV { |
| 12 | 12 | ||
| @@ -141,11 +141,14 @@ public: | |||
| 141 | } | 141 | } |
| 142 | }; | 142 | }; |
| 143 | 143 | ||
| 144 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 144 | void LoopProcess(Core::System& system) { |
| 145 | std::make_shared<PCV>(system)->InstallAsService(sm); | 145 | auto server_manager = std::make_unique<ServerManager>(system); |
| 146 | std::make_shared<CLKRST>(system, "clkrst")->InstallAsService(sm); | 146 | |
| 147 | std::make_shared<CLKRST>(system, "clkrst:i")->InstallAsService(sm); | 147 | server_manager->RegisterNamedService("pcv", std::make_shared<PCV>(system)); |
| 148 | std::make_shared<CLKRST_A>(system)->InstallAsService(sm); | 148 | server_manager->RegisterNamedService("clkrst", std::make_shared<CLKRST>(system, "clkrst")); |
| 149 | server_manager->RegisterNamedService("clkrst:i", std::make_shared<CLKRST>(system, "clkrst:i")); | ||
| 150 | server_manager->RegisterNamedService("clkrst:a", std::make_shared<CLKRST_A>(system)); | ||
| 151 | ServerManager::RunServer(std::move(server_manager)); | ||
| 149 | } | 152 | } |
| 150 | 153 | ||
| 151 | } // namespace Service::PCV | 154 | } // namespace Service::PCV |
diff --git a/src/core/hle/service/pcv/pcv.h b/src/core/hle/service/pcv/pcv.h index 6b26b6fa7..bf541e6fe 100644 --- a/src/core/hle/service/pcv/pcv.h +++ b/src/core/hle/service/pcv/pcv.h | |||
| @@ -7,10 +7,6 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::PCV { | 10 | namespace Service::PCV { |
| 15 | 11 | ||
| 16 | enum class DeviceCode : u32 { | 12 | enum class DeviceCode : u32 { |
| @@ -104,6 +100,6 @@ enum class DeviceCode : u32 { | |||
| 104 | OscClk = 0x40000080 | 100 | OscClk = 0x40000080 |
| 105 | }; | 101 | }; |
| 106 | 102 | ||
| 107 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 103 | void LoopProcess(Core::System& system); |
| 108 | 104 | ||
| 109 | } // namespace Service::PCV | 105 | } // namespace Service::PCV |
diff --git a/src/core/hle/service/pm/pm.cpp b/src/core/hle/service/pm/pm.cpp index b10e86c8f..02a4ca13b 100644 --- a/src/core/hle/service/pm/pm.cpp +++ b/src/core/hle/service/pm/pm.cpp | |||
| @@ -6,6 +6,7 @@ | |||
| 6 | #include "core/hle/kernel/k_process.h" | 6 | #include "core/hle/kernel/k_process.h" |
| 7 | #include "core/hle/kernel/kernel.h" | 7 | #include "core/hle/kernel/kernel.h" |
| 8 | #include "core/hle/service/pm/pm.h" | 8 | #include "core/hle/service/pm/pm.h" |
| 9 | #include "core/hle/service/server_manager.h" | ||
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | 11 | ||
| 11 | namespace Service::PM { | 12 | namespace Service::PM { |
| @@ -262,12 +263,15 @@ private: | |||
| 262 | const Kernel::KernelCore& kernel; | 263 | const Kernel::KernelCore& kernel; |
| 263 | }; | 264 | }; |
| 264 | 265 | ||
| 265 | void InstallInterfaces(Core::System& system) { | 266 | void LoopProcess(Core::System& system) { |
| 266 | std::make_shared<BootMode>(system)->InstallAsService(system.ServiceManager()); | 267 | auto server_manager = std::make_unique<ServerManager>(system); |
| 267 | std::make_shared<DebugMonitor>(system)->InstallAsService(system.ServiceManager()); | 268 | |
| 268 | std::make_shared<Info>(system, system.Kernel().GetProcessList()) | 269 | server_manager->RegisterNamedService("pm:bm", std::make_shared<BootMode>(system)); |
| 269 | ->InstallAsService(system.ServiceManager()); | 270 | server_manager->RegisterNamedService("pm:dmnt", std::make_shared<DebugMonitor>(system)); |
| 270 | std::make_shared<Shell>(system)->InstallAsService(system.ServiceManager()); | 271 | server_manager->RegisterNamedService( |
| 272 | "pm:info", std::make_shared<Info>(system, system.Kernel().GetProcessList())); | ||
| 273 | server_manager->RegisterNamedService("pm:shell", std::make_shared<Shell>(system)); | ||
| 274 | ServerManager::RunServer(std::move(server_manager)); | ||
| 271 | } | 275 | } |
| 272 | 276 | ||
| 273 | } // namespace Service::PM | 277 | } // namespace Service::PM |
diff --git a/src/core/hle/service/pm/pm.h b/src/core/hle/service/pm/pm.h index 060103928..5d4a1a171 100644 --- a/src/core/hle/service/pm/pm.h +++ b/src/core/hle/service/pm/pm.h | |||
| @@ -14,7 +14,6 @@ enum class SystemBootMode { | |||
| 14 | Maintenance, | 14 | Maintenance, |
| 15 | }; | 15 | }; |
| 16 | 16 | ||
| 17 | /// Registers all PM services with the specified service manager. | 17 | void LoopProcess(Core::System& system); |
| 18 | void InstallInterfaces(Core::System& system); | ||
| 19 | 18 | ||
| 20 | } // namespace Service::PM | 19 | } // namespace Service::PM |
diff --git a/src/core/hle/service/prepo/prepo.cpp b/src/core/hle/service/prepo/prepo.cpp index 90c5f8756..02af311e8 100644 --- a/src/core/hle/service/prepo/prepo.cpp +++ b/src/core/hle/service/prepo/prepo.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/service/acc/profile_manager.h" | 8 | #include "core/hle/service/acc/profile_manager.h" |
| 9 | #include "core/hle/service/prepo/prepo.h" | 9 | #include "core/hle/service/prepo/prepo.h" |
| 10 | #include "core/hle/service/server_manager.h" | ||
| 10 | #include "core/hle/service/service.h" | 11 | #include "core/hle/service/service.h" |
| 11 | #include "core/reporter.h" | 12 | #include "core/reporter.h" |
| 12 | 13 | ||
| @@ -183,12 +184,20 @@ private: | |||
| 183 | } | 184 | } |
| 184 | }; | 185 | }; |
| 185 | 186 | ||
| 186 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 187 | void LoopProcess(Core::System& system) { |
| 187 | std::make_shared<PlayReport>("prepo:a", system)->InstallAsService(service_manager); | 188 | auto server_manager = std::make_unique<ServerManager>(system); |
| 188 | std::make_shared<PlayReport>("prepo:a2", system)->InstallAsService(service_manager); | 189 | |
| 189 | std::make_shared<PlayReport>("prepo:m", system)->InstallAsService(service_manager); | 190 | server_manager->RegisterNamedService("prepo:a", |
| 190 | std::make_shared<PlayReport>("prepo:s", system)->InstallAsService(service_manager); | 191 | std::make_shared<PlayReport>("prepo:a", system)); |
| 191 | std::make_shared<PlayReport>("prepo:u", system)->InstallAsService(service_manager); | 192 | server_manager->RegisterNamedService("prepo:a2", |
| 193 | std::make_shared<PlayReport>("prepo:a2", system)); | ||
| 194 | server_manager->RegisterNamedService("prepo:m", | ||
| 195 | std::make_shared<PlayReport>("prepo:m", system)); | ||
| 196 | server_manager->RegisterNamedService("prepo:s", | ||
| 197 | std::make_shared<PlayReport>("prepo:s", system)); | ||
| 198 | server_manager->RegisterNamedService("prepo:u", | ||
| 199 | std::make_shared<PlayReport>("prepo:u", system)); | ||
| 200 | ServerManager::RunServer(std::move(server_manager)); | ||
| 192 | } | 201 | } |
| 193 | 202 | ||
| 194 | } // namespace Service::PlayReport | 203 | } // namespace Service::PlayReport |
diff --git a/src/core/hle/service/prepo/prepo.h b/src/core/hle/service/prepo/prepo.h index 37ea5afad..2c2462f93 100644 --- a/src/core/hle/service/prepo/prepo.h +++ b/src/core/hle/service/prepo/prepo.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::PlayReport { | 10 | namespace Service::PlayReport { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::PlayReport | 14 | } // namespace Service::PlayReport |
diff --git a/src/core/hle/service/psc/psc.cpp b/src/core/hle/service/psc/psc.cpp index 3a9412cf5..1650d2f39 100644 --- a/src/core/hle/service/psc/psc.cpp +++ b/src/core/hle/service/psc/psc.cpp | |||
| @@ -6,8 +6,8 @@ | |||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/service/psc/psc.h" | 8 | #include "core/hle/service/psc/psc.h" |
| 9 | #include "core/hle/service/server_manager.h" | ||
| 9 | #include "core/hle/service/service.h" | 10 | #include "core/hle/service/service.h" |
| 10 | #include "core/hle/service/sm/sm.h" | ||
| 11 | 11 | ||
| 12 | namespace Service::PSC { | 12 | namespace Service::PSC { |
| 13 | 13 | ||
| @@ -71,9 +71,12 @@ private: | |||
| 71 | } | 71 | } |
| 72 | }; | 72 | }; |
| 73 | 73 | ||
| 74 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 74 | void LoopProcess(Core::System& system) { |
| 75 | std::make_shared<PSC_C>(system)->InstallAsService(sm); | 75 | auto server_manager = std::make_unique<ServerManager>(system); |
| 76 | std::make_shared<PSC_M>(system)->InstallAsService(sm); | 76 | |
| 77 | server_manager->RegisterNamedService("psc:c", std::make_shared<PSC_C>(system)); | ||
| 78 | server_manager->RegisterNamedService("psc:m", std::make_shared<PSC_M>(system)); | ||
| 79 | ServerManager::RunServer(std::move(server_manager)); | ||
| 77 | } | 80 | } |
| 78 | 81 | ||
| 79 | } // namespace Service::PSC | 82 | } // namespace Service::PSC |
diff --git a/src/core/hle/service/psc/psc.h b/src/core/hle/service/psc/psc.h index d248372c2..459137f42 100644 --- a/src/core/hle/service/psc/psc.h +++ b/src/core/hle/service/psc/psc.h | |||
| @@ -13,6 +13,6 @@ class ServiceManager; | |||
| 13 | 13 | ||
| 14 | namespace Service::PSC { | 14 | namespace Service::PSC { |
| 15 | 15 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 16 | void LoopProcess(Core::System& system); |
| 17 | 17 | ||
| 18 | } // namespace Service::PSC | 18 | } // namespace Service::PSC |
diff --git a/src/core/hle/service/ptm/ptm.cpp b/src/core/hle/service/ptm/ptm.cpp index 4bea995c6..6f0cfe04b 100644 --- a/src/core/hle/service/ptm/ptm.cpp +++ b/src/core/hle/service/ptm/ptm.cpp | |||
| @@ -7,12 +7,16 @@ | |||
| 7 | #include "core/hle/service/ptm/psm.h" | 7 | #include "core/hle/service/ptm/psm.h" |
| 8 | #include "core/hle/service/ptm/ptm.h" | 8 | #include "core/hle/service/ptm/ptm.h" |
| 9 | #include "core/hle/service/ptm/ts.h" | 9 | #include "core/hle/service/ptm/ts.h" |
| 10 | #include "core/hle/service/server_manager.h" | ||
| 10 | 11 | ||
| 11 | namespace Service::PTM { | 12 | namespace Service::PTM { |
| 12 | 13 | ||
| 13 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 14 | void LoopProcess(Core::System& system) { |
| 14 | std::make_shared<PSM>(system)->InstallAsService(sm); | 15 | auto server_manager = std::make_unique<ServerManager>(system); |
| 15 | std::make_shared<TS>(system)->InstallAsService(sm); | 16 | |
| 17 | server_manager->RegisterNamedService("psm", std::make_shared<PSM>(system)); | ||
| 18 | server_manager->RegisterNamedService("ts", std::make_shared<TS>(system)); | ||
| 19 | ServerManager::RunServer(std::move(server_manager)); | ||
| 16 | } | 20 | } |
| 17 | 21 | ||
| 18 | } // namespace Service::PTM | 22 | } // namespace Service::PTM |
diff --git a/src/core/hle/service/ptm/ptm.h b/src/core/hle/service/ptm/ptm.h index 06224a24e..a0ae03d28 100644 --- a/src/core/hle/service/ptm/ptm.h +++ b/src/core/hle/service/ptm/ptm.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::PTM { | 10 | namespace Service::PTM { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::PTM | 14 | } // namespace Service::PTM |
diff --git a/src/core/hle/service/server_manager.cpp b/src/core/hle/service/server_manager.cpp new file mode 100644 index 000000000..1b3db3caf --- /dev/null +++ b/src/core/hle/service/server_manager.cpp | |||
| @@ -0,0 +1,448 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "common/scope_exit.h" | ||
| 5 | |||
| 6 | #include "core/core.h" | ||
| 7 | #include "core/hle/ipc_helpers.h" | ||
| 8 | #include "core/hle/kernel/hle_ipc.h" | ||
| 9 | #include "core/hle/kernel/k_client_port.h" | ||
| 10 | #include "core/hle/kernel/k_client_session.h" | ||
| 11 | #include "core/hle/kernel/k_event.h" | ||
| 12 | #include "core/hle/kernel/k_object_name.h" | ||
| 13 | #include "core/hle/kernel/k_port.h" | ||
| 14 | #include "core/hle/kernel/k_server_port.h" | ||
| 15 | #include "core/hle/kernel/k_server_session.h" | ||
| 16 | #include "core/hle/kernel/k_synchronization_object.h" | ||
| 17 | #include "core/hle/kernel/svc_results.h" | ||
| 18 | #include "core/hle/service/server_manager.h" | ||
| 19 | #include "core/hle/service/sm/sm.h" | ||
| 20 | |||
| 21 | namespace Service { | ||
| 22 | |||
| 23 | constexpr size_t MaximumWaitObjects = 0x40; | ||
| 24 | |||
| 25 | enum HandleType { | ||
| 26 | Port, | ||
| 27 | Session, | ||
| 28 | DeferEvent, | ||
| 29 | Event, | ||
| 30 | }; | ||
| 31 | |||
| 32 | ServerManager::ServerManager(Core::System& system) : m_system{system}, m_serve_mutex{system} { | ||
| 33 | // Initialize event. | ||
| 34 | m_event = Kernel::KEvent::Create(system.Kernel()); | ||
| 35 | m_event->Initialize(nullptr); | ||
| 36 | } | ||
| 37 | |||
| 38 | ServerManager::~ServerManager() { | ||
| 39 | // Signal stop. | ||
| 40 | m_stop_source.request_stop(); | ||
| 41 | m_event->Signal(); | ||
| 42 | |||
| 43 | // Wait for processing to stop. | ||
| 44 | m_stopped.wait(false); | ||
| 45 | m_threads.clear(); | ||
| 46 | |||
| 47 | // Clean up ports. | ||
| 48 | for (const auto& [port, handler] : m_ports) { | ||
| 49 | port->Close(); | ||
| 50 | } | ||
| 51 | |||
| 52 | // Clean up sessions. | ||
| 53 | for (const auto& [session, manager] : m_sessions) { | ||
| 54 | session->Close(); | ||
| 55 | } | ||
| 56 | |||
| 57 | for (const auto& request : m_deferrals) { | ||
| 58 | request.session->Close(); | ||
| 59 | } | ||
| 60 | |||
| 61 | // Close event. | ||
| 62 | m_event->GetReadableEvent().Close(); | ||
| 63 | m_event->Close(); | ||
| 64 | |||
| 65 | if (m_deferral_event) { | ||
| 66 | m_deferral_event->GetReadableEvent().Close(); | ||
| 67 | // Write event is owned by ServiceManager | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | void ServerManager::RunServer(std::unique_ptr<ServerManager>&& server_manager) { | ||
| 72 | server_manager->m_system.RunServer(std::move(server_manager)); | ||
| 73 | } | ||
| 74 | |||
| 75 | Result ServerManager::RegisterSession(Kernel::KServerSession* session, | ||
| 76 | std::shared_ptr<Kernel::SessionRequestManager> manager) { | ||
| 77 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); | ||
| 78 | |||
| 79 | // We are taking ownership of the server session, so don't open it. | ||
| 80 | // Begin tracking the server session. | ||
| 81 | { | ||
| 82 | std::scoped_lock ll{m_list_mutex}; | ||
| 83 | m_sessions.emplace(session, std::move(manager)); | ||
| 84 | } | ||
| 85 | |||
| 86 | // Signal the wakeup event. | ||
| 87 | m_event->Signal(); | ||
| 88 | |||
| 89 | R_SUCCEED(); | ||
| 90 | } | ||
| 91 | |||
| 92 | Result ServerManager::RegisterNamedService(const std::string& service_name, | ||
| 93 | std::shared_ptr<Kernel::SessionRequestHandler>&& handler, | ||
| 94 | u32 max_sessions) { | ||
| 95 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); | ||
| 96 | |||
| 97 | // Add the new server to sm:. | ||
| 98 | ASSERT(R_SUCCEEDED( | ||
| 99 | m_system.ServiceManager().RegisterService(service_name, max_sessions, handler))); | ||
| 100 | |||
| 101 | // Get the registered port. | ||
| 102 | auto port = m_system.ServiceManager().GetServicePort(service_name); | ||
| 103 | ASSERT(port.Succeeded()); | ||
| 104 | |||
| 105 | // Open a new reference to the server port. | ||
| 106 | (*port)->GetServerPort().Open(); | ||
| 107 | |||
| 108 | // Begin tracking the server port. | ||
| 109 | { | ||
| 110 | std::scoped_lock ll{m_list_mutex}; | ||
| 111 | m_ports.emplace(std::addressof((*port)->GetServerPort()), std::move(handler)); | ||
| 112 | } | ||
| 113 | |||
| 114 | // Signal the wakeup event. | ||
| 115 | m_event->Signal(); | ||
| 116 | |||
| 117 | R_SUCCEED(); | ||
| 118 | } | ||
| 119 | |||
| 120 | Result ServerManager::ManageNamedPort(const std::string& service_name, | ||
| 121 | std::shared_ptr<Kernel::SessionRequestHandler>&& handler, | ||
| 122 | u32 max_sessions) { | ||
| 123 | ASSERT(m_sessions.size() + m_ports.size() < MaximumWaitObjects); | ||
| 124 | |||
| 125 | // Create a new port. | ||
| 126 | auto* port = Kernel::KPort::Create(m_system.Kernel()); | ||
| 127 | port->Initialize(max_sessions, false, service_name); | ||
| 128 | |||
| 129 | // Register the port. | ||
| 130 | Kernel::KPort::Register(m_system.Kernel(), port); | ||
| 131 | |||
| 132 | // Ensure that our reference to the port is closed if we fail to register it. | ||
| 133 | SCOPE_EXIT({ | ||
| 134 | port->GetClientPort().Close(); | ||
| 135 | port->GetServerPort().Close(); | ||
| 136 | }); | ||
| 137 | |||
| 138 | // Register the object name with the kernel. | ||
| 139 | R_TRY(Kernel::KObjectName::NewFromName(m_system.Kernel(), std::addressof(port->GetClientPort()), | ||
| 140 | service_name.c_str())); | ||
| 141 | |||
| 142 | // Open a new reference to the server port. | ||
| 143 | port->GetServerPort().Open(); | ||
| 144 | |||
| 145 | // Begin tracking the server port. | ||
| 146 | { | ||
| 147 | std::scoped_lock ll{m_list_mutex}; | ||
| 148 | m_ports.emplace(std::addressof(port->GetServerPort()), std::move(handler)); | ||
| 149 | } | ||
| 150 | |||
| 151 | // We succeeded. | ||
| 152 | R_SUCCEED(); | ||
| 153 | } | ||
| 154 | |||
| 155 | Result ServerManager::ManageDeferral(Kernel::KEvent** out_event) { | ||
| 156 | // Create a new event. | ||
| 157 | m_deferral_event = Kernel::KEvent::Create(m_system.Kernel()); | ||
| 158 | ASSERT(m_deferral_event != nullptr); | ||
| 159 | |||
| 160 | // Initialize the event. | ||
| 161 | m_deferral_event->Initialize(nullptr); | ||
| 162 | |||
| 163 | // Set the output. | ||
| 164 | *out_event = m_deferral_event; | ||
| 165 | |||
| 166 | // We succeeded. | ||
| 167 | R_SUCCEED(); | ||
| 168 | } | ||
| 169 | |||
| 170 | void ServerManager::StartAdditionalHostThreads(const char* name, size_t num_threads) { | ||
| 171 | for (size_t i = 0; i < num_threads; i++) { | ||
| 172 | auto thread_name = fmt::format("{}:{}", name, i + 1); | ||
| 173 | m_threads.emplace_back(m_system.Kernel().RunOnHostCoreThread( | ||
| 174 | std::move(thread_name), [&] { this->LoopProcessImpl(); })); | ||
| 175 | } | ||
| 176 | } | ||
| 177 | |||
| 178 | Result ServerManager::LoopProcess() { | ||
| 179 | SCOPE_EXIT({ | ||
| 180 | m_stopped.store(true); | ||
| 181 | m_stopped.notify_all(); | ||
| 182 | }); | ||
| 183 | |||
| 184 | R_RETURN(this->LoopProcessImpl()); | ||
| 185 | } | ||
| 186 | |||
| 187 | Result ServerManager::LoopProcessImpl() { | ||
| 188 | while (!m_stop_source.stop_requested()) { | ||
| 189 | R_TRY(this->WaitAndProcessImpl()); | ||
| 190 | } | ||
| 191 | |||
| 192 | R_SUCCEED(); | ||
| 193 | } | ||
| 194 | |||
| 195 | Result ServerManager::WaitAndProcessImpl() { | ||
| 196 | Kernel::KScopedAutoObject<Kernel::KSynchronizationObject> wait_obj; | ||
| 197 | HandleType wait_type{}; | ||
| 198 | |||
| 199 | // Ensure we are the only thread waiting for this server. | ||
| 200 | std::unique_lock sl{m_serve_mutex}; | ||
| 201 | |||
| 202 | // If we're done, return before we start waiting. | ||
| 203 | R_SUCCEED_IF(m_stop_source.stop_requested()); | ||
| 204 | |||
| 205 | // Wait for a tracked object to become signaled. | ||
| 206 | { | ||
| 207 | s32 num_objs{}; | ||
| 208 | std::array<HandleType, MaximumWaitObjects> wait_types{}; | ||
| 209 | std::array<Kernel::KSynchronizationObject*, MaximumWaitObjects> wait_objs{}; | ||
| 210 | |||
| 211 | const auto AddWaiter{ | ||
| 212 | [&](Kernel::KSynchronizationObject* synchronization_object, HandleType type) { | ||
| 213 | // Open a new reference to the object. | ||
| 214 | synchronization_object->Open(); | ||
| 215 | |||
| 216 | // Insert into the list. | ||
| 217 | wait_types[num_objs] = type; | ||
| 218 | wait_objs[num_objs++] = synchronization_object; | ||
| 219 | }}; | ||
| 220 | |||
| 221 | { | ||
| 222 | std::scoped_lock ll{m_list_mutex}; | ||
| 223 | |||
| 224 | // Add all of our ports. | ||
| 225 | for (const auto& [port, handler] : m_ports) { | ||
| 226 | AddWaiter(port, HandleType::Port); | ||
| 227 | } | ||
| 228 | |||
| 229 | // Add all of our sessions. | ||
| 230 | for (const auto& [session, manager] : m_sessions) { | ||
| 231 | AddWaiter(session, HandleType::Session); | ||
| 232 | } | ||
| 233 | } | ||
| 234 | |||
| 235 | // Add the deferral wakeup event. | ||
| 236 | if (m_deferral_event != nullptr) { | ||
| 237 | AddWaiter(std::addressof(m_deferral_event->GetReadableEvent()), HandleType::DeferEvent); | ||
| 238 | } | ||
| 239 | |||
| 240 | // Add the wakeup event. | ||
| 241 | AddWaiter(std::addressof(m_event->GetReadableEvent()), HandleType::Event); | ||
| 242 | |||
| 243 | // Clean up extra references on exit. | ||
| 244 | SCOPE_EXIT({ | ||
| 245 | for (s32 i = 0; i < num_objs; i++) { | ||
| 246 | wait_objs[i]->Close(); | ||
| 247 | } | ||
| 248 | }); | ||
| 249 | |||
| 250 | // Wait for a signal. | ||
| 251 | s32 out_index{-1}; | ||
| 252 | R_TRY(Kernel::KSynchronizationObject::Wait(m_system.Kernel(), &out_index, wait_objs.data(), | ||
| 253 | num_objs, -1)); | ||
| 254 | ASSERT(out_index >= 0 && out_index < num_objs); | ||
| 255 | |||
| 256 | // Set the output index. | ||
| 257 | wait_obj = wait_objs[out_index]; | ||
| 258 | wait_type = wait_types[out_index]; | ||
| 259 | } | ||
| 260 | |||
| 261 | // Process what we just received, temporarily removing the object so it is | ||
| 262 | // not processed concurrently by another thread. | ||
| 263 | { | ||
| 264 | switch (wait_type) { | ||
| 265 | case HandleType::Port: { | ||
| 266 | // Port signaled. | ||
| 267 | auto* port = wait_obj->DynamicCast<Kernel::KServerPort*>(); | ||
| 268 | std::shared_ptr<Kernel::SessionRequestHandler> handler; | ||
| 269 | |||
| 270 | // Remove from tracking. | ||
| 271 | { | ||
| 272 | std::scoped_lock ll{m_list_mutex}; | ||
| 273 | ASSERT(m_ports.contains(port)); | ||
| 274 | m_ports.at(port).swap(handler); | ||
| 275 | m_ports.erase(port); | ||
| 276 | } | ||
| 277 | |||
| 278 | // Allow other threads to serve. | ||
| 279 | sl.unlock(); | ||
| 280 | |||
| 281 | // Finish. | ||
| 282 | R_RETURN(this->OnPortEvent(port, std::move(handler))); | ||
| 283 | } | ||
| 284 | case HandleType::Session: { | ||
| 285 | // Session signaled. | ||
| 286 | auto* session = wait_obj->DynamicCast<Kernel::KServerSession*>(); | ||
| 287 | std::shared_ptr<Kernel::SessionRequestManager> manager; | ||
| 288 | |||
| 289 | // Remove from tracking. | ||
| 290 | { | ||
| 291 | std::scoped_lock ll{m_list_mutex}; | ||
| 292 | ASSERT(m_sessions.contains(session)); | ||
| 293 | m_sessions.at(session).swap(manager); | ||
| 294 | m_sessions.erase(session); | ||
| 295 | } | ||
| 296 | |||
| 297 | // Allow other threads to serve. | ||
| 298 | sl.unlock(); | ||
| 299 | |||
| 300 | // Finish. | ||
| 301 | R_RETURN(this->OnSessionEvent(session, std::move(manager))); | ||
| 302 | } | ||
| 303 | case HandleType::DeferEvent: { | ||
| 304 | // Clear event. | ||
| 305 | ASSERT(R_SUCCEEDED(m_deferral_event->Clear())); | ||
| 306 | |||
| 307 | // Drain the list of deferrals while we process. | ||
| 308 | std::list<RequestState> deferrals; | ||
| 309 | { | ||
| 310 | std::scoped_lock ll{m_list_mutex}; | ||
| 311 | m_deferrals.swap(deferrals); | ||
| 312 | } | ||
| 313 | |||
| 314 | // Allow other threads to serve. | ||
| 315 | sl.unlock(); | ||
| 316 | |||
| 317 | // Finish. | ||
| 318 | R_RETURN(this->OnDeferralEvent(std::move(deferrals))); | ||
| 319 | } | ||
| 320 | case HandleType::Event: { | ||
| 321 | // Clear event and finish. | ||
| 322 | R_RETURN(m_event->Clear()); | ||
| 323 | } | ||
| 324 | default: { | ||
| 325 | UNREACHABLE(); | ||
| 326 | } | ||
| 327 | } | ||
| 328 | } | ||
| 329 | } | ||
| 330 | |||
| 331 | Result ServerManager::OnPortEvent(Kernel::KServerPort* port, | ||
| 332 | std::shared_ptr<Kernel::SessionRequestHandler>&& handler) { | ||
| 333 | // Accept a new server session. | ||
| 334 | Kernel::KServerSession* session = port->AcceptSession(); | ||
| 335 | ASSERT(session != nullptr); | ||
| 336 | |||
| 337 | // Create the session manager and install the handler. | ||
| 338 | auto manager = std::make_shared<Kernel::SessionRequestManager>(m_system.Kernel(), *this); | ||
| 339 | manager->SetSessionHandler(std::shared_ptr(handler)); | ||
| 340 | |||
| 341 | // Track the server session. | ||
| 342 | { | ||
| 343 | std::scoped_lock ll{m_list_mutex}; | ||
| 344 | m_ports.emplace(port, std::move(handler)); | ||
| 345 | m_sessions.emplace(session, std::move(manager)); | ||
| 346 | } | ||
| 347 | |||
| 348 | // Signal the wakeup event. | ||
| 349 | m_event->Signal(); | ||
| 350 | |||
| 351 | // We succeeded. | ||
| 352 | R_SUCCEED(); | ||
| 353 | } | ||
| 354 | |||
| 355 | Result ServerManager::OnSessionEvent(Kernel::KServerSession* session, | ||
| 356 | std::shared_ptr<Kernel::SessionRequestManager>&& manager) { | ||
| 357 | Result rc{ResultSuccess}; | ||
| 358 | |||
| 359 | // Try to receive a message. | ||
| 360 | std::shared_ptr<Kernel::HLERequestContext> context; | ||
| 361 | rc = session->ReceiveRequest(&context, manager); | ||
| 362 | |||
| 363 | // If the session has been closed, we're done. | ||
| 364 | if (rc == Kernel::ResultSessionClosed) { | ||
| 365 | // Close the session. | ||
| 366 | session->Close(); | ||
| 367 | |||
| 368 | // Finish. | ||
| 369 | R_SUCCEED(); | ||
| 370 | } | ||
| 371 | ASSERT(R_SUCCEEDED(rc)); | ||
| 372 | |||
| 373 | RequestState request{ | ||
| 374 | .session = session, | ||
| 375 | .context = std::move(context), | ||
| 376 | .manager = std::move(manager), | ||
| 377 | }; | ||
| 378 | |||
| 379 | // Complete the sync request with deferral handling. | ||
| 380 | R_RETURN(this->CompleteSyncRequest(std::move(request))); | ||
| 381 | } | ||
| 382 | |||
| 383 | Result ServerManager::CompleteSyncRequest(RequestState&& request) { | ||
| 384 | Result rc{ResultSuccess}; | ||
| 385 | Result service_rc{ResultSuccess}; | ||
| 386 | |||
| 387 | // Mark the request as not deferred. | ||
| 388 | request.context->SetIsDeferred(false); | ||
| 389 | |||
| 390 | // Complete the request. We have exclusive access to this session. | ||
| 391 | service_rc = request.manager->CompleteSyncRequest(request.session, *request.context); | ||
| 392 | |||
| 393 | // If we've been deferred, we're done. | ||
| 394 | if (request.context->GetIsDeferred()) { | ||
| 395 | // Insert into deferral list. | ||
| 396 | std::scoped_lock ll{m_list_mutex}; | ||
| 397 | m_deferrals.emplace_back(std::move(request)); | ||
| 398 | |||
| 399 | // Finish. | ||
| 400 | R_SUCCEED(); | ||
| 401 | } | ||
| 402 | |||
| 403 | // Send the reply. | ||
| 404 | rc = request.session->SendReplyHLE(); | ||
| 405 | |||
| 406 | // If the session has been closed, we're done. | ||
| 407 | if (rc == Kernel::ResultSessionClosed || service_rc == IPC::ERR_REMOTE_PROCESS_DEAD) { | ||
| 408 | // Close the session. | ||
| 409 | request.session->Close(); | ||
| 410 | |||
| 411 | // Finish. | ||
| 412 | R_SUCCEED(); | ||
| 413 | } | ||
| 414 | |||
| 415 | ASSERT(R_SUCCEEDED(rc)); | ||
| 416 | ASSERT(R_SUCCEEDED(service_rc)); | ||
| 417 | |||
| 418 | // Reinsert the session. | ||
| 419 | { | ||
| 420 | std::scoped_lock ll{m_list_mutex}; | ||
| 421 | m_sessions.emplace(request.session, std::move(request.manager)); | ||
| 422 | } | ||
| 423 | |||
| 424 | // Signal the wakeup event. | ||
| 425 | m_event->Signal(); | ||
| 426 | |||
| 427 | // We succeeded. | ||
| 428 | R_SUCCEED(); | ||
| 429 | } | ||
| 430 | |||
| 431 | Result ServerManager::OnDeferralEvent(std::list<RequestState>&& deferrals) { | ||
| 432 | ON_RESULT_FAILURE { | ||
| 433 | std::scoped_lock ll{m_list_mutex}; | ||
| 434 | m_deferrals.splice(m_deferrals.end(), deferrals); | ||
| 435 | }; | ||
| 436 | |||
| 437 | while (!deferrals.empty()) { | ||
| 438 | RequestState request = deferrals.front(); | ||
| 439 | deferrals.pop_front(); | ||
| 440 | |||
| 441 | // Try again to complete the request. | ||
| 442 | R_TRY(this->CompleteSyncRequest(std::move(request))); | ||
| 443 | } | ||
| 444 | |||
| 445 | R_SUCCEED(); | ||
| 446 | } | ||
| 447 | |||
| 448 | } // namespace Service | ||
diff --git a/src/core/hle/service/server_manager.h b/src/core/hle/service/server_manager.h new file mode 100644 index 000000000..57b954ae8 --- /dev/null +++ b/src/core/hle/service/server_manager.h | |||
| @@ -0,0 +1,91 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2023 yuzu Emulator Project | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #pragma once | ||
| 5 | |||
| 6 | #include <atomic> | ||
| 7 | #include <functional> | ||
| 8 | #include <list> | ||
| 9 | #include <map> | ||
| 10 | #include <mutex> | ||
| 11 | #include <string_view> | ||
| 12 | #include <vector> | ||
| 13 | |||
| 14 | #include "common/polyfill_thread.h" | ||
| 15 | #include "core/hle/result.h" | ||
| 16 | #include "core/hle/service/mutex.h" | ||
| 17 | |||
| 18 | namespace Core { | ||
| 19 | class System; | ||
| 20 | } | ||
| 21 | |||
| 22 | namespace Kernel { | ||
| 23 | class HLERequestContext; | ||
| 24 | class KEvent; | ||
| 25 | class KServerPort; | ||
| 26 | class KServerSession; | ||
| 27 | class KSynchronizationObject; | ||
| 28 | class SessionRequestHandler; | ||
| 29 | class SessionRequestManager; | ||
| 30 | } // namespace Kernel | ||
| 31 | |||
| 32 | namespace Service { | ||
| 33 | |||
| 34 | class ServerManager { | ||
| 35 | public: | ||
| 36 | explicit ServerManager(Core::System& system); | ||
| 37 | ~ServerManager(); | ||
| 38 | |||
| 39 | Result RegisterSession(Kernel::KServerSession* session, | ||
| 40 | std::shared_ptr<Kernel::SessionRequestManager> manager); | ||
| 41 | Result RegisterNamedService(const std::string& service_name, | ||
| 42 | std::shared_ptr<Kernel::SessionRequestHandler>&& handler, | ||
| 43 | u32 max_sessions = 64); | ||
| 44 | Result ManageNamedPort(const std::string& service_name, | ||
| 45 | std::shared_ptr<Kernel::SessionRequestHandler>&& handler, | ||
| 46 | u32 max_sessions = 64); | ||
| 47 | Result ManageDeferral(Kernel::KEvent** out_event); | ||
| 48 | |||
| 49 | Result LoopProcess(); | ||
| 50 | void StartAdditionalHostThreads(const char* name, size_t num_threads); | ||
| 51 | |||
| 52 | static void RunServer(std::unique_ptr<ServerManager>&& server); | ||
| 53 | |||
| 54 | private: | ||
| 55 | struct RequestState; | ||
| 56 | |||
| 57 | Result LoopProcessImpl(); | ||
| 58 | Result WaitAndProcessImpl(); | ||
| 59 | Result OnPortEvent(Kernel::KServerPort* port, | ||
| 60 | std::shared_ptr<Kernel::SessionRequestHandler>&& handler); | ||
| 61 | Result OnSessionEvent(Kernel::KServerSession* session, | ||
| 62 | std::shared_ptr<Kernel::SessionRequestManager>&& manager); | ||
| 63 | Result OnDeferralEvent(std::list<RequestState>&& deferrals); | ||
| 64 | Result CompleteSyncRequest(RequestState&& state); | ||
| 65 | |||
| 66 | private: | ||
| 67 | Core::System& m_system; | ||
| 68 | Mutex m_serve_mutex; | ||
| 69 | std::mutex m_list_mutex; | ||
| 70 | |||
| 71 | // Guest state tracking | ||
| 72 | std::map<Kernel::KServerPort*, std::shared_ptr<Kernel::SessionRequestHandler>> m_ports{}; | ||
| 73 | std::map<Kernel::KServerSession*, std::shared_ptr<Kernel::SessionRequestManager>> m_sessions{}; | ||
| 74 | Kernel::KEvent* m_event{}; | ||
| 75 | Kernel::KEvent* m_deferral_event{}; | ||
| 76 | |||
| 77 | // Deferral tracking | ||
| 78 | struct RequestState { | ||
| 79 | Kernel::KServerSession* session; | ||
| 80 | std::shared_ptr<Kernel::HLERequestContext> context; | ||
| 81 | std::shared_ptr<Kernel::SessionRequestManager> manager; | ||
| 82 | }; | ||
| 83 | std::list<RequestState> m_deferrals{}; | ||
| 84 | |||
| 85 | // Host state tracking | ||
| 86 | std::atomic<bool> m_stopped{}; | ||
| 87 | std::vector<std::jthread> m_threads{}; | ||
| 88 | std::stop_source m_stop_source{}; | ||
| 89 | }; | ||
| 90 | |||
| 91 | } // namespace Service | ||
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp index 1ffc1c694..31021ea03 100644 --- a/src/core/hle/service/service.cpp +++ b/src/core/hle/service/service.cpp | |||
| @@ -90,44 +90,13 @@ namespace Service { | |||
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, | 92 | ServiceFrameworkBase::ServiceFrameworkBase(Core::System& system_, const char* service_name_, |
| 93 | ServiceThreadType thread_type, u32 max_sessions_, | 93 | u32 max_sessions_, InvokerFn* handler_invoker_) |
| 94 | InvokerFn* handler_invoker_) | 94 | : SessionRequestHandler(system_.Kernel(), service_name_), system{system_}, |
| 95 | : SessionRequestHandler(system_.Kernel(), service_name_, thread_type), system{system_}, | ||
| 96 | service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {} | 95 | service_name{service_name_}, max_sessions{max_sessions_}, handler_invoker{handler_invoker_} {} |
| 97 | 96 | ||
| 98 | ServiceFrameworkBase::~ServiceFrameworkBase() { | 97 | ServiceFrameworkBase::~ServiceFrameworkBase() { |
| 99 | // Wait for other threads to release access before destroying | 98 | // Wait for other threads to release access before destroying |
| 100 | const auto guard = LockService(); | 99 | const auto guard = LockService(); |
| 101 | |||
| 102 | if (named_port != nullptr) { | ||
| 103 | named_port->GetClientPort().Close(); | ||
| 104 | named_port->GetServerPort().Close(); | ||
| 105 | named_port = nullptr; | ||
| 106 | } | ||
| 107 | } | ||
| 108 | |||
| 109 | void ServiceFrameworkBase::InstallAsService(SM::ServiceManager& service_manager) { | ||
| 110 | const auto guard = LockService(); | ||
| 111 | |||
| 112 | ASSERT(!service_registered); | ||
| 113 | |||
| 114 | service_manager.RegisterService(service_name, max_sessions, shared_from_this()); | ||
| 115 | service_registered = true; | ||
| 116 | } | ||
| 117 | |||
| 118 | Kernel::KClientPort& ServiceFrameworkBase::CreatePort() { | ||
| 119 | const auto guard = LockService(); | ||
| 120 | |||
| 121 | if (named_port == nullptr) { | ||
| 122 | ASSERT(!service_registered); | ||
| 123 | |||
| 124 | named_port = Kernel::KPort::Create(kernel); | ||
| 125 | named_port->Initialize(max_sessions, false, service_name); | ||
| 126 | |||
| 127 | service_registered = true; | ||
| 128 | } | ||
| 129 | |||
| 130 | return named_port->GetClientPort(); | ||
| 131 | } | 100 | } |
| 132 | 101 | ||
| 133 | void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { | 102 | void ServiceFrameworkBase::RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n) { |
| @@ -244,67 +213,69 @@ Services::Services(std::shared_ptr<SM::ServiceManager>& sm, Core::System& system | |||
| 244 | : hos_binder_driver_server{std::make_unique<NVFlinger::HosBinderDriverServer>(system)}, | 213 | : hos_binder_driver_server{std::make_unique<NVFlinger::HosBinderDriverServer>(system)}, |
| 245 | nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system, *hos_binder_driver_server)} { | 214 | nv_flinger{std::make_unique<NVFlinger::NVFlinger>(system, *hos_binder_driver_server)} { |
| 246 | 215 | ||
| 216 | auto& kernel = system.Kernel(); | ||
| 217 | |||
| 247 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it | 218 | // NVFlinger needs to be accessed by several services like Vi and AppletOE so we instantiate it |
| 248 | // here and pass it into the respective InstallInterfaces functions. | 219 | // here and pass it into the respective InstallInterfaces functions. |
| 249 | |||
| 250 | system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); | 220 | system.GetFileSystemController().CreateFactories(*system.GetFilesystem(), false); |
| 251 | 221 | ||
| 252 | system.Kernel().RegisterNamedService("sm:", SM::ServiceManager::InterfaceFactory); | 222 | // clang-format off |
| 253 | system.Kernel().RegisterInterfaceForNamedService("sm:", SM::ServiceManager::SessionHandler); | 223 | kernel.RunOnHostCoreProcess("audio", [&] { Audio::LoopProcess(system); }).detach(); |
| 254 | 224 | kernel.RunOnHostCoreProcess("FS", [&] { FileSystem::LoopProcess(system); }).detach(); | |
| 255 | Account::InstallInterfaces(system); | 225 | kernel.RunOnHostCoreProcess("jit", [&] { JIT::LoopProcess(system); }).detach(); |
| 256 | AM::InstallInterfaces(*sm, *nv_flinger, system); | 226 | kernel.RunOnHostCoreProcess("ldn", [&] { LDN::LoopProcess(system); }).detach(); |
| 257 | AOC::InstallInterfaces(*sm, system); | 227 | kernel.RunOnHostCoreProcess("Loader", [&] { LDR::LoopProcess(system); }).detach(); |
| 258 | APM::InstallInterfaces(system); | 228 | kernel.RunOnHostCoreProcess("nvservices", [&] { Nvidia::LoopProcess(*nv_flinger, system); }).detach(); |
| 259 | Audio::InstallInterfaces(*sm, system); | 229 | kernel.RunOnHostCoreProcess("bsdsocket", [&] { Sockets::LoopProcess(system); }).detach(); |
| 260 | BCAT::InstallInterfaces(system); | 230 | kernel.RunOnHostCoreProcess("vi", [&] { VI::LoopProcess(system, *nv_flinger, *hos_binder_driver_server); }).detach(); |
| 261 | BPC::InstallInterfaces(*sm, system); | 231 | |
| 262 | BtDrv::InstallInterfaces(*sm, system); | 232 | kernel.RunOnGuestCoreProcess("sm", [&] { SM::LoopProcess(system); }); |
| 263 | BTM::InstallInterfaces(*sm, system); | 233 | kernel.RunOnGuestCoreProcess("account", [&] { Account::LoopProcess(system); }); |
| 264 | Capture::InstallInterfaces(*sm, system); | 234 | kernel.RunOnGuestCoreProcess("am", [&] { AM::LoopProcess(*nv_flinger, system); }); |
| 265 | ERPT::InstallInterfaces(*sm, system); | 235 | kernel.RunOnGuestCoreProcess("aoc", [&] { AOC::LoopProcess(system); }); |
| 266 | ES::InstallInterfaces(*sm, system); | 236 | kernel.RunOnGuestCoreProcess("apm", [&] { APM::LoopProcess(system); }); |
| 267 | EUPLD::InstallInterfaces(*sm, system); | 237 | kernel.RunOnGuestCoreProcess("bcat", [&] { BCAT::LoopProcess(system); }); |
| 268 | Fatal::InstallInterfaces(*sm, system); | 238 | kernel.RunOnGuestCoreProcess("bpc", [&] { BPC::LoopProcess(system); }); |
| 269 | FGM::InstallInterfaces(*sm, system); | 239 | kernel.RunOnGuestCoreProcess("btdrv", [&] { BtDrv::LoopProcess(system); }); |
| 270 | FileSystem::InstallInterfaces(system); | 240 | kernel.RunOnGuestCoreProcess("btm", [&] { BTM::LoopProcess(system); }); |
| 271 | Friend::InstallInterfaces(*sm, system); | 241 | kernel.RunOnGuestCoreProcess("capsrv", [&] { Capture::LoopProcess(system); }); |
| 272 | Glue::InstallInterfaces(system); | 242 | kernel.RunOnGuestCoreProcess("erpt", [&] { ERPT::LoopProcess(system); }); |
| 273 | GRC::InstallInterfaces(*sm, system); | 243 | kernel.RunOnGuestCoreProcess("es", [&] { ES::LoopProcess(system); }); |
| 274 | HID::InstallInterfaces(*sm, system); | 244 | kernel.RunOnGuestCoreProcess("eupld", [&] { EUPLD::LoopProcess(system); }); |
| 275 | JIT::InstallInterfaces(*sm, system); | 245 | kernel.RunOnGuestCoreProcess("fatal", [&] { Fatal::LoopProcess(system); }); |
| 276 | LBL::InstallInterfaces(*sm, system); | 246 | kernel.RunOnGuestCoreProcess("fgm", [&] { FGM::LoopProcess(system); }); |
| 277 | LDN::InstallInterfaces(*sm, system); | 247 | kernel.RunOnGuestCoreProcess("friends", [&] { Friend::LoopProcess(system); }); |
| 278 | LDR::InstallInterfaces(*sm, system); | 248 | kernel.RunOnGuestCoreProcess("glue", [&] { Glue::LoopProcess(system); }); |
| 279 | LM::InstallInterfaces(system); | 249 | kernel.RunOnGuestCoreProcess("grc", [&] { GRC::LoopProcess(system); }); |
| 280 | Migration::InstallInterfaces(*sm, system); | 250 | kernel.RunOnGuestCoreProcess("hid", [&] { HID::LoopProcess(system); }); |
| 281 | Mii::InstallInterfaces(*sm, system); | 251 | kernel.RunOnGuestCoreProcess("lbl", [&] { LBL::LoopProcess(system); }); |
| 282 | MM::InstallInterfaces(*sm, system); | 252 | kernel.RunOnGuestCoreProcess("LogManager.Prod", [&] { LM::LoopProcess(system); }); |
| 283 | MNPP::InstallInterfaces(*sm, system); | 253 | kernel.RunOnGuestCoreProcess("mig", [&] { Migration::LoopProcess(system); }); |
| 284 | NCM::InstallInterfaces(*sm, system); | 254 | kernel.RunOnGuestCoreProcess("mii", [&] { Mii::LoopProcess(system); }); |
| 285 | NFC::InstallInterfaces(*sm, system); | 255 | kernel.RunOnGuestCoreProcess("mm", [&] { MM::LoopProcess(system); }); |
| 286 | NFP::InstallInterfaces(*sm, system); | 256 | kernel.RunOnGuestCoreProcess("mnpp", [&] { MNPP::LoopProcess(system); }); |
| 287 | NGCT::InstallInterfaces(*sm, system); | 257 | kernel.RunOnGuestCoreProcess("NCM", [&] { NCM::LoopProcess(system); }); |
| 288 | NIFM::InstallInterfaces(*sm, system); | 258 | kernel.RunOnGuestCoreProcess("nfc", [&] { NFC::LoopProcess(system); }); |
| 289 | NIM::InstallInterfaces(*sm, system); | 259 | kernel.RunOnGuestCoreProcess("nfp", [&] { NFP::LoopProcess(system); }); |
| 290 | NPNS::InstallInterfaces(*sm, system); | 260 | kernel.RunOnGuestCoreProcess("ngct", [&] { NGCT::LoopProcess(system); }); |
| 291 | NS::InstallInterfaces(*sm, system); | 261 | kernel.RunOnGuestCoreProcess("nifm", [&] { NIFM::LoopProcess(system); }); |
| 292 | Nvidia::InstallInterfaces(*sm, *nv_flinger, system); | 262 | kernel.RunOnGuestCoreProcess("nim", [&] { NIM::LoopProcess(system); }); |
| 293 | OLSC::InstallInterfaces(*sm, system); | 263 | kernel.RunOnGuestCoreProcess("npns", [&] { NPNS::LoopProcess(system); }); |
| 294 | PCIe::InstallInterfaces(*sm, system); | 264 | kernel.RunOnGuestCoreProcess("ns", [&] { NS::LoopProcess(system); }); |
| 295 | PCTL::InstallInterfaces(*sm, system); | 265 | kernel.RunOnGuestCoreProcess("olsc", [&] { OLSC::LoopProcess(system); }); |
| 296 | PCV::InstallInterfaces(*sm, system); | 266 | kernel.RunOnGuestCoreProcess("pcie", [&] { PCIe::LoopProcess(system); }); |
| 297 | PlayReport::InstallInterfaces(*sm, system); | 267 | kernel.RunOnGuestCoreProcess("pctl", [&] { PCTL::LoopProcess(system); }); |
| 298 | PM::InstallInterfaces(system); | 268 | kernel.RunOnGuestCoreProcess("pcv", [&] { PCV::LoopProcess(system); }); |
| 299 | PSC::InstallInterfaces(*sm, system); | 269 | kernel.RunOnGuestCoreProcess("prepo", [&] { PlayReport::LoopProcess(system); }); |
| 300 | PTM::InstallInterfaces(*sm, system); | 270 | kernel.RunOnGuestCoreProcess("ProcessManager", [&] { PM::LoopProcess(system); }); |
| 301 | Set::InstallInterfaces(*sm, system); | 271 | kernel.RunOnGuestCoreProcess("psc", [&] { PSC::LoopProcess(system); }); |
| 302 | Sockets::InstallInterfaces(*sm, system); | 272 | kernel.RunOnGuestCoreProcess("ptm", [&] { PTM::LoopProcess(system); }); |
| 303 | SPL::InstallInterfaces(*sm, system); | 273 | kernel.RunOnGuestCoreProcess("settings", [&] { Set::LoopProcess(system); }); |
| 304 | SSL::InstallInterfaces(*sm, system); | 274 | kernel.RunOnGuestCoreProcess("spl", [&] { SPL::LoopProcess(system); }); |
| 305 | Time::InstallInterfaces(system); | 275 | kernel.RunOnGuestCoreProcess("ssl", [&] { SSL::LoopProcess(system); }); |
| 306 | USB::InstallInterfaces(*sm, system); | 276 | kernel.RunOnGuestCoreProcess("time", [&] { Time::LoopProcess(system); }); |
| 307 | VI::InstallInterfaces(*sm, system, *nv_flinger, *hos_binder_driver_server); | 277 | kernel.RunOnGuestCoreProcess("usb", [&] { USB::LoopProcess(system); }); |
| 278 | // clang-format on | ||
| 308 | } | 279 | } |
| 309 | 280 | ||
| 310 | Services::~Services() = default; | 281 | Services::~Services() = default; |
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h index 22e2119d7..db3b31378 100644 --- a/src/core/hle/service/service.h +++ b/src/core/hle/service/service.h | |||
| @@ -19,8 +19,6 @@ class System; | |||
| 19 | 19 | ||
| 20 | namespace Kernel { | 20 | namespace Kernel { |
| 21 | class HLERequestContext; | 21 | class HLERequestContext; |
| 22 | class KClientPort; | ||
| 23 | class KPort; | ||
| 24 | class KServerSession; | 22 | class KServerSession; |
| 25 | class ServiceThread; | 23 | class ServiceThread; |
| 26 | } // namespace Kernel | 24 | } // namespace Kernel |
| @@ -67,18 +65,12 @@ public: | |||
| 67 | return max_sessions; | 65 | return max_sessions; |
| 68 | } | 66 | } |
| 69 | 67 | ||
| 70 | /// Creates a port pair and registers this service with the given ServiceManager. | ||
| 71 | void InstallAsService(SM::ServiceManager& service_manager); | ||
| 72 | |||
| 73 | /// Invokes a service request routine using the HIPC protocol. | 68 | /// Invokes a service request routine using the HIPC protocol. |
| 74 | void InvokeRequest(Kernel::HLERequestContext& ctx); | 69 | void InvokeRequest(Kernel::HLERequestContext& ctx); |
| 75 | 70 | ||
| 76 | /// Invokes a service request routine using the HIPC protocol. | 71 | /// Invokes a service request routine using the HIPC protocol. |
| 77 | void InvokeRequestTipc(Kernel::HLERequestContext& ctx); | 72 | void InvokeRequestTipc(Kernel::HLERequestContext& ctx); |
| 78 | 73 | ||
| 79 | /// Creates a port pair and registers it on the kernel's global port registry. | ||
| 80 | Kernel::KClientPort& CreatePort(); | ||
| 81 | |||
| 82 | /// Handles a synchronization request for the service. | 74 | /// Handles a synchronization request for the service. |
| 83 | Result HandleSyncRequest(Kernel::KServerSession& session, | 75 | Result HandleSyncRequest(Kernel::KServerSession& session, |
| 84 | Kernel::HLERequestContext& context) override; | 76 | Kernel::HLERequestContext& context) override; |
| @@ -99,9 +91,6 @@ protected: | |||
| 99 | /// Identifier string used to connect to the service. | 91 | /// Identifier string used to connect to the service. |
| 100 | std::string service_name; | 92 | std::string service_name; |
| 101 | 93 | ||
| 102 | /// Port used by ManageNamedPort. | ||
| 103 | Kernel::KPort* named_port{}; | ||
| 104 | |||
| 105 | private: | 94 | private: |
| 106 | template <typename T> | 95 | template <typename T> |
| 107 | friend class ServiceFramework; | 96 | friend class ServiceFramework; |
| @@ -116,8 +105,7 @@ private: | |||
| 116 | Kernel::HLERequestContext& ctx); | 105 | Kernel::HLERequestContext& ctx); |
| 117 | 106 | ||
| 118 | explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_, | 107 | explicit ServiceFrameworkBase(Core::System& system_, const char* service_name_, |
| 119 | ServiceThreadType thread_type, u32 max_sessions_, | 108 | u32 max_sessions_, InvokerFn* handler_invoker_); |
| 120 | InvokerFn* handler_invoker_); | ||
| 121 | ~ServiceFrameworkBase() override; | 109 | ~ServiceFrameworkBase() override; |
| 122 | 110 | ||
| 123 | void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); | 111 | void RegisterHandlersBase(const FunctionInfoBase* functions, std::size_t n); |
| @@ -181,15 +169,12 @@ protected: | |||
| 181 | * | 169 | * |
| 182 | * @param system_ The system context to construct this service under. | 170 | * @param system_ The system context to construct this service under. |
| 183 | * @param service_name_ Name of the service. | 171 | * @param service_name_ Name of the service. |
| 184 | * @param thread_type Specifies the thread type for this service. If this is set to CreateNew, | ||
| 185 | * it creates a new thread for it, otherwise this uses the default thread. | ||
| 186 | * @param max_sessions_ Maximum number of sessions that can be connected to this service at the | 172 | * @param max_sessions_ Maximum number of sessions that can be connected to this service at the |
| 187 | * same time. | 173 | * same time. |
| 188 | */ | 174 | */ |
| 189 | explicit ServiceFramework(Core::System& system_, const char* service_name_, | 175 | explicit ServiceFramework(Core::System& system_, const char* service_name_, |
| 190 | ServiceThreadType thread_type = ServiceThreadType::Default, | ||
| 191 | u32 max_sessions_ = ServerSessionCountMax) | 176 | u32 max_sessions_ = ServerSessionCountMax) |
| 192 | : ServiceFrameworkBase(system_, service_name_, thread_type, max_sessions_, Invoker) {} | 177 | : ServiceFrameworkBase(system_, service_name_, max_sessions_, Invoker) {} |
| 193 | 178 | ||
| 194 | /// Registers handlers in the service. | 179 | /// Registers handlers in the service. |
| 195 | template <std::size_t N> | 180 | template <std::size_t N> |
diff --git a/src/core/hle/service/set/settings.cpp b/src/core/hle/service/set/settings.cpp index 4ebc2a0ec..c48844f77 100644 --- a/src/core/hle/service/set/settings.cpp +++ b/src/core/hle/service/set/settings.cpp | |||
| @@ -1,20 +1,23 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/server_manager.h" | ||
| 4 | #include "core/hle/service/set/set.h" | 5 | #include "core/hle/service/set/set.h" |
| 5 | #include "core/hle/service/set/set_cal.h" | 6 | #include "core/hle/service/set/set_cal.h" |
| 6 | #include "core/hle/service/set/set_fd.h" | 7 | #include "core/hle/service/set/set_fd.h" |
| 7 | #include "core/hle/service/set/set_sys.h" | 8 | #include "core/hle/service/set/set_sys.h" |
| 8 | #include "core/hle/service/set/settings.h" | 9 | #include "core/hle/service/set/settings.h" |
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 10 | 10 | ||
| 11 | namespace Service::Set { | 11 | namespace Service::Set { |
| 12 | 12 | ||
| 13 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 13 | void LoopProcess(Core::System& system) { |
| 14 | std::make_shared<SET>(system)->InstallAsService(service_manager); | 14 | auto server_manager = std::make_unique<ServerManager>(system); |
| 15 | std::make_shared<SET_CAL>(system)->InstallAsService(service_manager); | 15 | |
| 16 | std::make_shared<SET_FD>(system)->InstallAsService(service_manager); | 16 | server_manager->RegisterNamedService("set", std::make_shared<SET>(system)); |
| 17 | std::make_shared<SET_SYS>(system)->InstallAsService(service_manager); | 17 | server_manager->RegisterNamedService("set:cal", std::make_shared<SET_CAL>(system)); |
| 18 | server_manager->RegisterNamedService("set:fd", std::make_shared<SET_FD>(system)); | ||
| 19 | server_manager->RegisterNamedService("set:sys", std::make_shared<SET_SYS>(system)); | ||
| 20 | ServerManager::RunServer(std::move(server_manager)); | ||
| 18 | } | 21 | } |
| 19 | 22 | ||
| 20 | } // namespace Service::Set | 23 | } // namespace Service::Set |
diff --git a/src/core/hle/service/set/settings.h b/src/core/hle/service/set/settings.h index 6cd7d634c..03cd4bb66 100644 --- a/src/core/hle/service/set/settings.h +++ b/src/core/hle/service/set/settings.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::Set { | 10 | namespace Service::Set { |
| 15 | 11 | ||
| 16 | /// Registers all Settings services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::Set | 14 | } // namespace Service::Set |
diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index 84720094f..53c877836 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp | |||
| @@ -12,6 +12,7 @@ | |||
| 12 | #include "core/hle/kernel/k_scoped_resource_reservation.h" | 12 | #include "core/hle/kernel/k_scoped_resource_reservation.h" |
| 13 | #include "core/hle/kernel/k_server_port.h" | 13 | #include "core/hle/kernel/k_server_port.h" |
| 14 | #include "core/hle/result.h" | 14 | #include "core/hle/result.h" |
| 15 | #include "core/hle/service/server_manager.h" | ||
| 15 | #include "core/hle/service/sm/sm.h" | 16 | #include "core/hle/service/sm/sm.h" |
| 16 | #include "core/hle/service/sm/sm_controller.h" | 17 | #include "core/hle/service/sm/sm_controller.h" |
| 17 | 18 | ||
| @@ -22,13 +23,19 @@ constexpr Result ERR_ALREADY_REGISTERED(ErrorModule::SM, 4); | |||
| 22 | constexpr Result ERR_INVALID_NAME(ErrorModule::SM, 6); | 23 | constexpr Result ERR_INVALID_NAME(ErrorModule::SM, 6); |
| 23 | constexpr Result ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); | 24 | constexpr Result ERR_SERVICE_NOT_REGISTERED(ErrorModule::SM, 7); |
| 24 | 25 | ||
| 25 | ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} {} | 26 | ServiceManager::ServiceManager(Kernel::KernelCore& kernel_) : kernel{kernel_} { |
| 27 | controller_interface = std::make_unique<Controller>(kernel.System()); | ||
| 28 | } | ||
| 26 | 29 | ||
| 27 | ServiceManager::~ServiceManager() { | 30 | ServiceManager::~ServiceManager() { |
| 28 | for (auto& [name, port] : service_ports) { | 31 | for (auto& [name, port] : service_ports) { |
| 29 | port->GetClientPort().Close(); | 32 | port->GetClientPort().Close(); |
| 30 | port->GetServerPort().Close(); | 33 | port->GetServerPort().Close(); |
| 31 | } | 34 | } |
| 35 | |||
| 36 | if (deferral_event) { | ||
| 37 | deferral_event->Close(); | ||
| 38 | } | ||
| 32 | } | 39 | } |
| 33 | 40 | ||
| 34 | void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { | 41 | void ServiceManager::InvokeControlRequest(Kernel::HLERequestContext& context) { |
| @@ -43,21 +50,12 @@ static Result ValidateServiceName(const std::string& name) { | |||
| 43 | return ResultSuccess; | 50 | return ResultSuccess; |
| 44 | } | 51 | } |
| 45 | 52 | ||
| 46 | Kernel::KClientPort& ServiceManager::InterfaceFactory(ServiceManager& self, Core::System& system) { | ||
| 47 | self.sm_interface = std::make_shared<SM>(self, system); | ||
| 48 | self.controller_interface = std::make_unique<Controller>(system); | ||
| 49 | return self.sm_interface->CreatePort(); | ||
| 50 | } | ||
| 51 | |||
| 52 | void ServiceManager::SessionHandler(ServiceManager& self, Kernel::KServerPort* server_port) { | ||
| 53 | self.sm_interface->AcceptSession(server_port); | ||
| 54 | } | ||
| 55 | |||
| 56 | Result ServiceManager::RegisterService(std::string name, u32 max_sessions, | 53 | Result ServiceManager::RegisterService(std::string name, u32 max_sessions, |
| 57 | Kernel::SessionRequestHandlerPtr handler) { | 54 | Kernel::SessionRequestHandlerPtr handler) { |
| 58 | 55 | ||
| 59 | CASCADE_CODE(ValidateServiceName(name)); | 56 | CASCADE_CODE(ValidateServiceName(name)); |
| 60 | 57 | ||
| 58 | std::scoped_lock lk{lock}; | ||
| 61 | if (registered_services.find(name) != registered_services.end()) { | 59 | if (registered_services.find(name) != registered_services.end()) { |
| 62 | LOG_ERROR(Service_SM, "Service is already registered! service={}", name); | 60 | LOG_ERROR(Service_SM, "Service is already registered! service={}", name); |
| 63 | return ERR_ALREADY_REGISTERED; | 61 | return ERR_ALREADY_REGISTERED; |
| @@ -68,6 +66,9 @@ Result ServiceManager::RegisterService(std::string name, u32 max_sessions, | |||
| 68 | 66 | ||
| 69 | service_ports.emplace(name, port); | 67 | service_ports.emplace(name, port); |
| 70 | registered_services.emplace(name, handler); | 68 | registered_services.emplace(name, handler); |
| 69 | if (deferral_event) { | ||
| 70 | deferral_event->Signal(); | ||
| 71 | } | ||
| 71 | 72 | ||
| 72 | return ResultSuccess; | 73 | return ResultSuccess; |
| 73 | } | 74 | } |
| @@ -75,6 +76,7 @@ Result ServiceManager::RegisterService(std::string name, u32 max_sessions, | |||
| 75 | Result ServiceManager::UnregisterService(const std::string& name) { | 76 | Result ServiceManager::UnregisterService(const std::string& name) { |
| 76 | CASCADE_CODE(ValidateServiceName(name)); | 77 | CASCADE_CODE(ValidateServiceName(name)); |
| 77 | 78 | ||
| 79 | std::scoped_lock lk{lock}; | ||
| 78 | const auto iter = registered_services.find(name); | 80 | const auto iter = registered_services.find(name); |
| 79 | if (iter == registered_services.end()) { | 81 | if (iter == registered_services.end()) { |
| 80 | LOG_ERROR(Service_SM, "Server is not registered! service={}", name); | 82 | LOG_ERROR(Service_SM, "Server is not registered! service={}", name); |
| @@ -89,9 +91,11 @@ Result ServiceManager::UnregisterService(const std::string& name) { | |||
| 89 | 91 | ||
| 90 | ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name) { | 92 | ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name) { |
| 91 | CASCADE_CODE(ValidateServiceName(name)); | 93 | CASCADE_CODE(ValidateServiceName(name)); |
| 94 | |||
| 95 | std::scoped_lock lk{lock}; | ||
| 92 | auto it = service_ports.find(name); | 96 | auto it = service_ports.find(name); |
| 93 | if (it == service_ports.end()) { | 97 | if (it == service_ports.end()) { |
| 94 | LOG_ERROR(Service_SM, "Server is not registered! service={}", name); | 98 | LOG_WARNING(Service_SM, "Server is not registered! service={}", name); |
| 95 | return ERR_SERVICE_NOT_REGISTERED; | 99 | return ERR_SERVICE_NOT_REGISTERED; |
| 96 | } | 100 | } |
| 97 | 101 | ||
| @@ -108,7 +112,7 @@ ResultVal<Kernel::KPort*> ServiceManager::GetServicePort(const std::string& name | |||
| 108 | void SM::Initialize(Kernel::HLERequestContext& ctx) { | 112 | void SM::Initialize(Kernel::HLERequestContext& ctx) { |
| 109 | LOG_DEBUG(Service_SM, "called"); | 113 | LOG_DEBUG(Service_SM, "called"); |
| 110 | 114 | ||
| 111 | is_initialized = true; | 115 | ctx.GetManager()->SetIsInitializedForSm(); |
| 112 | 116 | ||
| 113 | IPC::ResponseBuilder rb{ctx, 2}; | 117 | IPC::ResponseBuilder rb{ctx, 2}; |
| 114 | rb.Push(ResultSuccess); | 118 | rb.Push(ResultSuccess); |
| @@ -116,6 +120,11 @@ void SM::Initialize(Kernel::HLERequestContext& ctx) { | |||
| 116 | 120 | ||
| 117 | void SM::GetService(Kernel::HLERequestContext& ctx) { | 121 | void SM::GetService(Kernel::HLERequestContext& ctx) { |
| 118 | auto result = GetServiceImpl(ctx); | 122 | auto result = GetServiceImpl(ctx); |
| 123 | if (ctx.GetIsDeferred()) { | ||
| 124 | // Don't overwrite the command buffer. | ||
| 125 | return; | ||
| 126 | } | ||
| 127 | |||
| 119 | if (result.Succeeded()) { | 128 | if (result.Succeeded()) { |
| 120 | IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; | 129 | IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; |
| 121 | rb.Push(result.Code()); | 130 | rb.Push(result.Code()); |
| @@ -128,6 +137,11 @@ void SM::GetService(Kernel::HLERequestContext& ctx) { | |||
| 128 | 137 | ||
| 129 | void SM::GetServiceTipc(Kernel::HLERequestContext& ctx) { | 138 | void SM::GetServiceTipc(Kernel::HLERequestContext& ctx) { |
| 130 | auto result = GetServiceImpl(ctx); | 139 | auto result = GetServiceImpl(ctx); |
| 140 | if (ctx.GetIsDeferred()) { | ||
| 141 | // Don't overwrite the command buffer. | ||
| 142 | return; | ||
| 143 | } | ||
| 144 | |||
| 131 | IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; | 145 | IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; |
| 132 | rb.Push(result.Code()); | 146 | rb.Push(result.Code()); |
| 133 | rb.PushMoveObjects(result.Succeeded() ? result.Unwrap() : nullptr); | 147 | rb.PushMoveObjects(result.Succeeded() ? result.Unwrap() : nullptr); |
| @@ -145,7 +159,7 @@ static std::string PopServiceName(IPC::RequestParser& rp) { | |||
| 145 | } | 159 | } |
| 146 | 160 | ||
| 147 | ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& ctx) { | 161 | ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& ctx) { |
| 148 | if (!is_initialized) { | 162 | if (!ctx.GetManager()->GetIsInitializedForSm()) { |
| 149 | return ERR_NOT_INITIALIZED; | 163 | return ERR_NOT_INITIALIZED; |
| 150 | } | 164 | } |
| 151 | 165 | ||
| @@ -154,10 +168,15 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& | |||
| 154 | 168 | ||
| 155 | // Find the named port. | 169 | // Find the named port. |
| 156 | auto port_result = service_manager.GetServicePort(name); | 170 | auto port_result = service_manager.GetServicePort(name); |
| 157 | auto service = service_manager.GetService<Kernel::SessionRequestHandler>(name); | 171 | if (port_result.Code() == ERR_INVALID_NAME) { |
| 158 | if (port_result.Failed() || !service) { | 172 | LOG_ERROR(Service_SM, "Invalid service name '{}'", name); |
| 159 | LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, port_result.Code().raw); | 173 | return ERR_INVALID_NAME; |
| 160 | return port_result.Code(); | 174 | } |
| 175 | |||
| 176 | if (port_result.Failed()) { | ||
| 177 | LOG_INFO(Service_SM, "Waiting for service {} to become available", name); | ||
| 178 | ctx.SetIsDeferred(); | ||
| 179 | return ERR_SERVICE_NOT_REGISTERED; | ||
| 161 | } | 180 | } |
| 162 | auto& port = port_result.Unwrap(); | 181 | auto& port = port_result.Unwrap(); |
| 163 | 182 | ||
| @@ -167,7 +186,6 @@ ResultVal<Kernel::KClientSession*> SM::GetServiceImpl(Kernel::HLERequestContext& | |||
| 167 | LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.raw); | 186 | LOG_ERROR(Service_SM, "called service={} -> error 0x{:08X}", name, result.raw); |
| 168 | return result; | 187 | return result; |
| 169 | } | 188 | } |
| 170 | service->AcceptSession(&port->GetServerPort()); | ||
| 171 | 189 | ||
| 172 | LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); | 190 | LOG_DEBUG(Service_SM, "called service={} -> session={}", name, session->GetId()); |
| 173 | 191 | ||
| @@ -212,7 +230,7 @@ void SM::UnregisterService(Kernel::HLERequestContext& ctx) { | |||
| 212 | } | 230 | } |
| 213 | 231 | ||
| 214 | SM::SM(ServiceManager& service_manager_, Core::System& system_) | 232 | SM::SM(ServiceManager& service_manager_, Core::System& system_) |
| 215 | : ServiceFramework{system_, "sm:", ServiceThreadType::Default, 4}, | 233 | : ServiceFramework{system_, "sm:", 4}, |
| 216 | service_manager{service_manager_}, kernel{system_.Kernel()} { | 234 | service_manager{service_manager_}, kernel{system_.Kernel()} { |
| 217 | RegisterHandlers({ | 235 | RegisterHandlers({ |
| 218 | {0, &SM::Initialize, "Initialize"}, | 236 | {0, &SM::Initialize, "Initialize"}, |
| @@ -232,4 +250,16 @@ SM::SM(ServiceManager& service_manager_, Core::System& system_) | |||
| 232 | 250 | ||
| 233 | SM::~SM() = default; | 251 | SM::~SM() = default; |
| 234 | 252 | ||
| 253 | void LoopProcess(Core::System& system) { | ||
| 254 | auto& service_manager = system.ServiceManager(); | ||
| 255 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 256 | |||
| 257 | Kernel::KEvent* deferral_event{}; | ||
| 258 | server_manager->ManageDeferral(&deferral_event); | ||
| 259 | service_manager.SetDeferralEvent(deferral_event); | ||
| 260 | |||
| 261 | server_manager->ManageNamedPort("sm:", std::make_shared<SM>(system.ServiceManager(), system)); | ||
| 262 | ServerManager::RunServer(std::move(server_manager)); | ||
| 263 | } | ||
| 264 | |||
| 235 | } // namespace Service::SM | 265 | } // namespace Service::SM |
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 02a5dde9e..b7eeafdd6 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #pragma once | 4 | #pragma once |
| 5 | 5 | ||
| 6 | #include <memory> | 6 | #include <memory> |
| 7 | #include <mutex> | ||
| 7 | #include <string> | 8 | #include <string> |
| 8 | #include <unordered_map> | 9 | #include <unordered_map> |
| 9 | 10 | ||
| @@ -50,9 +51,6 @@ private: | |||
| 50 | 51 | ||
| 51 | class ServiceManager { | 52 | class ServiceManager { |
| 52 | public: | 53 | public: |
| 53 | static Kernel::KClientPort& InterfaceFactory(ServiceManager& self, Core::System& system); | ||
| 54 | static void SessionHandler(ServiceManager& self, Kernel::KServerPort* server_port); | ||
| 55 | |||
| 56 | explicit ServiceManager(Kernel::KernelCore& kernel_); | 54 | explicit ServiceManager(Kernel::KernelCore& kernel_); |
| 57 | ~ServiceManager(); | 55 | ~ServiceManager(); |
| 58 | 56 | ||
| @@ -73,16 +71,25 @@ public: | |||
| 73 | 71 | ||
| 74 | void InvokeControlRequest(Kernel::HLERequestContext& context); | 72 | void InvokeControlRequest(Kernel::HLERequestContext& context); |
| 75 | 73 | ||
| 74 | void SetDeferralEvent(Kernel::KEvent* deferral_event_) { | ||
| 75 | deferral_event = deferral_event_; | ||
| 76 | } | ||
| 77 | |||
| 76 | private: | 78 | private: |
| 77 | std::shared_ptr<SM> sm_interface; | 79 | std::shared_ptr<SM> sm_interface; |
| 78 | std::unique_ptr<Controller> controller_interface; | 80 | std::unique_ptr<Controller> controller_interface; |
| 79 | 81 | ||
| 80 | /// Map of registered services, retrieved using GetServicePort. | 82 | /// Map of registered services, retrieved using GetServicePort. |
| 83 | std::mutex lock; | ||
| 81 | std::unordered_map<std::string, Kernel::SessionRequestHandlerPtr> registered_services; | 84 | std::unordered_map<std::string, Kernel::SessionRequestHandlerPtr> registered_services; |
| 82 | std::unordered_map<std::string, Kernel::KPort*> service_ports; | 85 | std::unordered_map<std::string, Kernel::KPort*> service_ports; |
| 83 | 86 | ||
| 84 | /// Kernel context | 87 | /// Kernel context |
| 85 | Kernel::KernelCore& kernel; | 88 | Kernel::KernelCore& kernel; |
| 89 | Kernel::KEvent* deferral_event{}; | ||
| 86 | }; | 90 | }; |
| 87 | 91 | ||
| 92 | /// Runs SM services. | ||
| 93 | void LoopProcess(Core::System& system); | ||
| 94 | |||
| 88 | } // namespace Service::SM | 95 | } // namespace Service::SM |
diff --git a/src/core/hle/service/sm/sm_controller.cpp b/src/core/hle/service/sm/sm_controller.cpp index 1cf9dd1c4..f52522d1d 100644 --- a/src/core/hle/service/sm/sm_controller.cpp +++ b/src/core/hle/service/sm/sm_controller.cpp | |||
| @@ -10,6 +10,7 @@ | |||
| 10 | #include "core/hle/kernel/k_scoped_resource_reservation.h" | 10 | #include "core/hle/kernel/k_scoped_resource_reservation.h" |
| 11 | #include "core/hle/kernel/k_server_session.h" | 11 | #include "core/hle/kernel/k_server_session.h" |
| 12 | #include "core/hle/kernel/k_session.h" | 12 | #include "core/hle/kernel/k_session.h" |
| 13 | #include "core/hle/service/server_manager.h" | ||
| 13 | #include "core/hle/service/sm/sm_controller.h" | 14 | #include "core/hle/service/sm/sm_controller.h" |
| 14 | 15 | ||
| 15 | namespace Service::SM { | 16 | namespace Service::SM { |
| @@ -48,9 +49,9 @@ void Controller::CloneCurrentObject(Kernel::HLERequestContext& ctx) { | |||
| 48 | // Commit the session reservation. | 49 | // Commit the session reservation. |
| 49 | session_reservation.Commit(); | 50 | session_reservation.Commit(); |
| 50 | 51 | ||
| 51 | // Register with manager. | 52 | // Register with server manager. |
| 52 | session_manager->SessionHandler().RegisterSession(&session->GetServerSession(), | 53 | session_manager->GetServerManager().RegisterSession(&session->GetServerSession(), |
| 53 | session_manager); | 54 | session_manager); |
| 54 | 55 | ||
| 55 | // We succeeded. | 56 | // We succeeded. |
| 56 | IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; | 57 | IPC::ResponseBuilder rb{ctx, 2, 0, 1, IPC::ResponseBuilder::Flags::AlwaysMoveHandles}; |
diff --git a/src/core/hle/service/sockets/bsd.cpp b/src/core/hle/service/sockets/bsd.cpp index 330a66409..2789fa1ed 100644 --- a/src/core/hle/service/sockets/bsd.cpp +++ b/src/core/hle/service/sockets/bsd.cpp | |||
| @@ -881,8 +881,7 @@ void BSD::OnProxyPacketReceived(const Network::ProxyPacket& packet) { | |||
| 881 | } | 881 | } |
| 882 | 882 | ||
| 883 | BSD::BSD(Core::System& system_, const char* name) | 883 | BSD::BSD(Core::System& system_, const char* name) |
| 884 | : ServiceFramework{system_, name, ServiceThreadType::CreateNew}, room_network{ | 884 | : ServiceFramework{system_, name}, room_network{system_.GetRoomNetwork()} { |
| 885 | system_.GetRoomNetwork()} { | ||
| 886 | // clang-format off | 885 | // clang-format off |
| 887 | static const FunctionInfo functions[] = { | 886 | static const FunctionInfo functions[] = { |
| 888 | {0, &BSD::RegisterClient, "RegisterClient"}, | 887 | {0, &BSD::RegisterClient, "RegisterClient"}, |
diff --git a/src/core/hle/service/sockets/sockets.cpp b/src/core/hle/service/sockets/sockets.cpp index b191b5cf5..676d24e03 100644 --- a/src/core/hle/service/sockets/sockets.cpp +++ b/src/core/hle/service/sockets/sockets.cpp | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project | 1 | // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project |
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/service/server_manager.h" | ||
| 4 | #include "core/hle/service/sockets/bsd.h" | 5 | #include "core/hle/service/sockets/bsd.h" |
| 5 | #include "core/hle/service/sockets/nsd.h" | 6 | #include "core/hle/service/sockets/nsd.h" |
| 6 | #include "core/hle/service/sockets/sfdnsres.h" | 7 | #include "core/hle/service/sockets/sfdnsres.h" |
| @@ -8,15 +9,17 @@ | |||
| 8 | 9 | ||
| 9 | namespace Service::Sockets { | 10 | namespace Service::Sockets { |
| 10 | 11 | ||
| 11 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 12 | void LoopProcess(Core::System& system) { |
| 12 | std::make_shared<BSD>(system, "bsd:s")->InstallAsService(service_manager); | 13 | auto server_manager = std::make_unique<ServerManager>(system); |
| 13 | std::make_shared<BSD>(system, "bsd:u")->InstallAsService(service_manager); | ||
| 14 | std::make_shared<BSDCFG>(system)->InstallAsService(service_manager); | ||
| 15 | 14 | ||
| 16 | std::make_shared<NSD>(system, "nsd:a")->InstallAsService(service_manager); | 15 | server_manager->RegisterNamedService("bsd:s", std::make_shared<BSD>(system, "bsd:s")); |
| 17 | std::make_shared<NSD>(system, "nsd:u")->InstallAsService(service_manager); | 16 | server_manager->RegisterNamedService("bsd:u", std::make_shared<BSD>(system, "bsd:u")); |
| 18 | 17 | server_manager->RegisterNamedService("bsdcfg", std::make_shared<BSDCFG>(system)); | |
| 19 | std::make_shared<SFDNSRES>(system)->InstallAsService(service_manager); | 18 | server_manager->RegisterNamedService("nsd:a", std::make_shared<NSD>(system, "nsd:a")); |
| 19 | server_manager->RegisterNamedService("nsd:u", std::make_shared<NSD>(system, "nsd:u")); | ||
| 20 | server_manager->RegisterNamedService("sfdnsres", std::make_shared<SFDNSRES>(system)); | ||
| 21 | server_manager->StartAdditionalHostThreads("bsdsocket", 2); | ||
| 22 | ServerManager::RunServer(std::move(server_manager)); | ||
| 20 | } | 23 | } |
| 21 | 24 | ||
| 22 | } // namespace Service::Sockets | 25 | } // namespace Service::Sockets |
diff --git a/src/core/hle/service/sockets/sockets.h b/src/core/hle/service/sockets/sockets.h index 9840c11f9..acd2dae7b 100644 --- a/src/core/hle/service/sockets/sockets.h +++ b/src/core/hle/service/sockets/sockets.h | |||
| @@ -10,10 +10,6 @@ namespace Core { | |||
| 10 | class System; | 10 | class System; |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | namespace Service::SM { | ||
| 14 | class ServiceManager; | ||
| 15 | } | ||
| 16 | |||
| 17 | namespace Service::Sockets { | 13 | namespace Service::Sockets { |
| 18 | 14 | ||
| 19 | enum class Errno : u32 { | 15 | enum class Errno : u32 { |
| @@ -99,7 +95,6 @@ struct Linger { | |||
| 99 | u32 linger; | 95 | u32 linger; |
| 100 | }; | 96 | }; |
| 101 | 97 | ||
| 102 | /// Registers all Sockets services with the specified service manager. | 98 | void LoopProcess(Core::System& system); |
| 103 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 104 | 99 | ||
| 105 | } // namespace Service::Sockets | 100 | } // namespace Service::Sockets |
diff --git a/src/core/hle/service/spl/spl_module.cpp b/src/core/hle/service/spl/spl_module.cpp index 64eae1ebf..31679e1bb 100644 --- a/src/core/hle/service/spl/spl_module.cpp +++ b/src/core/hle/service/spl/spl_module.cpp | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include "common/settings.h" | 9 | #include "common/settings.h" |
| 10 | #include "core/hle/api_version.h" | 10 | #include "core/hle/api_version.h" |
| 11 | #include "core/hle/ipc_helpers.h" | 11 | #include "core/hle/ipc_helpers.h" |
| 12 | #include "core/hle/service/server_manager.h" | ||
| 12 | #include "core/hle/service/spl/csrng.h" | 13 | #include "core/hle/service/spl/csrng.h" |
| 13 | #include "core/hle/service/spl/spl.h" | 14 | #include "core/hle/service/spl/spl.h" |
| 14 | #include "core/hle/service/spl/spl_module.h" | 15 | #include "core/hle/service/spl/spl_module.h" |
| @@ -158,15 +159,18 @@ ResultVal<u64> Module::Interface::GetConfigImpl(ConfigItem config_item) const { | |||
| 158 | } | 159 | } |
| 159 | } | 160 | } |
| 160 | 161 | ||
| 161 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 162 | void LoopProcess(Core::System& system) { |
| 163 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 162 | auto module = std::make_shared<Module>(); | 164 | auto module = std::make_shared<Module>(); |
| 163 | std::make_shared<CSRNG>(system, module)->InstallAsService(service_manager); | 165 | |
| 164 | std::make_shared<SPL>(system, module)->InstallAsService(service_manager); | 166 | server_manager->RegisterNamedService("csrng", std::make_shared<CSRNG>(system, module)); |
| 165 | std::make_shared<SPL_MIG>(system, module)->InstallAsService(service_manager); | 167 | server_manager->RegisterNamedService("spl", std::make_shared<SPL>(system, module)); |
| 166 | std::make_shared<SPL_FS>(system, module)->InstallAsService(service_manager); | 168 | server_manager->RegisterNamedService("spl:mig", std::make_shared<SPL_MIG>(system, module)); |
| 167 | std::make_shared<SPL_SSL>(system, module)->InstallAsService(service_manager); | 169 | server_manager->RegisterNamedService("spl:fs", std::make_shared<SPL_FS>(system, module)); |
| 168 | std::make_shared<SPL_ES>(system, module)->InstallAsService(service_manager); | 170 | server_manager->RegisterNamedService("spl:ssl", std::make_shared<SPL_SSL>(system, module)); |
| 169 | std::make_shared<SPL_MANU>(system, module)->InstallAsService(service_manager); | 171 | server_manager->RegisterNamedService("spl:es", std::make_shared<SPL_ES>(system, module)); |
| 172 | server_manager->RegisterNamedService("spl:manu", std::make_shared<SPL_MANU>(system, module)); | ||
| 173 | ServerManager::RunServer(std::move(server_manager)); | ||
| 170 | } | 174 | } |
| 171 | 175 | ||
| 172 | } // namespace Service::SPL | 176 | } // namespace Service::SPL |
diff --git a/src/core/hle/service/spl/spl_module.h b/src/core/hle/service/spl/spl_module.h index 4c9a3c618..baed9efd7 100644 --- a/src/core/hle/service/spl/spl_module.h +++ b/src/core/hle/service/spl/spl_module.h | |||
| @@ -41,7 +41,6 @@ public: | |||
| 41 | }; | 41 | }; |
| 42 | }; | 42 | }; |
| 43 | 43 | ||
| 44 | /// Registers all SPL services with the specified service manager. | 44 | void LoopProcess(Core::System& system); |
| 45 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 46 | 45 | ||
| 47 | } // namespace Service::SPL | 46 | } // namespace Service::SPL |
diff --git a/src/core/hle/service/ssl/ssl.cpp b/src/core/hle/service/ssl/ssl.cpp index 015208593..c1fd1a59b 100644 --- a/src/core/hle/service/ssl/ssl.cpp +++ b/src/core/hle/service/ssl/ssl.cpp | |||
| @@ -2,8 +2,8 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "core/hle/ipc_helpers.h" | 4 | #include "core/hle/ipc_helpers.h" |
| 5 | #include "core/hle/service/server_manager.h" | ||
| 5 | #include "core/hle/service/service.h" | 6 | #include "core/hle/service/service.h" |
| 6 | #include "core/hle/service/sm/sm.h" | ||
| 7 | #include "core/hle/service/ssl/ssl.h" | 7 | #include "core/hle/service/ssl/ssl.h" |
| 8 | 8 | ||
| 9 | namespace Service::SSL { | 9 | namespace Service::SSL { |
| @@ -183,8 +183,11 @@ private: | |||
| 183 | } | 183 | } |
| 184 | }; | 184 | }; |
| 185 | 185 | ||
| 186 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system) { | 186 | void LoopProcess(Core::System& system) { |
| 187 | std::make_shared<SSL>(system)->InstallAsService(service_manager); | 187 | auto server_manager = std::make_unique<ServerManager>(system); |
| 188 | |||
| 189 | server_manager->RegisterNamedService("ssl", std::make_shared<SSL>(system)); | ||
| 190 | ServerManager::RunServer(std::move(server_manager)); | ||
| 188 | } | 191 | } |
| 189 | 192 | ||
| 190 | } // namespace Service::SSL | 193 | } // namespace Service::SSL |
diff --git a/src/core/hle/service/ssl/ssl.h b/src/core/hle/service/ssl/ssl.h index 27b38a003..f6e21bbb3 100644 --- a/src/core/hle/service/ssl/ssl.h +++ b/src/core/hle/service/ssl/ssl.h | |||
| @@ -7,13 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::SSL { | 10 | namespace Service::SSL { |
| 15 | 11 | ||
| 16 | /// Registers all SSL services with the specified service manager. | 12 | void LoopProcess(Core::System& system); |
| 17 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system); | ||
| 18 | 13 | ||
| 19 | } // namespace Service::SSL | 14 | } // namespace Service::SSL |
diff --git a/src/core/hle/service/time/time.cpp b/src/core/hle/service/time/time.cpp index f77cdbb43..8020e407c 100644 --- a/src/core/hle/service/time/time.cpp +++ b/src/core/hle/service/time/time.cpp | |||
| @@ -7,6 +7,7 @@ | |||
| 7 | #include "core/hardware_properties.h" | 7 | #include "core/hardware_properties.h" |
| 8 | #include "core/hle/ipc_helpers.h" | 8 | #include "core/hle/ipc_helpers.h" |
| 9 | #include "core/hle/kernel/kernel.h" | 9 | #include "core/hle/kernel/kernel.h" |
| 10 | #include "core/hle/service/server_manager.h" | ||
| 10 | #include "core/hle/service/time/time.h" | 11 | #include "core/hle/service/time/time.h" |
| 11 | #include "core/hle/service/time/time_interface.h" | 12 | #include "core/hle/service/time/time_interface.h" |
| 12 | #include "core/hle/service/time/time_manager.h" | 13 | #include "core/hle/service/time/time_manager.h" |
| @@ -397,11 +398,17 @@ Module::Interface::Interface(std::shared_ptr<Module> module_, Core::System& syst | |||
| 397 | 398 | ||
| 398 | Module::Interface::~Interface() = default; | 399 | Module::Interface::~Interface() = default; |
| 399 | 400 | ||
| 400 | void InstallInterfaces(Core::System& system) { | 401 | void LoopProcess(Core::System& system) { |
| 402 | auto server_manager = std::make_unique<ServerManager>(system); | ||
| 401 | auto module{std::make_shared<Module>()}; | 403 | auto module{std::make_shared<Module>()}; |
| 402 | std::make_shared<Time>(module, system, "time:a")->InstallAsService(system.ServiceManager()); | 404 | |
| 403 | std::make_shared<Time>(module, system, "time:s")->InstallAsService(system.ServiceManager()); | 405 | server_manager->RegisterNamedService("time:a", |
| 404 | std::make_shared<Time>(module, system, "time:u")->InstallAsService(system.ServiceManager()); | 406 | std::make_shared<Time>(module, system, "time:a")); |
| 407 | server_manager->RegisterNamedService("time:s", | ||
| 408 | std::make_shared<Time>(module, system, "time:s")); | ||
| 409 | server_manager->RegisterNamedService("time:u", | ||
| 410 | std::make_shared<Time>(module, system, "time:u")); | ||
| 411 | ServerManager::RunServer(std::move(server_manager)); | ||
| 405 | } | 412 | } |
| 406 | 413 | ||
| 407 | } // namespace Service::Time | 414 | } // namespace Service::Time |
diff --git a/src/core/hle/service/time/time.h b/src/core/hle/service/time/time.h index 76a46cfc7..c9936c645 100644 --- a/src/core/hle/service/time/time.h +++ b/src/core/hle/service/time/time.h | |||
| @@ -46,7 +46,6 @@ public: | |||
| 46 | }; | 46 | }; |
| 47 | }; | 47 | }; |
| 48 | 48 | ||
| 49 | /// Registers all Time services with the specified service manager. | 49 | void LoopProcess(Core::System& system); |
| 50 | void InstallInterfaces(Core::System& system); | ||
| 51 | 50 | ||
| 52 | } // namespace Service::Time | 51 | } // namespace Service::Time |
diff --git a/src/core/hle/service/usb/usb.cpp b/src/core/hle/service/usb/usb.cpp index ac46a406c..ddb73f394 100644 --- a/src/core/hle/service/usb/usb.cpp +++ b/src/core/hle/service/usb/usb.cpp | |||
| @@ -5,8 +5,8 @@ | |||
| 5 | 5 | ||
| 6 | #include "common/logging/log.h" | 6 | #include "common/logging/log.h" |
| 7 | #include "core/hle/ipc_helpers.h" | 7 | #include "core/hle/ipc_helpers.h" |
| 8 | #include "core/hle/service/server_manager.h" | ||
| 8 | #include "core/hle/service/service.h" | 9 | #include "core/hle/service/service.h" |
| 9 | #include "core/hle/service/sm/sm.h" | ||
| 10 | #include "core/hle/service/usb/usb.h" | 10 | #include "core/hle/service/usb/usb.h" |
| 11 | 11 | ||
| 12 | namespace Service::USB { | 12 | namespace Service::USB { |
| @@ -218,12 +218,15 @@ public: | |||
| 218 | } | 218 | } |
| 219 | }; | 219 | }; |
| 220 | 220 | ||
| 221 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system) { | 221 | void LoopProcess(Core::System& system) { |
| 222 | std::make_shared<USB_DS>(system)->InstallAsService(sm); | 222 | auto server_manager = std::make_unique<ServerManager>(system); |
| 223 | std::make_shared<USB_HS>(system)->InstallAsService(sm); | 223 | |
| 224 | std::make_shared<USB_PD>(system)->InstallAsService(sm); | 224 | server_manager->RegisterNamedService("usb:ds", std::make_shared<USB_DS>(system)); |
| 225 | std::make_shared<USB_PD_C>(system)->InstallAsService(sm); | 225 | server_manager->RegisterNamedService("usb:hs", std::make_shared<USB_HS>(system)); |
| 226 | std::make_shared<USB_PM>(system)->InstallAsService(sm); | 226 | server_manager->RegisterNamedService("usb:pd", std::make_shared<USB_PD>(system)); |
| 227 | server_manager->RegisterNamedService("usb:pd:c", std::make_shared<USB_PD_C>(system)); | ||
| 228 | server_manager->RegisterNamedService("usb:pm", std::make_shared<USB_PM>(system)); | ||
| 229 | ServerManager::RunServer(std::move(server_manager)); | ||
| 227 | } | 230 | } |
| 228 | 231 | ||
| 229 | } // namespace Service::USB | 232 | } // namespace Service::USB |
diff --git a/src/core/hle/service/usb/usb.h b/src/core/hle/service/usb/usb.h index b41b9684c..98376ebc0 100644 --- a/src/core/hle/service/usb/usb.h +++ b/src/core/hle/service/usb/usb.h | |||
| @@ -7,12 +7,8 @@ namespace Core { | |||
| 7 | class System; | 7 | class System; |
| 8 | } | 8 | } |
| 9 | 9 | ||
| 10 | namespace Service::SM { | ||
| 11 | class ServiceManager; | ||
| 12 | } | ||
| 13 | |||
| 14 | namespace Service::USB { | 10 | namespace Service::USB { |
| 15 | 11 | ||
| 16 | void InstallInterfaces(SM::ServiceManager& sm, Core::System& system); | 12 | void LoopProcess(Core::System& system); |
| 17 | 13 | ||
| 18 | } // namespace Service::USB | 14 | } // namespace Service::USB |
diff --git a/src/core/hle/service/vi/vi.cpp b/src/core/hle/service/vi/vi.cpp index 0915785d2..d9cfebd70 100644 --- a/src/core/hle/service/vi/vi.cpp +++ b/src/core/hle/service/vi/vi.cpp | |||
| @@ -26,6 +26,7 @@ | |||
| 26 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" | 26 | #include "core/hle/service/nvflinger/hos_binder_driver_server.h" |
| 27 | #include "core/hle/service/nvflinger/nvflinger.h" | 27 | #include "core/hle/service/nvflinger/nvflinger.h" |
| 28 | #include "core/hle/service/nvflinger/parcel.h" | 28 | #include "core/hle/service/nvflinger/parcel.h" |
| 29 | #include "core/hle/service/server_manager.h" | ||
| 29 | #include "core/hle/service/service.h" | 30 | #include "core/hle/service/service.h" |
| 30 | #include "core/hle/service/vi/vi.h" | 31 | #include "core/hle/service/vi/vi.h" |
| 31 | #include "core/hle/service/vi/vi_m.h" | 32 | #include "core/hle/service/vi/vi_m.h" |
| @@ -73,8 +74,7 @@ static_assert(sizeof(NativeWindow) == 0x28, "NativeWindow has wrong size"); | |||
| 73 | class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { | 74 | class IHOSBinderDriver final : public ServiceFramework<IHOSBinderDriver> { |
| 74 | public: | 75 | public: |
| 75 | explicit IHOSBinderDriver(Core::System& system_, NVFlinger::HosBinderDriverServer& server_) | 76 | explicit IHOSBinderDriver(Core::System& system_, NVFlinger::HosBinderDriverServer& server_) |
| 76 | : ServiceFramework{system_, "IHOSBinderDriver", ServiceThreadType::CreateNew}, | 77 | : ServiceFramework{system_, "IHOSBinderDriver"}, server(server_) { |
| 77 | server(server_) { | ||
| 78 | static const FunctionInfo functions[] = { | 78 | static const FunctionInfo functions[] = { |
| 79 | {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, | 79 | {0, &IHOSBinderDriver::TransactParcel, "TransactParcel"}, |
| 80 | {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, | 80 | {1, &IHOSBinderDriver::AdjustRefcount, "AdjustRefcount"}, |
| @@ -809,15 +809,17 @@ void detail::GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& | |||
| 809 | rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger, hos_binder_driver_server); | 809 | rb.PushIpcInterface<IApplicationDisplayService>(system, nv_flinger, hos_binder_driver_server); |
| 810 | } | 810 | } |
| 811 | 811 | ||
| 812 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, | 812 | void LoopProcess(Core::System& system, NVFlinger::NVFlinger& nv_flinger, |
| 813 | NVFlinger::NVFlinger& nv_flinger, | 813 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server) { |
| 814 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server) { | 814 | auto server_manager = std::make_unique<ServerManager>(system); |
| 815 | std::make_shared<VI_M>(system, nv_flinger, hos_binder_driver_server) | 815 | |
| 816 | ->InstallAsService(service_manager); | 816 | server_manager->RegisterNamedService( |
| 817 | std::make_shared<VI_S>(system, nv_flinger, hos_binder_driver_server) | 817 | "vi:m", std::make_shared<VI_M>(system, nv_flinger, hos_binder_driver_server)); |
| 818 | ->InstallAsService(service_manager); | 818 | server_manager->RegisterNamedService( |
| 819 | std::make_shared<VI_U>(system, nv_flinger, hos_binder_driver_server) | 819 | "vi:s", std::make_shared<VI_S>(system, nv_flinger, hos_binder_driver_server)); |
| 820 | ->InstallAsService(service_manager); | 820 | server_manager->RegisterNamedService( |
| 821 | "vi:u", std::make_shared<VI_U>(system, nv_flinger, hos_binder_driver_server)); | ||
| 822 | ServerManager::RunServer(std::move(server_manager)); | ||
| 821 | } | 823 | } |
| 822 | 824 | ||
| 823 | } // namespace Service::VI | 825 | } // namespace Service::VI |
diff --git a/src/core/hle/service/vi/vi.h b/src/core/hle/service/vi/vi.h index fc2d717e7..4ed7aaf2b 100644 --- a/src/core/hle/service/vi/vi.h +++ b/src/core/hle/service/vi/vi.h | |||
| @@ -18,10 +18,6 @@ class HosBinderDriverServer; | |||
| 18 | class NVFlinger; | 18 | class NVFlinger; |
| 19 | } // namespace Service::NVFlinger | 19 | } // namespace Service::NVFlinger |
| 20 | 20 | ||
| 21 | namespace Service::SM { | ||
| 22 | class ServiceManager; | ||
| 23 | } | ||
| 24 | |||
| 25 | namespace Service::VI { | 21 | namespace Service::VI { |
| 26 | 22 | ||
| 27 | enum class DisplayResolution : u32 { | 23 | enum class DisplayResolution : u32 { |
| @@ -52,9 +48,7 @@ void GetDisplayServiceImpl(Kernel::HLERequestContext& ctx, Core::System& system, | |||
| 52 | Permission permission); | 48 | Permission permission); |
| 53 | } // namespace detail | 49 | } // namespace detail |
| 54 | 50 | ||
| 55 | /// Registers all VI services with the specified service manager. | 51 | void LoopProcess(Core::System& system, NVFlinger::NVFlinger& nv_flinger, |
| 56 | void InstallInterfaces(SM::ServiceManager& service_manager, Core::System& system, | 52 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server); |
| 57 | NVFlinger::NVFlinger& nv_flinger, | ||
| 58 | NVFlinger::HosBinderDriverServer& hos_binder_driver_server); | ||
| 59 | 53 | ||
| 60 | } // namespace Service::VI | 54 | } // namespace Service::VI |