summaryrefslogtreecommitdiff
path: root/kernel/src/lib.rs
blob: 0a724c6d44cd838c02803afaae0ab53e2f87d970 (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
#![no_std]

pub mod console;
pub mod device_tree;
pub mod util;

#[cfg(not(test))]
mod panic;

/// The entrypoint to the kernel. This should be executed by hart0 alone. It performs some early
/// boot tasks, then wakes up any other harts.
///
/// # Safety
///
/// - The `device_tree` pointer must be a valid pointer into physical memory. See
///   `device_tree::FlattenedDeviceTree::from_ptr` for the precise requirements.
/// - This must be called in supervisor mode with paging and traps disabled, but with all traps
///   delegated to supervisor mode.
#[no_mangle]
pub unsafe extern "C" fn hart0_boot(device_tree: *const u8) -> ! {
    console::init();

    log::info!("device_tree = {device_tree:?}");
    let flattened_device_tree = unsafe { device_tree::FlattenedDeviceTree::from_ptr(device_tree) }
        .expect("invalid DeviceTree");
    for event in flattened_device_tree.struct_events() {
        let event = event.expect("invalid DeviceTree");
        dbg!(event);
    }

    todo!()
}