forked from AbleOS/ableos
recent changes <3
This commit is contained in:
parent
b1de5148b7
commit
dd6431ab84
|
@ -6,7 +6,7 @@ user_processes = ["shell"]
|
||||||
enabled = true
|
enabled = true
|
||||||
level = "Trace"
|
level = "Trace"
|
||||||
log_to_serial = true
|
log_to_serial = true
|
||||||
filter = ["ableos::vterm"]
|
filter = []
|
||||||
|
|
||||||
|
|
||||||
[tests]
|
[tests]
|
||||||
|
|
|
@ -45,6 +45,7 @@ impl InterruptIndex {
|
||||||
}
|
}
|
||||||
|
|
||||||
static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
|
static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
|
||||||
|
reset_pit_for_cpu();
|
||||||
let mut idt = InterruptDescriptorTable::new();
|
let mut idt = InterruptDescriptorTable::new();
|
||||||
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
idt.breakpoint.set_handler_fn(breakpoint_handler);
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -53,8 +54,6 @@ static IDT: Lazy<InterruptDescriptorTable> = Lazy::new(|| {
|
||||||
.set_stack_index(gdt::DOUBLE_FAULT_IST_INDEX);
|
.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::Timer.as_usize()].set_handler_fn(timer_interrupt_handler);
|
||||||
idt[InterruptIndex::Keyboard.as_usize()].set_handler_fn(keyboard_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);
|
// 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 {
|
unsafe {
|
||||||
asm!(
|
asm!(
|
||||||
|
|
||||||
|
|
||||||
|
// "call {disable}",
|
||||||
// Kernel tick
|
// Kernel tick
|
||||||
"call {tick}",
|
"call {tick}",
|
||||||
|
|
||||||
|
@ -97,11 +98,14 @@ extern "x86-interrupt" fn timer_interrupt_handler(_stack_frame: InterruptStackFr
|
||||||
"mov rdi, rsp",
|
"mov rdi, rsp",
|
||||||
"call {save}",
|
"call {save}",
|
||||||
|
|
||||||
|
// "call {enable}",
|
||||||
// Switch to next task (interrupt'll be returned there)
|
// Switch to next task (interrupt'll be returned there)
|
||||||
"jmp {switch_to_next}",
|
"jmp {switch_to_next}",
|
||||||
|
|
||||||
tick = sym crate::kmain::tick,
|
tick = sym crate::kmain::tick,
|
||||||
save = sym task_switcher::save_and_enqueue,
|
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,
|
switch_to_next = sym task_switcher::switch_to_next,
|
||||||
options(noreturn),
|
options(noreturn),
|
||||||
);
|
);
|
||||||
|
@ -126,17 +130,22 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
|
||||||
// trace!("{key:?}");
|
// trace!("{key:?}");
|
||||||
match key {
|
match key {
|
||||||
DecodedKey::Unicode(chr) => match chr {
|
DecodedKey::Unicode(chr) => match chr {
|
||||||
|
'\n' => {
|
||||||
|
KEYBUFF.lock().push('\n');
|
||||||
|
trace!("ENTER");
|
||||||
|
}
|
||||||
// Backspace
|
// Backspace
|
||||||
'\u{8}' => {
|
'\u{8}' => {
|
||||||
// TODO: Fix this and apply to new term
|
// TODO: Fix this and apply to new term
|
||||||
|
|
||||||
KEYBUFF.lock().push(8.into());
|
KEYBUFF.lock().push(8.into());
|
||||||
print!("\u{8}");
|
// print!("\u{8}");
|
||||||
}
|
}
|
||||||
// '^' => KERNEL_STATE.lock().shutdown(),
|
// '^' => KERNEL_STATE.lock().shutdown(),
|
||||||
chr => {
|
chr => {
|
||||||
KEYBUFF.lock().push(chr);
|
KEYBUFF.lock().push(chr);
|
||||||
print!("{chr}");
|
// trace!("{chr}");
|
||||||
|
// print!("{chr}");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
DecodedKey::RawKey(key) => {
|
DecodedKey::RawKey(key) => {
|
||||||
|
@ -144,10 +153,13 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
|
||||||
match KeyCode::from(key) {
|
match KeyCode::from(key) {
|
||||||
AltLeft | AltRight => (),
|
AltLeft | AltRight => (),
|
||||||
ArrowDown | ArrowRight | ArrowLeft | ArrowUp => {
|
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() {
|
pub fn reset_pit_for_cpu() {
|
||||||
set_pit_1(5000);
|
set_pit_1(1000);
|
||||||
set_pit_2(1000);
|
set_pit_2(1000);
|
||||||
set_pit_3(1000);
|
set_pit_3(1000);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,61 +16,63 @@ impl log::Log for SimpleLogger {
|
||||||
metadata.level() <= Level::Trace
|
metadata.level() <= Level::Trace
|
||||||
}
|
}
|
||||||
fn log(&self, record: &Record) {
|
fn log(&self, record: &Record) {
|
||||||
if self.enabled(record.metadata()) {
|
x86_64::instructions::interrupts::without_interrupts(|| {
|
||||||
let time_float = fetch_time();
|
if self.enabled(record.metadata()) {
|
||||||
use log::Level::*;
|
let time_float = fetch_time();
|
||||||
use Fg::*;
|
use log::Level::*;
|
||||||
|
use Fg::*;
|
||||||
|
|
||||||
let color = match record.level() {
|
let color = match record.level() {
|
||||||
log::Level::Error => (Fg::Red, "$RED$"),
|
log::Level::Error => (Fg::Red, "$RED$"),
|
||||||
log::Level::Warn => (Fg::LightYellow, "$LIGHTYELLOW$"),
|
log::Level::Warn => (Fg::LightYellow, "$LIGHTYELLOW$"),
|
||||||
log::Level::Info => (Fg::LightWhite, "$LIGHTGRAY$"),
|
log::Level::Info => (Fg::LightWhite, "$LIGHTGRAY$"),
|
||||||
log::Level::Debug => (Fg::Blue, "$BLUE$"),
|
log::Level::Debug => (Fg::Blue, "$BLUE$"),
|
||||||
log::Level::Trace => (Fg::Yellow, "$YELLOW$"),
|
log::Level::Trace => (Fg::Yellow, "$YELLOW$"),
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
let msg = format!(
|
let msg = format!(
|
||||||
"[{}{}$RESET$][$GREEN${}$RESET$]{}\n",
|
"[{}{}$RESET$][$GREEN${}$RESET$]{}\n",
|
||||||
color.1,
|
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,
|
|
||||||
record.level(),
|
record.level(),
|
||||||
Fg::Reset,
|
|
||||||
Fg::Green,
|
|
||||||
time_float,
|
time_float,
|
||||||
Reset,
|
|
||||||
Fg::Blue,
|
|
||||||
mod_path,
|
|
||||||
line,
|
|
||||||
Reset,
|
|
||||||
record.args()
|
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
|
/// Clear the log buffer
|
||||||
fn flush(&self) {}
|
fn flush(&self) {}
|
||||||
|
|
|
@ -5,7 +5,7 @@ use crate::arch::interrupts::{bsod, BSODSource};
|
||||||
|
|
||||||
#[panic_handler]
|
#[panic_handler]
|
||||||
fn panic_handler(info: &PanicInfo) -> ! {
|
fn panic_handler(info: &PanicInfo) -> ! {
|
||||||
error!("{}", info);
|
error!("{:?}", info);
|
||||||
|
|
||||||
bsod(BSODSource::Panic(info));
|
bsod(BSODSource::Panic(info));
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,6 +107,7 @@ pub fn real_shell() {
|
||||||
loop {
|
loop {
|
||||||
match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) {
|
match x86_64::instructions::interrupts::without_interrupts(|| KEYBUFF.lock().pop()) {
|
||||||
Some('\n') => {
|
Some('\n') => {
|
||||||
|
println!();
|
||||||
// match engine.eval_with_scope::<rhai::Dynamic>(&mut scope, &buf) {
|
// match engine.eval_with_scope::<rhai::Dynamic>(&mut scope, &buf) {
|
||||||
// Ok(o) => println!("{o}"),
|
// Ok(o) => println!("{o}"),
|
||||||
|
|
||||||
|
@ -117,9 +118,11 @@ pub fn real_shell() {
|
||||||
}
|
}
|
||||||
|
|
||||||
buf.clear();
|
buf.clear();
|
||||||
print!("{}", prompt);
|
print!("\n{}", prompt);
|
||||||
}
|
}
|
||||||
Some('\u{0008}') => {
|
Some('\u{0008}') => {
|
||||||
|
print!("\u{08}");
|
||||||
|
|
||||||
buf.pop();
|
buf.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,7 +133,10 @@ pub fn real_shell() {
|
||||||
buf.push(' ');
|
buf.push(' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
Some(chr) => buf.push(chr),
|
Some(chr) => {
|
||||||
|
buf.push(chr);
|
||||||
|
print!("{}", chr);
|
||||||
|
}
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue