From 6dc133c24a5c07d868f817756381544e463545d4 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 6 Jun 2017 14:51:42 -0700 Subject: Kernel: Remove some unnecessary namespace qualifications --- src/core/hle/kernel/hle_ipc.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 14f682f44..5de9d59d3 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -19,6 +19,8 @@ class ServerSession; */ class SessionRequestHandler : public std::enable_shared_from_this { public: + virtual ~SessionRequestHandler() = default; + /** * Handles a sync request from the emulated application. * @param server_session The ServerSession that was triggered for this sync request, @@ -27,27 +29,27 @@ public: * this request (ServerSession, Originator thread, Translated command buffer, etc). * @returns ResultCode the result code of the translate operation. */ - virtual void HandleSyncRequest(Kernel::SharedPtr server_session) = 0; + virtual void HandleSyncRequest(SharedPtr server_session) = 0; /** * Signals that a client has just connected to this HLE handler and keeps the * associated ServerSession alive for the duration of the connection. * @param server_session Owning pointer to the ServerSession associated with the connection. */ - void ClientConnected(Kernel::SharedPtr server_session); + void ClientConnected(SharedPtr server_session); /** * Signals that a client has just disconnected from this HLE handler and releases the * associated ServerSession. * @param server_session ServerSession associated with the connection. */ - void ClientDisconnected(Kernel::SharedPtr server_session); + void ClientDisconnected(SharedPtr server_session); protected: /// List of sessions that are connected to this handler. /// A ServerSession whose server endpoint is an HLE implementation is kept alive by this list // for the duration of the connection. - std::vector> connected_sessions; + std::vector> connected_sessions; }; } // namespace Kernel -- cgit v1.2.3 From 84c497292a27d75b83305d053e734ab5659ffe41 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Tue, 6 Jun 2017 21:20:52 -0700 Subject: Service: Add new ServiceFramework framework for writing HLE services The old "Interface" class had a few problems such as using free functions (Which didn't allow you to write the service handler as if it were a regular class.) which weren't very extensible. (Only received one parameter with a pointer to the Interface object.) The new ServiceFramework aims to solve these problems by working with member functions and passing a generic context struct as parameter. This struct can be extended in the future without having to update all existing service implementations. --- src/core/hle/kernel/hle_ipc.cpp | 2 ++ src/core/hle/kernel/hle_ipc.h | 36 ++++++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel') diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp index 0922b3f47..a60b8ef00 100644 --- a/src/core/hle/kernel/hle_ipc.cpp +++ b/src/core/hle/kernel/hle_ipc.cpp @@ -21,4 +21,6 @@ void SessionRequestHandler::ClientDisconnected(SharedPtr server_s boost::range::remove_erase(connected_sessions, server_session); } +HLERequestContext::~HLERequestContext() = default; + } // namespace Kernel diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h index 5de9d59d3..c30184eab 100644 --- a/src/core/hle/kernel/hle_ipc.h +++ b/src/core/hle/kernel/hle_ipc.h @@ -7,10 +7,13 @@ #include #include #include "core/hle/kernel/kernel.h" +#include "core/hle/kernel/server_session.h" -namespace Kernel { +namespace Service { +class ServiceFrameworkBase; +} -class ServerSession; +namespace Kernel { /** * Interface implemented by HLE Session handlers. @@ -52,4 +55,33 @@ protected: std::vector> connected_sessions; }; +/** + * Class containing information about an in-flight IPC request being handled by an HLE service + * implementation. Services should avoid using old global APIs (e.g. Kernel::GetCommandBuffer()) and + * when possible use the APIs in this class to service the request. + */ +class HLERequestContext { +public: + ~HLERequestContext(); + + /// Returns a pointer to the IPC command buffer for this request. + u32* CommandBuffer() const { + return cmd_buf; + } + + /** + * Returns the session through which this request was made. This can be used as a map key to + * access per-client data on services. + */ + SharedPtr Session() const { + return session; + } + +private: + friend class Service::ServiceFrameworkBase; + + u32* cmd_buf = nullptr; + SharedPtr session; +}; + } // namespace Kernel -- cgit v1.2.3