diff options
Diffstat (limited to 'kernel/src/lib.rs')
-rw-r--r-- | kernel/src/lib.rs | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 842609f..0a724c6 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -1,6 +1,7 @@ #![no_std] pub mod console; +pub mod device_tree; pub mod util; #[cfg(not(test))] @@ -8,12 +9,24 @@ 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 extern "C" fn hart0_boot(device_tree: *const u32) -> ! { +pub unsafe extern "C" fn hart0_boot(device_tree: *const u8) -> ! { console::init(); log::info!("device_tree = {device_tree:?}"); - dbg!(42); + 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!() } |