//! AbleOS Kernel Entrypoint use {hashbrown::HashMap, hbvm::mem::Address}; use crate::{capabilities, holeybytes::ExecThread, ipc::buffer::IpcBuffer}; // use crate::arch::sloop; use { crate::{ bootmodules::{build_cmd, BootModules}, device_tree::DeviceTree, }, alloc::format, log::{debug, info, trace}, spin::{Lazy, Mutex}, xml::XMLElement, }; pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! { debug!("Entered kmain"); let kcmd = build_cmd("Kernel Command Line", cmdline); trace!("Cmdline: {kcmd:?}"); for (i, bm) in boot_modules.iter().enumerate() { let name = format!("module-{}", i); let _bmcmd: XMLElement; if bm.cmd.len() >= 2 { // TODO: pass into the program // Pass CMDLine into an IPCBuffer and put the ptr to the IPCBuffer in r200 _bmcmd = build_cmd(name, bm.cmd.clone()); } } let dt = DEVICE_TREE.lock(); // TODO(Able): This line causes a deadlock info!("Device Tree: {}", dt); info!("Boot complete. Moving to init_system"); // TODO: schedule the disk driver from the initramfs // TODO: schedule the filesystem driver from the initramfs // TODO: Schedule the VFS from initramfs // TODO: schedule the init system from the initramfs let mut executor = crate::task::Executor::default(); unsafe { for module in boot_modules.into_iter().take(2) { executor.spawn(async move { if let Err(e) = ExecThread::new(&module.bytes, Address::new(0)).await { log::error!("{e:?}"); } }); } executor.run(); }; crate::arch::spin_loop() } pub static DEVICE_TREE: Lazy> = Lazy::new(|| { let dt = DeviceTree::new(); Mutex::new(dt) }); use alloc::vec::Vec; pub type IpcBuffers = HashMap; pub static IPC_BUFFERS: Lazy> = Lazy::new(|| { let bufs = HashMap::new(); Mutex::new(bufs) }); #[test_case] fn trivial_assertion() { trace!("trivial assertion... "); assert_eq!(1, 1); info!("[ok]"); }