summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Subv2016-12-14 12:33:49 -0500
committerGravatar Subv2016-12-14 12:45:36 -0500
commit016307ae656afc85ab59a5c2598205ef81f99231 (patch)
treeae2031654a2178e8ea824928be03fd8409f81222 /src/core/hle/kernel
parentMoved the HLE command buffer translation task to ServerSession instead of the... (diff)
downloadyuzu-016307ae656afc85ab59a5c2598205ef81f99231.tar.gz
yuzu-016307ae656afc85ab59a5c2598205ef81f99231.tar.xz
yuzu-016307ae656afc85ab59a5c2598205ef81f99231.zip
Fixed the codestyle to match our clang-format rules.
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_port.cpp6
-rw-r--r--src/core/hle/kernel/client_port.h5
-rw-r--r--src/core/hle/kernel/client_session.cpp9
-rw-r--r--src/core/hle/kernel/client_session.h11
-rw-r--r--src/core/hle/kernel/server_port.cpp3
-rw-r--r--src/core/hle/kernel/server_session.cpp25
-rw-r--r--src/core/hle/kernel/server_session.h25
7 files changed, 51 insertions, 33 deletions
diff --git a/src/core/hle/kernel/client_port.cpp b/src/core/hle/kernel/client_port.cpp
index bd8ef055d..22645f4ec 100644
--- a/src/core/hle/kernel/client_port.cpp
+++ b/src/core/hle/kernel/client_port.cpp
@@ -19,7 +19,8 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
19 // AcceptSession before returning from this call. 19 // AcceptSession before returning from this call.
20 20
21 if (active_sessions >= max_sessions) { 21 if (active_sessions >= max_sessions) {
22 // TODO(Subv): Return an error code in this situation after session disconnection is implemented. 22 // TODO(Subv): Return an error code in this situation after session disconnection is
23 // implemented.
23 /*return ResultCode(ErrorDescription::MaxConnectionsReached, 24 /*return ResultCode(ErrorDescription::MaxConnectionsReached,
24 ErrorModule::OS, ErrorSummary::WouldBlock, 25 ErrorModule::OS, ErrorSummary::WouldBlock,
25 ErrorLevel::Temporary);*/ 26 ErrorLevel::Temporary);*/
@@ -27,7 +28,8 @@ ResultVal<SharedPtr<ClientSession>> ClientPort::Connect() {
27 active_sessions++; 28 active_sessions++;
28 29
29 // Create a new session pair, let the created sessions inherit the parent port's HLE handler. 30 // Create a new session pair, let the created sessions inherit the parent port's HLE handler.
30 auto sessions = ServerSession::CreateSessionPair(server_port->GetName(), server_port->hle_handler); 31 auto sessions =
32 ServerSession::CreateSessionPair(server_port->GetName(), server_port->hle_handler);
31 auto client_session = std::get<SharedPtr<ClientSession>>(sessions); 33 auto client_session = std::get<SharedPtr<ClientSession>>(sessions);
32 auto server_session = std::get<SharedPtr<ServerSession>>(sessions); 34 auto server_session = std::get<SharedPtr<ServerSession>>(sessions);
33 35
diff --git a/src/core/hle/kernel/client_port.h b/src/core/hle/kernel/client_port.h
index 0039cf028..511490c7c 100644
--- a/src/core/hle/kernel/client_port.h
+++ b/src/core/hle/kernel/client_port.h
@@ -29,8 +29,9 @@ public:
29 } 29 }
30 30
31 /** 31 /**
32 * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's list of pending sessions, 32 * Creates a new Session pair, adds the created ServerSession to the associated ServerPort's
33 * and signals the ServerPort, causing any threads waiting on it to awake. 33 * list of pending sessions, and signals the ServerPort, causing any threads
34 * waiting on it to awake.
34 * @returns ClientSession The client endpoint of the created Session pair, or error code. 35 * @returns ClientSession The client endpoint of the created Session pair, or error code.
35 */ 36 */
36 ResultVal<SharedPtr<ClientSession>> Connect(); 37 ResultVal<SharedPtr<ClientSession>> Connect();
diff --git a/src/core/hle/kernel/client_session.cpp b/src/core/hle/kernel/client_session.cpp
index 17302baca..0331386ec 100644
--- a/src/core/hle/kernel/client_session.cpp
+++ b/src/core/hle/kernel/client_session.cpp
@@ -11,16 +11,19 @@ namespace Kernel {
11 11
12ClientSession::ClientSession() = default; 12ClientSession::ClientSession() = default;
13ClientSession::~ClientSession() { 13ClientSession::~ClientSession() {
14 // This destructor will be called automatically when the last ClientSession handle is closed by the emulated application. 14 // This destructor will be called automatically when the last ClientSession handle is closed by
15 // the emulated application.
15 16
16 if (server_session->hle_handler) 17 if (server_session->hle_handler)
17 server_session->hle_handler->ClientDisconnected(server_session); 18 server_session->hle_handler->ClientDisconnected(server_session);
18 19
19 // TODO(Subv): If the session is still open, set the connection status to 2 (Closed by client), 20 // TODO(Subv): If the session is still open, set the connection status to 2 (Closed by client),
20 // wake up all the ServerSession's waiting threads and set the WaitSynchronization result to 0xC920181A. 21 // wake up all the ServerSession's waiting threads and set the WaitSynchronization result to
22 // 0xC920181A.
21} 23}
22 24
23ResultVal<SharedPtr<ClientSession>> ClientSession::Create(ServerSession* server_session, std::string name) { 25ResultVal<SharedPtr<ClientSession>> ClientSession::Create(ServerSession* server_session,
26 std::string name) {
24 SharedPtr<ClientSession> client_session(new ClientSession); 27 SharedPtr<ClientSession> client_session(new ClientSession);
25 28
26 client_session->name = std::move(name); 29 client_session->name = std::move(name);
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index fedbd0625..ed468dec6 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -4,8 +4,8 @@
4 4
5#pragma once 5#pragma once
6 6
7#include <string>
8#include <memory> 7#include <memory>
8#include <string>
9 9
10#include "common/common_types.h" 10#include "common/common_types.h"
11 11
@@ -44,9 +44,9 @@ public:
44 */ 44 */
45 ResultCode SendSyncRequest(); 45 ResultCode SendSyncRequest();
46 46
47 std::string name; ///< Name of client port (optional) 47 std::string name; ///< Name of client port (optional)
48 ServerSession* server_session; ///< The server session associated with this client session. 48 ServerSession* server_session; ///< The server session associated with this client session.
49 SessionStatus session_status; ///< The session's current status. 49 SessionStatus session_status; ///< The session's current status.
50 50
51private: 51private:
52 ClientSession(); 52 ClientSession();
@@ -58,7 +58,8 @@ private:
58 * @param name Optional name of client session 58 * @param name Optional name of client session
59 * @return The created client session 59 * @return The created client session
60 */ 60 */
61 static ResultVal<SharedPtr<ClientSession>> Create(ServerSession* server_session, std::string name = "Unknown"); 61 static ResultVal<SharedPtr<ClientSession>> Create(ServerSession* server_session,
62 std::string name = "Unknown");
62}; 63};
63 64
64} // namespace 65} // namespace
diff --git a/src/core/hle/kernel/server_port.cpp b/src/core/hle/kernel/server_port.cpp
index f7699f023..6c19aa7c0 100644
--- a/src/core/hle/kernel/server_port.cpp
+++ b/src/core/hle/kernel/server_port.cpp
@@ -24,7 +24,8 @@ void ServerPort::Acquire() {
24} 24}
25 25
26std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> ServerPort::CreatePortPair( 26std::tuple<SharedPtr<ServerPort>, SharedPtr<ClientPort>> ServerPort::CreatePortPair(
27 u32 max_sessions, std::string name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) { 27 u32 max_sessions, std::string name,
28 std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
28 29
29 SharedPtr<ServerPort> server_port(new ServerPort); 30 SharedPtr<ServerPort> server_port(new ServerPort);
30 SharedPtr<ClientPort> client_port(new ClientPort); 31 SharedPtr<ClientPort> client_port(new ClientPort);
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index 1e54c3a2e..146458c1c 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -12,12 +12,14 @@ namespace Kernel {
12 12
13ServerSession::ServerSession() = default; 13ServerSession::ServerSession() = default;
14ServerSession::~ServerSession() { 14ServerSession::~ServerSession() {
15 // This destructor will be called automatically when the last ServerSession handle is closed by the emulated application. 15 // This destructor will be called automatically when the last ServerSession handle is closed by
16 // the emulated application.
16 // TODO(Subv): Reduce the ClientPort's connection count, 17 // TODO(Subv): Reduce the ClientPort's connection count,
17 // if the session is still open, set the connection status to 3 (Closed by server), 18 // if the session is still open, set the connection status to 3 (Closed by server),
18} 19}
19 20
20ResultVal<SharedPtr<ServerSession>> ServerSession::Create(std::string name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) { 21ResultVal<SharedPtr<ServerSession>> ServerSession::Create(
22 std::string name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
21 SharedPtr<ServerSession> server_session(new ServerSession); 23 SharedPtr<ServerSession> server_session(new ServerSession);
22 24
23 server_session->name = std::move(name); 25 server_session->name = std::move(name);
@@ -38,7 +40,8 @@ void ServerSession::Acquire() {
38 40
39ResultCode ServerSession::HandleSyncRequest() { 41ResultCode ServerSession::HandleSyncRequest() {
40 // The ServerSession received a sync request, this means that there's new data available 42 // The ServerSession received a sync request, this means that there's new data available
41 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or similar. 43 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
44 // similar.
42 45
43 // If this ServerSession has an associated HLE handler, forward the request to it. 46 // If this ServerSession has an associated HLE handler, forward the request to it.
44 if (hle_handler != nullptr) { 47 if (hle_handler != nullptr) {
@@ -50,17 +53,20 @@ ResultCode ServerSession::HandleSyncRequest() {
50 // TODO(Subv): Translate the response command buffer. 53 // TODO(Subv): Translate the response command buffer.
51 } 54 }
52 55
53 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting on it. 56 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting
57 // on it.
54 signaled = true; 58 signaled = true;
55 WakeupAllWaitingThreads(); 59 WakeupAllWaitingThreads();
56 return RESULT_SUCCESS; 60 return RESULT_SUCCESS;
57} 61}
58 62
59ServerSession::SessionPair ServerSession::CreateSessionPair(const std::string& name, 63ServerSession::SessionPair ServerSession::CreateSessionPair(
60 std::shared_ptr<Service::SessionRequestHandler> hle_handler) { 64 const std::string& name, std::shared_ptr<Service::SessionRequestHandler> hle_handler) {
61 auto server_session = ServerSession::Create(name + "_Server", std::move(hle_handler)).MoveFrom(); 65 auto server_session =
62 // We keep a non-owning pointer to the ServerSession in the ClientSession because we don't want to prevent the 66 ServerSession::Create(name + "_Server", std::move(hle_handler)).MoveFrom();
63 // ServerSession's destructor from being called when the emulated application closes the last ServerSession handle. 67 // We keep a non-owning pointer to the ServerSession in the ClientSession because we don't want
68 // to prevent the ServerSession's destructor from being called when the emulated
69 // application closes the last ServerSession handle.
64 auto client_session = ClientSession::Create(server_session.get(), name + "_Client").MoveFrom(); 70 auto client_session = ClientSession::Create(server_session.get(), name + "_Client").MoveFrom();
65 71
66 return std::make_tuple(std::move(server_session), std::move(client_session)); 72 return std::make_tuple(std::move(server_session), std::move(client_session));
@@ -70,5 +76,4 @@ ResultCode TranslateHLERequest(ServerSession* server_session) {
70 // TODO(Subv): Implement this function once multiple concurrent processes are supported. 76 // TODO(Subv): Implement this function once multiple concurrent processes are supported.
71 return RESULT_SUCCESS; 77 return RESULT_SUCCESS;
72} 78}
73
74} 79}
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 7abc09011..458284a5d 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -24,10 +24,10 @@ class ClientSession;
24 * 24 *
25 * To make a service call, the client must write the command header and parameters to the buffer 25 * To make a service call, the client must write the command header and parameters to the buffer
26 * located at offset 0x80 of the TLS (Thread-Local Storage) area, then execute a SendSyncRequest 26 * located at offset 0x80 of the TLS (Thread-Local Storage) area, then execute a SendSyncRequest
27 * SVC call with its ClientSession handle. The kernel will read the command header, using it to marshall 27 * SVC call with its ClientSession handle. The kernel will read the command header, using it to
28 * the parameters to the process at the server endpoint of the session. After the server replies to 28 * marshall the parameters to the process at the server endpoint of the session.
29 * the request, the response is marshalled back to the caller's TLS buffer and control is 29 * After the server replies to the request, the response is marshalled back to the caller's
30 * transferred back to it. 30 * TLS buffer and control is transferred back to it.
31 */ 31 */
32class ServerSession final : public WaitObject { 32class ServerSession final : public WaitObject {
33public: 33public:
@@ -47,7 +47,9 @@ public:
47 * @param name Optional name of the ports 47 * @param name Optional name of the ports
48 * @return The created session tuple 48 * @return The created session tuple
49 */ 49 */
50 static SessionPair CreateSessionPair(const std::string& name = "Unknown", std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr); 50 static SessionPair CreateSessionPair(
51 const std::string& name = "Unknown",
52 std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr);
51 53
52 /** 54 /**
53 * Handle a sync request from the emulated application. 55 * Handle a sync request from the emulated application.
@@ -61,7 +63,8 @@ public:
61 63
62 std::string name; ///< The name of this session (optional) 64 std::string name; ///< The name of this session (optional)
63 bool signaled; ///< Whether there's new data available to this ServerSession 65 bool signaled; ///< Whether there's new data available to this ServerSession
64 std::shared_ptr<Service::SessionRequestHandler> hle_handler; ///< This session's HLE request handler (optional) 66 std::shared_ptr<Service::SessionRequestHandler>
67 hle_handler; ///< This session's HLE request handler (optional)
65 68
66private: 69private:
67 ServerSession(); 70 ServerSession();
@@ -74,16 +77,18 @@ private:
74 * @param hle_handler Optional HLE handler for this server session. 77 * @param hle_handler Optional HLE handler for this server session.
75 * @return The created server session 78 * @return The created server session
76 */ 79 */
77 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown", std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr); 80 static ResultVal<SharedPtr<ServerSession>> Create(
81 std::string name = "Unknown",
82 std::shared_ptr<Service::SessionRequestHandler> hle_handler = nullptr);
78}; 83};
79 84
80/** 85/**
81 * Performs command buffer translation for an HLE IPC request. 86 * Performs command buffer translation for an HLE IPC request.
82 * The command buffer from the ServerSession thread's TLS is copied into a 87 * The command buffer from the ServerSession thread's TLS is copied into a
83 * buffer and all descriptors in the buffer are processed. 88 * buffer and all descriptors in the buffer are processed.
84 * TODO(Subv): Implement this function, currently we do not support multiple processes running at once, 89 * TODO(Subv): Implement this function, currently we do not support multiple processes running at
85 * but once that is implemented we'll need to properly translate all descriptors in the command buffer. 90 * once, but once that is implemented we'll need to properly translate all descriptors
91 * in the command buffer.
86 */ 92 */
87ResultCode TranslateHLERequest(ServerSession* server_session); 93ResultCode TranslateHLERequest(ServerSession* server_session);
88
89} 94}