summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTING.md2
-rw-r--r--src/core/hle/kernel/client_port.cpp4
-rw-r--r--src/core/hle/kernel/client_port.h2
-rw-r--r--src/core/hle/kernel/server_port.h1
-rw-r--r--src/core/hle/service/sm/sm.h19
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp1
6 files changed, 28 insertions, 1 deletions
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 008dc5b50..1b2056885 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -22,7 +22,7 @@ If clang format is found, then cmake will add a custom build target that can be
* Don't ever introduce new external dependencies into Core
* Don't use any platform specific code in Core
* Use namespaces often
-* Avoid the use of C-style casts and instead prefer C++-style `static_cast` and `reinterpret_cast`. Try to avoid using `dynamic_cast`. Never use `const_cast`. The only exception to this rule is for casting between two numeric types, where C-style casts are encouraged for brevity and readability.
+* Avoid the use of C-style casts and instead prefer C++-style `static_cast` and `reinterpret_cast`. Try to avoid using `dynamic_cast`. Never use `const_cast`.
### Naming Rules
* Functions: `PascalCase`
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 873d6c516..d4c91d529 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -17,6 +17,10 @@ namespace Kernel {
ClientPort::ClientPort(KernelCore& kernel) : Object{kernel} {}
ClientPort::~ClientPort() = default;
+SharedPtr<ServerPort> ClientPort::GetServerPort() const {
+ return server_port;
+}
+
ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
// Note: Threads do not wait for the server endpoint to call
// AcceptSession before returning from this call.
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h
index f3dfebbb1..6cd607206 100644
--- a/src/core/hle/kernel/client_port.h
+++ b/src/core/hle/kernel/client_port.h
@@ -30,6 +30,8 @@ public:
return HANDLE_TYPE;
}
+ SharedPtr<ServerPort> GetServerPort() const;
+
/**
* 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/kernel/server_port.h b/src/core/hle/kernel/server_port.h
index 62fb51349..e52f8245f 100644
--- a/src/core/hle/kernel/server_port.h
+++ b/src/core/hle/kernel/server_port.h
@@ -11,6 +11,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 da2c51082..4f8145dda 100644
--- a/src/core/hle/service/sm/sm.h
+++ b/src/core/hle/service/sm/sm.h
@@ -6,9 +6,12 @@
#include <memory>
#include <string>
+#include <type_traits>
#include <unordered_map>
+#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"
@@ -48,6 +51,22 @@ public:
ResultVal<Kernel::SharedPtr<Kernel::ClientPort>> GetServicePort(const std::string& name);
ResultVal<Kernel::SharedPtr<Kernel::ClientSession>> ConnectToService(const std::string& name);
+ template <typename T>
+ std::shared_ptr<T> GetService(const std::string& service_name) const {
+ static_assert(std::is_base_of_v<Kernel::SessionRequestHandler, T>,
+ "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::static_pointer_cast<T>(port->hle_handler);
+ }
+
void InvokeControlRequest(Kernel::HLERequestContext& context);
private:
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 60dcdc184..a91bc6dee 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -252,6 +252,7 @@ DrawParameters RasterizerOpenGL::SetupDraw() {
params.count = regs.vertex_buffer.count;
params.vertex_first = regs.vertex_buffer.first;
}
+ return params;
}
void RasterizerOpenGL::SetupShaders() {