summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar bunnei2018-01-24 23:09:03 -0500
committerGravatar GitHub2018-01-24 23:09:03 -0500
commit748c0de539674dc8ca4a5a8aadd2a61b0eabe652 (patch)
treeae56efe8654d3aa3a5e75ec04bd9dfdcc06023a9 /src/core/hle/kernel
parentaudout:u OpenAudioOut and IAudioOut (#138) (diff)
parentaudout_u: Various cleanups. (diff)
downloadyuzu-748c0de539674dc8ca4a5a8aadd2a61b0eabe652.tar.gz
yuzu-748c0de539674dc8ca4a5a8aadd2a61b0eabe652.tar.xz
yuzu-748c0de539674dc8ca4a5a8aadd2a61b0eabe652.zip
Merge pull request #137 from bunnei/improve-ipc
Improve IPC, unify Domains and Sessions, and add validation
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/client_session.h6
-rw-r--r--src/core/hle/kernel/domain.cpp63
-rw-r--r--src/core/hle/kernel/domain.h45
-rw-r--r--src/core/hle/kernel/handle_table.cpp10
-rw-r--r--src/core/hle/kernel/handle_table.h7
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp11
-rw-r--r--src/core/hle/kernel/hle_ipc.h27
-rw-r--r--src/core/hle/kernel/kernel.h16
-rw-r--r--src/core/hle/kernel/server_session.cpp47
-rw-r--r--src/core/hle/kernel/server_session.h18
-rw-r--r--src/core/hle/kernel/svc.cpp3
-rw-r--r--src/core/hle/kernel/sync_object.h35
12 files changed, 79 insertions, 209 deletions
diff --git a/src/core/hle/kernel/client_session.h b/src/core/hle/kernel/client_session.h
index d6ab4f893..2258f95bc 100644
--- a/src/core/hle/kernel/client_session.h
+++ b/src/core/hle/kernel/client_session.h
@@ -7,7 +7,7 @@
7#include <memory> 7#include <memory>
8#include <string> 8#include <string>
9#include "common/common_types.h" 9#include "common/common_types.h"
10#include "core/hle/kernel/sync_object.h" 10#include "core/hle/kernel/kernel.h"
11#include "core/hle/result.h" 11#include "core/hle/result.h"
12 12
13namespace Kernel { 13namespace Kernel {
@@ -16,7 +16,7 @@ class ServerSession;
16class Session; 16class Session;
17class Thread; 17class Thread;
18 18
19class ClientSession final : public SyncObject { 19class ClientSession final : public Object {
20public: 20public:
21 friend class ServerSession; 21 friend class ServerSession;
22 22
@@ -33,7 +33,7 @@ public:
33 return HANDLE_TYPE; 33 return HANDLE_TYPE;
34 } 34 }
35 35
36 ResultCode SendSyncRequest(SharedPtr<Thread> thread) override; 36 ResultCode SendSyncRequest(SharedPtr<Thread> thread);
37 37
38 std::string name; ///< Name of client port (optional) 38 std::string name; ///< Name of client port (optional)
39 39
diff --git a/src/core/hle/kernel/domain.cpp b/src/core/hle/kernel/domain.cpp
deleted file mode 100644
index 5035e9c08..000000000
--- a/src/core/hle/kernel/domain.cpp
+++ /dev/null
@@ -1,63 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include "common/logging/log.h"
6#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/client_port.h"
8#include "core/hle/kernel/domain.h"
9#include "core/hle/kernel/handle_table.h"
10#include "core/hle/kernel/hle_ipc.h"
11#include "core/hle/kernel/process.h"
12#include "core/hle/kernel/session.h"
13#include "core/hle/kernel/thread.h"
14
15namespace Kernel {
16
17ResultVal<SharedPtr<Domain>> Domain::Create(std::string name) {
18 SharedPtr<Domain> domain(new Domain);
19 domain->name = std::move(name);
20 return MakeResult(std::move(domain));
21}
22
23ResultVal<SharedPtr<Domain>> Domain::CreateFromSession(const Session& session) {
24 auto res = Create(session.port->GetName() + "_Domain");
25 auto& domain = res.Unwrap();
26 domain->request_handlers.push_back(std::move(session.server->hle_handler));
27 Kernel::g_handle_table.ConvertSessionToDomain(session, domain);
28 return res;
29}
30
31ResultCode Domain::SendSyncRequest(SharedPtr<Thread> thread) {
32 Kernel::HLERequestContext context(this);
33 u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
34 context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
35 Kernel::g_handle_table);
36
37 auto& domain_message_header = context.GetDomainMessageHeader();
38 if (domain_message_header) {
39 // If there is a DomainMessageHeader, then this is CommandType "Request"
40 const u32 object_id{context.GetDomainMessageHeader()->object_id};
41 switch (domain_message_header->command) {
42 case IPC::DomainMessageHeader::CommandType::SendMessage:
43 return request_handlers[object_id - 1]->HandleSyncRequest(context);
44
45 case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: {
46 LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id);
47
48 request_handlers[object_id - 1] = nullptr;
49
50 IPC::RequestBuilder rb{context, 2};
51 rb.Push(RESULT_SUCCESS);
52
53 return RESULT_SUCCESS;
54 }
55 }
56
57 LOG_CRITICAL(IPC, "Unknown domain command=%d", domain_message_header->command.Value());
58 UNIMPLEMENTED();
59 }
60 return request_handlers.front()->HandleSyncRequest(context);
61}
62
63} // namespace Kernel
diff --git a/src/core/hle/kernel/domain.h b/src/core/hle/kernel/domain.h
deleted file mode 100644
index 3fec3b0b2..000000000
--- a/src/core/hle/kernel/domain.h
+++ /dev/null
@@ -1,45 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <memory>
8#include <string>
9#include <vector>
10#include "core/hle/kernel/sync_object.h"
11#include "core/hle/result.h"
12
13namespace Kernel {
14
15class Session;
16class SessionRequestHandler;
17
18class Domain final : public SyncObject {
19public:
20 std::string GetTypeName() const override {
21 return "Domain";
22 }
23
24 static const HandleType HANDLE_TYPE = HandleType::Domain;
25 HandleType GetHandleType() const override {
26 return HANDLE_TYPE;
27 }
28
29 static ResultVal<SharedPtr<Domain>> CreateFromSession(const Session& server);
30
31 ResultCode SendSyncRequest(SharedPtr<Thread> thread) override;
32
33 /// The name of this domain (optional)
34 std::string name;
35
36 std::vector<std::shared_ptr<SessionRequestHandler>> request_handlers;
37
38private:
39 Domain() = default;
40 ~Domain() override = default;
41
42 static ResultVal<SharedPtr<Domain>> Create(std::string name = "Unknown");
43};
44
45} // namespace Kernel
diff --git a/src/core/hle/kernel/handle_table.cpp b/src/core/hle/kernel/handle_table.cpp
index 74d3d0514..3beb55753 100644
--- a/src/core/hle/kernel/handle_table.cpp
+++ b/src/core/hle/kernel/handle_table.cpp
@@ -5,12 +5,10 @@
5#include <utility> 5#include <utility>
6#include "common/assert.h" 6#include "common/assert.h"
7#include "common/logging/log.h" 7#include "common/logging/log.h"
8#include "core/hle/kernel/client_session.h"
9#include "core/hle/kernel/errors.h" 8#include "core/hle/kernel/errors.h"
10#include "core/hle/kernel/handle_table.h" 9#include "core/hle/kernel/handle_table.h"
11#include "core/hle/kernel/kernel.h" 10#include "core/hle/kernel/kernel.h"
12#include "core/hle/kernel/process.h" 11#include "core/hle/kernel/process.h"
13#include "core/hle/kernel/session.h"
14#include "core/hle/kernel/thread.h" 12#include "core/hle/kernel/thread.h"
15 13
16namespace Kernel { 14namespace Kernel {
@@ -55,14 +53,6 @@ ResultVal<Handle> HandleTable::Duplicate(Handle handle) {
55 return Create(std::move(object)); 53 return Create(std::move(object));
56} 54}
57 55
58void HandleTable::ConvertSessionToDomain(const Session& session, SharedPtr<Object> domain) {
59 for (auto& object : objects) {
60 if (DynamicObjectCast<ClientSession>(object) == session.client) {
61 object = domain;
62 }
63 }
64}
65
66ResultCode HandleTable::Close(Handle handle) { 56ResultCode HandleTable::Close(Handle handle) {
67 if (!IsValid(handle)) 57 if (!IsValid(handle))
68 return ERR_INVALID_HANDLE; 58 return ERR_INVALID_HANDLE;
diff --git a/src/core/hle/kernel/handle_table.h b/src/core/hle/kernel/handle_table.h
index 935cc22b5..ba968c666 100644
--- a/src/core/hle/kernel/handle_table.h
+++ b/src/core/hle/kernel/handle_table.h
@@ -17,8 +17,6 @@ enum KernelHandle : Handle {
17 CurrentProcess = 0xFFFF8001, 17 CurrentProcess = 0xFFFF8001,
18}; 18};
19 19
20class Session;
21
22/** 20/**
23 * This class allows the creation of Handles, which are references to objects that can be tested 21 * This class allows the creation of Handles, which are references to objects that can be tested
24 * for validity and looked up. Here they are used to pass references to kernel objects to/from the 22 * for validity and looked up. Here they are used to pass references to kernel objects to/from the
@@ -62,11 +60,6 @@ public:
62 ResultVal<Handle> Duplicate(Handle handle); 60 ResultVal<Handle> Duplicate(Handle handle);
63 61
64 /** 62 /**
65 * Convert all handles of the specified Session to the specified Domain.
66 */
67 void ConvertSessionToDomain(const Session& session, SharedPtr<Object> domain);
68
69 /**
70 * Closes a handle, removing it from the table and decreasing the object's ref-count. 63 * Closes a handle, removing it from the table and decreasing the object's ref-count.
71 * @return `RESULT_SUCCESS` or one of the following errors: 64 * @return `RESULT_SUCCESS` or one of the following errors:
72 * - `ERR_INVALID_HANDLE`: an invalid handle was passed in. 65 * - `ERR_INVALID_HANDLE`: an invalid handle was passed in.
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index ecf32c18a..db104e8a2 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -7,7 +7,6 @@
7#include "common/common_funcs.h" 7#include "common/common_funcs.h"
8#include "common/common_types.h" 8#include "common/common_types.h"
9#include "core/hle/ipc_helpers.h" 9#include "core/hle/ipc_helpers.h"
10#include "core/hle/kernel/domain.h"
11#include "core/hle/kernel/handle_table.h" 10#include "core/hle/kernel/handle_table.h"
12#include "core/hle/kernel/hle_ipc.h" 11#include "core/hle/kernel/hle_ipc.h"
13#include "core/hle/kernel/kernel.h" 12#include "core/hle/kernel/kernel.h"
@@ -26,10 +25,6 @@ void SessionRequestHandler::ClientDisconnected(SharedPtr<ServerSession> server_s
26 boost::range::remove_erase(connected_sessions, server_session); 25 boost::range::remove_erase(connected_sessions, server_session);
27} 26}
28 27
29HLERequestContext::HLERequestContext(SharedPtr<Kernel::Domain> domain) : domain(std::move(domain)) {
30 cmd_buf[0] = 0;
31}
32
33HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session) 28HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session)
34 : server_session(std::move(server_session)) { 29 : server_session(std::move(server_session)) {
35 cmd_buf[0] = 0; 30 cmd_buf[0] = 0;
@@ -87,7 +82,7 @@ void HLERequestContext::ParseCommandBuffer(u32_le* src_cmdbuf, bool incoming) {
87 // Padding to align to 16 bytes 82 // Padding to align to 16 bytes
88 rp.AlignWithPadding(); 83 rp.AlignWithPadding();
89 84
90 if (IsDomain() && (command_header->type == IPC::CommandType::Request || !incoming)) { 85 if (Session()->IsDomain() && (command_header->type == IPC::CommandType::Request || !incoming)) {
91 // If this is an incoming message, only CommandType "Request" has a domain header 86 // If this is an incoming message, only CommandType "Request" has a domain header
92 // All outgoing domain messages have the domain header 87 // All outgoing domain messages have the domain header
93 domain_message_header = 88 domain_message_header =
@@ -200,12 +195,12 @@ ResultCode HLERequestContext::WriteToOutgoingCommandBuffer(u32_le* dst_cmdbuf, P
200 195
201 // TODO(Subv): Translate the X/A/B/W buffers. 196 // TODO(Subv): Translate the X/A/B/W buffers.
202 197
203 if (IsDomain()) { 198 if (Session()->IsDomain()) {
204 ASSERT(domain_message_header->num_objects == domain_objects.size()); 199 ASSERT(domain_message_header->num_objects == domain_objects.size());
205 // Write the domain objects to the command buffer, these go after the raw untranslated data. 200 // Write the domain objects to the command buffer, these go after the raw untranslated data.
206 // TODO(Subv): This completely ignores C buffers. 201 // TODO(Subv): This completely ignores C buffers.
207 size_t domain_offset = size - domain_message_header->num_objects; 202 size_t domain_offset = size - domain_message_header->num_objects;
208 auto& request_handlers = domain->request_handlers; 203 auto& request_handlers = server_session->domain_request_handlers;
209 204
210 for (auto& object : domain_objects) { 205 for (auto& object : domain_objects) {
211 request_handlers.emplace_back(object); 206 request_handlers.emplace_back(object);
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 80fa48d7f..da8335b35 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -86,7 +86,6 @@ protected:
86 */ 86 */
87class HLERequestContext { 87class HLERequestContext {
88public: 88public:
89 HLERequestContext(SharedPtr<Kernel::Domain> domain);
90 HLERequestContext(SharedPtr<Kernel::ServerSession> session); 89 HLERequestContext(SharedPtr<Kernel::ServerSession> session);
91 ~HLERequestContext(); 90 ~HLERequestContext();
92 91
@@ -96,17 +95,10 @@ public:
96 } 95 }
97 96
98 /** 97 /**
99 * Returns the domain through which this request was made.
100 */
101 const SharedPtr<Kernel::Domain>& Domain() const {
102 return domain;
103 }
104
105 /**
106 * Returns the session through which this request was made. This can be used as a map key to 98 * Returns the session through which this request was made. This can be used as a map key to
107 * access per-client data on services. 99 * access per-client data on services.
108 */ 100 */
109 const SharedPtr<Kernel::ServerSession>& ServerSession() const { 101 const SharedPtr<Kernel::ServerSession>& Session() const {
110 return server_session; 102 return server_session;
111 } 103 }
112 104
@@ -151,10 +143,6 @@ public:
151 return domain_message_header; 143 return domain_message_header;
152 } 144 }
153 145
154 bool IsDomain() const {
155 return domain != nullptr;
156 }
157
158 template <typename T> 146 template <typename T>
159 SharedPtr<T> GetCopyObject(size_t index) { 147 SharedPtr<T> GetCopyObject(size_t index) {
160 ASSERT(index < copy_objects.size()); 148 ASSERT(index < copy_objects.size());
@@ -187,9 +175,20 @@ public:
187 domain_objects.clear(); 175 domain_objects.clear();
188 } 176 }
189 177
178 size_t NumMoveObjects() const {
179 return move_objects.size();
180 }
181
182 size_t NumCopyObjects() const {
183 return copy_objects.size();
184 }
185
186 size_t NumDomainObjects() const {
187 return domain_objects.size();
188 }
189
190private: 190private:
191 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; 191 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
192 SharedPtr<Kernel::Domain> domain;
193 SharedPtr<Kernel::ServerSession> server_session; 192 SharedPtr<Kernel::ServerSession> server_session;
194 // TODO(yuriks): Check common usage of this and optimize size accordingly 193 // TODO(yuriks): Check common usage of this and optimize size accordingly
195 boost::container::small_vector<SharedPtr<Object>, 8> move_objects; 194 boost::container::small_vector<SharedPtr<Object>, 8> move_objects;
diff --git a/src/core/hle/kernel/kernel.h b/src/core/hle/kernel/kernel.h
index 4d9549e45..c77e58f3c 100644
--- a/src/core/hle/kernel/kernel.h
+++ b/src/core/hle/kernel/kernel.h
@@ -31,7 +31,6 @@ enum class HandleType : u32 {
31 ServerPort, 31 ServerPort,
32 ClientSession, 32 ClientSession,
33 ServerSession, 33 ServerSession,
34 Domain,
35}; 34};
36 35
37enum { 36enum {
@@ -84,27 +83,12 @@ public:
84 case HandleType::CodeSet: 83 case HandleType::CodeSet:
85 case HandleType::ClientPort: 84 case HandleType::ClientPort:
86 case HandleType::ClientSession: 85 case HandleType::ClientSession:
87 case HandleType::Domain:
88 return false; 86 return false;
89 } 87 }
90 88
91 UNREACHABLE(); 89 UNREACHABLE();
92 } 90 }
93 91
94 /**
95 * Check if svcSendSyncRequest can be called on the object
96 * @return True svcSendSyncRequest can be called on the object, otherwise false
97 */
98 bool IsSyncable() const {
99 switch (GetHandleType()) {
100 case HandleType::ClientSession:
101 case HandleType::Domain:
102 return true;
103 }
104
105 UNREACHABLE();
106 }
107
108public: 92public:
109 static unsigned int next_object_id; 93 static unsigned int next_object_id;
110 94
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index 09d02a691..54481f7f1 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -4,6 +4,7 @@
4 4
5#include <tuple> 5#include <tuple>
6 6
7#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/client_port.h" 8#include "core/hle/kernel/client_port.h"
8#include "core/hle/kernel/client_session.h" 9#include "core/hle/kernel/client_session.h"
9#include "core/hle/kernel/handle_table.h" 10#include "core/hle/kernel/handle_table.h"
@@ -61,6 +62,38 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
61 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or 62 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
62 // similar. 63 // similar.
63 64
65 Kernel::HLERequestContext context(this);
66 u32* cmd_buf = (u32*)Memory::GetPointer(thread->GetTLSAddress());
67 context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
68 Kernel::g_handle_table);
69
70 // If the session has been converted to a domain, handle the doomain request
71 if (IsDomain()) {
72 auto& domain_message_header = context.GetDomainMessageHeader();
73 if (domain_message_header) {
74 // If there is a DomainMessageHeader, then this is CommandType "Request"
75 const u32 object_id{context.GetDomainMessageHeader()->object_id};
76 switch (domain_message_header->command) {
77 case IPC::DomainMessageHeader::CommandType::SendMessage:
78 return domain_request_handlers[object_id - 1]->HandleSyncRequest(context);
79
80 case IPC::DomainMessageHeader::CommandType::CloseVirtualHandle: {
81 LOG_DEBUG(IPC, "CloseVirtualHandle, object_id=0x%08X", object_id);
82
83 domain_request_handlers[object_id - 1] = nullptr;
84
85 IPC::ResponseBuilder rb{context, 2};
86 rb.Push(RESULT_SUCCESS);
87 return RESULT_SUCCESS;
88 }
89 }
90
91 LOG_CRITICAL(IPC, "Unknown domain command=%d", domain_message_header->command.Value());
92 ASSERT(false);
93 }
94 // If there is no domain header, the regular session handler is used
95 }
96
64 // If this ServerSession has an associated HLE handler, forward the request to it. 97 // If this ServerSession has an associated HLE handler, forward the request to it.
65 ResultCode result{RESULT_SUCCESS}; 98 ResultCode result{RESULT_SUCCESS};
66 if (hle_handler != nullptr) { 99 if (hle_handler != nullptr) {
@@ -69,11 +102,6 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
69 if (translate_result.IsError()) 102 if (translate_result.IsError())
70 return translate_result; 103 return translate_result;
71 104
72 Kernel::HLERequestContext context(this);
73 u32* cmd_buf = (u32*)Memory::GetPointer(Kernel::GetCurrentThread()->GetTLSAddress());
74 context.PopulateFromIncomingCommandBuffer(cmd_buf, *Kernel::g_current_process,
75 Kernel::g_handle_table);
76
77 result = hle_handler->HandleSyncRequest(context); 105 result = hle_handler->HandleSyncRequest(context);
78 } else { 106 } else {
79 // Add the thread to the list of threads that have issued a sync request with this 107 // Add the thread to the list of threads that have issued a sync request with this
@@ -84,6 +112,15 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
84 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting 112 // If this ServerSession does not have an HLE implementation, just wake up the threads waiting
85 // on it. 113 // on it.
86 WakeupAllWaitingThreads(); 114 WakeupAllWaitingThreads();
115
116 // Handle scenario when ConvertToDomain command was issued, as we must do the conversion at the
117 // end of the command such that only commands following this one are handled as domains
118 if (convert_to_domain) {
119 ASSERT_MSG(domain_request_handlers.empty(), "already a domain");
120 domain_request_handlers = {hle_handler};
121 convert_to_domain = false;
122 }
123
87 return result; 124 return result;
88} 125}
89 126
diff --git a/src/core/hle/kernel/server_session.h b/src/core/hle/kernel/server_session.h
index 6ff4ef8c1..144692106 100644
--- a/src/core/hle/kernel/server_session.h
+++ b/src/core/hle/kernel/server_session.h
@@ -79,7 +79,10 @@ public:
79 std::string name; ///< The name of this session (optional) 79 std::string name; ///< The name of this session (optional)
80 std::shared_ptr<Session> parent; ///< The parent session, which links to the client endpoint. 80 std::shared_ptr<Session> parent; ///< The parent session, which links to the client endpoint.
81 std::shared_ptr<SessionRequestHandler> 81 std::shared_ptr<SessionRequestHandler>
82 hle_handler; ///< This session's HLE request handler (optional) 82 hle_handler; ///< This session's HLE request handler (applicable when not a domain)
83
84 /// This is the list of domain request handlers (after conversion to a domain)
85 std::vector<std::shared_ptr<SessionRequestHandler>> domain_request_handlers;
83 86
84 /// List of threads that are pending a response after a sync request. This list is processed in 87 /// List of threads that are pending a response after a sync request. This list is processed in
85 /// a LIFO manner, thus, the last request will be dispatched first. 88 /// a LIFO manner, thus, the last request will be dispatched first.
@@ -91,6 +94,16 @@ public:
91 /// TODO(Subv): Find a better name for this. 94 /// TODO(Subv): Find a better name for this.
92 SharedPtr<Thread> currently_handling; 95 SharedPtr<Thread> currently_handling;
93 96
97 /// Returns true if the session has been converted to a domain, otherwise False
98 bool IsDomain() const {
99 return !domain_request_handlers.empty();
100 }
101
102 /// Converts the session to a domain at the end of the current command
103 void ConvertToDomain() {
104 convert_to_domain = true;
105 }
106
94private: 107private:
95 ServerSession(); 108 ServerSession();
96 ~ServerSession() override; 109 ~ServerSession() override;
@@ -102,6 +115,9 @@ private:
102 * @return The created server session 115 * @return The created server session
103 */ 116 */
104 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown"); 117 static ResultVal<SharedPtr<ServerSession>> Create(std::string name = "Unknown");
118
119 /// When set to True, converts the session to a domain at the end of the command
120 bool convert_to_domain{};
105}; 121};
106 122
107/** 123/**
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp
index 516309036..4c0276cf0 100644
--- a/src/core/hle/kernel/svc.cpp
+++ b/src/core/hle/kernel/svc.cpp
@@ -20,7 +20,6 @@
20#include "core/hle/kernel/shared_memory.h" 20#include "core/hle/kernel/shared_memory.h"
21#include "core/hle/kernel/svc.h" 21#include "core/hle/kernel/svc.h"
22#include "core/hle/kernel/svc_wrap.h" 22#include "core/hle/kernel/svc_wrap.h"
23#include "core/hle/kernel/sync_object.h"
24#include "core/hle/kernel/thread.h" 23#include "core/hle/kernel/thread.h"
25#include "core/hle/lock.h" 24#include "core/hle/lock.h"
26#include "core/hle/result.h" 25#include "core/hle/result.h"
@@ -87,7 +86,7 @@ static ResultCode ConnectToNamedPort(Handle* out_handle, VAddr port_name_address
87 86
88/// Makes a blocking IPC call to an OS service. 87/// Makes a blocking IPC call to an OS service.
89static ResultCode SendSyncRequest(Handle handle) { 88static ResultCode SendSyncRequest(Handle handle) {
90 SharedPtr<SyncObject> session = g_handle_table.Get<SyncObject>(handle); 89 SharedPtr<ClientSession> session = g_handle_table.Get<ClientSession>(handle);
91 if (!session) { 90 if (!session) {
92 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle); 91 LOG_ERROR(Kernel_SVC, "called with invalid handle=0x%08X", handle);
93 return ERR_INVALID_HANDLE; 92 return ERR_INVALID_HANDLE;
diff --git a/src/core/hle/kernel/sync_object.h b/src/core/hle/kernel/sync_object.h
deleted file mode 100644
index f2befa2ea..000000000
--- a/src/core/hle/kernel/sync_object.h
+++ /dev/null
@@ -1,35 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <boost/smart_ptr/intrusive_ptr.hpp>
8#include "core/hle/kernel/kernel.h"
9#include "core/hle/result.h"
10
11namespace Kernel {
12
13class Thread;
14
15/// Class that represents a Kernel object that svcSendSyncRequest can be called on
16class SyncObject : public Object {
17public:
18 /**
19 * Handle a sync request from the emulated application.
20 * @param thread Thread that initiated the request.
21 * @returns ResultCode from the operation.
22 */
23 virtual ResultCode SendSyncRequest(SharedPtr<Thread> thread) = 0;
24};
25
26// Specialization of DynamicObjectCast for SyncObjects
27template <>
28inline SharedPtr<SyncObject> DynamicObjectCast<SyncObject>(SharedPtr<Object> object) {
29 if (object != nullptr && object->IsSyncable()) {
30 return boost::static_pointer_cast<SyncObject>(std::move(object));
31 }
32 return nullptr;
33}
34
35} // namespace Kernel