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/server_session.cpp | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'src/core/hle/kernel/server_session.cpp') diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp index 720c0eb94..200a7b815 100644 --- a/src/core/hle/kernel/server_session.cpp +++ b/src/core/hle/kernel/server_session.cpp @@ -14,11 +14,12 @@ namespace Kernel { ServerSession::ServerSession() {} ServerSession::~ServerSession() {} -ResultVal> ServerSession::Create(std::string name) { +ResultVal> ServerSession::Create(std::string name, std::shared_ptr hle_handler) { SharedPtr server_session(new ServerSession); server_session->name = std::move(name); server_session->signaled = false; + server_session->hle_handler = hle_handler; return MakeResult>(std::move(server_session)); } @@ -34,23 +35,21 @@ void ServerSession::Acquire() { ResultCode ServerSession::HandleSyncRequest() { // The ServerSession received a sync request, this means that there's new data available - // from one of its ClientSessions, so wake up any threads that may be waiting on a svcReplyAndReceive or similar. + // 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(this)); + + // If this ServerSession does not have an HLE implementation, just wake up the threads waiting on it. signaled = true; WakeupAllWaitingThreads(); return RESULT_SUCCESS; } -SharedPtr ServerSession::CreateClientSession() { - // In Citra, some types of ServerSessions (File and Directory sessions) are not created as a pair of Server-Client sessions, - // but are instead created as a single ServerSession, which then hands over a ClientSession on demand (When opening the File or Directory). - // The real kernel (Or more specifically, the real FS service) does create the pair of Sessions at the same time (via svcCreateSession), and simply - // stores the ClientSession until it is needed. - return ClientSession::Create(SharedPtr(this), nullptr, name + "Client").MoveFrom(); -} - -std::tuple, SharedPtr> ServerSession::CreateSessionPair(SharedPtr client_port, const std::string& name) { - auto server_session = ServerSession::Create(name + "Server").MoveFrom(); - auto client_session = ClientSession::Create(server_session, client_port, name + "Client").MoveFrom(); +std::tuple, SharedPtr> ServerSession::CreateSessionPair(const std::string& name, std::shared_ptr hle_handler) { + auto server_session = ServerSession::Create(name + "Server", hle_handler).MoveFrom(); + auto client_session = ClientSession::Create(server_session, name + "Client").MoveFrom(); return std::make_tuple(server_session, client_session); } -- cgit v1.2.3