1
0
Fork 0

runtime/panic: prevent nested panic and added core ID in panic msg.

This commit is contained in:
pca006132 2020-07-16 16:24:27 +08:00 committed by Gitea
parent 16158acfa9
commit caef2a9f84
1 changed files with 13 additions and 0 deletions

View File

@ -1,8 +1,21 @@
use libboard_zynq::{print, println};
use libregister::RegisterR;
use libcortex_a9::regs::MPIDR;
use unwind::backtrace;
static mut PANICKED: [bool; 2] = [false; 2];
#[panic_handler]
fn panic(info: &core::panic::PanicInfo) -> ! {
let id = MPIDR.read().cpu_id() as usize;
print!("Core {} ", id);
unsafe {
if PANICKED[id] {
println!("nested panic!");
loop {}
}
PANICKED[id] = true;
}
print!("panic at ");
if let Some(location) = info.location() {
print!("{}:{}:{}", location.file(), location.line(), location.column());