diff options
Diffstat (limited to '')
-rw-r--r-- | src/core/hle/service/sm/sm.h | 35 |
1 files changed, 20 insertions, 15 deletions
diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 02a5dde9e..6697f4007 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -4,6 +4,7 @@ #pragma once #include <memory> +#include <mutex> #include <string> #include <unordered_map> @@ -35,33 +36,28 @@ public: ~SM() override; private: - void Initialize(Kernel::HLERequestContext& ctx); - void GetService(Kernel::HLERequestContext& ctx); - void GetServiceTipc(Kernel::HLERequestContext& ctx); - void RegisterService(Kernel::HLERequestContext& ctx); - void UnregisterService(Kernel::HLERequestContext& ctx); + void Initialize(HLERequestContext& ctx); + void GetService(HLERequestContext& ctx); + void GetServiceTipc(HLERequestContext& ctx); + void RegisterService(HLERequestContext& ctx); + void UnregisterService(HLERequestContext& ctx); - ResultVal<Kernel::KClientSession*> GetServiceImpl(Kernel::HLERequestContext& ctx); + ResultVal<Kernel::KClientSession*> GetServiceImpl(HLERequestContext& ctx); ServiceManager& service_manager; - bool is_initialized{}; Kernel::KernelCore& kernel; }; class ServiceManager { public: - static Kernel::KClientPort& InterfaceFactory(ServiceManager& self, Core::System& system); - static void SessionHandler(ServiceManager& self, Kernel::KServerPort* server_port); - explicit ServiceManager(Kernel::KernelCore& kernel_); ~ServiceManager(); - Result RegisterService(std::string name, u32 max_sessions, - Kernel::SessionRequestHandlerPtr handler); + Result RegisterService(std::string name, u32 max_sessions, SessionRequestHandlerPtr handler); Result UnregisterService(const std::string& name); ResultVal<Kernel::KPort*> GetServicePort(const std::string& name); - template <Common::DerivedFrom<Kernel::SessionRequestHandler> T> + template <Common::DerivedFrom<SessionRequestHandler> T> std::shared_ptr<T> GetService(const std::string& service_name) const { auto service = registered_services.find(service_name); if (service == registered_services.end()) { @@ -71,18 +67,27 @@ public: return std::static_pointer_cast<T>(service->second); } - void InvokeControlRequest(Kernel::HLERequestContext& context); + void InvokeControlRequest(HLERequestContext& context); + + void SetDeferralEvent(Kernel::KEvent* deferral_event_) { + deferral_event = deferral_event_; + } private: std::shared_ptr<SM> sm_interface; std::unique_ptr<Controller> controller_interface; /// Map of registered services, retrieved using GetServicePort. - std::unordered_map<std::string, Kernel::SessionRequestHandlerPtr> registered_services; + std::mutex lock; + std::unordered_map<std::string, SessionRequestHandlerPtr> registered_services; std::unordered_map<std::string, Kernel::KPort*> service_ports; /// Kernel context Kernel::KernelCore& kernel; + Kernel::KEvent* deferral_event{}; }; +/// Runs SM services. +void LoopProcess(Core::System& system); + } // namespace Service::SM |