soft_panic: log error message

This commit is contained in:
mwojcik 2022-09-02 14:50:11 +08:00
parent 3ba6555bb0
commit dfc0cc7c9a

View File

@ -6,6 +6,7 @@ use unwind::backtrace;
#[cfg(feature = "target_kasli_soc")]
use libboard_zynq::error_led::ErrorLED;
use crate::comms::soft_panic_main;
use log::error;
use libboard_zynq::timer::GlobalTimer;
use libconfig::Config;
@ -15,15 +16,8 @@ static mut SOFT_PANICKED: bool = false;
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
let id = MPIDR.read().cpu_id() as usize;
print!("Core {} ", id);
#[cfg(feature = "target_kasli_soc")]
{
let mut err_led = ErrorLED::error_led();
err_led.toggle(true);
}
let soft_panicked = unsafe { SOFT_PANICKED };
print!("panic at ");
print!("Core {} panic at ", id);
if let Some(location) = info.location() {
print!("{}:{}:{}", location.file(), location.line(), location.column());
} else {
@ -35,6 +29,7 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
println!("");
}
unsafe {
// soft panics only allowed for core 0
if PANICKED[id] && (SOFT_PANICKED || id == 1) {
println!("nested panic!");
loop {}
@ -42,9 +37,13 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
SOFT_PANICKED = true;
PANICKED[id] = true;
}
if !soft_panicked && id == 0 {
soft_panic();
soft_panic(info);
}
#[cfg(feature = "target_kasli_soc")]
{
let mut err_led = ErrorLED::error_led();
err_led.toggle(true);
}
println!("Backtrace: ");
let _ = backtrace(|ip| {
@ -56,8 +55,16 @@ fn panic(info: &core::panic::PanicInfo) -> ! {
loop {}
}
fn soft_panic() -> ! {
fn soft_panic(info: &core::panic::PanicInfo) -> ! {
// log panic info to log (prints not visible in coremgmt logs)
if let Some(location) = info.location() {
error!("panic at {}:{}:{}", location.file(), location.line(), location.column());
} else {
error!("panic at unknown location");
}
if let Some(message) = info.message() {
error!("panic message: {}", message);
}
let timer = GlobalTimer::start();
let cfg = match Config::new() {
Ok(cfg) => cfg,