From d3694a930ee75358c09f8ca800a3081ce7b34dd0 Mon Sep 17 00:00:00 2001 From: B3n30 Date: Wed, 3 Oct 2018 19:05:31 +0200 Subject: [PATCH 1/2] Give frontend access to the hle service interfaces --- src/core/hle/kernel/client_port.h | 6 +++++- src/core/hle/service/sm/sm.cpp | 2 -- src/core/hle/service/sm/sm.h | 22 +++++++++++++++++++--- 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h index b1269ea5c..46227347e 100644 --- a/src/core/hle/kernel/client_port.h +++ b/src/core/hle/kernel/client_port.h @@ -7,11 +7,11 @@ #include #include "common/common_types.h" #include "core/hle/kernel/object.h" +#include "core/hle/kernel/server_port.h" #include "core/hle/result.h" namespace Kernel { -class ServerPort; class ClientSession; class ClientPort final : public Object { @@ -29,6 +29,10 @@ public: return HANDLE_TYPE; } + SharedPtr GetServerPort() const { + return server_port; + } + /** * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's * list of pending sessions, and signals the ServerPort, causing any threads diff --git a/src/core/hle/service/sm/sm.cpp b/src/core/hle/service/sm/sm.cpp index df432ec74..588de7daa 100644 --- a/src/core/hle/service/sm/sm.cpp +++ b/src/core/hle/service/sm/sm.cpp @@ -4,9 +4,7 @@ #include #include "common/assert.h" -#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/client_session.h" -#include "core/hle/kernel/server_port.h" #include "core/hle/result.h" #include "core/hle/service/sm/sm.h" #include "core/hle/service/sm/srv.h" diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index 585f19d79..dd3a05275 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -6,16 +6,16 @@ #include #include +#include #include - +#include "core/hle/kernel/client_port.h" #include "core/hle/kernel/object.h" +#include "core/hle/kernel/server_port.h" #include "core/hle/result.h" #include "core/hle/service/service.h" namespace Kernel { -class ClientPort; class ClientSession; -class ServerPort; class SessionRequestHandler; } // namespace Kernel @@ -46,6 +46,22 @@ public: ResultVal> GetServicePort(const std::string& name); ResultVal> ConnectToService(const std::string& name); + template + std::shared_ptr GetService(const std::string& service_name) { + static_assert(std::is_base_of_v, + "Not a base of ServiceFrameworkBase"); + auto service = registered_services.find(service_name); + if (service == registered_services.end()) { + LOG_DEBUG(Service, "Can't find service: {}", service_name); + return nullptr; + } + auto port = service->second->GetServerPort(); + if (port == nullptr) { + return nullptr; + } + return std::dynamic_pointer_cast(port->hle_handler); + } + private: std::weak_ptr srv_interface; From 544eb25c993e7514eafe59644af9601d50c6d5cb Mon Sep 17 00:00:00 2001 From: B3n30 Date: Wed, 3 Oct 2018 20:08:01 +0200 Subject: [PATCH 2/2] fixup! Give frontend access to the hle service interfaces --- src/core/hle/kernel/server_port.h | 1 + src/core/hle/service/sm/sm.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h index 9413d8ab7..6d458b188 100644 --- a/src/core/hle/kernel/server_port.h +++ b/src/core/hle/kernel/server_port.h @@ -10,6 +10,7 @@ #include "common/common_types.h" #include "core/hle/kernel/object.h" #include "core/hle/kernel/wait_object.h" +#include "core/hle/result.h" namespace Kernel { diff --git a/src/core/hle/service/sm/sm.h b/src/core/hle/service/sm/sm.h index dd3a05275..9e9164a66 100644 --- a/src/core/hle/service/sm/sm.h +++ b/src/core/hle/service/sm/sm.h @@ -47,7 +47,7 @@ public: ResultVal> ConnectToService(const std::string& name); template - std::shared_ptr GetService(const std::string& service_name) { + std::shared_ptr GetService(const std::string& service_name) const { static_assert(std::is_base_of_v, "Not a base of ServiceFrameworkBase"); auto service = registered_services.find(service_name); @@ -59,7 +59,7 @@ public: if (port == nullptr) { return nullptr; } - return std::dynamic_pointer_cast(port->hle_handler); + return std::static_pointer_cast(port->hle_handler); } private: