From 62cce51eff15b648179a3ad8c77a0885e9394a10 Mon Sep 17 00:00:00 2001 From: natrixaeria Date: Sat, 26 Oct 2019 00:54:05 +0200 Subject: Create a kernel panic screen --- kernel/src/lib.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'kernel/src/lib.rs') diff --git a/kernel/src/lib.rs b/kernel/src/lib.rs index 48cb93d..8d2eee2 100644 --- a/kernel/src/lib.rs +++ b/kernel/src/lib.rs @@ -16,6 +16,8 @@ pub extern "C" fn _start() -> ! { write!(&mut stdout, "hello world!"); + panic!("i has panicing"); + core::iter::successors(Some(0), |n| Some(n + 1)) .for_each(|n| write!(&mut stdout, "hello world {}!", n).unwrap() @@ -27,5 +29,21 @@ pub extern "C" fn _start() -> ! { #[panic_handler] #[no_mangle] pub extern "C" fn panic_handler(_info: &core::panic::PanicInfo) -> ! { + let mut stderr = vga_text::OStream::new(); + stderr.set_state(vga_text::CharState::from_colors( + vga_text::Color::LightRed, vga_text::Color::Red)); + stderr.clear(); + stderr.print(b"uff-os"); + stderr.set_row(10); + stderr.set_state(vga_text::CharState::from_colors( + vga_text::Color::White, vga_text::Color::Red)); + stderr.print_centered(b""); + stderr.set_row(14); + let text = _info.payload() + .downcast_ref::<&str>() + .unwrap_or(&"no panic informations are obtainable"); + stderr.set_state(vga_text::CharState::from_colors( + vga_text::Color::Cyan, vga_text::Color::Red)); + stderr.print_centered(text.as_bytes()); loop {} } -- cgit v1.2.3-70-g09d2