summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Subv2016-06-18 13:39:26 -0500
committerGravatar Subv2016-11-30 23:04:00 -0500
commitc5e7e0fa26fc793c8b9f3effe25586f7fb57953e (patch)
tree2acac9450de6b1d8cc42d89f9aa08759d77f9cd9 /src
parentKernel/HLE: Service::Interface no longer inherits from any Kernel object, and... (diff)
downloadyuzu-c5e7e0fa26fc793c8b9f3effe25586f7fb57953e.tar.gz
yuzu-c5e7e0fa26fc793c8b9f3effe25586f7fb57953e.tar.xz
yuzu-c5e7e0fa26fc793c8b9f3effe25586f7fb57953e.zip
IPC/HLE: Associate the ClientSessions with their parent port's HLE interface if it exists.
Pass the triggering ServerSession to the HLE command handler to differentiate which session caused the request.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/kernel/client_port.cpp10
-rw-r--r--src/core/hle/kernel/client_port.h12
-rw-r--r--src/core/hle/kernel/client_session.cpp9
-rw-r--r--src/core/hle/kernel/client_session.h6
-rw-r--r--src/core/hle/service/service.cpp8
-rw-r--r--src/core/hle/service/service.h2
6 files changed, 21 insertions, 26 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 9a9cd4bfd..0ac36cd12 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -14,7 +14,7 @@ namespace Kernel {
14ClientPort::ClientPort() {} 14ClientPort::ClientPort() {}
15ClientPort::~ClientPort() {} 15ClientPort::~ClientPort() {}
16 16
17Kernel::SharedPtr<ClientPort> ClientPort::CreateForHLE(u32 max_sessions, std::unique_ptr<Service::Interface> hle_interface) { 17Kernel::SharedPtr<ClientPort> ClientPort::CreateForHLE(u32 max_sessions, std::shared_ptr<Service::Interface> hle_interface) {
18 SharedPtr<ClientPort> client_port(new ClientPort); 18 SharedPtr<ClientPort> client_port(new ClientPort);
19 client_port->max_sessions = max_sessions; 19 client_port->max_sessions = max_sessions;
20 client_port->active_sessions = 0; 20 client_port->active_sessions = 0;
@@ -34,12 +34,4 @@ void ClientPort::AddWaitingSession(SharedPtr<ServerSession> server_session) {
34 server_port->WakeupAllWaitingThreads(); 34 server_port->WakeupAllWaitingThreads();
35} 35}
36 36
37ResultCode ClientPort::HandleSyncRequest() {
38 // Forward the request to the associated HLE interface if it exists
39 if (hle_interface != nullptr)
40 return hle_interface->HandleSyncRequest();
41
42 return RESULT_SUCCESS;
43}
44
45} // namespace 37} // namespace
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h
index ee65606ba..52308f13f 100644
--- a/src/core/hle/kernel/client_port.h
+++ b/src/core/hle/kernel/client_port.h
@@ -28,19 +28,13 @@ public:
28 * @param hle_interface Interface object that implements the commands of the service. 28 * @param hle_interface Interface object that implements the commands of the service.
29 * @returns ClientPort for the given HLE interface. 29 * @returns ClientPort for the given HLE interface.
30 */ 30 */
31 static Kernel::SharedPtr<ClientPort> CreateForHLE(u32 max_sessions, std::unique_ptr<Service::Interface> hle_interface); 31 static Kernel::SharedPtr<ClientPort> CreateForHLE(u32 max_sessions, std::shared_ptr<Service::Interface> hle_interface);
32 32
33 /** 33 /**
34 * Adds the specified server session to the queue of pending sessions of the associated ServerPort 34 * Adds the specified server session to the queue of pending sessions of the associated ServerPort
35 * @param server_session Server session to add to the queue 35 * @param server_session Server session to add to the queue
36 */ 36 */
37 virtual void AddWaitingSession(SharedPtr<ServerSession> server_session); 37 void AddWaitingSession(SharedPtr<ServerSession> server_session);
38
39 /**
40 * Handle a sync request from the emulated application.
41 * @returns ResultCode from the operation.
42 */
43 ResultCode HandleSyncRequest();
44 38
45 std::string GetTypeName() const override { return "ClientPort"; } 39 std::string GetTypeName() const override { return "ClientPort"; }
46 std::string GetName() const override { return name; } 40 std::string GetName() const override { return name; }
@@ -54,7 +48,7 @@ public:
54 u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have 48 u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
55 u32 active_sessions; ///< Number of currently open sessions to this port 49 u32 active_sessions; ///< Number of currently open sessions to this port
56 std::string name; ///< Name of client port (optional) 50 std::string name; ///< Name of client port (optional)
57 std::unique_ptr<Service::Interface> hle_interface = nullptr; ///< HLE implementation of this port's request handler 51 std::shared_ptr<Service::Interface> hle_interface = nullptr; ///< HLE implementation of this port's request handler
58 52
59private: 53private:
60 ClientPort(); 54 ClientPort();
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp
index f1ad9b65b..22fa2ff03 100644
--- a/src/core/hle/kernel/client_session.cpp
+++ b/src/core/hle/kernel/client_session.cpp
@@ -8,6 +8,7 @@
8#include "core/hle/kernel/client_session.h" 8#include "core/hle/kernel/client_session.h"
9#include "core/hle/kernel/server_session.h" 9#include "core/hle/kernel/server_session.h"
10#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
11#include "core/hle/service/service.h"
11 12
12namespace Kernel { 13namespace Kernel {
13 14
@@ -20,6 +21,7 @@ ResultVal<SharedPtr<ClientSession>> ClientSession::Create(SharedPtr<ServerSessio
20 client_session->name = std::move(name); 21 client_session->name = std::move(name);
21 client_session->server_session = server_session; 22 client_session->server_session = server_session;
22 client_session->client_port = client_port; 23 client_session->client_port = client_port;
24 client_session->hle_helper = client_port->hle_interface;
23 25
24 return MakeResult<SharedPtr<ClientSession>>(std::move(client_session)); 26 return MakeResult<SharedPtr<ClientSession>>(std::move(client_session));
25} 27}
@@ -31,10 +33,9 @@ ResultCode ClientSession::HandleSyncRequest() {
31 if (result.IsError()) 33 if (result.IsError())
32 return result; 34 return result;
33 35
34 // Tell the client port to handle the request in case it's an HLE service. 36 // If this ClientSession has an associated HLE helper, forward the request to it.
35 // The client port can be nullptr for port-less sessions (Like for example File and Directory sessions). 37 if (hle_helper != nullptr)
36 if (client_port != nullptr) 38 result = hle_helper->HandleSyncRequest(server_session);
37 result = client_port->HandleSyncRequest();
38 39
39 return result; 40 return result;
40} 41}
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index 4fe9b4517..c2fc0d7dd 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -5,11 +5,16 @@
5#pragma once 5#pragma once
6 6
7#include <string> 7#include <string>
8#include <memory>
8 9
9#include "common/common_types.h" 10#include "common/common_types.h"
10 11
11#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
12 13
14namespace Service {
15class Interface;
16}
17
13namespace Kernel { 18namespace Kernel {
14 19
15class ClientPort; 20class ClientPort;
@@ -41,6 +46,7 @@ public:
41 std::string name; ///< Name of client port (optional) 46 std::string name; ///< Name of client port (optional)
42 SharedPtr<ServerSession> server_session; ///< The server session associated with this client session. 47 SharedPtr<ServerSession> server_session; ///< The server session associated with this client session.
43 SharedPtr<ClientPort> client_port; ///< The client port which this session is connected to. 48 SharedPtr<ClientPort> client_port; ///< The client port which this session is connected to.
49 std::shared_ptr<Service::Interface> hle_helper = nullptr; ///< HLE implementation of this port's request handler
44 50
45private: 51private:
46 ClientSession(); 52 ClientSession();
diff --git a/src/core/hle/service/service.cpp b/src/core/hle/service/service.cpp
index abfc1806b..56e4f8734 100644
--- a/src/core/hle/service/service.cpp
+++ b/src/core/hle/service/service.cpp
@@ -61,7 +61,9 @@ static std::string MakeFunctionString(const char* name, const char* port_name,
61 return function_string; 61 return function_string;
62} 62}
63 63
64ResultCode Interface::HandleSyncRequest() { 64ResultCode Interface::HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session) {
65 // TODO(Subv): Make use of the server_session in the HLE service handlers to distinguish which session triggered each command.
66
65 u32* cmd_buff = Kernel::GetCommandBuffer(); 67 u32* cmd_buff = Kernel::GetCommandBuffer();
66 auto itr = m_functions.find(cmd_buff[0]); 68 auto itr = m_functions.find(cmd_buff[0]);
67 69
@@ -97,12 +99,12 @@ void Interface::Register(const FunctionInfo* functions, size_t n) {
97// Module interface 99// Module interface
98 100
99static void AddNamedPort(Interface* interface_) { 101static void AddNamedPort(Interface* interface_) {
100 auto client_port = Kernel::ClientPort::CreateForHLE(interface_->GetMaxSessions(), std::unique_ptr<Interface>(interface_)); 102 auto client_port = Kernel::ClientPort::CreateForHLE(interface_->GetMaxSessions(), std::shared_ptr<Interface>(interface_));
101 g_kernel_named_ports.emplace(interface_->GetPortName(), client_port); 103 g_kernel_named_ports.emplace(interface_->GetPortName(), client_port);
102} 104}
103 105
104void AddService(Interface* interface_) { 106void AddService(Interface* interface_) {
105 auto client_port = Kernel::ClientPort::CreateForHLE(interface_->GetMaxSessions(), std::unique_ptr<Interface>(interface_)); 107 auto client_port = Kernel::ClientPort::CreateForHLE(interface_->GetMaxSessions(), std::shared_ptr<Interface>(interface_));
106 g_srv_services.emplace(interface_->GetPortName(), client_port); 108 g_srv_services.emplace(interface_->GetPortName(), client_port);
107} 109}
108 110
diff --git a/src/core/hle/service/service.h b/src/core/hle/service/service.h
index b22caca07..e2d04450a 100644
--- a/src/core/hle/service/service.h
+++ b/src/core/hle/service/service.h
@@ -56,7 +56,7 @@ public:
56 return "[UNKNOWN SERVICE PORT]"; 56 return "[UNKNOWN SERVICE PORT]";
57 } 57 }
58 58
59 ResultCode HandleSyncRequest(); 59 ResultCode HandleSyncRequest(Kernel::SharedPtr<Kernel::ServerSession> server_session);
60 60
61protected: 61protected:
62 /** 62 /**