From d2638b1fb4fd1dae612669be5ccbf020b16fa6a5 Mon Sep 17 00:00:00 2001 From: Able Date: Fri, 11 Mar 2022 15:14:35 -0600 Subject: [PATCH] Patch| Logging repaired --- .gitignore | 2 - ableos/.cargo/config.toml | 3 +- ableos/Cargo.lock | 44 ++++++++++--- ableos/Cargo.toml | 8 ++- ableos/assets/kernel.toml | 2 +- ableos/src/arch/riscv/drivers/uart.rs | 6 +- ableos/src/arch/x86_64/init.rs | 6 +- ableos/src/boot_conf.rs | 3 +- ableos/src/experiments/absi.rs | 1 + ableos/src/kmain.rs | 89 +++------------------------ ableos/src/lib.rs | 6 +- ableos/src/logger.rs | 11 ++-- ableos/src/scratchpad.rs | 5 +- 13 files changed, 78 insertions(+), 108 deletions(-) diff --git a/.gitignore b/.gitignore index be26578..5311cc6 100644 --- a/.gitignore +++ b/.gitignore @@ -6,5 +6,3 @@ shadeable/target qprofiler userland/*/target kernel/target - -kernel/target \ No newline at end of file diff --git a/ableos/.cargo/config.toml b/ableos/.cargo/config.toml index 001c838..917f998 100644 --- a/ableos/.cargo/config.toml +++ b/ableos/.cargo/config.toml @@ -1,5 +1,6 @@ [build] -target = "riscv64gc-unknown-none-elf" +# target = "riscv64gc-unknown-none-elf" +target = "json_targets/x86_64-ableos.json" [unstable] build-std = ["core", "compiler_builtins", "alloc"] diff --git a/ableos/Cargo.lock b/ableos/Cargo.lock index ee8ad12..5f88b6b 100644 --- a/ableos/Cargo.lock +++ b/ableos/Cargo.lock @@ -34,7 +34,7 @@ dependencies = [ "externc-libm", "facepalm", "genfs", - "hashbrown 0.11.2", + "hashbrown 0.7.2", "kernel", "lazy_static", "libwasm", @@ -56,6 +56,7 @@ dependencies = [ "toml", "uart_16550", "unicode-width", + "vga", "volatile 0.2.7", "wasmi", "watson", @@ -143,6 +144,21 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "conquer-once" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c6d3a9775a69f6d1fe2cc888999b67ed30257d3da4d2af91984e722f2ec918a" +dependencies = [ + "conquer-util", +] + +[[package]] +name = "conquer-util" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e763eef8846b13b380f37dfecda401770b0ca4e56e95170237bd7c25c7db3582" + [[package]] name = "const-random" version = "0.1.13" @@ -223,6 +239,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "font8x8" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "875488b8711a968268c7cf5d139578713097ca4635a76044e8fe8eedf831d07e" + [[package]] name = "genfs" version = "0.1.4" @@ -250,12 +272,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "hashbrown" -version = "0.11.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" - [[package]] name = "hashbrown" version = "0.12.0" @@ -788,6 +804,20 @@ name = "versioning" version = "0.1.2" source = "git+https://git.ablecorp.us/able/versioning#ef472283e6e7a2e395ee56434087b3a6fad53ff2" +[[package]] +name = "vga" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67cbcb7bfff998d176ffb8f2c3dfd6cb0fe62740e36dee6c64fc3928c01001bf" +dependencies = [ + "bitflags", + "conquer-once", + "font8x8", + "num-traits", + "spinning_top", + "x86_64", +] + [[package]] name = "volatile" version = "0.2.7" diff --git a/ableos/Cargo.toml b/ableos/Cargo.toml index ee6ede2..4fe49e5 100644 --- a/ableos/Cargo.toml +++ b/ableos/Cargo.toml @@ -93,11 +93,16 @@ features = ["derive", "alloc"] + + [dependencies.hashbrown] -version = "0.11.2" +version = "0.7.2" default-features = false features = ["inline-more"] + + + [dependencies.rkyv] version = "0.7.29" default-features = false @@ -159,3 +164,4 @@ uart_16550 = "0.2.0" volatile = "0.2.6" x86_64 = "*" pc-beeper = {git = "https://github.com/AbleOS/pc-beeper"} +vga = "*" diff --git a/ableos/assets/kernel.toml b/ableos/assets/kernel.toml index b666058..e29e993 100644 --- a/ableos/assets/kernel.toml +++ b/ableos/assets/kernel.toml @@ -3,7 +3,7 @@ system_processes = [] user_processes = ["shell"] [logging] -enabled = false +enabled = true level = "Trace" [tests] diff --git a/ableos/src/arch/riscv/drivers/uart.rs b/ableos/src/arch/riscv/drivers/uart.rs index bff6017..33fb0ca 100644 --- a/ableos/src/arch/riscv/drivers/uart.rs +++ b/ableos/src/arch/riscv/drivers/uart.rs @@ -144,11 +144,11 @@ macro_rules! sprint macro_rules! sprintln { () => ({ - print!("\r\n") + sprint!("\r\n") }); - ($fmt:expr) => (print!(concat!($fmt, "\r\n"))); + ($fmt:expr) => (sprint!(concat!($fmt, "\r\n"))); ($fmt:expr, $($args:tt)+) => ({ - print!(concat!($fmt, "\r\n"), $($args)+) + sprint!(concat!($fmt, "\r\n"), $($args)+) }); } diff --git a/ableos/src/arch/x86_64/init.rs b/ableos/src/arch/x86_64/init.rs index 75faf68..4aa0778 100644 --- a/ableos/src/arch/x86_64/init.rs +++ b/ableos/src/arch/x86_64/init.rs @@ -1,5 +1,5 @@ // #![allow(clippy::print_literal)] -use crate::{logger, SCHEDULER}; +use crate::{logger, scheduler::SCHEDULER, serial_println}; use super::{gdt, interrupts}; @@ -13,7 +13,9 @@ pub fn init() { let result = logger::init(); match result { - Ok(_) => {} + Ok(_) => { + serial_println!("Logger initialized"); + } Err(err) => error!("{}", err), } gdt::init(); diff --git a/ableos/src/boot_conf.rs b/ableos/src/boot_conf.rs index e711287..c48daf8 100644 --- a/ableos/src/boot_conf.rs +++ b/ableos/src/boot_conf.rs @@ -57,5 +57,6 @@ pub struct TestsConfig { #[derive(Serialize, Debug, Deserialize)] pub struct BootConfig { - pub processes: Vec, + pub system_processes: Vec, + pub user_processes: Vec, } diff --git a/ableos/src/experiments/absi.rs b/ableos/src/experiments/absi.rs index ccad9d7..5c60c87 100644 --- a/ableos/src/experiments/absi.rs +++ b/ableos/src/experiments/absi.rs @@ -1,4 +1,5 @@ // TODO improve tokenizer/parser + pub fn colorify(eval: &str) { let y = eval.split("$"); for z in y { diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index bd742e4..c88d733 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -8,14 +8,8 @@ use { crate::{ arch::{init, sloop}, - relib::network::socket::{SimpleSock, Socket}, - // scheduler::SCHEDULER, - // VgaBuffer, - // SCREEN_BUFFER, scratchpad, - // SCHEDULER, - SCREEN_BUFFER, }, facepalm::start_facepalm, lazy_static::lazy_static, @@ -36,89 +30,18 @@ pub fn kernel_main() -> ! { } else { log::set_max_level(log::LevelFilter::Off); } - let mut scheduler = SCHEDULER.lock(); - /* - - - - - use crate::scheduler::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(), - }]); + process_1.capabilities.files = FileAccess::Some(vec![]); scheduler.add_process(process_1); for ref_process in &scheduler.list { trace!("{:?}", ref_process); } drop(scheduler); - - - */ - // use crate::proto_filetable::file::FileLocations; - - /* - if false { - let mut sock_print_id = SimpleSock::new(); - sock_print_id.register_protocol("Screen Printer".to_string()); - sock_print_id.write(format!("🐑").into()); - - let mut mode = SCREEN_BUFFER.lock(); - - mode.force_redraw(); - for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() { - // mode.draw_char(0, 0, current, from_vga_16(Color16::Red)); - } - // mode.copy_to_buffer(); - } - <<<<<<< HEAD - */ - /* - // TODO: create a scratchpad module - if false { - // Currently not implemented - let acpi_handler = AcpiStruct {}; - let mut table; - unsafe { - table = AcpiTables::search_for_rsdp_bios(acpi_handler); - } - } - - ======= - mode.copy_to_buffer(); - } - - start_facepalm(); - scratchpad(); - >>>>>>> master - - */ // start_facepalm(); - // scratchpad(); - - /* - if false { - // disable(); - let mut mode = SCREEN_BUFFER.lock(); - mode.force_redraw(); - - // mode.copy_to_buffer(); - mode.clear(); - - mode.draw_char(0, 0, 'v', 0xff00ffff); - - // mode.copy_to_buffer(); - drop(mode); - // enable() - // sloop::halt(); - } - - - */ + scratchpad(); sloop() } @@ -176,4 +99,10 @@ impl acpi::AcpiHandler for AcpiStruct { use kernel::KERNEL_VERSION; -use crate::{boot_conf::KernelConfig, scheduler::SCHEDULER, systeminfo::RELEASE_TYPE}; +use crate::{ + boot_conf::KernelConfig, + kprint, + scheduler::{capabilities::FileAccess, SCHEDULER}, + serial_print, serial_println, + systeminfo::RELEASE_TYPE, +}; diff --git a/ableos/src/lib.rs b/ableos/src/lib.rs index f5f3346..a7914d9 100644 --- a/ableos/src/lib.rs +++ b/ableos/src/lib.rs @@ -87,11 +87,9 @@ pub use virtio::*; // pub mod alias_table; // pub use alias_table::*; -#[cfg(target_arch = "x86_64")] -pub mod tests; -#[cfg(target_arch = "x86_64")] -pub use tests::*; +// pub mod tests; +// pub use tests::*; pub mod scratchpad; pub use scratchpad::*; diff --git a/ableos/src/logger.rs b/ableos/src/logger.rs index ad3fea3..0341ebd 100644 --- a/ableos/src/logger.rs +++ b/ableos/src/logger.rs @@ -1,7 +1,7 @@ use core::sync::atomic::Ordering; use crate::network::socket::{SimpleSock, Socket}; -// use crate::serial_println; +use crate::{kprint, serial_println}; use kernel::TICK; use lliw::{Fg, Reset}; @@ -19,8 +19,9 @@ impl log::Log for SimpleLogger { fn log(&self, record: &Record) { if self.enabled(record.metadata()) { let color; + disable(); let time = TICK.load(Ordering::Relaxed) as f64; - + enable(); let time_float = time; match record.level() { @@ -37,9 +38,10 @@ impl log::Log for SimpleLogger { time_float, record.args() ); - + // kprint!("{}", msg); // NOTE: This needs to be fixed before merge - println!( + + serial_println!( "[{}{}{}][{}{}{}] {}", color.0, record.level(), @@ -64,6 +66,7 @@ impl log::Log for SimpleLogger { } use log::{LevelFilter, SetLoggerError}; +use x86_64::instructions::interrupts::{disable, enable}; static LOGGER: SimpleLogger = SimpleLogger; diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index f6f8126..2782206 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -1,10 +1,11 @@ use acpi::AcpiTables; -use crate::rhai_shell::rhai_shell; +use crate::{kprintln, rhai_shell::rhai_shell, serial_println}; /// Experimental scratchpad for testing. pub fn scratchpad() { - pci_fun(); + // pci_fun(); + rhai_shell(); }