ableos/kernel/src/kmain.rs

62 lines
1.5 KiB
Rust
Raw Normal View History

2023-03-30 16:43:04 -05:00
//! AbleOS Kernel Entrypoint
2023-07-08 23:22:44 -05:00
// use crate::arch::sloop;
2023-05-06 06:50:24 -05:00
use {
2023-07-08 23:22:44 -05:00
crate::{
bootmodules::{build_cmd, BootModules},
device_tree::DeviceTree,
scheduler::Scheduler,
2023-07-08 23:22:44 -05:00
},
alloc::format,
log::{debug, info, trace},
2023-05-06 06:50:24 -05:00
spin::{Lazy, Mutex},
2023-06-16 05:20:37 -05:00
xml::XMLElement,
2023-05-06 06:50:24 -05:00
};
2023-04-05 12:29:20 -05:00
2023-07-08 23:22:44 -05:00
pub fn kmain(cmdline: &str, boot_modules: BootModules) -> ! {
2023-05-25 07:04:19 -05:00
debug!("Entered kmain");
2023-03-30 16:43:04 -05:00
2023-07-08 23:22:44 -05:00
let kcmd = build_cmd("Kernel Command Line", &cmdline);
trace!("Cmdline: {kcmd:?}");
2023-03-30 16:43:04 -05:00
2023-07-08 23:22:44 -05:00
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
_bmcmd = build_cmd(name, bm.cmd.clone());
2023-04-05 12:29:20 -05:00
}
}
2023-07-08 23:22:44 -05:00
2023-05-23 05:16:14 -05:00
let dt = DEVICE_TREE.lock();
2023-04-05 12:29:20 -05:00
info!("Device Tree: {}", dt);
2023-07-08 23:22:44 -05:00
info!("Boot complete. Moving to init_system");
2023-06-25 22:34:24 -05:00
// TODO: schedule the disk driver from the initramfs
// TODO: schedule the filesystem driver from the initramfs
// TODO: schedule the init system from the initramfs
2023-05-15 02:19:34 -05:00
// capabilities::example();
2023-07-12 06:03:29 -05:00
let mut sched = Scheduler::new();
sched.new_process(boot_modules[0].bytes.clone());
sched.new_process(boot_modules[1].bytes.clone());
2023-07-08 23:22:44 -05:00
sched.run();
2023-07-08 23:22:44 -05:00
// sloop();
2023-03-30 16:43:04 -05:00
}
2023-04-10 01:16:30 -05:00
2023-05-06 06:50:24 -05:00
pub static DEVICE_TREE: Lazy<Mutex<DeviceTree>> = Lazy::new(|| {
2023-05-23 05:16:14 -05:00
let dt = DeviceTree::new();
2023-05-06 06:50:24 -05:00
Mutex::new(dt)
});
2023-05-15 02:19:34 -05:00
#[test_case]
fn trivial_assertion() {
trace!("trivial assertion... ");
assert_eq!(1, 1);
info!("[ok]");
}