diff options
| author | 2015-05-10 18:35:37 -0500 | |
|---|---|---|
| committer | 2015-05-10 18:35:37 -0500 | |
| commit | 000876858d52d7e4fa8e21bc4407d43d548eff30 (patch) | |
| tree | f0af4cde78349cfe4ea7875b24d37cf85eb3eb03 /src/core/hle/kernel/thread.cpp | |
| parent | Merge pull request #726 from bunnei/gpu-improvements (diff) | |
| download | yuzu-000876858d52d7e4fa8e21bc4407d43d548eff30.tar.gz yuzu-000876858d52d7e4fa8e21bc4407d43d548eff30.tar.xz yuzu-000876858d52d7e4fa8e21bc4407d43d548eff30.zip | |
Core/Memory: Give every emulated thread it's own TLS area.
The TLS area for thread T with id Ti is located at TLS_AREA_VADDR + (Ti - 1) * 0x200.
This allows some games like Mario Kart 7 to continue further.
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
| -rw-r--r-- | src/core/hle/kernel/thread.cpp | 10 |
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 | ||
| 502 | VAddr Thread::GetTLSAddress() const { | ||
| 503 | return context.tls; | ||
| 504 | } | ||
| 505 | |||
| 498 | //////////////////////////////////////////////////////////////////////////////////////////////////// | 506 | //////////////////////////////////////////////////////////////////////////////////////////////////// |
| 499 | 507 | ||
| 500 | void ThreadingInit() { | 508 | void ThreadingInit() { |