Add separate panic display
All checks were successful
Build / build (push) Successful in 2m44s

This commit is contained in:
Mathieu Strypsteen 2024-12-18 12:32:19 +01:00
parent 5e934e54fc
commit 6119ebd5b9
4 changed files with 27 additions and 4 deletions

View file

@ -18,5 +18,6 @@ log = "0.4.22"
[lints.clippy]
missing_safety_doc = "allow"
needless_range_loop = "allow"
too_many_arguments = "allow"
type_complexity = "allow"
upper_case_acronyms = "allow"

View file

@ -23,7 +23,7 @@ use kernel_common::{
paging::{KERNEL_HEAP_INITIAL_SIZE, KERNEL_HEAP_START},
};
use log::{error, info};
use misc::display::{setup_display, DISPLAY};
use misc::display::{setup_display, PANIC_DISPLAY};
use sys::{
acpica_osl::AE_OK,
early_acpi::EarlyACPIHandler,
@ -115,8 +115,9 @@ fn panic(info: &PanicInfo) -> ! {
}
error!("{}", info);
let str = format!("{}", info);
let mut display = DISPLAY.lock();
let mut display = PANIC_DISPLAY.lock();
if let Some(display) = display.as_mut() {
display.clear();
display.print(&str);
}
}

View file

@ -18,7 +18,9 @@ pub struct Display {
current_y: usize,
}
//TODO: Change to mutex
pub static DISPLAY: Spinlock<Option<Display>> = Spinlock::new(None);
pub static PANIC_DISPLAY: Spinlock<Option<Display>> = Spinlock::new(None);
impl Display {
fn write_char(&mut self, x: usize, y: usize, c: char) {
@ -28,6 +30,12 @@ impl Display {
let text = Text::new(&str, pos, style);
text.draw(&mut self.framebuffer).unwrap();
}
pub fn clear(&mut self) {
self.framebuffer.clear(Bgr888::BLACK).unwrap();
self.current_x = 0;
self.current_y = 0;
self.copy_to_fb();
}
fn scroll(&mut self) {
let line_size = self.framebuffer.stride * 20 * 4;
self.framebuffer.framebuffer.copy_within(line_size..line_size * self.height, 0);
@ -78,5 +86,20 @@ pub fn setup_display(info: FramebufferInfo) {
current_x: 0,
current_y: 0,
};
*PANIC_DISPLAY.lock() = Some(display);
let fb = vec![0; info.height as usize * info.stride as usize * 4];
let display = Display {
framebuffer: FramebufferTarget {
framebuffer: fb,
width: info.width as usize,
height: info.height as usize,
stride: info.stride as usize,
},
framebuffer_addr: addr,
width: info.width as usize / 10 - 1,
height: info.height as usize / 20 - 1,
current_x: 0,
current_y: 0,
};
*DISPLAY.lock() = Some(display);
}

View file

@ -15,11 +15,9 @@ unsafe impl RawMutex for RawSpinlock {
fn lock(&self) {
self.raw_lock();
}
fn try_lock(&self) -> bool {
unimplemented!();
}
unsafe fn unlock(&self) {
self.raw_unlock();
}