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

Commit 3e50b91

Browse files
committed
Support user thread mode in hard fault handler
1 parent 939d68f commit 3e50b91

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

asm.s

-5
This file was deleted.

build.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ fn main() {
1212
let is_armv6m = is_armv6m(&target);
1313

1414
if target.starts_with("thumbv") {
15-
cc::Build::new().file("asm.s").compile("asm");
15+
cc::Build::new().file("hardfault.s").compile("asm");
1616
}
1717

1818
// Put the linker script somewhere the linker can find it

hardfault.s

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
.global HardFault
2+
.thumb_func
3+
HardFault:
4+
movs r0, lr
5+
lsl r0, r0, #29 // Test bit[2] of EXC_RETURN to determine thread mode
6+
bmi HardFault.PSP
7+
8+
HardFault.MSP:
9+
mrs r0, MSP // Use Main Stack Pointer (if in privileged mode)
10+
bl UserHardFault // Jump to hard fault handler
11+
12+
HardFault.PSP:
13+
mrs r0, PSP // Use Process Stack Pointer (if in user mode)
14+
bl UserHardFault // Jump to hard fault handler

0 commit comments

Comments
 (0)