diff options
author | Lioncash <mathew1800@gmail.com> | 2015-05-11 02:50:23 +0200 |
---|---|---|
committer | Lioncash <mathew1800@gmail.com> | 2015-05-11 02:50:23 +0200 |
commit | 2a19de1d09f725e8ef267a51d4c5ff994b036b04 (patch) | |
tree | 945fc0617a3329e14f0b4ec3cf2679a0054cbb7b /src/core/hle/kernel/thread.cpp | |
parent | Merge pull request #726 from bunnei/gpu-improvements (diff) | |
parent | fixup! Set the TLS address in the scheduler (diff) | |
download | yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.gz yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.bz2 yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.lz yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.xz yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.tar.zst yuzu-2a19de1d09f725e8ef267a51d4c5ff994b036b04.zip |
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r-- | src/core/hle/kernel/thread.cpp | 11 |
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) { new_thread->current_priority = new_thread->nominal_priority; Core::g_app_core->LoadContext(new_thread->context); + Core::g_app_core->SetCP15Register(CP15_THREAD_URO, new_thread->GetTLSAddress()); } else { current_thread = nullptr; } @@ -402,6 +403,12 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point, thread->name = std::move(name); thread->callback_handle = wakeup_callback_handle_table.Create(thread).MoveFrom(); + VAddr tls_address = Memory::TLS_AREA_VADDR + (thread->thread_id - 1) * 0x200; + + ASSERT_MSG(tls_address < Memory::TLS_AREA_VADDR_END, "Too many threads"); + + thread->tls_address = tls_address; + // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used // to initialize the context Core::g_app_core->ResetContext(thread->context, stack_top, entry_point, arg); @@ -495,6 +502,10 @@ void Thread::SetWaitSynchronizationOutput(s32 output) { context.cpu_registers[1] = output; } +VAddr Thread::GetTLSAddress() const { + return tls_address; +} + //////////////////////////////////////////////////////////////////////////////////////////////////// void ThreadingInit() { |