summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar Lioncash2015-05-10 20:50:23 -0400
committerGravatar Lioncash2015-05-10 20:50:23 -0400
commit2a19de1d09f725e8ef267a51d4c5ff994b036b04 (patch)
tree945fc0617a3329e14f0b4ec3cf2679a0054cbb7b /src/core/hle/kernel/thread.cpp
parentMerge pull request #726 from bunnei/gpu-improvements (diff)
parentfixup! Set the TLS address in the scheduler (diff)
downloadyuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.gz
yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.xz
yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.zip
Merge pull request #741 from Subv/tls
Give each emulated thread it's own TLS memory
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index 0a3fd7cb1..5de8f9a73 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -197,6 +197,7 @@ static void SwitchContext(Thread* new_thread) {
197 new_thread->current_priority = new_thread->nominal_priority; 197 new_thread->current_priority = new_thread->nominal_priority;
198 198
199 Core::g_app_core->LoadContext(new_thread->context); 199 Core::g_app_core->LoadContext(new_thread->context);
200 Core::g_app_core->SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress());
200 } else { 201 } else {
201 current_thread = nullptr; 202 current_thread = nullptr;
202 } 203 }
@@ -402,6 +403,12 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
402 thread->name = std::move(name); 403 thread->name = std::move(name);
403 thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom(); 404 thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom();
404 405
406 VAddr tls_address = Memory::TLS_AREA_VADDR + (thread->thread_id - 1) * 0x200;
407
408 ASSERT_MSG(tls_address < Memory::TLS_AREA_VADDR_END, "Too many threads");
409
410 thread->tls_address = tls_address;
411
405 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used 412 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
406 // to initialize the context 413 // to initialize the context
407 Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg); 414 Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg);
@@ -495,6 +502,10 @@ void Thread::SetWaitSynchronizationOutput(s32 output) {
495 context.cpu_registers[1] = output; 502 context.cpu_registers[1] = output;
496} 503}
497 504
505VAddr Thread::GetTLSAddress() const {
506 return tls_address;
507}
508
498//////////////////////////////////////////////////////////////////////////////////////////////////// 509////////////////////////////////////////////////////////////////////////////////////////////////////
499 510
500void ThreadingInit() { 511void ThreadingInit() {