diff --git a/ableos/assets/kernel.toml b/ableos/assets/kernel.toml index a7b45af2e..ae07a949c 100644 --- a/ableos/assets/kernel.toml +++ b/ableos/assets/kernel.toml @@ -6,7 +6,7 @@ user_processes = ["shell"] enabled = true level = "Trace" log_to_serial = true -filter = ["ableos::vterm"] +filter = [] [tests] diff --git a/ableos/src/arch/x86_64/interrupts.rs b/ableos/src/arch/x86_64/interrupts.rs index 32f1227eb..68e9fda2c 100644 --- a/ableos/src/arch/x86_64/interrupts.rs +++ b/ableos/src/arch/x86_64/interrupts.rs @@ -45,6 +45,7 @@ impl InterruptIndex { } static IDT: Lazy = Lazy::new(|| { + reset_pit_for_cpu(); let mut idt = InterruptDescriptorTable::new(); idt.breakpoint.set_handler_fn(breakpoint_handler); unsafe { @@ -53,8 +54,6 @@ static IDT: Lazy = Lazy::new(|| { .set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX); } - reset_pit_for_cpu(); - idt[InterruptIndex::Timer.as_usize()].set_handler_fn(timer_interrupt_handler); idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_interrupt_handler); // idt[InterruptIndex::Mouse.as_usize()].set_handler_fn(crate::hardware::mouse_interrupt_handler); @@ -88,6 +87,8 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFr unsafe { asm!( + + // "call {disable}", // Kernel tick "call {tick}", @@ -97,11 +98,14 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFr "mov rdi, rsp", "call {save}", + // "call {enable}", // Switch to next task (interrupt'll be returned there) "jmp {switch_to_next}", tick = sym crate::kmain::tick, save = sym task_switcher::save_and_enqueue, + // disable = sym x86_64::instructions::interrupts::disable, + // enable = sym x86_64::instructions::interrupts::enable, switch_to_next = sym task_switcher::switch_to_next, options(noreturn), ); @@ -126,17 +130,22 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac // trace!("{key:?}"); match key { DecodedKey::Unicode(chr) => match chr { + '\n' => { + KEYBUFF.lock().push('\n'); + trace!("ENTER"); + } // Backspace '\u{8}' => { // TODO: Fix this and apply to new term KEYBUFF.lock().push(8.into()); - print!("\u{8}"); + // print!("\u{8}"); } // '^' => KERNEL_STATE.lock().shutdown(), chr => { KEYBUFF.lock().push(chr); - print!("{chr}"); + // trace!("{chr}"); + // print!("{chr}"); } }, DecodedKey::RawKey(key) => { @@ -144,10 +153,13 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac match KeyCode::from(key) { AltLeft | AltRight => (), ArrowDown | ArrowRight | ArrowLeft | ArrowUp => { - warn!("ArrowKeys are unsupported currently"); + // warn!("ArrowKeys are unsupported currently"); } - kc => trace!("Unprintable key: {kc:?}"), + kc => { + + // trace!("Unprintable key: {kc:?}"), + } }; } } @@ -195,7 +207,7 @@ pub fn set_pit_3(freq: u32) { } pub fn reset_pit_for_cpu() { - set_pit_1(5000); + set_pit_1(1000); set_pit_2(1000); set_pit_3(1000); } diff --git a/ableos/src/logger.rs b/ableos/src/logger.rs index db6e84d10..20254c8cf 100644 --- a/ableos/src/logger.rs +++ b/ableos/src/logger.rs @@ -16,61 +16,63 @@ impl log::Log for SimpleLogger { metadata.level() <= Level::Trace } fn log(&self, record: &Record) { - if self.enabled(record.metadata()) { - let time_float = fetch_time(); - use log::Level::*; - use Fg::*; + x86_64::instructions::interrupts::without_interrupts(|| { + if self.enabled(record.metadata()) { + let time_float = fetch_time(); + use log::Level::*; + use Fg::*; - let color = match record.level() { - log::Level::Error => (Fg::Red, "$RED$"), - log::Level::Warn => (Fg::LightYellow, "$LIGHTYELLOW$"), - log::Level::Info => (Fg::LightWhite, "$LIGHTGRAY$"), - log::Level::Debug => (Fg::Blue, "$BLUE$"), - log::Level::Trace => (Fg::Yellow, "$YELLOW$"), - }; + let color = match record.level() { + log::Level::Error => (Fg::Red, "$RED$"), + log::Level::Warn => (Fg::LightYellow, "$LIGHTYELLOW$"), + log::Level::Info => (Fg::LightWhite, "$LIGHTGRAY$"), + log::Level::Debug => (Fg::Blue, "$BLUE$"), + log::Level::Trace => (Fg::Yellow, "$YELLOW$"), + }; - /* - let msg = format!( - "[{}{}$RESET$][$GREEN${}$RESET$]{}\n", - color.1, - record.level(), - time_float, - record.args() - ); - */ - let mod_path = match record.module_path() { - Some(p) => { - if KERNEL_CONF.logging.filter.contains(&p.to_string()) { - return; - } - - p - } - None => "unknown", - }; - - let line = match record.line() { - Some(line_number) => line_number.to_string(), - None => "??".to_string(), - }; - - if KERNEL_CONF.logging.log_to_serial { - serial_println!( - "[{}{}{}][{}{}{}][{}{}@{}{}] {}", - color.0, + /* + let msg = format!( + "[{}{}$RESET$][$GREEN${}$RESET$]{}\n", + color.1, record.level(), - Fg::Reset, - Fg::Green, time_float, - Reset, - Fg::Blue, - mod_path, - line, - Reset, record.args() ); + */ + let mod_path = match record.module_path() { + Some(p) => { + if KERNEL_CONF.logging.filter.contains(&p.to_string()) { + return; + } + + p + } + None => "unknown", + }; + + let line = match record.line() { + Some(line_number) => line_number.to_string(), + None => "??".to_string(), + }; + + if KERNEL_CONF.logging.log_to_serial { + serial_println!( + "[{}{}{}][{}{}{}][{}{}@{}{}] {}", + color.0, + record.level(), + Fg::Reset, + Fg::Green, + time_float, + Reset, + Fg::Blue, + mod_path, + line, + Reset, + record.args() + ); + } } - } + }); } /// Clear the log buffer fn flush(&self) {} diff --git a/ableos/src/panic.rs b/ableos/src/panic.rs index 725f7f3dd..d2a79384f 100644 --- a/ableos/src/panic.rs +++ b/ableos/src/panic.rs @@ -5,7 +5,7 @@ use crate::arch::interrupts::{bsod, BSODSource}; #[panic_handler] fn panic_handler(info: &PanicInfo) -> ! { - error!("{}", info); + error!("{:?}", info); bsod(BSODSource::Panic(info)); } diff --git a/ableos/src/scratchpad.rs b/ableos/src/scratchpad.rs index 6d8b9c5be..400685706 100644 --- a/ableos/src/scratchpad.rs +++ b/ableos/src/scratchpad.rs @@ -107,6 +107,7 @@ pub fn real_shell() { loop { match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) { Some('\n') => { + println!(); // match engine.eval_with_scope::(&mut scope, &buf) { // Ok(o) => println!("{o}"), @@ -117,9 +118,11 @@ pub fn real_shell() { } buf.clear(); - print!("{}", prompt); + print!("\n{}", prompt); } Some('\u{0008}') => { + print!("\u{08}"); + buf.pop(); } @@ -130,7 +133,10 @@ pub fn real_shell() { buf.push(' '); } - Some(chr) => buf.push(chr), + Some(chr) => { + buf.push(chr); + print!("{}", chr); + } None => (), } }