From 2b61ad947c64d76875311e6af08c87a5592055b3 Mon Sep 17 00:00:00 2001 From: Christian Cunningham Date: Fri, 26 Aug 2022 19:49:13 -0700 Subject: SpinLocks --- src/_arch/arm/cpu/boot.rs | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/_arch/arm/cpu/boot.rs') diff --git a/src/_arch/arm/cpu/boot.rs b/src/_arch/arm/cpu/boot.rs index b81a16a..1b4ed74 100644 --- a/src/_arch/arm/cpu/boot.rs +++ b/src/_arch/arm/cpu/boot.rs @@ -18,3 +18,54 @@ global_asm!(include_str!("boot.s")); pub unsafe fn _start_rust() -> ! { crate::kernel_init() } + +/// # Rust entry for other cores of the `kernel` binary. +/// +/// This function is unmangled so that the +/// ASM boot code can switch to Rust safely. +#[no_mangle] +pub extern "C" fn _start_other_core(_core: u32) -> ! { + loop { + use crate::INITIALIZED_BOOL; + use core::sync::atomic::Ordering; + if let Ok(true) = + INITIALIZED_BOOL.compare_exchange(true, false, Ordering::Acquire, Ordering::Relaxed) + { + crate::serial_println!("Ran core {}!", _core); + let u = crate::Box::::new(42); + crate::serial_println!("{}", u); + INITIALIZED_BOOL.store(true, Ordering::Release); + break; + } + } + #[allow(unreachable_code)] + loop {} +} + +/// # Prefetch +#[no_mangle] +pub extern "C" fn prefetch() -> ! { + crate::serial_println!("Prefetch handler"); + loop {} +} + +/// # Data +#[no_mangle] +pub extern "C" fn data() -> ! { + crate::serial_println!("Data handler"); + loop {} +} + +/// # IRQ +#[no_mangle] +pub extern "C" fn irq() -> ! { + crate::serial_println!("IRQ handler"); + loop {} +} + +/// # FIQ +#[no_mangle] +pub extern "C" fn fiq() -> ! { + crate::serial_println!("FIQ handler"); + loop {} +} -- cgit v1.2.1