diff options
author | Subv <subv2112@gmail.com> | 2016-06-14 18:03:30 -0500 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2016-11-30 23:02:05 -0500 |
commit | 073653e858abf377fd1ebbdb071809c8830ce99d (patch) | |
tree | a29e1c1e50d53162ed89cd90e8c069525150392f /src/core/hle/svc.cpp | |
parent | 68c00ee771791e5975912c4e0d4be0fb5ab6b8fa (diff) |
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.
Diffstat (limited to 'src/core/hle/svc.cpp')
-rw-r--r-- | src/core/hle/svc.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index c6b80dc500..be03e53bc4 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -13,6 +13,7 @@ #include "core/hle/function_wrappers.h" #include "core/hle/kernel/address_arbiter.h" #include "core/hle/kernel/client_port.h" +#include "core/hle/kernel/client_session.h" #include "core/hle/kernel/event.h" #include "core/hle/kernel/memory.h" #include "core/hle/kernel/mutex.h" @@ -222,20 +223,31 @@ static ResultCode ConnectToPort(Handle* out_handle, const char* port_name) { return ERR_NOT_FOUND; } - CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(it->second)); + auto client_port = it->second; + + // Create a new session pair + auto sessions = Kernel::ServerSession::CreateSessionPair(client_port, port_name); + auto client_session = std::get<Kernel::SharedPtr<Kernel::ClientSession>>(sessions); + auto server_session = std::get<Kernel::SharedPtr<Kernel::ServerSession>>(sessions); + + // Add the server session to the port's queue + client_port->AddWaitingSession(server_session); + + // Return the client session + CASCADE_RESULT(*out_handle, Kernel::g_handle_table.Create(client_session)); return RESULT_SUCCESS; } /// Synchronize to an OS service static ResultCode SendSyncRequest(Handle handle) { - SharedPtr<Kernel::Session> session = Kernel::g_handle_table.Get<Kernel::Session>(handle); + SharedPtr<Kernel::ClientSession> session = Kernel::g_handle_table.Get<Kernel::ClientSession>(handle); if (session == nullptr) { return ERR_INVALID_HANDLE; } LOG_TRACE(Kernel_SVC, "called handle=0x%08X(%s)", handle, session->GetName().c_str()); - return session->SyncRequest().Code(); + return session->HandleSyncRequest(); } /// Close a handle |