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

Support user thread mode in hard fault handler #77

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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