Panic and uncaught exception handling #60

Merged
sb10q merged 2 commits from pca006132/artiq-zynq:exception into master 2020-07-16 17:11:36 +08:00
2 changed files with 15 additions and 0 deletions

View File

@ -189,5 +189,7 @@ pub fn terminate(exception: &'static eh_artiq::Exception<'static>, backtrace: &'
let core1_tx: &mut sync_channel::Sender<Message> = unsafe { mem::transmute(KERNEL_CHANNEL_1TO0) };
core1_tx.send(Message::KernelException(exception, &backtrace[..cursor]));
// TODO: remove after implementing graceful kernel termination.
error!("Core1 uncaught exception");
loop {}
}

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());