diff options
| author | 2015-01-31 14:23:09 -0200 | |
|---|---|---|
| committer | 2015-02-02 15:37:03 -0200 | |
| commit | a9b86db3cfec5ce907051d6730ffd98c0fd03876 (patch) | |
| tree | 791877de9d2a746a5a73e32a3bb3110670cff91a /src/core/hle/kernel/thread.cpp | |
| parent | Kernel: Remove previous scheduled event when a Timer is re-Set (diff) | |
| download | yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.gz yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.tar.xz yuzu-a9b86db3cfec5ce907051d6730ffd98c0fd03876.zip | |
Kernel: Use separate Handle tables for CoreTiming userdata
This is to support the removal of GetHandle soon
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 1ea5589cb..72a14bfac 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -4,7 +4,6 @@ | |||
| 4 | 4 | ||
| 5 | #include <algorithm> | 5 | #include <algorithm> |
| 6 | #include <list> | 6 | #include <list> |
| 7 | #include <map> | ||
| 8 | #include <vector> | 7 | #include <vector> |
| 9 | 8 | ||
| 10 | #include "common/common.h" | 9 | #include "common/common.h" |
| @@ -228,13 +227,15 @@ void WaitCurrentThread_ArbitrateAddress(VAddr wait_address) { | |||
| 228 | 227 | ||
| 229 | /// Event type for the thread wake up event | 228 | /// Event type for the thread wake up event |
| 230 | static int ThreadWakeupEventType = -1; | 229 | static int ThreadWakeupEventType = -1; |
| 230 | // TODO(yuriks): This can be removed if Thread objects are explicitly pooled in the future, allowing | ||
| 231 | // us to simply use a pool index or similar. | ||
| 232 | static Kernel::HandleTable wakeup_callback_handle_table; | ||
| 231 | 233 | ||
| 232 | /// Callback that will wake up the thread it was scheduled for | 234 | /// Callback that will wake up the thread it was scheduled for |
| 233 | static void ThreadWakeupCallback(u64 parameter, int cycles_late) { | 235 | static void ThreadWakeupCallback(u64 thread_handle, int cycles_late) { |
| 234 | Handle handle = static_cast<Handle>(parameter); | 236 | SharedPtr<Thread> thread = wakeup_callback_handle_table.Get<Thread>((Handle)thread_handle); |
| 235 | SharedPtr<Thread> thread = Kernel::g_handle_table.Get<Thread>(handle); | ||
| 236 | if (thread == nullptr) { | 237 | if (thread == nullptr) { |
| 237 | LOG_ERROR(Kernel, "Thread doesn't exist %u", handle); | 238 | LOG_CRITICAL(Kernel, "Callback fired for invalid thread %08X", thread_handle); |
| 238 | return; | 239 | return; |
| 239 | } | 240 | } |
| 240 | 241 | ||
| @@ -254,7 +255,7 @@ void Thread::WakeAfterDelay(s64 nanoseconds) { | |||
| 254 | return; | 255 | return; |
| 255 | 256 | ||
| 256 | u64 microseconds = nanoseconds / 1000; | 257 | u64 microseconds = nanoseconds / 1000; |
| 257 | CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, GetHandle()); | 258 | CoreTiming::ScheduleEvent(usToCycles(microseconds), ThreadWakeupEventType, callback_handle); |
| 258 | } | 259 | } |
| 259 | 260 | ||
| 260 | void Thread::ReleaseWaitObject(WaitObject* wait_object) { | 261 | void Thread::ReleaseWaitObject(WaitObject* wait_object) { |
| @@ -301,7 +302,7 @@ void Thread::ReleaseWaitObject(WaitObject* wait_object) { | |||
| 301 | 302 | ||
| 302 | void Thread::ResumeFromWait() { | 303 | void Thread::ResumeFromWait() { |
| 303 | // Cancel any outstanding wakeup events | 304 | // Cancel any outstanding wakeup events |
| 304 | CoreTiming::UnscheduleEvent(ThreadWakeupEventType, GetHandle()); | 305 | CoreTiming::UnscheduleEvent(ThreadWakeupEventType, callback_handle); |
| 305 | 306 | ||
| 306 | status &= ~THREADSTATUS_WAIT; | 307 | status &= ~THREADSTATUS_WAIT; |
| 307 | 308 | ||
| @@ -384,6 +385,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, | |||
| 384 | thread->wait_objects.clear(); | 385 | thread->wait_objects.clear(); |
| 385 | thread->wait_address = 0; | 386 | thread->wait_address = 0; |
| 386 | thread->name = std::move(name); | 387 | thread->name = std::move(name); |
| 388 | thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom(); | ||
| 387 | 389 | ||
| 388 | ResetThread(thread.get(), arg, 0); | 390 | ResetThread(thread.get(), arg, 0); |
| 389 | CallThread(thread.get()); | 391 | CallThread(thread.get()); |
| @@ -419,10 +421,8 @@ void Thread::SetPriority(s32 priority) { | |||
| 419 | 421 | ||
| 420 | SharedPtr<Thread> SetupIdleThread() { | 422 | SharedPtr<Thread> SetupIdleThread() { |
| 421 | // We need to pass a few valid values to get around parameter checking in Thread::Create. | 423 | // We need to pass a few valid values to get around parameter checking in Thread::Create. |
| 422 | auto thread_res = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0, | 424 | auto thread = Thread::Create("idle", Memory::KERNEL_MEMORY_VADDR, THREADPRIO_LOWEST, 0, |
| 423 | THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE); | 425 | THREADPROCESSORID_0, 0, Kernel::DEFAULT_STACK_SIZE).MoveFrom(); |
| 424 | _dbg_assert_(Kernel, thread_res.Succeeded()); | ||
| 425 | SharedPtr<Thread> thread = std::move(*thread_res); | ||
| 426 | 426 | ||
| 427 | thread->idle = true; | 427 | thread->idle = true; |
| 428 | CallThread(thread.get()); | 428 | CallThread(thread.get()); |