1
0
Fork 0
forked from AbleOS/ableos
ableos_time/ableos/src/kmain.rs

81 lines
2 KiB
Rust
Raw Normal View History

2021-11-16 00:09:27 -06:00
#![allow(clippy::empty_loop)]
2021-11-28 14:50:14 -06:00
2022-07-28 20:15:02 -05:00
use core::sync::atomic::Ordering;
use crate::arch::drivers::sysinfo::master;
2022-07-29 06:13:26 -05:00
use crate::ipc::channel::ChannelMessage;
2022-07-28 20:15:02 -05:00
use crate::ipc::{self, IPC};
use crate::scheduler::SCHEDULER;
2022-07-28 20:15:02 -05:00
use crate::time::fetch_time;
2022-07-29 06:13:26 -05:00
use crate::SectionType;
use crate::{
arch::{init, sloop},
relib::network::socket::{SimpleSock, Socket},
scratchpad,
2021-11-16 00:09:27 -06:00
};
2022-04-11 17:23:11 -05:00
use crate::{boot_conf::KernelConfig, systeminfo::RELEASE_TYPE};
2022-07-28 20:15:02 -05:00
use kernel::{KERNEL_VERSION, TICK};
2022-07-29 06:13:26 -05:00
use libwasm::syscalls::time_calls::get_time;
use spin::Lazy;
2022-07-29 06:13:26 -05:00
use x86_64::instructions::interrupts::{disable, enable};
2022-01-13 08:54:33 -06:00
// TODO: Change this structure to allow for multiple cores loaded
pub static KERNEL_CONF: Lazy<KernelConfig> = Lazy::new(KernelConfig::new);
2021-11-23 06:01:42 -06:00
/// The main entry point of the kernel
2021-11-16 00:09:27 -06:00
#[no_mangle]
2021-11-23 06:01:42 -06:00
pub fn kernel_main() -> ! {
2021-11-16 00:09:27 -06:00
init::init();
if KERNEL_CONF.logging.enabled {
log::set_max_level(KERNEL_CONF.log_level());
} else {
log::set_max_level(log::LevelFilter::Off);
}
2022-02-03 13:47:58 -06:00
2022-07-28 20:15:02 -05:00
let mut ipc_service = IPC.lock();
// create some channels or whatever here then drop it
2022-07-29 06:13:26 -05:00
let log_handle = ipc_service.create_channel("LOG", true);
2022-07-28 20:15:02 -05:00
drop(ipc_service);
x86_64::instructions::interrupts::without_interrupts(|| {
2022-07-29 06:13:26 -05:00
let mut scheduler = SCHEDULER.lock();
// TODO: This task never gets run
scheduler.enqueue_spawn(traceloop);
//
scheduler.enqueue_spawn(scratchpad);
});
2022-02-18 10:04:10 -06:00
sloop()
2021-11-16 00:09:27 -06:00
}
2021-11-23 08:49:41 -06:00
2022-07-29 06:13:26 -05:00
pub fn traceloop() {
let mut last_time = 0.0;
loop {
// let time = fetch_time();
// if time > last_time {
// last_time = time;
// trace!("Timer");
// }
}
}
2022-01-22 00:01:16 -06:00
pub fn cpu_socket_startup() {
let mut cpu_info_socket = SimpleSock::new();
cpu_info_socket.register_protocol("CPU_INFO".to_string());
2022-01-18 06:15:51 -06:00
2022-02-18 10:04:10 -06:00
// let x = master().unwrap();
// let _xyz = x.brand_string().unwrap();
2022-01-18 06:15:51 -06:00
}
pub fn log_version_data() {
2022-04-11 13:53:33 -05:00
info!("{} v{:?}", RELEASE_TYPE, KERNEL_VERSION);
2022-01-18 06:15:51 -06:00
info!(
"Brand String: {}",
master().unwrap().brand_string().unwrap()
2022-01-18 06:15:51 -06:00
);
}