summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2016-12-09 12:52:12 -0500
committerGravatar Subv2016-12-09 12:52:12 -0500
commitebbb55ec8f827096f1c743cc4b7f4a2aa05a3ed3 (patch)
treebea70b5f82c2777939b69e4774bae5a320e33669 /src
parentKernel/IPC: Small codestyle cleanup (diff)
downloadyuzu-ebbb55ec8f827096f1c743cc4b7f4a2aa05a3ed3.tar.gz
yuzu-ebbb55ec8f827096f1c743cc4b7f4a2aa05a3ed3.tar.xz
yuzu-ebbb55ec8f827096f1c743cc4b7f4a2aa05a3ed3.zip
Moved the HLE command buffer translation task to ServerSession instead of the HLE handler superclass.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/server_session.cpp15
-rw-r--r--src/core/hle/kernel/server_session.h10
-rw-r--r--src/core/hle/service/fs/archive.cpp4
-rw-r--r--src/core/hle/service/fs/archive.h4
-rw-r--r--src/core/hle/service/service.cpp22
-rw-r--r--src/core/hle/service/service.h30
6 files changed, 38 insertions, 47 deletions
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index 3fac6b934..1e54c3a2e 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -41,8 +41,14 @@ ResultCode ServerSession::HandleSyncRequest() {
41 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or similar. 41 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or similar.
42 42
43 // If this ServerSession has an associated HLE handler, forward the request to it. 43 // If this ServerSession has an associated HLE handler, forward the request to it.
44 if (hle_handler != nullptr) 44 if (hle_handler != nullptr) {
45 return hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this)); 45 // Attempt to translate the incoming request's command buffer.
46 ResultCode result = TranslateHLERequest(this);
47 if (result.IsError())
48 return result;
49 hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this));
50 // TODO(Subv): Translate the response command buffer.
51 }
46 52
47 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting on it. 53 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting on it.
48 signaled = true; 54 signaled = true;
@@ -60,4 +66,9 @@ ServerSession::SessionPair ServerSession::CreateSessionPair(const std::string& n
60 return std::make_tuple(std::move(server_session), std::move(client_session)); 66 return std::make_tuple(std::move(server_session), std::move(client_session));
61} 67}
62 68
69ResultCode TranslateHLERequest(ServerSession* server_session) {
70 // TODO(Subv): Implement this function once multiple concurrent processes are supported.
71 return RESULT_SUCCESS;
72}
73
63} 74}
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 7f00db07b..7abc09011 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -76,4 +76,14 @@ private:
76 */ 76 */
77 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown", std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr); 77 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown", std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr);
78}; 78};
79
80/**
81 * Performs command buffer translation for an HLE IPC request.
82 * The command buffer from the ServerSession thread's TLS is copied into a
83 * buffer and all descriptors in the buffer are processed.
84 * TODO(Subv): Implement this function, currently we do not support multiple processes running at once,
85 * but once that is implemented we'll need to properly translate all descriptors in the command buffer.
86 */
87ResultCode TranslateHLERequest(ServerSession* server_session);
88
79} 89}
diff --git a/src/core/hle/service/fs/archive.cpp b/src/core/hle/service/fs/archive.cpp
index b63c6eaac..bca57061e 100644
--- a/src/core/hle/service/fs/archive.cpp
+++ b/src/core/hle/service/fs/archive.cpp
@@ -93,7 +93,7 @@ File::File(std::unique_ptr<FileSys::FileBackend>&& backend, const FileSys::Path&
93 93
94File::~File() {} 94File::~File() {}
95 95
96void File::HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) { 96void File::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
97 u32* cmd_buff = Kernel::GetCommandBuffer(); 97 u32* cmd_buff = Kernel::GetCommandBuffer();
98 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); 98 FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]);
99 switch (cmd) { 99 switch (cmd) {
@@ -207,7 +207,7 @@ Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend,
207 207
208Directory::~Directory() {} 208Directory::~Directory() {}
209 209
210void Directory::HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) { 210void Directory::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
211 u32* cmd_buff = Kernel::GetCommandBuffer(); 211 u32* cmd_buff = Kernel::GetCommandBuffer();
212 DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); 212 DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]);
213 switch (cmd) { 213 switch (cmd) {
diff --git a/src/core/hle/service/fs/archive.h b/src/core/hle/service/fs/archive.h
index 09a922fb5..eb76706a1 100644
--- a/src/core/hle/service/fs/archive.h
+++ b/src/core/hle/service/fs/archive.h
@@ -55,7 +55,7 @@ public:
55 std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface 55 std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface
56 56
57protected: 57protected:
58 void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; 58 void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
59}; 59};
60 60
61class Directory final : public SessionRequestHandler { 61class Directory final : public SessionRequestHandler {
@@ -71,7 +71,7 @@ public:
71 std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface 71 std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface
72 72
73protected: 73protected:
74 void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; 74 void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
75}; 75};
76 76
77/** 77/**
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index 4f973c634..418b128b1 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -66,21 +66,6 @@ static std::string MakeFunctionString(const char* name, const char* port_name,
66 return function_string; 66 return function_string;
67} 67}
68 68
69ResultCode SessionRequestHandler::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
70 // Attempt to translate the incoming request's command buffer.
71 ResultCode result = TranslateRequest(server_session);
72
73 if (result.IsError())
74 return result;
75
76 // Actually handle the request
77 HandleSyncRequestImpl(server_session);
78
79 // TODO(Subv): Translate the response command buffer.
80
81 return RESULT_SUCCESS;
82}
83
84void SessionRequestHandler::ClientConnected(Kernel::SharedPtr<Kernel::ServerSession> server_session) { 69void SessionRequestHandler::ClientConnected(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
85 connected_sessions.push_back(server_session); 70 connected_sessions.push_back(server_session);
86} 71}
@@ -89,15 +74,10 @@ void SessionRequestHandler::ClientDisconnected(Kernel::SharedPtr<Kernel::ServerS
89 boost::range::remove_erase(connected_sessions, server_session); 74 boost::range::remove_erase(connected_sessions, server_session);
90} 75}
91 76
92ResultCode SessionRequestHandler::TranslateRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
93 // TODO(Subv): Implement this function once multiple concurrent processes are supported.
94 return RESULT_SUCCESS;
95}
96
97Interface::Interface(u32 max_sessions) : max_sessions(max_sessions) {} 77Interface::Interface(u32 max_sessions) : max_sessions(max_sessions) {}
98Interface::~Interface() = default; 78Interface::~Interface() = default;
99 79
100void Interface::HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) { 80void Interface::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
101 // TODO(Subv): Make use of the server_session in the HLE service handlers to distinguish which session triggered each command. 81 // TODO(Subv): Make use of the server_session in the HLE service handlers to distinguish which session triggered each command.
102 82
103 u32* cmd_buff = Kernel::GetCommandBuffer(); 83 u32* cmd_buff = Kernel::GetCommandBuffer();
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index 2293b473a..a3af48684 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -15,6 +15,11 @@
15#include "core/hle/result.h" 15#include "core/hle/result.h"
16#include "core/memory.h" 16#include "core/memory.h"
17 17
18
19namespace Kernel {
20class ServerSession;
21}
22
18//////////////////////////////////////////////////////////////////////////////////////////////////// 23////////////////////////////////////////////////////////////////////////////////////////////////////
19// Namespace Service 24// Namespace Service
20 25
@@ -31,12 +36,14 @@ static const u32 DefaultMaxSessions = 10; ///< Arbitrary default number of maxim
31class SessionRequestHandler { 36class SessionRequestHandler {
32public: 37public:
33 /** 38 /**
34 * Dispatches and handles a sync request from the emulated application. 39 * Handles a sync request from the emulated application.
35 * @param server_session The ServerSession that was triggered for this sync request, 40 * @param server_session The ServerSession that was triggered for this sync request,
36 * it should be used to differentiate which client (As in ClientSession) we're answering to. 41 * it should be used to differentiate which client (As in ClientSession) we're answering to.
42 * TODO(Subv): Use a wrapper structure to hold all the information relevant to
43 * this request (ServerSession, Originator thread, Translated command buffer, etc).
37 * @returns ResultCode the result code of the translate operation. 44 * @returns ResultCode the result code of the translate operation.
38 */ 45 */
39 ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session); 46 virtual void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) = 0;
40 47
41 /** 48 /**
42 * Signals that a client has just connected to this HLE handler and keeps the 49 * Signals that a client has just connected to this HLE handler and keeps the
@@ -53,23 +60,6 @@ public:
53 void ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> server_session); 60 void ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> server_session);
54 61
55protected: 62protected:
56 /**
57 * Handles a sync request from the emulated application and writes the response to the command buffer.
58 * TODO(Subv): Use a wrapper structure to hold all the information relevant to
59 * this request (ServerSession, Originator thread, Translated command buffer, etc).
60 */
61 virtual void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) = 0;
62
63private:
64 /**
65 * Performs command buffer translation for this request.
66 * The command buffer from the ServerSession thread's TLS is copied into a
67 * buffer and all descriptors in the buffer are processed.
68 * TODO(Subv): Implement this function, currently we do not support multiple processes running at once,
69 * but once that is implemented we'll need to properly translate all descriptors in the command buffer.
70 */
71 ResultCode TranslateRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session);
72
73 /// List of sessions that are connected to this handler. 63 /// List of sessions that are connected to this handler.
74 /// A ServerSession whose server endpoint is an HLE implementation is kept alive by this list for the duration of the connection. 64 /// A ServerSession whose server endpoint is an HLE implementation is kept alive by this list for the duration of the connection.
75 std::vector<Kernel::SharedPtr<Kernel::ServerSession>> connected_sessions; 65 std::vector<Kernel::SharedPtr<Kernel::ServerSession>> connected_sessions;
@@ -120,7 +110,7 @@ public:
120 } 110 }
121 111
122protected: 112protected:
123 void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; 113 void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override;
124 114
125 /** 115 /**
126 * Registers the functions in the service 116 * Registers the functions in the service