From b1de5148b7fe16f7213ce36cb36f3c5fd141c956 Mon Sep 17 00:00:00 2001 From: able Date: Sun, 31 Jul 2022 06:21:50 -0500 Subject: [PATCH] filtering out undesired logging --- ableos/assets/kernel.toml | 4 ++- ableos/src/arch/x86_64/interrupts.rs | 8 ++--- ableos/src/boot_conf.rs | 1 + ableos/src/kmain.rs | 1 + ableos/src/logger.rs | 8 ++++- ableos/src/print.rs | 4 +-- ableos/src/relib/image/mono_bitmap.rs | 22 ++++++------- ableos/src/scratchpad.rs | 2 ++ ableos/src/vterm.rs | 45 +++++++++++++++------------ 9 files changed, 56 insertions(+), 39 deletions(-) diff --git a/ableos/assets/kernel.toml b/ableos/assets/kernel.toml index f12e603f..a7b45af2 100644 --- a/ableos/assets/kernel.toml +++ b/ableos/assets/kernel.toml @@ -6,8 +6,10 @@ user_processes = ["shell"] enabled = true level = "Trace" log_to_serial = true +filter = ["ableos::vterm"] + [tests] run_tests = false run_demos = false -run_shader_tests = false \ No newline at end of file +run_shader_tests = false diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 2f5d3896..32f1227e 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -79,7 +79,7 @@ extern "x86-interrupt" fn double_fault_handler( _error_code: u64, ) -> ! { bsod(BSODSource::DoubleFault(&stack_frame)); - panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame); + // panic!("EXCEPTION: DOUBLE FAULT\n{:#?}", stack_frame); } #[naked] @@ -123,7 +123,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac .add_byte(unsafe { Port::new(0x60).read() }) .map(|x| x.and_then(|ev| keyboard.process_keyevent(ev))) { - trace!("{key:?}"); + // trace!("{key:?}"); match key { DecodedKey::Unicode(chr) => match chr { // Backspace @@ -147,7 +147,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac warn!("ArrowKeys are unsupported currently"); } - kc => print!("{kc:?}"), + kc => trace!("Unprintable key: {kc:?}"), }; } } @@ -195,7 +195,7 @@ pub fn set_pit_3(freq: u32) { } pub fn reset_pit_for_cpu() { - set_pit_1(50); + set_pit_1(5000); set_pit_2(1000); set_pit_3(1000); } diff --git a/ableos/src/boot_conf.rs b/ableos/src/boot_conf.rs index e91cf25c..87f6530b 100644 --- a/ableos/src/boot_conf.rs +++ b/ableos/src/boot_conf.rs @@ -53,6 +53,7 @@ pub struct LoggingConfig { pub enabled: bool, pub log_to_serial: bool, pub level: LogLevel, + pub filter: Vec, } #[derive(Serialize, Debug, Deserialize)] pub struct TestsConfig { diff --git a/ableos/src/kmain.rs b/ableos/src/kmain.rs index 4b609ac4..274e6a61 100644 --- a/ableos/src/kmain.rs +++ b/ableos/src/kmain.rs @@ -33,6 +33,7 @@ pub fn kernel_main() -> ! { // /* if KERNEL_CONF.logging.enabled { log::set_max_level(KERNEL_CONF.log_level()); + // println!("{:#?}", *KERNEL_CONF); } else { log::set_max_level(log::LevelFilter::Off); } diff --git a/ableos/src/logger.rs b/ableos/src/logger.rs index cea2ce46..db6e84d1 100644 --- a/ableos/src/logger.rs +++ b/ableos/src/logger.rs @@ -39,7 +39,13 @@ impl log::Log for SimpleLogger { ); */ let mod_path = match record.module_path() { - Some(p) => p, + Some(p) => { + if KERNEL_CONF.logging.filter.contains(&p.to_string()) { + return; + } + + p + } None => "unknown", }; diff --git a/ableos/src/print.rs b/ableos/src/print.rs index 04cac19f..6b7724c5 100644 --- a/ableos/src/print.rs +++ b/ableos/src/print.rs @@ -38,14 +38,14 @@ impl core::fmt::Write for Stdout { } */ - trace!("printing"); + // trace!("printing"); // x86_64::instructions::interrupts::without_interrupts(|| { let mut term = TERM.lock(); term.set_dirty(true); term.print(s.to_string()); drop(term); // }); - trace!("Finished printing"); + // trace!("Finished printing"); Ok(()) } #[cfg(target_arch = "riscv64")] diff --git a/ableos/src/relib/image/mono_bitmap.rs b/ableos/src/relib/image/mono_bitmap.rs index 59e73863..1276d5e1 100644 --- a/ableos/src/relib/image/mono_bitmap.rs +++ b/ableos/src/relib/image/mono_bitmap.rs @@ -1,8 +1,11 @@ use crate::{ graphics::SCREEN_BUFFER, relib::encoding::rle::{decode, encode}, + vga_e::VGAE, + VgaBuffer, }; use shadeable::pixel_format::new_rgba64; +use vga::writers::GraphicsWriter; pub fn bruh() { #[rustfmt::skip] @@ -10,27 +13,24 @@ pub fn bruh() { let xyz_old = decode(&xyz_new); - trace!("encoded {:?}", xyz_new.len()); - trace!("decoded {:?}", xyz_old.len()); - - let mut screen_lock = SCREEN_BUFFER.lock(); - - for y in 0..20 { - for x in 0..20 { + let screen_lock = VGAE.lock(); + screen_lock.set_mode(); + for y in 0..8 { + for x in 0..8 { // trace!(""); - // info!("x{} | y{}", x, y); + info!("x{} | y{}", x, y); // Stops at 419 match xyz_old[y * 290 + x] { 221..=255 => { - screen_lock.set_pixel(x, y, new_rgba64(255, 255, 255, 0)); + screen_lock.set_pixel(x, y, vga::colors::Color16::Red); } 170..=220 => { - screen_lock.set_pixel(x, y, new_rgba64(128, 128, 128, 0)); + screen_lock.set_pixel(x, y, vga::colors::Color16::DarkGrey); } 100..=169 => { - screen_lock.set_pixel(x, y, new_rgba64(56, 56, 56, 0)); + screen_lock.set_pixel(x, y, vga::colors::Color16::LightGrey); } _ => { // VGAE.lock().set_pixel(x, y, Color16::Red); diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 818e0b30..d7d57249 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -7,6 +7,7 @@ use crate::channels::{Channel, ChannelPermission}; use crate::devices::pci; use crate::filesystem::FILE_SYSTEM; use crate::handle::Handle; +use crate::image::mono_bitmap::bruh; use crate::ipc::IPC; use crate::rhai_shell::shell; use crate::rhai_shell::KEYBUFF; @@ -70,6 +71,7 @@ impl Path { /// Experimental scratchpad for testing. pub fn scratchpad() { + // bruh(); real_shell(); } diff --git a/ableos/src/vterm.rs b/ableos/src/vterm.rs index 429fefca..155ec726 100644 --- a/ableos/src/vterm.rs +++ b/ableos/src/vterm.rs @@ -46,7 +46,7 @@ impl Term { // trace!("IMPOSSIBLE BACKSPACE"); return; } - // trace!("BACKSPACE"); + trace!("BACKSPACE"); self.x -= 1; self.term[TERM_MINUS_ONE_LINE + (self.x as usize)] = '\0'; } @@ -81,27 +81,32 @@ impl Term { let mode = VGAE.lock(); mode.clear_screen(Color16::Black); - let mouse_coord = x86_64::instructions::interrupts::without_interrupts(|| { - let cursor = MOUSE.lock(); + /* + let mouse = false; + if mouse { + let mouse_coord = x86_64::instructions::interrupts::without_interrupts(|| { + let cursor = MOUSE.lock(); - (cursor.get_x() as usize, cursor.get_y() as usize) - }); + (cursor.get_x() as usize, cursor.get_y() as usize) + }); - mode.draw_line( - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), - (mouse_coord.0 as isize + 10, mouse_coord.1 as isize + 10), - CURSOR_COLOR, - ); - mode.draw_line( - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), - (mouse_coord.0 as isize + 5, mouse_coord.1 as isize + 0), - CURSOR_COLOR, - ); - mode.draw_line( - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), - (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 5), - CURSOR_COLOR, - ); + mode.draw_line( + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), + (mouse_coord.0 as isize + 10, mouse_coord.1 as isize + 10), + CURSOR_COLOR, + ); + mode.draw_line( + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), + (mouse_coord.0 as isize + 5, mouse_coord.1 as isize + 0), + CURSOR_COLOR, + ); + mode.draw_line( + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 0), + (mouse_coord.0 as isize + 0, mouse_coord.1 as isize + 5), + CURSOR_COLOR, + ); + } + */ let mut x = 0; let mut y = 0;