make the LCD panic handler Precursor-specific

This commit is contained in:
bunnie 2023-04-10 15:41:59 +08:00
parent 2903de5b7b
commit 344dd5094b

View file

@ -5,24 +5,27 @@ use core::panic::PanicInfo;
#[panic_handler] #[panic_handler]
fn handle_panic(_arg: &PanicInfo) -> ! { fn handle_panic(_arg: &PanicInfo) -> ! {
println!("PANIC in PID {}: {}", crate::arch::current_pid(), _arg); println!("PANIC in PID {}: {}", crate::arch::current_pid(), _arg);
use crate::platform::precursor::lcdpanic::ErrorWriter; #[cfg(any(feature = "precursor", feature = "renode"))]
use core::fmt::Write; {
if let Ok(mut writer) = ErrorWriter::new() { use crate::platform::precursor::lcdpanic::ErrorWriter;
writeln!( use core::fmt::Write;
writer, if let Ok(mut writer) = ErrorWriter::new() {
"PANIC in PID {}: {}", writeln!(
crate::arch::current_pid(), writer,
_arg "PANIC in PID {}: {}",
) crate::arch::current_pid(),
.ok(); _arg
let process = crate::arch::process::Process::current(); )
writeln!(writer, "Current thread: {}", process.current_tid()).ok(); .ok();
writeln!( let process = crate::arch::process::Process::current();
writer, writeln!(writer, "Current thread: {}", process.current_tid()).ok();
"{}", writeln!(
crate::arch::process::Process::current().current_thread() writer,
) "{}",
.ok(); crate::arch::process::Process::current().current_thread()
)
.ok();
}
} }
loop { loop {
arch::idle(); arch::idle();