1
0
Fork 0
forked from AbleOS/ableos
This commit is contained in:
TheOddGarlic 2022-08-01 10:22:26 +03:00
commit 47a896440b
5 changed files with 79 additions and 59 deletions

View file

@ -6,7 +6,7 @@ user_processes = ["shell"]
enabled = true
level = "Trace"
log_to_serial = true
filter = ["ableos::vterm"]
filter = []
[tests]

View file

@ -45,6 +45,7 @@ impl InterruptIndex {
}
static IDT: Lazy<InterruptDescriptorTable> = 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<InterruptDescriptorTable> = 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);
}

View file

@ -16,6 +16,7 @@ impl log::Log for SimpleLogger {
metadata.level() <= Level::Trace
}
fn log(&self, record: &Record) {
x86_64::instructions::interrupts::without_interrupts(|| {
if self.enabled(record.metadata()) {
let time_float = fetch_time();
use log::Level::*;
@ -71,6 +72,7 @@ impl log::Log for SimpleLogger {
);
}
}
});
}
/// Clear the log buffer
fn flush(&self) {}

View file

@ -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));
}

View file

@ -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::<rhai::Dynamic>(&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 => (),
}
}