summaryrefslogtreecommitdiffstats
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2016-12-05 17:02:08 +0100
committerSubv <subv2112@gmail.com>2016-12-05 17:02:08 +0100
commitdd8887c8cfbb6d3010dde240278a3d4018c5dd85 (patch)
tree9990a463d5daccdab41ae9c90a5c698aed0d4795 /src/core/hle/kernel
parentDeclare empty ServerSession and ClientSession constructors as default. (diff)
downloadyuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.tar
yuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.tar.gz
yuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.tar.bz2
yuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.tar.lz
yuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.tar.xz
yuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.tar.zst
yuzu-dd8887c8cfbb6d3010dde240278a3d4018c5dd85.zip
Diffstat (limited to '')
-rw-r--r--src/core/hle/kernel/client_port.cpp10
-rw-r--r--src/core/hle/kernel/client_port.h10
-rw-r--r--src/core/hle/kernel/client_session.cpp2
-rw-r--r--src/core/hle/kernel/client_session.h21
-rw-r--r--src/core/hle/kernel/server_port.cpp3
-rw-r--r--src/core/hle/kernel/server_port.h13
-rw-r--r--src/core/hle/kernel/server_session.cpp6
-rw-r--r--src/core/hle/kernel/server_session.h30
8 files changed, 60 insertions, 35 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 5ee7679eb..f25cb48dd 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -13,10 +13,18 @@ namespace Kernel {
ClientPort::ClientPort() {}
ClientPort::~ClientPort() {}
-void ClientPort::AddWaitingSession(SharedPtr<ServerSession> server_session) {
+SharedPtr<ClientSession> ClientPort::Connect() {
+ // 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);
+ auto client_session = std::get<SharedPtr<ClientSession>>(sessions);
+ auto server_session = std::get<SharedPtr<ServerSession>>(sessions);
+
server_port->pending_sessions.push_back(server_session);
+
// Wake the threads waiting on the ServerPort
server_port->WakeupAllWaitingThreads();
+
+ return std::move(client_session);
}
} // namespace
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h
index 4848cb4c4..d217c6649 100644
--- a/src/core/hle/kernel/client_port.h
+++ b/src/core/hle/kernel/client_port.h
@@ -11,7 +11,7 @@
namespace Kernel {
class ServerPort;
-class ServerSession;
+class ClientSession;
class ClientPort final : public Object {
public:
@@ -29,15 +29,17 @@ public:
}
/**
- * Adds the specified server session to the queue of pending sessions of the associated ServerPort
- * @param server_session Server session to add to the queue
+ * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's list of pending sessions,
+ * and signals the ServerPort, causing any threads waiting on it to awake.
+ * @returns ClientSession The client endpoint of the created Session pair.
*/
- void AddWaitingSession(SharedPtr<ServerSession> server_session);
+ SharedPtr<ClientSession> Connect();
SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port.
u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
u32 active_sessions; ///< Number of currently open sessions to this port
std::string name; ///< Name of client port (optional)
+
private:
ClientPort();
~ClientPort() override;
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp
index c90fbc69d..6c577610d 100644
--- a/src/core/hle/kernel/client_session.cpp
+++ b/src/core/hle/kernel/client_session.cpp
@@ -20,7 +20,7 @@ ResultVal<SharedPtr<ClientSession>> ClientSession::Create(SharedPtr<ServerSessio
return MakeResult<SharedPtr<ClientSession>>(std::move(client_session));
}
-ResultCode ClientSession::HandleSyncRequest() {
+ResultCode ClientSession::SendSyncRequest() {
// Signal the server session that new data is available
return server_session->HandleSyncRequest();
}
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index e34528301..45f479901 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -17,17 +17,12 @@ class ServerSession;
class ClientSession final : public Object {
public:
- /**
- * Creates a client session.
- * @param server_session The server session associated with this client session
- * @param name Optional name of client session
- * @return The created client session
- */
- static ResultVal<SharedPtr<ClientSession>> Create(SharedPtr<ServerSession> server_session, std::string name = "Unknown");
+ friend class ServerSession;
std::string GetTypeName() const override {
return "ClientSession";
}
+
std::string GetName() const override {
return name;
}
@@ -38,10 +33,10 @@ public:
}
/**
- * Handle a SyncRequest from the emulated application.
+ * Sends an SyncRequest from the current emulated thread.
* @return ResultCode of the operation.
*/
- ResultCode HandleSyncRequest();
+ ResultCode SendSyncRequest();
std::string name; ///< Name of client port (optional)
SharedPtr<ServerSession> server_session; ///< The server session associated with this client session.
@@ -49,6 +44,14 @@ public:
private:
ClientSession();
~ClientSession() override;
+
+ /**
+ * Creates a client session.
+ * @param server_session The server session associated with this client session
+ * @param name Optional name of client session
+ * @return The created client session
+ */
+ static ResultVal<SharedPtr<ClientSession>> Create(SharedPtr<ServerSession> server_session, std::string name = "Unknown");
};
} // namespace
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp
index 8e3ec8a14..f90fe76d5 100644
--- a/src/core/hle/kernel/server_port.cpp
+++ b/src/core/hle/kernel/server_port.cpp
@@ -24,12 +24,13 @@ void ServerPort::Acquire() {
}
std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> ServerPort::CreatePortPair(
- u32 max_sessions, std::string name) {
+ u32 max_sessions, std::string name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
SharedPtr<ServerPort> server_port(new ServerPort);
SharedPtr<ClientPort> client_port(new ClientPort);
server_port->name = name + "_Server";
+ server_port->hle_handler = 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 fa9448ca0..dee0b1a9a 100644
--- a/src/core/hle/kernel/server_port.h
+++ b/src/core/hle/kernel/server_port.h
@@ -9,6 +9,10 @@
#include "common/common_types.h"
#include "core/hle/kernel/kernel.h"
+namespace Service {
+class SessionRequestHandler;
+}
+
namespace Kernel {
class ClientPort;
@@ -19,10 +23,13 @@ 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");
+ u32 max_sessions, std::string name = "UnknownPort",
+ std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr);
std::string GetTypeName() const override {
return "ServerPort";
@@ -41,6 +48,10 @@ public:
std::vector<SharedPtr<WaitObject>>
pending_sessions; ///< ServerSessions waiting to be accepted by the port
+ /// This session's HLE request handler template (optional)
+ /// ServerSessions created from this port inherit a reference to this handler.
+ std::shared_ptr<Service::SessionRequestHandler> hle_handler;
+
bool ShouldWait() override;
void Acquire() override;
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index be334efd7..3782cb493 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -47,10 +47,10 @@ ResultCode ServerSession::HandleSyncRequest() {
}
std::tuple<SharedPtr<ServerSession>, SharedPtr<ClientSession>> ServerSession::CreateSessionPair(const std::string& name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
- auto server_session = ServerSession::Create(name + "Server", hle_handler).MoveFrom();
- auto client_session = ClientSession::Create(server_session, name + "Client").MoveFrom();
+ 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);
+ return std::make_tuple(std::move(server_session), std::move(client_session));
}
}
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 70661e9af..c73ccee73 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -29,20 +29,8 @@ class ClientSession;
* the request, the response is marshalled back to the caller's TLS buffer and control is
* transferred back to it.
*/
-class ServerSession : public WaitObject {
+class ServerSession final : public WaitObject {
public:
- ServerSession();
- ~ServerSession() override;
-
- /**
- * 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<Service::SessionRequestHandler> hle_handler = nullptr);
-
std::string GetTypeName() const override {
return "ServerSession";
}
@@ -61,10 +49,9 @@ public:
/**
* Handle a sync request from the emulated application.
- * Only HLE services should override this function.
* @returns ResultCode from the operation.
*/
- virtual ResultCode HandleSyncRequest();
+ ResultCode HandleSyncRequest();
bool ShouldWait() override;
@@ -73,5 +60,18 @@ public:
std::string name; ///< The name of this session (optional)
bool signaled; ///< Whether there's new data available to this ServerSession
std::shared_ptr<Service::SessionRequestHandler> hle_handler; ///< This session's HLE request handler (optional)
+
+private:
+ ServerSession();
+ ~ServerSession() override;
+
+ /**
+ * 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<Service::SessionRequestHandler> hle_handler = nullptr);
};
}