summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 0a3fd7cb1..61199c12a 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -402,9 +402,13 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
402 thread->name = std::move(name); 402 thread->name = std::move(name);
403 thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom(); 403 thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom();
404 404
405 VAddr tls_address = Memory::TLS_AREA_VADDR + (thread->thread_id - 1) * 0x200;
406
407 ASSERT_MSG(tls_address < Memory::TLS_AREA_VADDR_END, "Too many threads");
408
405 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used 409 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
406 // to initialize the context 410 // to initialize the context
407 Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg); 411 Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg, tls_address);
408 412
409 ready_queue.push_back(thread->current_priority, thread.get()); 413 ready_queue.push_back(thread->current_priority, thread.get());
410 thread->status = THREADSTATUS_READY; 414 thread->status = THREADSTATUS_READY;
@@ -495,6 +499,10 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
495 context.cpu_registers[1] = output; 499 context.cpu_registers[1] = output;
496} 500}
497 501
502VAddr Thread::GetTLSAddress() const {
503 return context.tls;
504}
505
498//////////////////////////////////////////////////////////////////////////////////////////////////// 506////////////////////////////////////////////////////////////////////////////////////////////////////
499 507
500void ThreadingInit() { 508void ThreadingInit() {