akern-gkgoat-fork/kernel/src/kmain.rs

70 lines
1.9 KiB
Rust
Raw Normal View History

2023-03-30 16:43:04 -05:00
//! AbleOS Kernel Entrypoint
2023-04-07 16:44:33 -05:00
// use std::collections::HashMap;
2023-04-05 12:29:20 -05:00
use log::{info, trace};
2023-04-07 16:44:33 -05:00
use spin::{Lazy, Mutex};
2023-04-05 12:29:20 -05:00
2023-04-07 16:44:33 -05:00
use crate::arch::{hardware_random_u64, sloop};
use crate::handle::Handle;
2023-04-10 01:16:30 -05:00
use crate::schedule::Scheduler;
2023-04-05 12:29:20 -05:00
use crate::{interp, task};
use crate::alloc::string::ToString;
2023-03-30 16:43:04 -05:00
pub fn kmain(cmdline: &str, bootstrap: Option<&'static [u8]>) -> ! {
log::debug!("Entered kmain");
2023-04-05 12:29:20 -05:00
let mut cmdline = cmdline.to_string();
cmdline.pop();
cmdline.remove(0);
let kcmd = clparse::Arguments::parse(cmdline.to_string()).unwrap();
log::info!("Cmdline: {kcmd:?}");
2023-04-10 01:16:30 -05:00
// if kcmd.arguments.get("baka") == Some(&"true".to_string()) {
// let _ = crate::arch::log(format_args!(include_str!("../data/⑨. バカ")));
// }
2023-03-30 16:43:04 -05:00
2023-04-10 01:16:30 -05:00
// if kcmd.arguments.get("foobles") == Some(&"true".to_string()) {
// let _ = crate::arch::log(format_args!("foobles\n"));
// }
2023-04-07 16:44:33 -05:00
2023-04-05 12:29:20 -05:00
let bootstrap = bootstrap/*.expect("no bootstrap found")*/;
match bootstrap {
Some(bootstrap_mod) => {}
None => {
info!("No bootstrap module loaded.")
}
}
2023-04-10 01:16:30 -05:00
// use xml::XMLElement;
// let kcmd = XMLElement::new("cmdline");
// let hnd = Handle::new();
// kcmd.set_attribute("")
// OBJECTS.lock().insert(hnd, kcmd);
// let abc = interp::wasm();
// trace!("{:?}", abc);
2023-04-05 12:29:20 -05:00
2023-04-10 01:16:30 -05:00
let sch = SCHEDULER;
let mut sch = sch.lock();
let wc = interp::build_wasm_context(alloc::vec::Vec::new()).unwrap();
sch.schedule(wc, crate::schedule::ContextWake::None);
2023-03-30 16:43:04 -05:00
2023-04-10 01:16:30 -05:00
sch.run();
// crate::arch::sloop()
2023-03-30 16:43:04 -05:00
}
2023-04-07 16:44:33 -05:00
pub const OBJECTS: Lazy<Mutex<HashMap<Handle, xml::XMLElement>>> = Lazy::new(|| {
let mut obj: HashMap<Handle, xml::XMLElement> = HashMap::new();
Mutex::new(obj)
});
use hashbrown::HashMap;
2023-04-10 01:16:30 -05:00
pub const SCHEDULER: Lazy<Mutex<Scheduler>> = Lazy::new(|| {
let mut sch = Scheduler::new();
Mutex::new(sch)
});