Kernel: Don't require APs that are not started to start :D

This commit is contained in:
Bananymous 2024-09-10 16:19:43 +03:00
parent a4838386e6
commit eabe759ebf
1 changed files with 5 additions and 2 deletions

View File

@ -277,6 +277,7 @@ namespace Kernel
memcpy(PageTable::fast_page_as_ptr(), g_ap_init_addr, PAGE_SIZE); memcpy(PageTable::fast_page_as_ptr(), g_ap_init_addr, PAGE_SIZE);
}); });
uint8_t initialized_aps = 0;
for (auto& processor : m_processors) for (auto& processor : m_processors)
{ {
if (processor.apic_id == bsp_id) if (processor.apic_id == bsp_id)
@ -339,15 +340,17 @@ namespace Kernel
udelay(100); udelay(100);
} }
}); });
initialized_aps++;
} }
__atomic_store_n(&g_ap_startup_done[0], 1, __ATOMIC_SEQ_CST); __atomic_store_n(&g_ap_startup_done[0], 1, __ATOMIC_SEQ_CST);
const size_t timeout_ms = SystemTimer::get().ms_since_boot() + 500; const size_t timeout_ms = SystemTimer::get().ms_since_boot() + 500;
while (__atomic_load_n(&g_ap_running_count[0], __ATOMIC_SEQ_CST) < m_processors.size() - 1) while (__atomic_load_n(&g_ap_running_count[0], __ATOMIC_SEQ_CST) < initialized_aps)
{ {
if (SystemTimer::get().ms_since_boot() >= timeout_ms) if (SystemTimer::get().ms_since_boot() >= timeout_ms)
Kernel::panic("Could not start all processors"); Kernel::panic("Could not start all APs ({}/{} started)", g_ap_running_count[0], initialized_aps);
__builtin_ia32_pause(); __builtin_ia32_pause();
} }