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

Commit

Permalink
Support user thread mode in hard fault handler
Browse files Browse the repository at this point in the history
  • Loading branch information
crawford committed Jun 24, 2018
1 parent 939d68f commit 3e50b91
Show file tree
Hide file tree
Showing 3 changed files with 15 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
14 changes: 14 additions & 0 deletions hardfault.s
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
.global HardFault
.thumb_func
HardFault:
movs r0, lr
lsl r0, r0, #29 // Test bit[2] of EXC_RETURN to determine thread mode
bmi HardFault.PSP

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

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

0 comments on commit 3e50b91

Please sign in to comment.