aboutsummaryrefslogtreecommitdiff
path: root/src/_arch/arm/cpu/boot.rs
blob: 1b4ed742c4a6d4172e6f819e6e0fca58f5b24466 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
//! # Architectural boot code
//!
//! crate::cpu::boot::arch_boot
//!
//! ## Boot code for ARM
//!
//! Provides the initial handoff
//! function from Assembly to Rust.

use core::arch::global_asm;
global_asm!(include_str!("boot.s"));

/// # Rust entry of the `kernel` binary.
///
/// This function is unmangled so that the
/// ASM boot code can switch to Rust safely.
#[no_mangle]
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::<u32>::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 {}
}