summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Yuri Kunde Schlesner2017-06-08 21:03:03 -0700
committerGravatar GitHub2017-06-08 21:03:03 -0700
commit78398d097879bc04fa55b32b166ee49a35ceaec4 (patch)
tree9461a35f42be4fedd5b58633510cc46503ef8db1 /src/core/hle/kernel
parentMerge pull request #2761 from yuriks/session-references (diff)
parentService/sm: Convert 'srv:' to ServiceFramework (diff)
downloadyuzu-78398d097879bc04fa55b32b166ee49a35ceaec4.tar.gz
yuzu-78398d097879bc04fa55b32b166ee49a35ceaec4.tar.xz
yuzu-78398d097879bc04fa55b32b166ee49a35ceaec4.zip
Merge pull request #2756 from yuriks/service-framework
New service framework
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp2
-rw-r--r--src/core/hle/kernel/hle_ipc.h46
2 files changed, 42 insertions, 6 deletions
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<ServerSession> server_s
21 boost::range::remove_erase(connected_sessions, server_session); 21 boost::range::remove_erase(connected_sessions, server_session);
22} 22}
23 23
24HLERequestContext::~HLERequestContext() = default;
25
24} // namespace Kernel 26} // namespace Kernel
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 14f682f44..c30184eab 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -7,10 +7,13 @@
7#include <memory> 7#include <memory>
8#include <vector> 8#include <vector>
9#include "core/hle/kernel/kernel.h" 9#include "core/hle/kernel/kernel.h"
10#include "core/hle/kernel/server_session.h"
10 11
11namespace Kernel { 12namespace Service {
13class ServiceFrameworkBase;
14}
12 15
13class ServerSession; 16namespace Kernel {
14 17
15/** 18/**
16 * Interface implemented by HLE Session handlers. 19 * Interface implemented by HLE Session handlers.
@@ -19,6 +22,8 @@ class ServerSession;
19 */ 22 */
20class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> { 23class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> {
21public: 24public:
25 virtual ~SessionRequestHandler() = default;
26
22 /** 27 /**
23 * Handles a sync request from the emulated application. 28 * Handles a sync request from the emulated application.
24 * @param server_session The ServerSession that was triggered for this sync request, 29 * @param server_session The ServerSession that was triggered for this sync request,
@@ -27,27 +32,56 @@ public:
27 * this request (ServerSession, Originator thread, Translated command buffer, etc). 32 * this request (ServerSession, Originator thread, Translated command buffer, etc).
28 * @returns ResultCode the result code of the translate operation. 33 * @returns ResultCode the result code of the translate operation.
29 */ 34 */
30 virtual void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) = 0; 35 virtual void HandleSyncRequest(SharedPtr<ServerSession> server_session) = 0;
31 36
32 /** 37 /**
33 * Signals that a client has just connected to this HLE handler and keeps the 38 * Signals that a client has just connected to this HLE handler and keeps the
34 * associated ServerSession alive for the duration of the connection. 39 * associated ServerSession alive for the duration of the connection.
35 * @param server_session Owning pointer to the ServerSession associated with the connection. 40 * @param server_session Owning pointer to the ServerSession associated with the connection.
36 */ 41 */
37 void ClientConnected(Kernel::SharedPtr<Kernel::ServerSession> server_session); 42 void ClientConnected(SharedPtr<ServerSession> server_session);
38 43
39 /** 44 /**
40 * Signals that a client has just disconnected from this HLE handler and releases the 45 * Signals that a client has just disconnected from this HLE handler and releases the
41 * associated ServerSession. 46 * associated ServerSession.
42 * @param server_session ServerSession associated with the connection. 47 * @param server_session ServerSession associated with the connection.
43 */ 48 */
44 void ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> server_session); 49 void ClientDisconnected(SharedPtr<ServerSession> server_session);
45 50
46protected: 51protected:
47 /// List of sessions that are connected to this handler. 52 /// List of sessions that are connected to this handler.
48 /// A ServerSession whose server endpoint is an HLE implementation is kept alive by this list 53 /// A ServerSession whose server endpoint is an HLE implementation is kept alive by this list
49 // for the duration of the connection. 54 // for the duration of the connection.
50 std::vector<Kernel::SharedPtr<Kernel::ServerSession>> connected_sessions; 55 std::vector<SharedPtr<ServerSession>> connected_sessions;
56};
57
58/**
59 * Class containing information about an in-flight IPC request being handled by an HLE service
60 * implementation. Services should avoid using old global APIs (e.g. Kernel::GetCommandBuffer()) and
61 * when possible use the APIs in this class to service the request.
62 */
63class HLERequestContext {
64public:
65 ~HLERequestContext();
66
67 /// Returns a pointer to the IPC command buffer for this request.
68 u32* CommandBuffer() const {
69 return cmd_buf;
70 }
71
72 /**
73 * Returns the session through which this request was made. This can be used as a map key to
74 * access per-client data on services.
75 */
76 SharedPtr<ServerSession> Session() const {
77 return session;
78 }
79
80private:
81 friend class Service::ServiceFrameworkBase;
82
83 u32* cmd_buf = nullptr;
84 SharedPtr<ServerSession> session;
51}; 85};
52 86
53} // namespace Kernel 87} // namespace Kernel