From 073653e858abf377fd1ebbdb071809c8830ce99d Mon Sep 17 00:00:00 2001 From: Subv Date: Tue, 14 Jun 2016 18:03:30 -0500 Subject: Kernel/IPC: Use Ports and Sessions as the fundamental building block of Inter Process Communication. All handles obtained via srv::GetServiceHandle or svcConnectToPort are references to ClientSessions. Service modules will wait on the counterpart of those ClientSessions (Called ServerSessions) using svcReplyAndReceive or svcWaitSynchronization[1|N], and will be awoken when a SyncRequest is performed. HLE Interfaces are now ClientPorts which override the HandleSyncRequest virtual member function to perform command handling immediately. --- src/core/hle/kernel/client_session.h | 50 ++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 src/core/hle/kernel/client_session.h (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h new file mode 100644 index 000000000..4fe9b4517 --- /dev/null +++ b/src/core/hle/kernel/client_session.h @@ -0,0 +1,50 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include + +#include "common/common_types.h" + +#include "core/hle/kernel/kernel.h" + +namespace Kernel { + +class ClientPort; +class ServerSession; + +class ClientSession final : public Object { +public: + /** + * Creates a client session. + * @param server_session The server session associated with this client session + * @param client_port The client port which this session is connected to + * @param name Optional name of client session + * @return The created client session + */ + static ResultVal> Create(SharedPtr server_session, SharedPtr client_port, std::string name = "Unknown"); + + std::string GetTypeName() const override { return "ClientSession"; } + std::string GetName() const override { return name; } + + static const HandleType HANDLE_TYPE = HandleType::ClientSession; + HandleType GetHandleType() const override { return HANDLE_TYPE; } + + /** + * Handle a SyncRequest from the emulated application. + * @return ResultCode of the operation. + */ + ResultCode HandleSyncRequest(); + + std::string name; ///< Name of client port (optional) + SharedPtr server_session; ///< The server session associated with this client session. + SharedPtr client_port; ///< The client port which this session is connected to. + +private: + ClientSession(); + ~ClientSession() override; +}; + +} // namespace -- cgit v1.2.3 From c5e7e0fa26fc793c8b9f3effe25586f7fb57953e Mon Sep 17 00:00:00 2001 From: Subv Date: Sat, 18 Jun 2016 13:39:26 -0500 Subject: IPC/HLE: Associate the ClientSessions with their parent port's HLE interface if it exists. Pass the triggering ServerSession to the HLE command handler to differentiate which session caused the request. --- src/core/hle/kernel/client_session.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 4fe9b4517..c2fc0d7dd 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -5,11 +5,16 @@ #pragma once #include +#include #include "common/common_types.h" #include "core/hle/kernel/kernel.h" +namespace Service { +class Interface; +} + namespace Kernel { class ClientPort; @@ -41,6 +46,7 @@ public: std::string name; ///< Name of client port (optional) SharedPtr server_session; ///< The server session associated with this client session. SharedPtr client_port; ///< The client port which this session is connected to. + std::shared_ptr hle_helper = nullptr; ///< HLE implementation of this port's request handler private: ClientSession(); -- cgit v1.2.3 From 009b15b3aa9858930f461d825f7dd030fc963801 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 30 Nov 2016 22:50:13 -0500 Subject: A bit of a redesign. Sessions and Ports are now detached from each other. HLE services are handled by means of a SessionRequestHandler class, Interface now inherits from this class. The File and Directory classes are no longer kernel objects, but SessionRequestHandlers instead, bound to a ServerSession when requested. File::OpenLinkFile now creates a new session pair and binds the File instance to it. --- src/core/hle/kernel/client_session.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index c2fc0d7dd..a951ea4d6 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -25,11 +25,10 @@ public: /** * Creates a client session. * @param server_session The server session associated with this client session - * @param client_port The client port which this session is connected to * @param name Optional name of client session * @return The created client session */ - static ResultVal> Create(SharedPtr server_session, SharedPtr client_port, std::string name = "Unknown"); + static ResultVal> Create(SharedPtr server_session, std::string name = "Unknown"); std::string GetTypeName() const override { return "ClientSession"; } std::string GetName() const override { return name; } @@ -45,8 +44,6 @@ public: std::string name; ///< Name of client port (optional) SharedPtr server_session; ///< The server session associated with this client session. - SharedPtr client_port; ///< The client port which this session is connected to. - std::shared_ptr hle_helper = nullptr; ///< HLE implementation of this port's request handler private: ClientSession(); -- cgit v1.2.3 From 2eceee3a4cc2786dae4e9b80a8b5f3bb666d3fc6 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 30 Nov 2016 23:28:31 -0500 Subject: Fixed the rebase mistakes. --- src/core/hle/kernel/client_session.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index a951ea4d6..e34528301 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -11,13 +11,8 @@ #include "core/hle/kernel/kernel.h" -namespace Service { -class Interface; -} - namespace Kernel { -class ClientPort; class ServerSession; class ClientSession final : public Object { @@ -30,11 +25,17 @@ public: */ static ResultVal> Create(SharedPtr server_session, std::string name = "Unknown"); - std::string GetTypeName() const override { return "ClientSession"; } - std::string GetName() const override { return name; } + std::string GetTypeName() const override { + return "ClientSession"; + } + std::string GetName() const override { + return name; + } static const HandleType HANDLE_TYPE = HandleType::ClientSession; - HandleType GetHandleType() const override { return HANDLE_TYPE; } + HandleType GetHandleType() const override { + return HANDLE_TYPE; + } /** * Handle a SyncRequest from the emulated application. -- cgit v1.2.3 From dd8887c8cfbb6d3010dde240278a3d4018c5dd85 Mon Sep 17 00:00:00 2001 From: Subv Date: Mon, 5 Dec 2016 11:02:08 -0500 Subject: KServerPorts now have an HLE handler "template", which is inherited by all ServerSessions created from it. --- src/core/hle/kernel/client_session.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index e34528301..45f479901 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -17,17 +17,12 @@ class ServerSession; class ClientSession final : public Object { public: - /** - * Creates a client session. - * @param server_session The server session associated with this client session - * @param name Optional name of client session - * @return The created client session - */ - static ResultVal> Create(SharedPtr server_session, std::string name = "Unknown"); + friend class ServerSession; std::string GetTypeName() const override { return "ClientSession"; } + std::string GetName() const override { return name; } @@ -38,10 +33,10 @@ public: } /** - * Handle a SyncRequest from the emulated application. + * Sends an SyncRequest from the current emulated thread. * @return ResultCode of the operation. */ - ResultCode HandleSyncRequest(); + ResultCode SendSyncRequest(); std::string name; ///< Name of client port (optional) SharedPtr server_session; ///< The server session associated with this client session. @@ -49,6 +44,14 @@ public: private: ClientSession(); ~ClientSession() override; + + /** + * Creates a client session. + * @param server_session The server session associated with this client session + * @param name Optional name of client session + * @return The created client session + */ + static ResultVal> Create(SharedPtr server_session, std::string name = "Unknown"); }; } // namespace -- cgit v1.2.3 From 386112da3265d111595329508b860800e5cf14e8 Mon Sep 17 00:00:00 2001 From: Subv Date: Thu, 8 Dec 2016 15:01:10 -0500 Subject: Added a framework for partially handling Session disconnections. Further implementation will happen in a future commit. Fixes a regression. --- src/core/hle/kernel/client_session.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index 45f479901..fedbd0625 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -15,6 +15,12 @@ namespace Kernel { class ServerSession; +enum class SessionStatus { + Open = 1, + ClosedByClient = 2, + ClosedBYServer = 3, +}; + class ClientSession final : public Object { public: friend class ServerSession; @@ -39,7 +45,8 @@ public: ResultCode SendSyncRequest(); std::string name; ///< Name of client port (optional) - SharedPtr server_session; ///< The server session associated with this client session. + ServerSession* server_session; ///< The server session associated with this client session. + SessionStatus session_status; ///< The session's current status. private: ClientSession(); @@ -51,7 +58,7 @@ private: * @param name Optional name of client session * @return The created client session */ - static ResultVal> Create(SharedPtr server_session, std::string name = "Unknown"); + static ResultVal> Create(ServerSession* server_session, std::string name = "Unknown"); }; } // namespace -- cgit v1.2.3 From 016307ae656afc85ab59a5c2598205ef81f99231 Mon Sep 17 00:00:00 2001 From: Subv Date: Wed, 14 Dec 2016 12:33:49 -0500 Subject: Fixed the codestyle to match our clang-format rules. --- src/core/hle/kernel/client_session.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/core/hle/kernel/client_session.h') diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h index fedbd0625..ed468dec6 100644 --- a/src/core/hle/kernel/client_session.h +++ b/src/core/hle/kernel/client_session.h @@ -4,8 +4,8 @@ #pragma once -#include #include +#include #include "common/common_types.h" @@ -44,9 +44,9 @@ public: */ ResultCode SendSyncRequest(); - std::string name; ///< Name of client port (optional) - ServerSession* server_session; ///< The server session associated with this client session. - SessionStatus session_status; ///< The session's current status. + std::string name; ///< Name of client port (optional) + ServerSession* server_session; ///< The server session associated with this client session. + SessionStatus session_status; ///< The session's current status. private: ClientSession(); @@ -58,7 +58,8 @@ private: * @param name Optional name of client session * @return The created client session */ - static ResultVal> Create(ServerSession* server_session, std::string name = "Unknown"); + static ResultVal> Create(ServerSession* server_session, + std::string name = "Unknown"); }; } // namespace -- cgit v1.2.3