exception

Attribute Macro exception 

Source
#[exception]
Expand description

Creates an unsafe exception handler.

It’s unsafe because you are not supposed to call it - it should only be called from assembly routines registered in the interrupt vector table.

When placed on a function like:

#[exception(Undefined)]
fn foo(addr: usize) -> ! {
    panic!("On no")
}

You get something like:

#[doc(hidden)]
#[export_name = "_undefined_handler"]
pub unsafe extern "C" fn __cortex_ar_rt_undefined_handler(addr: usize) -> ! {
    foo(addr)
}

fn foo(addr: usize) -> ! {
    panic!("On no")
}

The supported arguments are:

  • Undefined (creates _undefined_handler)
  • SupervisorCall (creates _svc_handler)
  • PrefetchAbort (creates _prefetch_abort_handler)
  • DataAbort (creates _data_abort_handler)
  • Irq (creates _irq_handler) - although people should prefer #[irq].