ableos/kernel/src/kmain.rs

49 lines
1.2 KiB
Rust

//! AbleOS Kernel Entrypoint
// use std::collections::HashMap;
use {
log::info,
spin::{Lazy, Mutex},
};
use crate::device_tree::DeviceTree;
use crate::alloc::string::ToString;
pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! {
log::debug!("Entered kmain");
let mut cmdline = cmdline.to_string();
cmdline.pop();
cmdline.remove(0);
let kcmd = clparse::Arguments::parse(cmdline.to_string()).unwrap();
log::info!("Cmdline: {kcmd:?}");
if kcmd.arguments.get("baka") == Some(&"true".to_string()) {
let _ = crate::arch::log(format_args!(include_str!("../data/⑨. バカ")));
}
if kcmd.arguments.get("foobles") == Some(&"true".to_string()) {
let _ = crate::arch::log(format_args!("foobles\n\r"));
}
let bootstrap = bootstrap/*.expect("no bootstrap found")*/;
match bootstrap {
Some(bootstrap_mod) => {}
None => {
info!("No bootstrap module loaded.")
}
}
let mut dt = DEVICE_TREE.lock();
info!("Device Tree {}", &dt);
crate::arch::sloop()
}
pub static DEVICE_TREE: Lazy<Mutex<DeviceTree>> = Lazy::new(|| {
let mut dt = DeviceTree::new();
Mutex::new(dt)
});