summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel
diff options
context:
space:
mode:
authorGravatar Weiyi Wang2019-04-02 12:30:03 -0400
committerGravatar fearlessTobi2019-05-18 19:53:39 +0200
commit8d6342384b3932e18e98c223debd192ae1b73216 (patch)
tree72f22cdf74ea9a55fa1e5590b185fc5f96300bec /src/core/hle/kernel
parentMerge pull request #2457 from lioncash/about (diff)
downloadyuzu-8d6342384b3932e18e98c223debd192ae1b73216.tar.gz
yuzu-8d6342384b3932e18e98c223debd192ae1b73216.tar.xz
yuzu-8d6342384b3932e18e98c223debd192ae1b73216.zip
HLE/IPC: HLEContext can memorize the client thread and use it for SleepClientThread
This reduces the boilerplate that services have to write out the current thread explicitly. Using current thread instead of client thread is also semantically incorrect, and will be a problem when we implement multicore (at which time there will be multiple current threads)
Diffstat (limited to 'src/core/hle/kernel')
-rw-r--r--src/core/hle/kernel/hle_ipc.cpp7
-rw-r--r--src/core/hle/kernel/hle_ipc.h8
-rw-r--r--src/core/hle/kernel/server_session.cpp2
3 files changed, 9 insertions, 8 deletions
diff --git a/src/core/hle/kernel/hle_ipc.cpp b/src/core/hle/kernel/hle_ipc.cpp
index fe710eb6e..182f6f792 100644
--- a/src/core/hle/kernel/hle_ipc.cpp
+++ b/src/core/hle/kernel/hle_ipc.cpp
@@ -43,7 +43,7 @@ void SessionRequestHandler::ClientDisconnected(const SharedPtr<ServerSession>& s
43} 43}
44 44
45SharedPtr<WritableEvent> HLERequestContext::SleepClientThread( 45SharedPtr<WritableEvent> HLERequestContext::SleepClientThread(
46 SharedPtr<Thread> thread, const std::string& reason, u64 timeout, WakeupCallback&& callback, 46 const std::string& reason, u64 timeout, WakeupCallback&& callback,
47 SharedPtr<WritableEvent> writable_event) { 47 SharedPtr<WritableEvent> writable_event) {
48 // Put the client thread to sleep until the wait event is signaled or the timeout expires. 48 // Put the client thread to sleep until the wait event is signaled or the timeout expires.
49 thread->SetWakeupCallback([context = *this, callback]( 49 thread->SetWakeupCallback([context = *this, callback](
@@ -76,8 +76,9 @@ SharedPtr<WritableEvent> HLERequestContext::SleepClientThread(
76 return writable_event; 76 return writable_event;
77} 77}
78 78
79HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session) 79HLERequestContext::HLERequestContext(SharedPtr<Kernel::ServerSession> server_session,
80 : server_session(std::move(server_session)) { 80 SharedPtr<Thread> thread)
81 : server_session(std::move(server_session)), thread(thread) {
81 cmd_buf[0] = 0; 82 cmd_buf[0] = 0;
82} 83}
83 84
diff --git a/src/core/hle/kernel/hle_ipc.h b/src/core/hle/kernel/hle_ipc.h
index 2bdd9f02c..ccf5e56aa 100644
--- a/src/core/hle/kernel/hle_ipc.h
+++ b/src/core/hle/kernel/hle_ipc.h
@@ -97,7 +97,7 @@ protected:
97 */ 97 */
98class HLERequestContext { 98class HLERequestContext {
99public: 99public:
100 explicit HLERequestContext(SharedPtr<ServerSession> session); 100 explicit HLERequestContext(SharedPtr<ServerSession> session, SharedPtr<Thread> thread);
101 ~HLERequestContext(); 101 ~HLERequestContext();
102 102
103 /// Returns a pointer to the IPC command buffer for this request. 103 /// Returns a pointer to the IPC command buffer for this request.
@@ -119,7 +119,6 @@ public:
119 /** 119 /**
120 * Puts the specified guest thread to sleep until the returned event is signaled or until the 120 * Puts the specified guest thread to sleep until the returned event is signaled or until the
121 * specified timeout expires. 121 * specified timeout expires.
122 * @param thread Thread to be put to sleep.
123 * @param reason Reason for pausing the thread, to be used for debugging purposes. 122 * @param reason Reason for pausing the thread, to be used for debugging purposes.
124 * @param timeout Timeout in nanoseconds after which the thread will be awoken and the callback 123 * @param timeout Timeout in nanoseconds after which the thread will be awoken and the callback
125 * invoked with a Timeout reason. 124 * invoked with a Timeout reason.
@@ -130,8 +129,8 @@ public:
130 * created. 129 * created.
131 * @returns Event that when signaled will resume the thread and call the callback function. 130 * @returns Event that when signaled will resume the thread and call the callback function.
132 */ 131 */
133 SharedPtr<WritableEvent> SleepClientThread(SharedPtr<Thread> thread, const std::string& reason, 132 SharedPtr<WritableEvent> SleepClientThread(const std::string& reason, u64 timeout,
134 u64 timeout, WakeupCallback&& callback, 133 WakeupCallback&& callback,
135 SharedPtr<WritableEvent> writable_event = nullptr); 134 SharedPtr<WritableEvent> writable_event = nullptr);
136 135
137 /// Populates this context with data from the requesting process/thread. 136 /// Populates this context with data from the requesting process/thread.
@@ -268,6 +267,7 @@ private:
268 267
269 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf; 268 std::array<u32, IPC::COMMAND_BUFFER_LENGTH> cmd_buf;
270 SharedPtr<Kernel::ServerSession> server_session; 269 SharedPtr<Kernel::ServerSession> server_session;
270 SharedPtr<Thread> thread;
271 // TODO(yuriks): Check common usage of this and optimize size accordingly 271 // TODO(yuriks): Check common usage of this and optimize size accordingly
272 boost::container::small_vector<SharedPtr<Object>, 8> move_objects; 272 boost::container::small_vector<SharedPtr<Object>, 8> move_objects;
273 boost::container::small_vector<SharedPtr<Object>, 8> copy_objects; 273 boost::container::small_vector<SharedPtr<Object>, 8> copy_objects;
diff --git a/src/core/hle/kernel/server_session.cpp b/src/core/hle/kernel/server_session.cpp
index 696a82cd9..30b2bfb5a 100644
--- a/src/core/hle/kernel/server_session.cpp
+++ b/src/core/hle/kernel/server_session.cpp
@@ -130,7 +130,7 @@ ResultCode ServerSession::HandleSyncRequest(SharedPtr<Thread> thread) {
130 // The ServerSession received a sync request, this means that there's new data available 130 // The ServerSession received a sync request, this means that there's new data available
131 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or 131 // from its ClientSession, so wake up any threads that may be waiting on a svcReplyAndReceive or
132 // similar. 132 // similar.
133 Kernel::HLERequestContext context(this); 133 Kernel::HLERequestContext context(this, thread);
134 u32* cmd_buf = (u32*)Memory::GetPointer(thread->GetTLSAddress()); 134 u32* cmd_buf = (u32*)Memory::GetPointer(thread->GetTLSAddress());
135 context.PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf); 135 context.PopulateFromIncomingCommandBuffer(kernel.CurrentProcess()->GetHandleTable(), cmd_buf);
136 136