From 0c701fc51cf216a36e00309804c825a74307f111 Mon Sep 17 00:00:00 2001 From: Josh Junon Date: Mon, 29 Jul 2024 22:02:20 +0200 Subject: [PATCH] kernel: add lock-step multicore spinlock macro and step between shared/local init --- oro-kernel/src/lib.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/oro-kernel/src/lib.rs b/oro-kernel/src/lib.rs index dfff3b68..8512dc05 100644 --- a/oro-kernel/src/lib.rs +++ b/oro-kernel/src/lib.rs @@ -59,6 +59,20 @@ pub enum CoreType { /// Specifically, all safety requirements must be met, such as /// marking exactly one core as primary. pub unsafe fn boot(core_config: &CoreConfig) -> ! { + #[allow(clippy::missing_docs_in_private_items)] + macro_rules! wait_for_all_cores { + () => {{ + static BARRIER: ::oro_common::sync::SpinBarrier = + ::oro_common::sync::SpinBarrier::new(); + + if core_config.core_type == CoreType::Primary { + BARRIER.set_total::(core_config.boot_config.core_count); + } + + BARRIER.wait(); + }}; + } + A::disable_interrupts(); A::after_transfer(); @@ -66,7 +80,7 @@ pub unsafe fn boot(core_config: &CoreConfig) -> ! { A::init_shared(); } - // TODO(qix-): barrier. But we need the core count from the boot protocol info first. + wait_for_all_cores!(); A::init_local();