Skip to content
This repository has been archived by the owner on Jan 24, 2022. It is now read-only.

Commit

Permalink
two separate default handlers
Browse files Browse the repository at this point in the history
  • Loading branch information
japaric committed Aug 25, 2018
1 parent 64de8b6 commit 903e97a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
4 changes: 2 additions & 2 deletions link.x.in
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ PROVIDE(DebugMonitor = DefaultHandler);
PROVIDE(PendSV = DefaultHandler);
PROVIDE(SysTick = DefaultHandler);

PROVIDE(DefaultHandler = EndlessLoop);
PROVIDE(UserHardFault = EndlessLoop);
PROVIDE(DefaultHandler = DefaultHandler_);
PROVIDE(UserHardFault = UserHardFault_);

/* # Interrupt vectors */
EXTERN(__INTERRUPTS); /* `static` variable similar to `__EXCEPTIONS` */
Expand Down
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,20 @@ pub unsafe extern "C" fn Reset() -> ! {
}
}

#[allow(unused_variables)]
#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn EndlessLoop() -> ! {
pub unsafe extern "C" fn UserHardFault_(ef: &ExceptionFrame) -> ! {
loop {
// add some side effect to prevent this from turning into a UDF instruction
// see rust-lang/rust#28728 for details
atomic::compiler_fence(Ordering::SeqCst);
}
}

#[doc(hidden)]
#[no_mangle]
pub unsafe extern "C" fn DefaultHandler_() -> ! {
loop {
// add some side effect to prevent this from turning into a UDF instruction
// see rust-lang/rust#28728 for details
Expand Down

0 comments on commit 903e97a

Please sign in to comment.