summaryrefslogtreecommitdiff
path: root/src/core/hle/kernel/thread.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-12-03 15:32:45 -0800
committerGravatar GitHub2020-12-03 15:32:45 -0800
commit69aaad9b9684570284efcdb5921e54d0f5983838 (patch)
tree364256228dfcdfc989a597aca2a6c753b173f93a /src/core/hle/kernel/thread.cpp
parentMerge pull request #5059 from lioncash/mouse (diff)
parentkernel: scheduler: Minor cleanup to remove duplicated code. (diff)
downloadyuzu-69aaad9b9684570284efcdb5921e54d0f5983838.tar.gz
yuzu-69aaad9b9684570284efcdb5921e54d0f5983838.tar.xz
yuzu-69aaad9b9684570284efcdb5921e54d0f5983838.zip
Merge pull request #4996 from bunnei/use-4jits
Kernel: Refactor to use 4-instances of Dynarmic & various cleanups and improvements
Diffstat (limited to 'src/core/hle/kernel/thread.cpp')
-rw-r--r--src/core/hle/kernel/thread.cpp32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp
index da0cb26b6..7d1eb2c6e 100644
--- a/src/core/hle/kernel/thread.cpp
+++ b/src/core/hle/kernel/thread.cpp
@@ -12,7 +12,6 @@
12#include "common/fiber.h" 12#include "common/fiber.h"
13#include "common/logging/log.h" 13#include "common/logging/log.h"
14#include "common/thread_queue_list.h" 14#include "common/thread_queue_list.h"
15#include "core/arm/arm_interface.h"
16#include "core/core.h" 15#include "core/core.h"
17#include "core/cpu_manager.h" 16#include "core/cpu_manager.h"
18#include "core/hardware_properties.h" 17#include "core/hardware_properties.h"
@@ -62,7 +61,6 @@ void Thread::Stop() {
62 // Mark the TLS slot in the thread's page as free. 61 // Mark the TLS slot in the thread's page as free.
63 owner_process->FreeTLSRegion(tls_address); 62 owner_process->FreeTLSRegion(tls_address);
64 } 63 }
65 arm_interface.reset();
66 has_exited = true; 64 has_exited = true;
67 } 65 }
68 global_handle = 0; 66 global_handle = 0;
@@ -90,10 +88,6 @@ void Thread::ResumeFromWait() {
90 // before actually resuming. We can ignore subsequent wakeups if the thread status has 88 // before actually resuming. We can ignore subsequent wakeups if the thread status has
91 // already been set to ThreadStatus::Ready. 89 // already been set to ThreadStatus::Ready.
92 return; 90 return;
93
94 case ThreadStatus::Running:
95 DEBUG_ASSERT_MSG(false, "Thread with object id {} has already resumed.", GetObjectId());
96 return;
97 case ThreadStatus::Dead: 91 case ThreadStatus::Dead:
98 // This should never happen, as threads must complete before being stopped. 92 // This should never happen, as threads must complete before being stopped.
99 DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.", 93 DEBUG_ASSERT_MSG(false, "Thread with object id {} cannot be resumed because it's DEAD.",
@@ -217,22 +211,9 @@ ResultVal<std::shared_ptr<Thread>> Thread::Create(Core::System& system, ThreadTy
217 thread->tls_address = 0; 211 thread->tls_address = 0;
218 } 212 }
219 213
220 thread->arm_interface.reset(); 214 // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used
215 // to initialize the context
221 if ((type_flags & THREADTYPE_HLE) == 0) { 216 if ((type_flags & THREADTYPE_HLE) == 0) {
222#ifdef ARCHITECTURE_x86_64
223 if (owner_process && !owner_process->Is64BitProcess()) {
224 thread->arm_interface = std::make_unique<Core::ARM_Dynarmic_32>(
225 system, kernel.Interrupts(), kernel.IsMulticore(), kernel.GetExclusiveMonitor(),
226 processor_id);
227 } else {
228 thread->arm_interface = std::make_unique<Core::ARM_Dynarmic_64>(
229 system, kernel.Interrupts(), kernel.IsMulticore(), kernel.GetExclusiveMonitor(),
230 processor_id);
231 }
232#else
233#error Platform not supported yet.
234#endif
235
236 ResetThreadContext32(thread->context_32, static_cast<u32>(stack_top), 217 ResetThreadContext32(thread->context_32, static_cast<u32>(stack_top),
237 static_cast<u32>(entry_point), static_cast<u32>(arg)); 218 static_cast<u32>(entry_point), static_cast<u32>(arg));
238 ResetThreadContext64(thread->context_64, stack_top, entry_point, arg); 219 ResetThreadContext64(thread->context_64, stack_top, entry_point, arg);
@@ -268,14 +249,6 @@ VAddr Thread::GetCommandBufferAddress() const {
268 return GetTLSAddress() + command_header_offset; 249 return GetTLSAddress() + command_header_offset;
269} 250}
270 251
271Core::ARM_Interface& Thread::ArmInterface() {
272 return *arm_interface;
273}
274
275const Core::ARM_Interface& Thread::ArmInterface() const {
276 return *arm_interface;
277}
278
279void Thread::SetStatus(ThreadStatus new_status) { 252void Thread::SetStatus(ThreadStatus new_status) {
280 if (new_status == status) { 253 if (new_status == status) {
281 return; 254 return;
@@ -283,7 +256,6 @@ void Thread::SetStatus(ThreadStatus new_status) {
283 256
284 switch (new_status) { 257 switch (new_status) {
285 case ThreadStatus::Ready: 258 case ThreadStatus::Ready:
286 case ThreadStatus::Running:
287 SetSchedulingStatus(ThreadSchedStatus::Runnable); 259 SetSchedulingStatus(ThreadSchedStatus::Runnable);
288 break; 260 break;
289 case ThreadStatus::Dormant: 261 case ThreadStatus::Dormant: