diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 10e1f47f6..926c6dc84 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -64,8 +64,6 @@ struct KernelCore::Impl { | |||
| 64 | 64 | ||
| 65 | is_phantom_mode_for_singlecore = false; | 65 | is_phantom_mode_for_singlecore = false; |
| 66 | 66 | ||
| 67 | InitializePhysicalCores(); | ||
| 68 | |||
| 69 | // Derive the initial memory layout from the emulated board | 67 | // Derive the initial memory layout from the emulated board |
| 70 | Init::InitializeSlabResourceCounts(kernel); | 68 | Init::InitializeSlabResourceCounts(kernel); |
| 71 | DeriveInitialMemoryLayout(); | 69 | DeriveInitialMemoryLayout(); |
| @@ -77,6 +75,7 @@ struct KernelCore::Impl { | |||
| 77 | Init::InitializeKPageBufferSlabHeap(system); | 75 | Init::InitializeKPageBufferSlabHeap(system); |
| 78 | InitializeShutdownThreads(); | 76 | InitializeShutdownThreads(); |
| 79 | InitializePreemption(kernel); | 77 | InitializePreemption(kernel); |
| 78 | InitializePhysicalCores(); | ||
| 80 | 79 | ||
| 81 | RegisterHostThread(); | 80 | RegisterHostThread(); |
| 82 | } | 81 | } |
| @@ -193,8 +192,21 @@ struct KernelCore::Impl { | |||
| 193 | exclusive_monitor = | 192 | exclusive_monitor = |
| 194 | Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); | 193 | Core::MakeExclusiveMonitor(system.Memory(), Core::Hardware::NUM_CPU_CORES); |
| 195 | for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { | 194 | for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) { |
| 195 | const s32 core{static_cast<s32>(i)}; | ||
| 196 | |||
| 196 | schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel()); | 197 | schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel()); |
| 197 | cores.emplace_back(i, system, *schedulers[i], interrupts); | 198 | cores.emplace_back(i, system, *schedulers[i], interrupts); |
| 199 | |||
| 200 | auto* main_thread{Kernel::KThread::Create(system.Kernel())}; | ||
| 201 | main_thread->SetName(fmt::format("MainThread:{}", core)); | ||
| 202 | main_thread->SetCurrentCore(core); | ||
| 203 | ASSERT(Kernel::KThread::InitializeMainThread(system, main_thread, core).IsSuccess()); | ||
| 204 | |||
| 205 | auto* idle_thread{Kernel::KThread::Create(system.Kernel())}; | ||
| 206 | idle_thread->SetCurrentCore(core); | ||
| 207 | ASSERT(Kernel::KThread::InitializeIdleThread(system, idle_thread, core).IsSuccess()); | ||
| 208 | |||
| 209 | schedulers[i]->Initialize(main_thread, idle_thread, core); | ||
| 198 | } | 210 | } |
| 199 | } | 211 | } |
| 200 | 212 | ||
| @@ -1093,10 +1105,11 @@ void KernelCore::Suspend(bool suspended) { | |||
| 1093 | } | 1105 | } |
| 1094 | 1106 | ||
| 1095 | void KernelCore::ShutdownCores() { | 1107 | void KernelCore::ShutdownCores() { |
| 1108 | KScopedSchedulerLock lk{*this}; | ||
| 1109 | |||
| 1096 | for (auto* thread : impl->shutdown_threads) { | 1110 | for (auto* thread : impl->shutdown_threads) { |
| 1097 | void(thread->Run()); | 1111 | void(thread->Run()); |
| 1098 | } | 1112 | } |
| 1099 | InterruptAllPhysicalCores(); | ||
| 1100 | } | 1113 | } |
| 1101 | 1114 | ||
| 1102 | bool KernelCore::IsMulticore() const { | 1115 | bool KernelCore::IsMulticore() const { |