diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 16 | ||||
| -rw-r--r-- | src/core/hle/kernel/thread.h | 3 | ||||
| -rw-r--r-- | src/core/hle/svc.cpp | 9 |
3 files changed, 24 insertions, 4 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index f59795901..6da238828 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp | |||
| @@ -49,6 +49,8 @@ public: | |||
| 49 | 49 | ||
| 50 | ThreadContext context; | 50 | ThreadContext context; |
| 51 | 51 | ||
| 52 | u32 thread_id; | ||
| 53 | |||
| 52 | u32 status; | 54 | u32 status; |
| 53 | u32 entry_point; | 55 | u32 entry_point; |
| 54 | u32 stack_top; | 56 | u32 stack_top; |
| @@ -325,6 +327,9 @@ Thread* CreateThread(Handle& handle, const char* name, u32 entry_point, s32 prio | |||
| 325 | thread_queue.push_back(handle); | 327 | thread_queue.push_back(handle); |
| 326 | thread_ready_queue.prepare(priority); | 328 | thread_ready_queue.prepare(priority); |
| 327 | 329 | ||
| 330 | // TODO(Subv): Assign valid ids to each thread, they are much lower than handle values | ||
| 331 | // they appear to begin at 276 and continue from there | ||
| 332 | thread->thread_id = handle; | ||
| 328 | thread->status = THREADSTATUS_DORMANT; | 333 | thread->status = THREADSTATUS_DORMANT; |
| 329 | thread->entry_point = entry_point; | 334 | thread->entry_point = entry_point; |
| 330 | thread->stack_top = stack_top; | 335 | thread->stack_top = stack_top; |
| @@ -465,6 +470,17 @@ void Reschedule() { | |||
| 465 | } | 470 | } |
| 466 | } | 471 | } |
| 467 | 472 | ||
| 473 | ResultCode GetThreadId(u32* thread_id, Handle handle) { | ||
| 474 | Thread* thread = g_object_pool.Get<Thread>(handle); | ||
| 475 | if (thread == nullptr) | ||
| 476 | return ResultCode(ErrorDescription::InvalidHandle, ErrorModule::OS, | ||
| 477 | ErrorSummary::WrongArgument, ErrorLevel::Permanent); | ||
| 478 | |||
| 479 | *thread_id = thread->thread_id; | ||
| 480 | |||
| 481 | return RESULT_SUCCESS; | ||
| 482 | } | ||
| 483 | |||
| 468 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 484 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 469 | 485 | ||
| 470 | void ThreadingInit() { | 486 | void ThreadingInit() { |
diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index ce63a70d3..e87867ac0 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h | |||
| @@ -58,6 +58,9 @@ void Reschedule(); | |||
| 58 | /// Stops the current thread | 58 | /// Stops the current thread |
| 59 | ResultCode StopThread(Handle thread, const char* reason); | 59 | ResultCode StopThread(Handle thread, const char* reason); |
| 60 | 60 | ||
| 61 | // Retrieves the thread id of the specified thread handle | ||
| 62 | ResultCode GetThreadId(u32* thread_id, Handle handle); | ||
| 63 | |||
| 61 | /// Resumes a thread from waiting by marking it as "ready" | 64 | /// Resumes a thread from waiting by marking it as "ready" |
| 62 | void ResumeThreadFromWait(Handle handle); | 65 | void ResumeThreadFromWait(Handle handle); |
| 63 | 66 | ||
diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index 43a3cbe03..a5805ed05 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp | |||
| @@ -281,10 +281,11 @@ static Result ReleaseMutex(Handle handle) { | |||
| 281 | return res.raw; | 281 | return res.raw; |
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | /// Get current thread ID | 284 | /// Get the ID for the specified thread. |
| 285 | static Result GetThreadId(u32* thread_id, Handle thread) { | 285 | static Result GetThreadId(u32* thread_id, Handle handle) { |
| 286 | ERROR_LOG(SVC, "(UNIMPLEMENTED) called thread=0x%08X", thread); | 286 | DEBUG_LOG(SVC, "called thread=0x%08X", handle); |
| 287 | return 0; | 287 | ResultCode result = Kernel::GetThreadId(thread_id, handle); |
| 288 | return result.raw; | ||
| 288 | } | 289 | } |
| 289 | 290 | ||
| 290 | /// Query memory | 291 | /// Query memory |