diff options
Diffstat (limited to 'src/core/hle')
-rw-r--r-- | src/core/hle/kernel/server_session.cpp | 15 | ||||
-rw-r--r-- | src/core/hle/kernel/server_session.h | 10 | ||||
-rw-r--r-- | src/core/hle/service/fs/archive.cpp | 4 | ||||
-rw-r--r-- | src/core/hle/service/fs/archive.h | 4 | ||||
-rw-r--r-- | src/core/hle/service/service.cpp | 22 | ||||
-rw-r--r-- | src/core/hle/service/service.h | 30 |
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() { // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or similar. // If this ServerSession has an associated HLE handler, forward the request to it. - if (hle_handler != nullptr) - return hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this)); + if (hle_handler != nullptr) { + // Attempt to translate the incoming request's command buffer. + ResultCode result = TranslateHLERequest(this); + if (result.IsError()) + return result; + hle_handler->HandleSyncRequest(SharedPtr<ServerSession>(this)); + // TODO(Subv): Translate the response command buffer. + } // If this ServerSession does not have an HLE implementation, just wake up the threads waiting on it. signaled = true; @@ -60,4 +66,9 @@ ServerSession::SessionPair ServerSession::CreateSessionPair(const std::string& n return std::make_tuple(std::move(server_session), std::move(client_session)); } +ResultCode TranslateHLERequest(ServerSession* server_session) { + // TODO(Subv): Implement this function once multiple concurrent processes are supported. + return RESULT_SUCCESS; +} + } 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: */ static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown", std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr); }; + +/** + * Performs command buffer translation for an HLE IPC request. + * The command buffer from the ServerSession thread's TLS is copied into a + * buffer and all descriptors in the buffer are processed. + * TODO(Subv): Implement this function, currently we do not support multiple processes running at once, + * but once that is implemented we'll need to properly translate all descriptors in the command buffer. + */ +ResultCode TranslateHLERequest(ServerSession* server_session); + } 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& File::~File() {} -void File::HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) { +void File::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) { u32* cmd_buff = Kernel::GetCommandBuffer(); FileCommand cmd = static_cast<FileCommand>(cmd_buff[0]); switch (cmd) { @@ -207,7 +207,7 @@ Directory::Directory(std::unique_ptr<FileSys::DirectoryBackend>&& backend, Directory::~Directory() {} -void Directory::HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) { +void Directory::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) { u32* cmd_buff = Kernel::GetCommandBuffer(); DirectoryCommand cmd = static_cast<DirectoryCommand>(cmd_buff[0]); 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: std::unique_ptr<FileSys::FileBackend> backend; ///< File backend interface protected: - void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; + void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; }; class Directory final : public SessionRequestHandler { @@ -71,7 +71,7 @@ public: std::unique_ptr<FileSys::DirectoryBackend> backend; ///< File backend interface protected: - void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; + void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; }; /** 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, return function_string; } -ResultCode SessionRequestHandler::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) { - // Attempt to translate the incoming request's command buffer. - ResultCode result = TranslateRequest(server_session); - - if (result.IsError()) - return result; - - // Actually handle the request - HandleSyncRequestImpl(server_session); - - // TODO(Subv): Translate the response command buffer. - - return RESULT_SUCCESS; -} - void SessionRequestHandler::ClientConnected(Kernel::SharedPtr<Kernel::ServerSession> server_session) { connected_sessions.push_back(server_session); } @@ -89,15 +74,10 @@ void SessionRequestHandler::ClientDisconnected(Kernel::SharedPtr<Kernel::ServerS boost::range::remove_erase(connected_sessions, server_session); } -ResultCode SessionRequestHandler::TranslateRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) { - // TODO(Subv): Implement this function once multiple concurrent processes are supported. - return RESULT_SUCCESS; -} - Interface::Interface(u32 max_sessions) : max_sessions(max_sessions) {} Interface::~Interface() = default; -void Interface::HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) { +void Interface::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) { // TODO(Subv): Make use of the server_session in the HLE service handlers to distinguish which session triggered each command. 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 @@ #include "core/hle/result.h" #include "core/memory.h" + +namespace Kernel { +class ServerSession; +} + //////////////////////////////////////////////////////////////////////////////////////////////////// // Namespace Service @@ -31,12 +36,14 @@ static const u32 DefaultMaxSessions = 10; ///< Arbitrary default number of maxim class SessionRequestHandler { public: /** - * Dispatches and handles a sync request from the emulated application. + * Handles a sync request from the emulated application. * @param server_session The ServerSession that was triggered for this sync request, * it should be used to differentiate which client (As in ClientSession) we're answering to. + * TODO(Subv): Use a wrapper structure to hold all the information relevant to + * this request (ServerSession, Originator thread, Translated command buffer, etc). * @returns ResultCode the result code of the translate operation. */ - ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session); + virtual void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) = 0; /** * Signals that a client has just connected to this HLE handler and keeps the @@ -53,23 +60,6 @@ public: void ClientDisconnected(Kernel::SharedPtr<Kernel::ServerSession> server_session); protected: - /** - * Handles a sync request from the emulated application and writes the response to the command buffer. - * TODO(Subv): Use a wrapper structure to hold all the information relevant to - * this request (ServerSession, Originator thread, Translated command buffer, etc). - */ - virtual void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) = 0; - -private: - /** - * Performs command buffer translation for this request. - * The command buffer from the ServerSession thread's TLS is copied into a - * buffer and all descriptors in the buffer are processed. - * TODO(Subv): Implement this function, currently we do not support multiple processes running at once, - * but once that is implemented we'll need to properly translate all descriptors in the command buffer. - */ - ResultCode TranslateRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session); - /// 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<Kernel::SharedPtr<Kernel::ServerSession>> connected_sessions; @@ -120,7 +110,7 @@ public: } protected: - void HandleSyncRequestImpl(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; + void HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) override; /** * Registers the functions in the service |