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

Commit

Permalink
Try #77:
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] committed Jun 22, 2018
2 parents 939d68f + 13f9849 commit 70f39b7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
5 changes: 0 additions & 5 deletions asm.s

This file was deleted.

2 changes: 1 addition & 1 deletion build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() {
let is_armv6m = is_armv6m(&target);

if target.starts_with("thumbv") {
cc::Build::new().file("asm.s").compile("asm");
cc::Build::new().file("hardfault.s").compile("asm");
}

// Put the linker script somewhere the linker can find it
Expand Down
16 changes: 16 additions & 0 deletions hardfault.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.global HardFault
.thumb_func
HardFault:
movs r0, #4
mov r1, lr
tst r0, r1 // Test bit[3] of EXC_RETURN to determine thread mode

beq HardFault.MSP

HardFault.PSP:
mrs r0, PSP // Use Process Stack Pointer (if in user mode)
bl UserHardFault // Jump to hard fault handler

HardFault.MSP:
mrs r0, MSP // Use Main Stack Pointer (if in privileged mode)
bl UserHardFault // Jump to hard fault handler

0 comments on commit 70f39b7

Please sign in to comment.