diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/k_address_arbiter.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_condition_variable.cpp | 22 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_server_session.cpp | 2 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 7 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.h | 12 | ||||
| -rw-r--r-- | src/core/hle/kernel/svc.cpp | 3 |
6 files changed, 21 insertions, 41 deletions
diff --git a/src/core/hle/kernel/k_address_arbiter.cpp b/src/core/hle/kernel/k_address_arbiter.cpp index 6771ef621..c5c81a880 100644 --- a/src/core/hle/kernel/k_address_arbiter.cpp +++ b/src/core/hle/kernel/k_address_arbiter.cpp | |||
| @@ -97,7 +97,7 @@ ResultCode KAddressArbiter::Signal(VAddr addr, s32 count) { | |||
| 97 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 97 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 98 | (it->GetAddressArbiterKey() == addr)) { | 98 | (it->GetAddressArbiterKey() == addr)) { |
| 99 | KThread* target_thread = std::addressof(*it); | 99 | KThread* target_thread = std::addressof(*it); |
| 100 | target_thread->SetSyncedObject(nullptr, ResultSuccess); | 100 | target_thread->SetWaitResult(ResultSuccess); |
| 101 | 101 | ||
| 102 | ASSERT(target_thread->IsWaitingForAddressArbiter()); | 102 | ASSERT(target_thread->IsWaitingForAddressArbiter()); |
| 103 | target_thread->Wakeup(); | 103 | target_thread->Wakeup(); |
| @@ -130,7 +130,7 @@ ResultCode KAddressArbiter::SignalAndIncrementIfEqual(VAddr addr, s32 value, s32 | |||
| 130 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 130 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 131 | (it->GetAddressArbiterKey() == addr)) { | 131 | (it->GetAddressArbiterKey() == addr)) { |
| 132 | KThread* target_thread = std::addressof(*it); | 132 | KThread* target_thread = std::addressof(*it); |
| 133 | target_thread->SetSyncedObject(nullptr, ResultSuccess); | 133 | target_thread->SetWaitResult(ResultSuccess); |
| 134 | 134 | ||
| 135 | ASSERT(target_thread->IsWaitingForAddressArbiter()); | 135 | ASSERT(target_thread->IsWaitingForAddressArbiter()); |
| 136 | target_thread->Wakeup(); | 136 | target_thread->Wakeup(); |
| @@ -198,7 +198,7 @@ ResultCode KAddressArbiter::SignalAndModifyByWaitingCountIfEqual(VAddr addr, s32 | |||
| 198 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && | 198 | while ((it != thread_tree.end()) && (count <= 0 || num_waiters < count) && |
| 199 | (it->GetAddressArbiterKey() == addr)) { | 199 | (it->GetAddressArbiterKey() == addr)) { |
| 200 | KThread* target_thread = std::addressof(*it); | 200 | KThread* target_thread = std::addressof(*it); |
| 201 | target_thread->SetSyncedObject(nullptr, ResultSuccess); | 201 | target_thread->SetWaitResult(ResultSuccess); |
| 202 | 202 | ||
| 203 | ASSERT(target_thread->IsWaitingForAddressArbiter()); | 203 | ASSERT(target_thread->IsWaitingForAddressArbiter()); |
| 204 | target_thread->Wakeup(); | 204 | target_thread->Wakeup(); |
| @@ -225,7 +225,7 @@ ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement | |||
| 225 | } | 225 | } |
| 226 | 226 | ||
| 227 | // Set the synced object. | 227 | // Set the synced object. |
| 228 | cur_thread->SetSyncedObject(nullptr, ResultTimedOut); | 228 | cur_thread->SetWaitResult(ResultTimedOut); |
| 229 | 229 | ||
| 230 | // Read the value from userspace. | 230 | // Read the value from userspace. |
| 231 | s32 user_value{}; | 231 | s32 user_value{}; |
| @@ -274,8 +274,7 @@ ResultCode KAddressArbiter::WaitIfLessThan(VAddr addr, s32 value, bool decrement | |||
| 274 | } | 274 | } |
| 275 | 275 | ||
| 276 | // Get the result. | 276 | // Get the result. |
| 277 | KSynchronizationObject* dummy{}; | 277 | return cur_thread->GetWaitResult(); |
| 278 | return cur_thread->GetWaitResult(&dummy); | ||
| 279 | } | 278 | } |
| 280 | 279 | ||
| 281 | ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { | 280 | ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { |
| @@ -292,7 +291,7 @@ ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { | |||
| 292 | } | 291 | } |
| 293 | 292 | ||
| 294 | // Set the synced object. | 293 | // Set the synced object. |
| 295 | cur_thread->SetSyncedObject(nullptr, ResultTimedOut); | 294 | cur_thread->SetWaitResult(ResultTimedOut); |
| 296 | 295 | ||
| 297 | // Read the value from userspace. | 296 | // Read the value from userspace. |
| 298 | s32 user_value{}; | 297 | s32 user_value{}; |
| @@ -334,8 +333,7 @@ ResultCode KAddressArbiter::WaitIfEqual(VAddr addr, s32 value, s64 timeout) { | |||
| 334 | } | 333 | } |
| 335 | 334 | ||
| 336 | // Get the result. | 335 | // Get the result. |
| 337 | KSynchronizationObject* dummy{}; | 336 | return cur_thread->GetWaitResult(); |
| 338 | return cur_thread->GetWaitResult(&dummy); | ||
| 339 | } | 337 | } |
| 340 | 338 | ||
| 341 | } // namespace Kernel | 339 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/k_condition_variable.cpp b/src/core/hle/kernel/k_condition_variable.cpp index ed6f328fc..9eacbed7e 100644 --- a/src/core/hle/kernel/k_condition_variable.cpp +++ b/src/core/hle/kernel/k_condition_variable.cpp | |||
| @@ -84,14 +84,14 @@ ResultCode KConditionVariable::SignalToAddress(VAddr addr) { | |||
| 84 | next_value |= Svc::HandleWaitMask; | 84 | next_value |= Svc::HandleWaitMask; |
| 85 | } | 85 | } |
| 86 | 86 | ||
| 87 | next_owner_thread->SetSyncedObject(nullptr, ResultSuccess); | 87 | next_owner_thread->SetWaitResult(ResultSuccess); |
| 88 | next_owner_thread->Wakeup(); | 88 | next_owner_thread->Wakeup(); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | // Write the value to userspace. | 91 | // Write the value to userspace. |
| 92 | if (!WriteToUser(system, addr, std::addressof(next_value))) { | 92 | if (!WriteToUser(system, addr, std::addressof(next_value))) { |
| 93 | if (next_owner_thread) { | 93 | if (next_owner_thread) { |
| 94 | next_owner_thread->SetSyncedObject(nullptr, ResultInvalidCurrentMemory); | 94 | next_owner_thread->SetWaitResult(ResultInvalidCurrentMemory); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| 97 | return ResultInvalidCurrentMemory; | 97 | return ResultInvalidCurrentMemory; |
| @@ -110,7 +110,7 @@ ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 val | |||
| 110 | ASSERT(owner_thread.IsNull()); | 110 | ASSERT(owner_thread.IsNull()); |
| 111 | { | 111 | { |
| 112 | KScopedSchedulerLock sl(kernel); | 112 | KScopedSchedulerLock sl(kernel); |
| 113 | cur_thread->SetSyncedObject(nullptr, ResultSuccess); | 113 | cur_thread->SetWaitResult(ResultSuccess); |
| 114 | 114 | ||
| 115 | // Check if the thread should terminate. | 115 | // Check if the thread should terminate. |
| 116 | R_UNLESS(!cur_thread->IsTerminationRequested(), ResultTerminationRequested); | 116 | R_UNLESS(!cur_thread->IsTerminationRequested(), ResultTerminationRequested); |
| @@ -151,8 +151,7 @@ ResultCode KConditionVariable::WaitForAddress(Handle handle, VAddr addr, u32 val | |||
| 151 | } | 151 | } |
| 152 | 152 | ||
| 153 | // Get the wait result. | 153 | // Get the wait result. |
| 154 | KSynchronizationObject* dummy{}; | 154 | return cur_thread->GetWaitResult(); |
| 155 | return cur_thread->GetWaitResult(std::addressof(dummy)); | ||
| 156 | } | 155 | } |
| 157 | 156 | ||
| 158 | KThread* KConditionVariable::SignalImpl(KThread* thread) { | 157 | KThread* KConditionVariable::SignalImpl(KThread* thread) { |
| @@ -179,7 +178,7 @@ KThread* KConditionVariable::SignalImpl(KThread* thread) { | |||
| 179 | if (can_access) { | 178 | if (can_access) { |
| 180 | if (prev_tag == Svc::InvalidHandle) { | 179 | if (prev_tag == Svc::InvalidHandle) { |
| 181 | // If nobody held the lock previously, we're all good. | 180 | // If nobody held the lock previously, we're all good. |
| 182 | thread->SetSyncedObject(nullptr, ResultSuccess); | 181 | thread->SetWaitResult(ResultSuccess); |
| 183 | thread->Wakeup(); | 182 | thread->Wakeup(); |
| 184 | } else { | 183 | } else { |
| 185 | // Get the previous owner. | 184 | // Get the previous owner. |
| @@ -195,13 +194,13 @@ KThread* KConditionVariable::SignalImpl(KThread* thread) { | |||
| 195 | thread_to_close = owner_thread; | 194 | thread_to_close = owner_thread; |
| 196 | } else { | 195 | } else { |
| 197 | // The lock was tagged with a thread that doesn't exist. | 196 | // The lock was tagged with a thread that doesn't exist. |
| 198 | thread->SetSyncedObject(nullptr, ResultInvalidState); | 197 | thread->SetWaitResult(ResultInvalidState); |
| 199 | thread->Wakeup(); | 198 | thread->Wakeup(); |
| 200 | } | 199 | } |
| 201 | } | 200 | } |
| 202 | } else { | 201 | } else { |
| 203 | // If the address wasn't accessible, note so. | 202 | // If the address wasn't accessible, note so. |
| 204 | thread->SetSyncedObject(nullptr, ResultInvalidCurrentMemory); | 203 | thread->SetWaitResult(ResultInvalidCurrentMemory); |
| 205 | thread->Wakeup(); | 204 | thread->Wakeup(); |
| 206 | } | 205 | } |
| 207 | 206 | ||
| @@ -265,7 +264,7 @@ ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) | |||
| 265 | KScopedSchedulerLockAndSleep slp{kernel, cur_thread, timeout}; | 264 | KScopedSchedulerLockAndSleep slp{kernel, cur_thread, timeout}; |
| 266 | 265 | ||
| 267 | // Set the synced object. | 266 | // Set the synced object. |
| 268 | cur_thread->SetSyncedObject(nullptr, ResultTimedOut); | 267 | cur_thread->SetWaitResult(ResultTimedOut); |
| 269 | 268 | ||
| 270 | // Check that the thread isn't terminating. | 269 | // Check that the thread isn't terminating. |
| 271 | if (cur_thread->IsTerminationRequested()) { | 270 | if (cur_thread->IsTerminationRequested()) { |
| @@ -290,7 +289,7 @@ ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) | |||
| 290 | } | 289 | } |
| 291 | 290 | ||
| 292 | // Wake up the next owner. | 291 | // Wake up the next owner. |
| 293 | next_owner_thread->SetSyncedObject(nullptr, ResultSuccess); | 292 | next_owner_thread->SetWaitResult(ResultSuccess); |
| 294 | next_owner_thread->Wakeup(); | 293 | next_owner_thread->Wakeup(); |
| 295 | } | 294 | } |
| 296 | 295 | ||
| @@ -340,8 +339,7 @@ ResultCode KConditionVariable::Wait(VAddr addr, u64 key, u32 value, s64 timeout) | |||
| 340 | } | 339 | } |
| 341 | 340 | ||
| 342 | // Get the result. | 341 | // Get the result. |
| 343 | KSynchronizationObject* dummy{}; | 342 | return cur_thread->GetWaitResult(); |
| 344 | return cur_thread->GetWaitResult(std::addressof(dummy)); | ||
| 345 | } | 343 | } |
| 346 | 344 | ||
| 347 | } // namespace Kernel | 345 | } // namespace Kernel |
diff --git a/src/core/hle/kernel/k_server_session.cpp b/src/core/hle/kernel/k_server_session.cpp index 2bd53ccbd..1f7220d48 100644 --- a/src/core/hle/kernel/k_server_session.cpp +++ b/src/core/hle/kernel/k_server_session.cpp | |||
| @@ -176,7 +176,7 @@ ResultCode KServerSession::CompleteSyncRequest(HLERequestContext& context) { | |||
| 176 | KScopedSchedulerLock lock(kernel); | 176 | KScopedSchedulerLock lock(kernel); |
| 177 | if (!context.IsThreadWaiting()) { | 177 | if (!context.IsThreadWaiting()) { |
| 178 | context.GetThread().Wakeup(); | 178 | context.GetThread().Wakeup(); |
| 179 | context.GetThread().SetSyncedObject(nullptr, result); | 179 | context.GetThread().SetWaitResult(result); |
| 180 | } | 180 | } |
| 181 | } | 181 | } |
| 182 | 182 | ||
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 3331b4845..2c1f29bad 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -130,9 +130,6 @@ ResultCode KThread::Initialize(KThreadFunction func, uintptr_t arg, VAddr user_s | |||
| 130 | priority = prio; | 130 | priority = prio; |
| 131 | base_priority = prio; | 131 | base_priority = prio; |
| 132 | 132 | ||
| 133 | // Set sync object and waiting lock to null. | ||
| 134 | synced_object = nullptr; | ||
| 135 | |||
| 136 | // Initialize sleeping queue. | 133 | // Initialize sleeping queue. |
| 137 | sleeping_queue = nullptr; | 134 | sleeping_queue = nullptr; |
| 138 | 135 | ||
| @@ -279,7 +276,7 @@ void KThread::Finalize() { | |||
| 279 | while (it != waiter_list.end()) { | 276 | while (it != waiter_list.end()) { |
| 280 | // The thread shouldn't be a kernel waiter. | 277 | // The thread shouldn't be a kernel waiter. |
| 281 | it->SetLockOwner(nullptr); | 278 | it->SetLockOwner(nullptr); |
| 282 | it->SetSyncedObject(nullptr, ResultInvalidState); | 279 | it->SetWaitResult(ResultInvalidState); |
| 283 | it->Wakeup(); | 280 | it->Wakeup(); |
| 284 | it = waiter_list.erase(it); | 281 | it = waiter_list.erase(it); |
| 285 | } | 282 | } |
| @@ -650,7 +647,7 @@ void KThread::WaitCancel() { | |||
| 650 | sleeping_queue->WakeupThread(this); | 647 | sleeping_queue->WakeupThread(this); |
| 651 | wait_cancelled = true; | 648 | wait_cancelled = true; |
| 652 | } else { | 649 | } else { |
| 653 | SetSyncedObject(nullptr, ResultCancelled); | 650 | SetWaitResult(ResultCancelled); |
| 654 | SetState(ThreadState::Runnable); | 651 | SetState(ThreadState::Runnable); |
| 655 | wait_cancelled = false; | 652 | wait_cancelled = false; |
| 656 | } | 653 | } |
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index bea5fd84d..f9a324eb3 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -197,11 +197,6 @@ public: | |||
| 197 | 197 | ||
| 198 | void Suspend(); | 198 | void Suspend(); |
| 199 | 199 | ||
| 200 | void SetSyncedObject(KSynchronizationObject* obj, ResultCode wait_res) { | ||
| 201 | synced_object = obj; | ||
| 202 | wait_result = wait_res; | ||
| 203 | } | ||
| 204 | |||
| 205 | constexpr void SetSyncedIndex(s32 index) { | 200 | constexpr void SetSyncedIndex(s32 index) { |
| 206 | synced_index = index; | 201 | synced_index = index; |
| 207 | } | 202 | } |
| @@ -212,18 +207,12 @@ public: | |||
| 212 | 207 | ||
| 213 | constexpr void SetWaitResult(ResultCode wait_res) { | 208 | constexpr void SetWaitResult(ResultCode wait_res) { |
| 214 | wait_result = wait_res; | 209 | wait_result = wait_res; |
| 215 | synced_object = nullptr; | ||
| 216 | } | 210 | } |
| 217 | 211 | ||
| 218 | constexpr ResultCode GetWaitResult() const { | 212 | constexpr ResultCode GetWaitResult() const { |
| 219 | return wait_result; | 213 | return wait_result; |
| 220 | } | 214 | } |
| 221 | 215 | ||
| 222 | [[nodiscard]] ResultCode GetWaitResult(KSynchronizationObject** out) const { | ||
| 223 | *out = synced_object; | ||
| 224 | return wait_result; | ||
| 225 | } | ||
| 226 | |||
| 227 | /* | 216 | /* |
| 228 | * Returns the Thread Local Storage address of the current thread | 217 | * Returns the Thread Local Storage address of the current thread |
| 229 | * @returns VAddr of the thread's TLS | 218 | * @returns VAddr of the thread's TLS |
| @@ -716,7 +705,6 @@ private: | |||
| 716 | KAffinityMask physical_affinity_mask{}; | 705 | KAffinityMask physical_affinity_mask{}; |
| 717 | u64 thread_id{}; | 706 | u64 thread_id{}; |
| 718 | std::atomic<s64> cpu_time{}; | 707 | std::atomic<s64> cpu_time{}; |
| 719 | KSynchronizationObject* synced_object{}; | ||
| 720 | VAddr address_key{}; | 708 | VAddr address_key{}; |
| 721 | KProcess* parent{}; | 709 | KProcess* parent{}; |
| 722 | VAddr kernel_stack_top{}; | 710 | VAddr kernel_stack_top{}; |
diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index e5e879eb5..50c6e513d 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp | |||
| @@ -325,8 +325,7 @@ static ResultCode SendSyncRequest(Core::System& system, Handle handle) { | |||
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | 327 | ||
| 328 | KSynchronizationObject* dummy{}; | 328 | return thread->GetWaitResult(); |
| 329 | return thread->GetWaitResult(std::addressof(dummy)); | ||
| 330 | } | 329 | } |
| 331 | 330 | ||
| 332 | static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { | 331 | static ResultCode SendSyncRequest32(Core::System& system, Handle handle) { |