121
121
::"r" ( portUNMASK_VALUE ) ); \
122
122
}
123
123
124
+ /* The space on the stack required to hold the FPU registers.
125
+ * There are 32 128-bit registers.*/
126
+ #define portFPU_REGISTER_WORDS ( 32 * 2 )
127
+
124
128
/*-----------------------------------------------------------*/
125
129
126
130
/*
@@ -229,23 +233,47 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
229
233
* pxTopOfStack = ( StackType_t ) 0x00 ; /* XZR - has no effect, used so there are an even number of registers. */
230
234
pxTopOfStack -- ;
231
235
* pxTopOfStack = ( StackType_t ) 0x00 ; /* R30 - procedure call link register. */
232
- pxTopOfStack -- ;
233
-
234
- * pxTopOfStack = portINITIAL_PSTATE ;
235
- pxTopOfStack -- ;
236
236
237
- * pxTopOfStack = ( StackType_t ) pxCode ; /* Exception return address. */
238
237
pxTopOfStack -- ;
238
+ * pxTopOfStack = portINITIAL_PSTATE ;
239
239
240
- /* The task will start with a critical nesting count of 0 as interrupts are
241
- * enabled. */
242
- * pxTopOfStack = portNO_CRITICAL_NESTING ;
243
240
pxTopOfStack -- ;
241
+ * pxTopOfStack = ( StackType_t ) pxCode ; /* Exception return address. */
244
242
245
- /* The task will start without a floating point context. A task that uses
246
- * the floating point hardware must call vPortTaskUsesFPU() before executing
247
- * any floating point instructions. */
248
- * pxTopOfStack = portNO_FLOATING_POINT_CONTEXT ;
243
+ #if ( configUSE_TASK_FPU_SUPPORT == 1 )
244
+ {
245
+ /* The task will start with a critical nesting count of 0 as interrupts are
246
+ * enabled. */
247
+ pxTopOfStack -- ;
248
+ * pxTopOfStack = portNO_CRITICAL_NESTING ;
249
+
250
+ /* The task will start without a floating point context. A task that
251
+ * uses the floating point hardware must call vPortTaskUsesFPU() before
252
+ * executing any floating point instructions. */
253
+ pxTopOfStack -- ;
254
+ * pxTopOfStack = portNO_FLOATING_POINT_CONTEXT ;
255
+ }
256
+ #elif ( configUSE_TASK_FPU_SUPPORT == 2 )
257
+ {
258
+ /* The task will start with a floating point context. Leave enough
259
+ * space for the registers - and ensure they are initialised to 0. */
260
+ pxTopOfStack -= portFPU_REGISTER_WORDS ;
261
+ memset ( pxTopOfStack , 0x00 , portFPU_REGISTER_WORDS * sizeof ( StackType_t ) );
262
+
263
+ /* The task will start with a critical nesting count of 0 as interrupts are
264
+ * enabled. */
265
+ pxTopOfStack -- ;
266
+ * pxTopOfStack = portNO_CRITICAL_NESTING ;
267
+
268
+ pxTopOfStack -- ;
269
+ * pxTopOfStack = pdTRUE ;
270
+ ullPortTaskHasFPUContext = pdTRUE ;
271
+ }
272
+ #else /* if ( configUSE_TASK_FPU_SUPPORT == 1 ) */
273
+ {
274
+ #error "Invalid configUSE_TASK_FPU_SUPPORT setting - configUSE_TASK_FPU_SUPPORT must be set to 1, 2, or left undefined."
275
+ }
276
+ #endif /* if ( configUSE_TASK_FPU_SUPPORT == 1 ) */
249
277
250
278
return pxTopOfStack ;
251
279
}
@@ -384,6 +412,8 @@ void FreeRTOS_Tick_Handler( void )
384
412
}
385
413
/*-----------------------------------------------------------*/
386
414
415
+ #if ( configUSE_TASK_FPU_SUPPORT != 2 )
416
+
387
417
void vPortTaskUsesFPU ( void )
388
418
{
389
419
/* A task is registering the fact that it needs an FPU context. Set the
@@ -393,6 +423,8 @@ void vPortTaskUsesFPU( void )
393
423
/* Consider initialising the FPSR here - but probably not necessary in
394
424
* AArch64. */
395
425
}
426
+
427
+ #endif /* configUSE_TASK_FPU_SUPPORT */
396
428
/*-----------------------------------------------------------*/
397
429
398
430
void vPortClearInterruptMask ( UBaseType_t uxNewMaskValue )
0 commit comments