diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 97a5dc2e0..39d5122f5 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -237,20 +237,13 @@ struct KernelCore::Impl { | |||
| 237 | is_phantom_mode_for_singlecore = value; | 237 | is_phantom_mode_for_singlecore = value; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | [[nodiscard]] Core::EmuThreadHandle GetCurrentEmuThreadID() { | 240 | [[nodiscard]] EmuThreadHandle GetCurrentEmuThreadID() { |
| 241 | Core::EmuThreadHandle result = Core::EmuThreadHandle::InvalidHandle(); | 241 | const auto thread_id = GetCurrentHostThreadID(); |
| 242 | result.host_handle = GetCurrentHostThreadID(); | 242 | if (thread_id >= Core::Hardware::NUM_CPU_CORES) { |
| 243 | if (result.host_handle >= Core::Hardware::NUM_CPU_CORES) { | 243 | // Reserved value for HLE threads |
| 244 | return result; | 244 | return EmuThreadHandleReserved + (static_cast<u64>(thread_id) << 1); |
| 245 | } | 245 | } |
| 246 | const Kernel::KScheduler& sched = cores[result.host_handle].Scheduler(); | 246 | return reinterpret_cast<uintptr_t>(schedulers[thread_id].get()); |
| 247 | const Kernel::KThread* current = sched.GetCurrentThread(); | ||
| 248 | if (current != nullptr && !IsPhantomModeForSingleCore()) { | ||
| 249 | result.guest_handle = current->GetGlobalHandle(); | ||
| 250 | } else { | ||
| 251 | result.guest_handle = InvalidHandle; | ||
| 252 | } | ||
| 253 | return result; | ||
| 254 | } | 247 | } |
| 255 | 248 | ||
| 256 | void InitializeMemoryLayout() { | 249 | void InitializeMemoryLayout() { |
| @@ -555,7 +548,7 @@ u32 KernelCore::GetCurrentHostThreadID() const { | |||
| 555 | return impl->GetCurrentHostThreadID(); | 548 | return impl->GetCurrentHostThreadID(); |
| 556 | } | 549 | } |
| 557 | 550 | ||
| 558 | Core::EmuThreadHandle KernelCore::GetCurrentEmuThreadID() const { | 551 | EmuThreadHandle KernelCore::GetCurrentEmuThreadID() const { |
| 559 | return impl->GetCurrentEmuThreadID(); | 552 | return impl->GetCurrentEmuThreadID(); |
| 560 | } | 553 | } |
| 561 | 554 | ||