diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 50 |
1 files changed, 25 insertions, 25 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 43bce1863..1b7ba39f4 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -102,15 +102,21 @@ struct KernelCore::Impl { | |||
| 102 | next_user_process_id = Process::ProcessIDMin; | 102 | next_user_process_id = Process::ProcessIDMin; |
| 103 | next_thread_id = 1; | 103 | next_thread_id = 1; |
| 104 | 104 | ||
| 105 | for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | 105 | for (s32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { |
| 106 | if (suspend_threads[i]) { | 106 | if (suspend_threads[core_id]) { |
| 107 | suspend_threads[i]->Close(); | 107 | suspend_threads[core_id]->Close(); |
| 108 | suspend_threads[core_id] = nullptr; | ||
| 108 | } | 109 | } |
| 110 | |||
| 111 | schedulers[core_id].reset(); | ||
| 109 | } | 112 | } |
| 110 | 113 | ||
| 111 | cores.clear(); | 114 | cores.clear(); |
| 112 | 115 | ||
| 113 | current_process = nullptr; | 116 | if (current_process) { |
| 117 | current_process->Close(); | ||
| 118 | current_process = nullptr; | ||
| 119 | } | ||
| 114 | 120 | ||
| 115 | global_handle_table.Clear(); | 121 | global_handle_table.Clear(); |
| 116 | 122 | ||
| @@ -195,10 +201,9 @@ struct KernelCore::Impl { | |||
| 195 | 201 | ||
| 196 | void InitializeSuspendThreads() { | 202 | void InitializeSuspendThreads() { |
| 197 | for (s32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { | 203 | for (s32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { |
| 198 | suspend_threads[core_id] = std::make_unique<KThread>(system.Kernel()); | 204 | suspend_threads[core_id] = KThread::Create(system.Kernel()); |
| 199 | KAutoObject::Create(suspend_threads[core_id].get()); | 205 | ASSERT(KThread::InitializeHighPriorityThread(system, suspend_threads[core_id], {}, {}, |
| 200 | ASSERT(KThread::InitializeHighPriorityThread(system, suspend_threads[core_id].get(), {}, | 206 | core_id) |
| 201 | {}, core_id) | ||
| 202 | .IsSuccess()); | 207 | .IsSuccess()); |
| 203 | suspend_threads[core_id]->SetName(fmt::format("SuspendThread:{}", core_id)); | 208 | suspend_threads[core_id]->SetName(fmt::format("SuspendThread:{}", core_id)); |
| 204 | } | 209 | } |
| @@ -577,15 +582,10 @@ struct KernelCore::Impl { | |||
| 577 | const PAddr irs_phys_addr{system_pool.GetAddress() + hid_size + font_size}; | 582 | const PAddr irs_phys_addr{system_pool.GetAddress() + hid_size + font_size}; |
| 578 | const PAddr time_phys_addr{system_pool.GetAddress() + hid_size + font_size + irs_size}; | 583 | const PAddr time_phys_addr{system_pool.GetAddress() + hid_size + font_size + irs_size}; |
| 579 | 584 | ||
| 580 | hid_shared_mem = std::make_unique<KSharedMemory>(system.Kernel()); | 585 | hid_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 581 | font_shared_mem = std::make_unique<KSharedMemory>(system.Kernel()); | 586 | font_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 582 | irs_shared_mem = std::make_unique<KSharedMemory>(system.Kernel()); | 587 | irs_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 583 | time_shared_mem = std::make_unique<KSharedMemory>(system.Kernel()); | 588 | time_shared_mem = KSharedMemory::Create(system.Kernel()); |
| 584 | |||
| 585 | KAutoObject::Create(hid_shared_mem.get()); | ||
| 586 | KAutoObject::Create(font_shared_mem.get()); | ||
| 587 | KAutoObject::Create(irs_shared_mem.get()); | ||
| 588 | KAutoObject::Create(time_shared_mem.get()); | ||
| 589 | 589 | ||
| 590 | hid_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, | 590 | hid_shared_mem->Initialize(system.Kernel(), system.DeviceMemory(), nullptr, |
| 591 | {hid_phys_addr, hid_size / PageSize}, KMemoryPermission::None, | 591 | {hid_phys_addr, hid_size / PageSize}, KMemoryPermission::None, |
| @@ -656,10 +656,10 @@ struct KernelCore::Impl { | |||
| 656 | std::unique_ptr<KSlabHeap<Page>> user_slab_heap_pages; | 656 | std::unique_ptr<KSlabHeap<Page>> user_slab_heap_pages; |
| 657 | 657 | ||
| 658 | // Shared memory for services | 658 | // Shared memory for services |
| 659 | std::unique_ptr<Kernel::KSharedMemory> hid_shared_mem; | 659 | Kernel::KSharedMemory* hid_shared_mem{}; |
| 660 | std::unique_ptr<Kernel::KSharedMemory> font_shared_mem; | 660 | Kernel::KSharedMemory* font_shared_mem{}; |
| 661 | std::unique_ptr<Kernel::KSharedMemory> irs_shared_mem; | 661 | Kernel::KSharedMemory* irs_shared_mem{}; |
| 662 | std::unique_ptr<Kernel::KSharedMemory> time_shared_mem; | 662 | Kernel::KSharedMemory* time_shared_mem{}; |
| 663 | 663 | ||
| 664 | // Threads used for services | 664 | // Threads used for services |
| 665 | std::unordered_set<std::shared_ptr<Kernel::ServiceThread>> service_threads; | 665 | std::unordered_set<std::shared_ptr<Kernel::ServiceThread>> service_threads; |
| @@ -668,7 +668,7 @@ struct KernelCore::Impl { | |||
| 668 | // the release of itself | 668 | // the release of itself |
| 669 | std::unique_ptr<Common::ThreadWorker> service_thread_manager; | 669 | std::unique_ptr<Common::ThreadWorker> service_thread_manager; |
| 670 | 670 | ||
| 671 | std::array<std::unique_ptr<KThread>, Core::Hardware::NUM_CPU_CORES> suspend_threads; | 671 | std::array<KThread*, Core::Hardware::NUM_CPU_CORES> suspend_threads; |
| 672 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; | 672 | std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{}; |
| 673 | std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; | 673 | std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{}; |
| 674 | 674 | ||
| @@ -938,9 +938,9 @@ void KernelCore::Suspend(bool in_suspention) { | |||
| 938 | { | 938 | { |
| 939 | KScopedSchedulerLock lock(*this); | 939 | KScopedSchedulerLock lock(*this); |
| 940 | const auto state = should_suspend ? ThreadState::Runnable : ThreadState::Waiting; | 940 | const auto state = should_suspend ? ThreadState::Runnable : ThreadState::Waiting; |
| 941 | for (std::size_t i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | 941 | for (s32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) { |
| 942 | impl->suspend_threads[i]->SetState(state); | 942 | impl->suspend_threads[core_id]->SetState(state); |
| 943 | impl->suspend_threads[i]->SetWaitReasonForDebugging( | 943 | impl->suspend_threads[core_id]->SetWaitReasonForDebugging( |
| 944 | ThreadWaitReasonForDebugging::Suspended); | 944 | ThreadWaitReasonForDebugging::Suspended); |
| 945 | } | 945 | } |
| 946 | } | 946 | } |