2023-03-30 16:43:04 -05:00
|
|
|
//! AbleOS Kernel Entrypoint
|
|
|
|
|
2023-04-07 16:44:33 -05:00
|
|
|
// use std::collections::HashMap;
|
|
|
|
|
2023-05-06 06:50:24 -05:00
|
|
|
use {
|
2023-05-08 04:35:37 -05:00
|
|
|
log::info,
|
2023-05-06 06:50:24 -05:00
|
|
|
spin::{Lazy, Mutex},
|
|
|
|
};
|
2023-04-05 12:29:20 -05:00
|
|
|
|
2023-05-15 02:19:34 -05:00
|
|
|
use {embedded_graphics::pixelcolor::Rgb888, hbvm::engine::Engine};
|
|
|
|
|
|
|
|
use crate::{
|
|
|
|
arch::{graphics::DISPLAY, logging::SERIAL_CONSOLE},
|
|
|
|
device_tree::DeviceTree,
|
|
|
|
// host_functions::read_device_tree,
|
|
|
|
};
|
2023-04-05 12:29:20 -05:00
|
|
|
|
|
|
|
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-05-06 06:50:24 -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-05-06 06:50:24 -05:00
|
|
|
if kcmd.arguments.get("foobles") == Some(&"true".to_string()) {
|
|
|
|
let _ = crate::arch::log(format_args!("foobles\n\r"));
|
|
|
|
}
|
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-05-06 06:50:24 -05:00
|
|
|
let mut dt = DEVICE_TREE.lock();
|
2023-04-05 12:29:20 -05:00
|
|
|
|
2023-05-06 06:50:24 -05:00
|
|
|
info!("Device Tree {}", &dt);
|
2023-05-15 02:19:34 -05:00
|
|
|
|
|
|
|
let bytes = alloc::vec![0];
|
|
|
|
let mut prog = Engine::new(bytes);
|
|
|
|
// prog.enviroment_call_table[0] = read_device_tree;
|
|
|
|
prog.run();
|
|
|
|
prog.dump();
|
|
|
|
|
|
|
|
// TODO: change this to a driver
|
|
|
|
{
|
|
|
|
let mut buf = [8; 128 * 4];
|
|
|
|
|
|
|
|
let mut sc = SERIAL_CONSOLE.lock();
|
|
|
|
loop {
|
|
|
|
let byte = sc.receive();
|
|
|
|
if byte == b'\r' {
|
|
|
|
sc.send(b'\n');
|
|
|
|
}
|
|
|
|
sc.send(byte);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-12 13:08:07 -05:00
|
|
|
crate::arch::sloop()
|
2023-03-30 16:43:04 -05:00
|
|
|
}
|
2023-05-15 02:19:34 -05:00
|
|
|
use embedded_graphics::prelude::RgbColor;
|
2023-04-10 01:16:30 -05:00
|
|
|
|
2023-05-15 02:19:34 -05:00
|
|
|
use hbvm::bytecode::ops::Operations::*;
|
2023-05-06 06:50:24 -05:00
|
|
|
pub static DEVICE_TREE: Lazy<Mutex<DeviceTree>> = Lazy::new(|| {
|
|
|
|
let mut dt = DeviceTree::new();
|
|
|
|
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]");
|
|
|
|
}
|