Skip to content

Commit 882d195

Browse files
committed
[libcpu][cortex-m33]Added HardFault_Handler to save floating point registers
1 parent 60b3ccb commit 882d195

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

libcpu/arm/cortex-m33/context_gcc.S

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,12 @@ HardFault_Handler:
281281
MRS r0, psp /* get fault context from thread. */
282282
get_sp_done:
283283

284+
#if defined (__VFP_FP__) && !defined(__SOFTFP__)
285+
TST lr, #0x10 /* if(!EXC_RETURN[4]) */
286+
IT EQ
287+
VSTMDBEQ r0!, {d8 - d15} /* push FPU register s16~s31 */
288+
#endif
289+
284290
STMFD r0!, {r4 - r11} /* push r4 - r11 register */
285291

286292
LDR r2, =rt_trustzone_current_context /* r2 = &rt_secure_current_context */

libcpu/arm/cortex-m33/context_iar.S

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,13 @@ HardFault_Handler:
275275
MRS r0, psp ; get fault context from thread.
276276
get_sp_done
277277

278+
#if defined ( __ARMVFP__ )
279+
TST lr, #0x10 ; if(!EXC_RETURN[4])
280+
BNE skip_push_fpu
281+
VSTMDB r0!, {d8 - d15} ; push FPU register s16~s31
282+
skip_push_fpu
283+
#endif
284+
278285
STMFD r0!, {r4 - r11} ; push r4 - r11 register
279286

280287
LDR r2, =rt_trustzone_current_context ; r2 = &rt_secure_current_context

libcpu/arm/cortex-m33/context_rvds.S

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,17 @@ rt_hw_interrupt_thread_switch PROC
272272
HardFault_Handler PROC
273273

274274
; get current context
275-
MRS r0, msp ;get fault context from handler
276-
TST lr, #0x04 ;if(!EXC_RETURN[2])
275+
MRS r0, msp ; get fault context from handler
276+
TST lr, #0x04 ; if(!EXC_RETURN[2])
277277
BEQ get_sp_done
278-
MRS r0, psp ;get fault context from thread
278+
MRS r0, psp ; get fault context from thread
279279
get_sp_done
280280

281+
IF {FPU} != "SoftVFP"
282+
TST lr, #0x10 ; if(!EXC_RETURN[4])
283+
VSTMFDEQ r0!, {d8 - d15} ; push FPU register s16~s31
284+
ENDIF
285+
281286
STMFD r0!, {r4 - r11} ; push r4 - r11 register
282287

283288
LDR r2, =rt_trustzone_current_context ; r2 = &rt_secure_current_context

0 commit comments

Comments
 (0)