Merge branch 'master' of https://git.ablecorp.us:443/theoddgarlic/ableos
This commit is contained in:
commit
47a896440b
|
@ -6,7 +6,7 @@ user_processes = ["shell"]
|
|||
enabled = true
|
||||
level = "Trace"
|
||||
log_to_serial = true
|
||||
filter = ["ableos::vterm"]
|
||||
filter = []
|
||||
|
||||
|
||||
[tests]
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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 => (),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue