summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Subv2016-06-17 17:09:43 -0500
committerGravatar Subv2016-11-30 23:03:59 -0500
commitc19afd21188e91b9dd2780cf5cb9872a17ad113d (patch)
tree5404cd7850f049d474dbcc3cc4ee80874b0c7627 /src/core/hle/kernel
parentfixup! Kernel/IPC: Use Ports and Sessions as the fundamental building block ... (diff)
downloadyuzu-c19afd21188e91b9dd2780cf5cb9872a17ad113d.tar.gz
yuzu-c19afd21188e91b9dd2780cf5cb9872a17ad113d.tar.xz
yuzu-c19afd21188e91b9dd2780cf5cb9872a17ad113d.zip
Kernel/HLE: Service::Interface no longer inherits from any Kernel object, and is now its own standalone class.
Interface is now used by aggregation in ClientPort, to forward service commands to their HLE implementation if needed.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_port.cpp23
-rw-r--r--src/core/hle/kernel/client_port.h29
2 files changed, 44 insertions, 8 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index 5ee7679eb..9a9cd4bfd 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -7,16 +7,39 @@
7#include "core/hle/kernel/kernel.h" 7#include "core/hle/kernel/kernel.h"
8#include "core/hle/kernel/server_port.h" 8#include "core/hle/kernel/server_port.h"
9#include "core/hle/kernel/server_session.h" 9#include "core/hle/kernel/server_session.h"
10#include "core/hle/service/service.h"
10 11
11namespace Kernel { 12namespace Kernel {
12 13
13ClientPort::ClientPort() {} 14ClientPort::ClientPort() {}
14ClientPort::~ClientPort() {} 15ClientPort::~ClientPort() {}
15 16
17Kernel::SharedPtr<ClientPort> ClientPort::CreateForHLE(u32 max_sessions, std::unique_ptr<Service::Interface> hle_interface) {
18 SharedPtr<ClientPort> client_port(new ClientPort);
19 client_port->max_sessions = max_sessions;
20 client_port->active_sessions = 0;
21 client_port->name = hle_interface->GetPortName();
22 client_port->hle_interface = std::move(hle_interface);
23
24 return client_port;
25}
26
16void ClientPort::AddWaitingSession(SharedPtr<ServerSession> server_session) { 27void ClientPort::AddWaitingSession(SharedPtr<ServerSession> server_session) {
28 // A port that has an associated HLE interface doesn't have a server port.
29 if (hle_interface != nullptr)
30 return;
31
17 server_port->pending_sessions.push_back(server_session); 32 server_port->pending_sessions.push_back(server_session);
18 // Wake the threads waiting on the ServerPort 33 // Wake the threads waiting on the ServerPort
19 server_port->WakeupAllWaitingThreads(); 34 server_port->WakeupAllWaitingThreads();
20} 35}
21 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
22} // namespace 45} // namespace
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h
index eb0882870..ee65606ba 100644
--- a/src/core/hle/kernel/client_port.h
+++ b/src/core/hle/kernel/client_port.h
@@ -5,19 +5,32 @@
5#pragma once 5#pragma once
6 6
7#include <string> 7#include <string>
8#include <memory>
8#include "common/common_types.h" 9#include "common/common_types.h"
9#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
10 11
12namespace Service {
13class Interface;
14}
15
11namespace Kernel { 16namespace Kernel {
12 17
13class ServerPort; 18class ServerPort;
14class ServerSession; 19class ServerSession;
15 20
16class ClientPort : public Object { 21class ClientPort final : public Object {
17public: 22public:
18 friend class ServerPort; 23 friend class ServerPort;
19 24
20 /** 25 /**
26 * Creates a serverless ClientPort that represents a bridge between the HLE implementation of a service/port and the emulated application.
27 * @param max_sessions Maximum number of sessions that this port is able to handle concurrently.
28 * @param hle_interface Interface object that implements the commands of the service.
29 * @returns ClientPort for the given HLE interface.
30 */
31 static Kernel::SharedPtr<ClientPort> CreateForHLE(u32 max_sessions, std::unique_ptr<Service::Interface> hle_interface);
32
33 /**
21 * 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
22 * @param server_session Server session to add to the queue 35 * @param server_session Server session to add to the queue
23 */ 36 */
@@ -25,10 +38,9 @@ public:
25 38
26 /** 39 /**
27 * Handle a sync request from the emulated application. 40 * Handle a sync request from the emulated application.
28 * Only HLE services should override this function.
29 * @returns ResultCode from the operation. 41 * @returns ResultCode from the operation.
30 */ 42 */
31 virtual ResultCode HandleSyncRequest() { return RESULT_SUCCESS; } 43 ResultCode HandleSyncRequest();
32 44
33 std::string GetTypeName() const override { return "ClientPort"; } 45 std::string GetTypeName() const override { return "ClientPort"; }
34 std::string GetName() const override { return name; } 46 std::string GetName() const override { return name; }
@@ -38,12 +50,13 @@ public:
38 return HANDLE_TYPE; 50 return HANDLE_TYPE;
39 } 51 }
40 52
41 SharedPtr<ServerPort> server_port; ///< ServerPort associated with this client port. 53 SharedPtr<ServerPort> server_port = nullptr; ///< ServerPort associated with this client port.
42 u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have 54 u32 max_sessions; ///< Maximum number of simultaneous sessions the port can have
43 u32 active_sessions; ///< Number of currently open sessions to this port 55 u32 active_sessions; ///< Number of currently open sessions to this port
44 std::string name; ///< Name of client port (optional) 56 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
45 58
46protected: 59private:
47 ClientPort(); 60 ClientPort();
48 ~ClientPort() override; 61 ~ClientPort() override;
49}; 62};