summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorYuri Kunde Schlesner <yuriks@yuriks.net>2017-06-06 17:04:02 +0200
committerGitHub <noreply@github.com>2017-06-06 17:04:02 +0200
commitfc1bd06192a10b52425b76880531b520dd68e86d (patch)
treebe459930c35e50f698ef7747730092116eea6a74 /src/core/hle/kernel
parentMerge pull request #2752 from yuriks/move-session-request-handler (diff)
parentKernel: Add a dedicated SetHleHandler method to ServerPort/ServerSession (diff)
downloadyuzu-fc1bd06192a10b52425b76880531b520dd68e86d.tar
yuzu-fc1bd06192a10b52425b76880531b520dd68e86d.tar.gz
yuzu-fc1bd06192a10b52425b76880531b520dd68e86d.tar.bz2
yuzu-fc1bd06192a10b52425b76880531b520dd68e86d.tar.lz
yuzu-fc1bd06192a10b52425b76880531b520dd68e86d.tar.xz
yuzu-fc1bd06192a10b52425b76880531b520dd68e86d.tar.zst
yuzu-fc1bd06192a10b52425b76880531b520dd68e86d.zip
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_port.cpp11
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp2
-rw-r--r--src/core/hle/kernel/hle_ipc.h3
-rw-r--r--src/core/hle/kernel/server_port.cpp3
-rw-r--r--src/core/hle/kernel/server_port.h14
-rw-r--r--src/core/hle/kernel/server_session.cpp16
-rw-r--r--src/core/hle/kernel/server_session.h20
7 files changed, 36 insertions, 33 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 45533ed45..ce5d94e99 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -26,20 +26,17 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
active_sessions++;
// Create a new session pair, let the created sessions inherit the parent port's HLE handler.
- auto sessions =
- ServerSession::CreateSessionPair(server_port->GetName(), server_port->hle_handler, this);
- auto client_session = std::get<SharedPtr<ClientSession>>(sessions);
- auto server_session = std::get<SharedPtr<ServerSession>>(sessions);
+ auto sessions = ServerSession::CreateSessionPair(server_port->GetName(), this);
if (server_port->hle_handler)
- server_port->hle_handler->ClientConnected(server_session);
+ server_port->hle_handler->ClientConnected(std::get<SharedPtr<ServerSession>>(sessions));
else
- server_port->pending_sessions.push_back(std::move(server_session));
+ server_port->pending_sessions.push_back(std::get<SharedPtr<ServerSession>>(sessions));
// Wake the threads waiting on the ServerPort
server_port->WakeupAllWaitingThreads();
- return MakeResult<SharedPtr<ClientSession>>(std::move(client_session));
+ return MakeResult(std::get<SharedPtr<ClientSession>>(sessions));
}
} // namespace
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index 4886afa5c..0922b3f47 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -12,10 +12,12 @@
namespace Kernel {
void SessionRequestHandler::ClientConnected(SharedPtr<ServerSession> server_session) {
+ server_session->SetHleHandler(shared_from_this());
connected_sessions.push_back(server_session);
}
void SessionRequestHandler::ClientDisconnected(SharedPtr<ServerSession> server_session) {
+ server_session->SetHleHandler(nullptr);
boost::range::remove_erase(connected_sessions, server_session);
}
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index b3550734c..14f682f44 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -4,6 +4,7 @@
#pragma once
+#include <memory>
#include <vector>
#include "core/hle/kernel/kernel.h"
@@ -16,7 +17,7 @@ class ServerSession;
* This can be provided to a ServerSession in order to hook into several relevant events
* (such as a new connection or a SyncRequest) so they can be implemented in the emulator.
*/
-class SessionRequestHandler {
+class SessionRequestHandler : public std::enable_shared_from_this<SessionRequestHandler> {
public:
/**
* Handles a sync request from the emulated application.
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp
index f6e0c7dbf..4d20c39a1 100644
--- a/src/core/hle/kernel/server_port.cpp
+++ b/src/core/hle/kernel/server_port.cpp
@@ -24,13 +24,12 @@ void ServerPort::Acquire(Thread* thread) {
}
std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> ServerPort::CreatePortPair(
- u32 max_sessions, std::string name, std::shared_ptr<SessionRequestHandler> hle_handler) {
+ u32 max_sessions, std::string name) {
SharedPtr<ServerPort> server_port(new ServerPort);
SharedPtr<ClientPort> client_port(new ClientPort);
server_port->name = name + "_Server";
- server_port->hle_handler = std::move(hle_handler);
client_port->name = name + "_Client";
client_port->server_port = server_port;
client_port->max_sessions = max_sessions;
diff --git a/src/core/hle/kernel/server_port.h b/src/core/hle/kernel/server_port.h
index 281559acf..f1419cd46 100644
--- a/src/core/hle/kernel/server_port.h
+++ b/src/core/hle/kernel/server_port.h
@@ -20,15 +20,13 @@ class ServerPort final : public WaitObject {
public:
/**
* Creates a pair of ServerPort and an associated ClientPort.
+ *
* @param max_sessions Maximum number of sessions to the port
* @param name Optional name of the ports
- * @param hle_handler Optional HLE handler template for the port,
- * ServerSessions crated from this port will inherit a reference to this handler.
* @return The created port tuple
*/
static std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> CreatePortPair(
- u32 max_sessions, std::string name = "UnknownPort",
- std::shared_ptr<SessionRequestHandler> hle_handler = nullptr);
+ u32 max_sessions, std::string name = "UnknownPort");
std::string GetTypeName() const override {
return "ServerPort";
@@ -42,6 +40,14 @@ public:
return HANDLE_TYPE;
}
+ /**
+ * Sets the HLE handler template for the port. ServerSessions crated by connecting to this port
+ * will inherit a reference to this handler.
+ */
+ void SetHleHandler(std::shared_ptr<SessionRequestHandler> hle_handler_) {
+ hle_handler = std::move(hle_handler_);
+ }
+
std::string name; ///< Name of port (optional)
std::vector<SharedPtr<WaitObject>>
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index dc39d5229..2dc709bc9 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -28,16 +28,14 @@ ServerSession::~ServerSession() {
parent->server = nullptr;
}
-ResultVal<SharedPtr<ServerSession>> ServerSession::Create(
- std::string name, std::shared_ptr<SessionRequestHandler> hle_handler) {
+ResultVal<SharedPtr<ServerSession>> ServerSession::Create(std::string name) {
SharedPtr<ServerSession> server_session(new ServerSession);
server_session->name = std::move(name);
server_session->signaled = false;
- server_session->hle_handler = std::move(hle_handler);
server_session->parent = nullptr;
- return MakeResult<SharedPtr<ServerSession>>(std::move(server_session));
+ return MakeResult(std::move(server_session));
}
bool ServerSession::ShouldWait(Thread* thread) const {
@@ -71,13 +69,9 @@ ResultCode ServerSession::HandleSyncRequest() {
return RESULT_SUCCESS;
}
-ServerSession::SessionPair ServerSession::CreateSessionPair(
- const std::string& name, std::shared_ptr<SessionRequestHandler> hle_handler,
- SharedPtr<ClientPort> port) {
-
- auto server_session =
- ServerSession::Create(name + "_Server", std::move(hle_handler)).MoveFrom();
-
+ServerSession::SessionPair ServerSession::CreateSessionPair(const std::string& name,
+ SharedPtr<ClientPort> port) {
+ auto server_session = ServerSession::Create(name + "_Server").MoveFrom();
SharedPtr<ClientSession> client_session(new ClientSession);
client_session->name = name + "_Client";
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 62d23cf0a..28f365b9e 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -50,14 +50,20 @@ public:
/**
* Creates a pair of ServerSession and an associated ClientSession.
* @param name Optional name of the ports.
- * @param hle_handler Optional HLE handler for this server session.
* @param client_port Optional The ClientPort that spawned this session.
* @return The created session tuple
*/
- static SessionPair CreateSessionPair(
- const std::string& name = "Unknown",
- std::shared_ptr<SessionRequestHandler> hle_handler = nullptr,
- SharedPtr<ClientPort> client_port = nullptr);
+ static SessionPair CreateSessionPair(const std::string& name = "Unknown",
+ SharedPtr<ClientPort> client_port = nullptr);
+
+ /**
+ * Sets the HLE handler for the session. This handler will be called to service IPC requests
+ * instead of the regular IPC machinery. (The regular IPC machinery is currently not
+ * implemented.)
+ */
+ void SetHleHandler(std::shared_ptr<SessionRequestHandler> hle_handler_) {
+ hle_handler = std::move(hle_handler_);
+ }
/**
* Handle a sync request from the emulated application.
@@ -83,11 +89,9 @@ private:
* Creates a server session. The server session can have an optional HLE handler,
* which will be invoked to handle the IPC requests that this session receives.
* @param name Optional name of the server session.
- * @param hle_handler Optional HLE handler for this server session.
* @return The created server session
*/
- static ResultVal<SharedPtr<ServerSession>> Create(
- std::string name = "Unknown", std::shared_ptr<SessionRequestHandler> hle_handler = nullptr);
+ static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown");
};
/**