Supervisor mode

This commit is contained in:
2026-01-30 16:22:53 +01:00
parent 7a25e89d4c
commit 53043fd3cd
11 changed files with 457 additions and 108 deletions

View File

@@ -1,31 +1,32 @@
use core::arch::asm;
use core::arch::riscv64::wfi;
use alloc::{
format,
string::{String, ToString},
};
use alloc::{format, string::ToString};
use log::error;
use crate::vga::{Color, FONT_HEIGHT, Vga};
use crate::vga::{Color, Vga, FONT_HEIGHT};
#[panic_handler]
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
error!("PANIC !");
let mut panic_message = if let Some(message) = panic_info.message().as_str() {
message.to_string()
} else {
String::new()
};
let mut panic_message = panic_info.message().to_string();
if let Some(location) = panic_info.location() {
panic_message = format!("{panic_message} at {}:{}", location.file(), location.line());
}
error!("{panic_message}");
Vga::clear_screen(Color::WHITE);
unsafe { Vga::draw_string(0, 0, "PANIC !", Color::BLACK) };
unsafe { Vga::draw_string(0, FONT_HEIGHT as u16, panic_message, Color::BLACK) };
unsafe { Vga::draw_string(0, 0, "PANIC !", Color::BLACK, Color::WHITE) };
unsafe {
Vga::draw_string(
0,
FONT_HEIGHT as u16,
panic_message,
Color::BLACK,
Color::WHITE,
)
};
loop {
unsafe { asm!("wfi") }
unsafe { wfi() }
}
}