33 lines
813 B
Rust
33 lines
813 B
Rust
use core::arch::riscv64::wfi;
|
|
|
|
use alloc::{format, string::ToString};
|
|
use log::error;
|
|
|
|
use crate::vga::{Color, Vga, FONT_HEIGHT};
|
|
|
|
#[panic_handler]
|
|
fn panic(panic_info: &core::panic::PanicInfo) -> ! {
|
|
error!("PANIC !");
|
|
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, Color::WHITE) };
|
|
unsafe {
|
|
Vga::draw_string(
|
|
0,
|
|
FONT_HEIGHT as u16,
|
|
panic_message,
|
|
Color::BLACK,
|
|
Color::WHITE,
|
|
)
|
|
};
|
|
|
|
loop {
|
|
unsafe { wfi() }
|
|
}
|
|
}
|