Skip to content

Commit b290c71

Browse files
committed
The HAL CM4 for ARM and IAR toolchains is valid only for FPU present. These guards were added
to mbed SDK as there are targets with Cortex-M4. This is similar to the implementation already done for GCC ARM Signed-off-by: Mahadevan Mahesh <[email protected]>
1 parent 670b098 commit b290c71

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

rtos/rtx/TARGET_CORTEX_M/TARGET_RTOS_M4_M7/TOOLCHAIN_ARM/HAL_CM4.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ SVC_Handler_Veneer
164164

165165
SVC_ContextSave
166166
TST LR,#0x10 ; is it extended frame?
167+
#if (__FPU_PRESENT == 1)
167168
VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs
169+
#endif
168170
MOVEQ R0,#0x01 ; os_tsk->stack_frame val
169171
MOVNE R0,#0x00
170172
STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val
@@ -184,7 +186,9 @@ SVC_ContextRestore
184186
CMP R0,#0 ; Basic/Extended Stack Frame
185187
MVNEQ LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value
186188
MVNNE LR,#:NOT:0xFFFFFFED
189+
#if (__FPU_PRESENT == 1)
187190
VLDMIANE R12!,{S16-S31} ; restore VFP hi-registers
191+
#endif
188192
MSR PSP,R12 ; Write PSP
189193

190194
SVC_Exit
@@ -247,7 +251,9 @@ Sys_Switch
247251

248252
MRS R12,PSP ; Read PSP
249253
TST LR,#0x10 ; is it extended frame?
254+
#if (__FPU_PRESENT == 1)
250255
VSTMDBEQ R12!,{S16-S31} ; yes, stack also VFP hi-regs
256+
#endif
251257
MOVEQ R0,#0x01 ; os_tsk->stack_frame val
252258
MOVNE R0,#0x00
253259
STRB R0,[R1,#TCB_STACKF] ; os_tsk.run->stack_frame = val
@@ -266,7 +272,9 @@ Sys_Switch
266272
CMP R0,#0 ; Basic/Extended Stack Frame
267273
MVNEQ LR,#:NOT:0xFFFFFFFD ; set EXC_RETURN value
268274
MVNNE LR,#:NOT:0xFFFFFFED
275+
#if (__FPU_PRESENT == 1)
269276
VLDMIANE R12!,{S16-S31} ; restore VFP hi-regs
277+
#endif
270278
MSR PSP,R12 ; Write PSP
271279

272280
Sys_Exit

rtos/rtx/TARGET_CORTEX_M/TARGET_RTOS_M4_M7/TOOLCHAIN_IAR/HAL_CM4.S

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,12 @@ SVC_Handler_Veneer:
188188

189189
SVC_ContextSave:
190190
TST LR,#0x10 /* is it extended frame? */
191+
#if (__FPU_PRESENT == 1)
191192
ITTE EQ
192193
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
194+
#else
195+
ITE EQ
196+
#endif
193197
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
194198
MOVNE R0,#0x00
195199
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
@@ -207,10 +211,16 @@ SVC_ContextRestore:
207211
LDMIA R12!,{R4-R11} /* Restore New Context */
208212
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
209213
CMP R0,#0 /* Basic/Extended Stack Frame */
214+
#if (__FPU_PRESENT == 1)
210215
ITEE EQ
216+
#else
217+
ITE EQ
218+
#endif
211219
MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */
212220
MVNNE LR,#~0xFFFFFFED
221+
#if (__FPU_PRESENT == 1)
213222
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
223+
#endif
214224
MSR PSP,R12 /* Write PSP */
215225

216226
SVC_Exit:
@@ -274,8 +284,12 @@ Sys_Switch:
274284

275285
MRS R12,PSP /* Read PSP */
276286
TST LR,#0x10 /* is it extended frame? */
287+
#if (__FPU_PRESENT == 1)
277288
ITTE EQ
278289
VSTMDBEQ R12!,{S16-S31} /* yes, stack also VFP hi-regs */
290+
#else
291+
ITE EQ
292+
#endif
279293
MOVEQ R0,#0x01 /* os_tsk->stack_frame val */
280294
MOVNE R0,#0x00
281295
STRB R0,[R1,#TCB_STACKF] /* os_tsk.run->stack_frame = val */
@@ -292,10 +306,16 @@ Sys_Switch:
292306
LDMIA R12!,{R4-R11} /* Restore New Context */
293307
LDRB R0,[R2,#TCB_STACKF] /* Stack Frame */
294308
CMP R0,#0 /* Basic/Extended Stack Frame */
309+
#if (__FPU_PRESENT == 1)
295310
ITEE EQ
311+
#else
312+
ITE EQ
313+
#endif
296314
MVNEQ LR,#~0xFFFFFFFD /* set EXC_RETURN value */
297315
MVNNE LR,#~0xFFFFFFED
316+
#if (__FPU_PRESENT == 1)
298317
VLDMIANE R12!,{S16-S31} /* restore VFP hi-registers */
318+
#endif
299319
MSR PSP,R12 /* Write PSP */
300320

301321
Sys_Exit:

0 commit comments

Comments
 (0)