diff options
author | Subv <subv2112@gmail.com> | 2016-06-15 01:03:30 +0200 |
---|---|---|
committer | Subv <subv2112@gmail.com> | 2016-12-01 05:02:05 +0100 |
commit | 073653e858abf377fd1ebbdb071809c8830ce99d (patch) | |
tree | a29e1c1e50d53162ed89cd90e8c069525150392f /src/core/hle/kernel/server_session.cpp | |
parent | Merge pull request #2228 from freiro/winver_fix (diff) | |
download | yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.gz yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.bz2 yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.lz yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.xz yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.tar.zst yuzu-073653e858abf377fd1ebbdb071809c8830ce99d.zip |
Diffstat (limited to 'src/core/hle/kernel/server_session.cpp')
-rw-r--r-- | src/core/hle/kernel/server_session.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp new file mode 100644 index 000000000..9f5350ce5 --- /dev/null +++ b/src/core/hle/kernel/server_session.cpp @@ -0,0 +1,58 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include <tuple> + +#include "core/hle/kernel/client_port.h" +#include "core/hle/kernel/client_session.h" +#include "core/hle/kernel/server_session.h" +#include "core/hle/kernel/thread.h" + +namespace Kernel { + +ServerSession::ServerSession() {} +ServerSession::~ServerSession() {} + +ResultVal<SharedPtr<ServerSession>> ServerSession::Create(std::string name) { + SharedPtr<ServerSession> server_session(new ServerSession); + + server_session->name = std::move(name); + server_session->signaled = false; + + return MakeResult<SharedPtr<ServerSession>>(std::move(server_session)); +} + +bool ServerSession::ShouldWait() { + return !signaled; +} + +void ServerSession::Acquire() { + ASSERT_MSG(!ShouldWait(), "object unavailable!"); + signaled = false; +} + +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. + signaled = true; + WakeupAllWaitingThreads(); + return RESULT_SUCCESS; +} + +SharedPtr<ClientSession> 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<ServerSession>(this), nullptr, name + "Client").MoveFrom(); +} + +std::tuple<SharedPtr<ServerSession>, SharedPtr<ClientSession>> ServerSession::CreateSessionPair(SharedPtr<ClientPort> client_port, std::string name) { + auto server_session = ServerSession::Create(name + "Server").MoveFrom(); + auto client_session = ClientSession::Create(server_session, client_port, name + "Client").MoveFrom(); + + return std::make_tuple(server_session, client_session); +} + +} |