#![allow(clippy::empty_loop)] use alloc::{format, vec::Vec}; use crate::{ boot_conf::BootConfig, capabilities::FileAccess, file::{File, PathRep}, scheduler::SCHEDULER, ALIAS_TABLE, }; // use crate::scheduler; use { crate::{ arch::{init, sloop}, boot_conf, experiments::{ info::master, systeminfo::{KERNEL_VERSION, RELEASE_TYPE}, }, graphics::{VgaBuffer, SCREEN_BUFFER}, relib::network::socket::Socket, relib::network::socket::{SimpleSock, SocketReturns}, vga_e::{self, num_to_vga16}, }, alloc::{ string::{String, ToString}, vec, }, core::sync::atomic::{AtomicU64, Ordering::*}, lazy_static::lazy_static, log::*, picorand::PicoRandGenerate, rkyv::{ser::serializers::AllocSerializer, Deserialize}, shadeable::pixel_format::from_vga_16, y_compositor_protocol::Version, }; #[no_mangle] #[allow(unconditional_recursion)] pub extern "C" fn stack_overflow() -> u8 { stack_overflow(); // meme number 69 // NOTE: Any specific reason for this number aside from memes? } lazy_static! { pub static ref KEY_BUFFER: spin::Mutex = spin::Mutex::new("".to_string()); pub static ref TICK: AtomicU64 = AtomicU64::new(0); pub static ref BOOT_CONF: BootConfig = boot_conf::BootConfig::new(); } /// The main entry point of the kernel #[no_mangle] pub fn kernel_main() -> ! { init::init(); log::set_max_level(BOOT_CONF.log_level()); use crate::scheduler::Priority; let mut scheduler = SCHEDULER.lock(); use Priority::*; let mut process_1 = scheduler.new_process(High); process_1.capabilities.files = FileAccess::Some(vec![PathRep { location: FileLocations::Home, file_name: "test".to_string(), }]); scheduler.add_process(process_1); for ref_process in &scheduler.list { trace!("{:?}", ref_process); } drop(scheduler); use crate::proto_filetable::contain::FILE_TABLE; use crate::proto_filetable::file::FileLocations; let mut file_table = FILE_TABLE.lock(); let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string()); new_file.write_bytes(b"Hello, world!"); file_table.add_file("test", new_file); let file = file_table.get_file("test"); match file { Some(file) => { let file_bytes = &file.data_pointer; let file_string = String::from_utf8(file_bytes.to_vec()).unwrap(); info!("{}", file_string); } None => { info!("File not found"); } } crate::tests::screen_writer_test(); use crate::wasm::WasmProgram; let ret = WasmProgram::new_from_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]); trace!("Binary Valid: {:?}", ret.validate_header()); sloop() } /// called by arch specific timers to tick up all kernel related functions pub fn tick() { let mut data = TICK.load(Relaxed); data += 1; crate::kernel_state::KERNEL_STATE.lock().update_state(); let mut scheduler = SCHEDULER.lock(); scheduler.bump_exec(); TICK.store(data, Relaxed) } /// called every time a key is pressed to add it to the randomness pool pub fn key_entropy(key: u8) {} pub fn cpu_socket_startup() { let mut cpu_info_socket = SimpleSock::new(); cpu_info_socket.register_protocol("CPU_INFO".to_string()); let x = master().unwrap(); let _xyz = x.brand_string().unwrap(); } pub fn log_version_data() { info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); info!( "Brand String: {:?}", master().unwrap().brand_string().unwrap() ); }