diff options
| author | 2020-12-31 00:46:09 -0800 | |
|---|---|---|
| committer | 2021-01-28 21:42:25 -0800 | |
| commit | eea346ba8eed49111d34e2fb1eee8a1ad53c4614 (patch) | |
| tree | cbb3c011970c59e756dae5d358eadcb679b060e8 /src/core/hle/kernel | |
| parent | arm: arm_dynarmic: Skip calls when JIT is invalid. (diff) | |
| download | yuzu-eea346ba8eed49111d34e2fb1eee8a1ad53c4614.tar.gz yuzu-eea346ba8eed49111d34e2fb1eee8a1ad53c4614.tar.xz yuzu-eea346ba8eed49111d34e2fb1eee8a1ad53c4614.zip | |
hle: kernel: KThread: Remove thread types that do not exist.
Diffstat (limited to 'src/core/hle/kernel')
| -rw-r--r-- | src/core/hle/kernel/k_scheduler.cpp | 27 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.cpp | 21 | ||||
| -rw-r--r-- | src/core/hle/kernel/k_thread.h | 15 | ||||
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 8 |
4 files changed, 27 insertions, 44 deletions
diff --git a/src/core/hle/kernel/k_scheduler.cpp b/src/core/hle/kernel/k_scheduler.cpp index 0f7a541c8..edc5df733 100644 --- a/src/core/hle/kernel/k_scheduler.cpp +++ b/src/core/hle/kernel/k_scheduler.cpp | |||
| @@ -627,11 +627,11 @@ void KScheduler::OnThreadStart() { | |||
| 627 | void KScheduler::Unload(KThread* thread) { | 627 | void KScheduler::Unload(KThread* thread) { |
| 628 | if (thread) { | 628 | if (thread) { |
| 629 | thread->SetIsRunning(false); | 629 | thread->SetIsRunning(false); |
| 630 | if (thread->IsContinuousOnSVC() && !thread->IsHLEThread()) { | 630 | if (thread->IsContinuousOnSVC()) { |
| 631 | system.ArmInterface(core_id).ExceptionalExit(); | 631 | system.ArmInterface(core_id).ExceptionalExit(); |
| 632 | thread->SetContinuousOnSVC(false); | 632 | thread->SetContinuousOnSVC(false); |
| 633 | } | 633 | } |
| 634 | if (!thread->IsHLEThread() && !thread->HasExited()) { | 634 | if (!thread->HasExited()) { |
| 635 | Core::ARM_Interface& cpu_core = system.ArmInterface(core_id); | 635 | Core::ARM_Interface& cpu_core = system.ArmInterface(core_id); |
| 636 | cpu_core.SaveContext(thread->GetContext32()); | 636 | cpu_core.SaveContext(thread->GetContext32()); |
| 637 | cpu_core.SaveContext(thread->GetContext64()); | 637 | cpu_core.SaveContext(thread->GetContext64()); |
| @@ -655,14 +655,13 @@ void KScheduler::Reload(KThread* thread) { | |||
| 655 | if (thread_owner_process != nullptr) { | 655 | if (thread_owner_process != nullptr) { |
| 656 | system.Kernel().MakeCurrentProcess(thread_owner_process); | 656 | system.Kernel().MakeCurrentProcess(thread_owner_process); |
| 657 | } | 657 | } |
| 658 | if (!thread->IsHLEThread()) { | 658 | |
| 659 | Core::ARM_Interface& cpu_core = system.ArmInterface(core_id); | 659 | Core::ARM_Interface& cpu_core = system.ArmInterface(core_id); |
| 660 | cpu_core.LoadContext(thread->GetContext32()); | 660 | cpu_core.LoadContext(thread->GetContext32()); |
| 661 | cpu_core.LoadContext(thread->GetContext64()); | 661 | cpu_core.LoadContext(thread->GetContext64()); |
| 662 | cpu_core.SetTlsAddress(thread->GetTLSAddress()); | 662 | cpu_core.SetTlsAddress(thread->GetTLSAddress()); |
| 663 | cpu_core.SetTPIDR_EL0(thread->GetTPIDR_EL0()); | 663 | cpu_core.SetTPIDR_EL0(thread->GetTPIDR_EL0()); |
| 664 | cpu_core.ClearExclusiveState(); | 664 | cpu_core.ClearExclusiveState(); |
| 665 | } | ||
| 666 | } | 665 | } |
| 667 | } | 666 | } |
| 668 | 667 | ||
| @@ -722,7 +721,7 @@ void KScheduler::SwitchToCurrent() { | |||
| 722 | return state.needs_scheduling.load(std::memory_order_relaxed); | 721 | return state.needs_scheduling.load(std::memory_order_relaxed); |
| 723 | }; | 722 | }; |
| 724 | do { | 723 | do { |
| 725 | if (current_thread != nullptr && !current_thread->IsHLEThread()) { | 724 | if (current_thread != nullptr) { |
| 726 | current_thread->context_guard.lock(); | 725 | current_thread->context_guard.lock(); |
| 727 | if (current_thread->GetRawState() != ThreadState::Runnable) { | 726 | if (current_thread->GetRawState() != ThreadState::Runnable) { |
| 728 | current_thread->context_guard.unlock(); | 727 | current_thread->context_guard.unlock(); |
| @@ -764,9 +763,9 @@ void KScheduler::Initialize() { | |||
| 764 | std::string name = "Idle Thread Id:" + std::to_string(core_id); | 763 | std::string name = "Idle Thread Id:" + std::to_string(core_id); |
| 765 | std::function<void(void*)> init_func = Core::CpuManager::GetIdleThreadStartFunc(); | 764 | std::function<void(void*)> init_func = Core::CpuManager::GetIdleThreadStartFunc(); |
| 766 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); | 765 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); |
| 767 | ThreadType type = static_cast<ThreadType>(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_IDLE); | 766 | auto thread_res = KThread::Create(system, THREADTYPE_KERNEL, name, 0, THREADPRIO_LOWEST, 0, |
| 768 | auto thread_res = KThread::Create(system, type, name, 0, 64, 0, static_cast<u32>(core_id), 0, | 767 | static_cast<u32>(core_id), 0, nullptr, std::move(init_func), |
| 769 | nullptr, std::move(init_func), init_func_parameter); | 768 | init_func_parameter); |
| 770 | idle_thread = thread_res.Unwrap().get(); | 769 | idle_thread = thread_res.Unwrap().get(); |
| 771 | 770 | ||
| 772 | { | 771 | { |
diff --git a/src/core/hle/kernel/k_thread.cpp b/src/core/hle/kernel/k_thread.cpp index 1ec29636c..0f349dad2 100644 --- a/src/core/hle/kernel/k_thread.cpp +++ b/src/core/hle/kernel/k_thread.cpp | |||
| @@ -125,7 +125,7 @@ ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, Thread | |||
| 125 | void* thread_start_parameter) { | 125 | void* thread_start_parameter) { |
| 126 | auto& kernel = system.Kernel(); | 126 | auto& kernel = system.Kernel(); |
| 127 | // Check if priority is in ranged. Lowest priority -> highest priority id. | 127 | // Check if priority is in ranged. Lowest priority -> highest priority id. |
| 128 | if (priority > THREADPRIO_LOWEST && ((type_flags & THREADTYPE_IDLE) == 0)) { | 128 | if (priority > THREADPRIO_LOWEST) { |
| 129 | LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); | 129 | LOG_ERROR(Kernel_SVC, "Invalid thread priority: {}", priority); |
| 130 | return ERR_INVALID_THREAD_PRIORITY; | 130 | return ERR_INVALID_THREAD_PRIORITY; |
| 131 | } | 131 | } |
| @@ -164,10 +164,10 @@ ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, Thread | |||
| 164 | thread->owner_process = owner_process; | 164 | thread->owner_process = owner_process; |
| 165 | thread->type = type_flags; | 165 | thread->type = type_flags; |
| 166 | thread->signaled = false; | 166 | thread->signaled = false; |
| 167 | if ((type_flags & THREADTYPE_IDLE) == 0) { | 167 | |
| 168 | auto& scheduler = kernel.GlobalSchedulerContext(); | 168 | auto& scheduler = kernel.GlobalSchedulerContext(); |
| 169 | scheduler.AddThread(thread); | 169 | scheduler.AddThread(thread); |
| 170 | } | 170 | |
| 171 | if (owner_process) { | 171 | if (owner_process) { |
| 172 | thread->tls_address = thread->owner_process->CreateTLSRegion(); | 172 | thread->tls_address = thread->owner_process->CreateTLSRegion(); |
| 173 | thread->owner_process->RegisterThread(thread.get()); | 173 | thread->owner_process->RegisterThread(thread.get()); |
| @@ -175,13 +175,10 @@ ResultVal<std::shared_ptr<KThread>> KThread::Create(Core::System& system, Thread | |||
| 175 | thread->tls_address = 0; | 175 | thread->tls_address = 0; |
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | // TODO(peachum): move to ScheduleThread() when scheduler is added so selected core is used | 178 | ResetThreadContext32(thread->context_32, static_cast<u32>(stack_top), |
| 179 | // to initialize the context | 179 | static_cast<u32>(entry_point), static_cast<u32>(arg)); |
| 180 | if ((type_flags & THREADTYPE_HLE) == 0) { | 180 | ResetThreadContext64(thread->context_64, stack_top, entry_point, arg); |
| 181 | ResetThreadContext32(thread->context_32, static_cast<u32>(stack_top), | 181 | |
| 182 | static_cast<u32>(entry_point), static_cast<u32>(arg)); | ||
| 183 | ResetThreadContext64(thread->context_64, stack_top, entry_point, arg); | ||
| 184 | } | ||
| 185 | thread->host_context = | 182 | thread->host_context = |
| 186 | std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); | 183 | std::make_shared<Common::Fiber>(std::move(thread_start_func), thread_start_parameter); |
| 187 | 184 | ||
diff --git a/src/core/hle/kernel/k_thread.h b/src/core/hle/kernel/k_thread.h index 75257d2b4..d9fe2e363 100644 --- a/src/core/hle/kernel/k_thread.h +++ b/src/core/hle/kernel/k_thread.h | |||
| @@ -51,9 +51,6 @@ enum ThreadPriority : u32 { | |||
| 51 | enum ThreadType : u32 { | 51 | enum ThreadType : u32 { |
| 52 | THREADTYPE_USER = 0x1, | 52 | THREADTYPE_USER = 0x1, |
| 53 | THREADTYPE_KERNEL = 0x2, | 53 | THREADTYPE_KERNEL = 0x2, |
| 54 | THREADTYPE_HLE = 0x4, | ||
| 55 | THREADTYPE_IDLE = 0x8, | ||
| 56 | THREADTYPE_SUSPEND = 0x10, | ||
| 57 | }; | 54 | }; |
| 58 | 55 | ||
| 59 | enum ThreadProcessorId : s32 { | 56 | enum ThreadProcessorId : s32 { |
| @@ -309,16 +306,8 @@ public: | |||
| 309 | return context_64; | 306 | return context_64; |
| 310 | } | 307 | } |
| 311 | 308 | ||
| 312 | bool IsHLEThread() const { | 309 | bool IsKernelThread() const { |
| 313 | return (type & THREADTYPE_HLE) != 0; | 310 | return (type & THREADTYPE_KERNEL) != 0; |
| 314 | } | ||
| 315 | |||
| 316 | bool IsSuspendThread() const { | ||
| 317 | return (type & THREADTYPE_SUSPEND) != 0; | ||
| 318 | } | ||
| 319 | |||
| 320 | bool IsIdleThread() const { | ||
| 321 | return (type & THREADTYPE_IDLE) != 0; | ||
| 322 | } | 311 | } |
| 323 | 312 | ||
| 324 | bool WasRunning() const { | 313 | bool WasRunning() const { |
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 523dd63a5..6ae0bdeed 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -168,11 +168,9 @@ struct KernelCore::Impl { | |||
| 168 | std::string name = "Suspend Thread Id:" + std::to_string(i); | 168 | std::string name = "Suspend Thread Id:" + std::to_string(i); |
| 169 | std::function<void(void*)> init_func = Core::CpuManager::GetSuspendThreadStartFunc(); | 169 | std::function<void(void*)> init_func = Core::CpuManager::GetSuspendThreadStartFunc(); |
| 170 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); | 170 | void* init_func_parameter = system.GetCpuManager().GetStartFuncParamater(); |
| 171 | const auto type = | 171 | auto thread_res = KThread::Create(system, THREADTYPE_KERNEL, std::move(name), 0, 0, 0, |
| 172 | static_cast<ThreadType>(THREADTYPE_KERNEL | THREADTYPE_HLE | THREADTYPE_SUSPEND); | 172 | static_cast<u32>(i), 0, nullptr, std::move(init_func), |
| 173 | auto thread_res = | 173 | init_func_parameter); |
| 174 | KThread::Create(system, type, std::move(name), 0, 0, 0, static_cast<u32>(i), 0, | ||
| 175 | nullptr, std::move(init_func), init_func_parameter); | ||
| 176 | 174 | ||
| 177 | suspend_threads[i] = std::move(thread_res).Unwrap(); | 175 | suspend_threads[i] = std::move(thread_res).Unwrap(); |
| 178 | } | 176 | } |