|
133 | 133 | #define portMAX_8_BIT_VALUE ( ( uint8_t ) 0xff )
|
134 | 134 | #define portBIT_0_SET ( ( uint8_t ) 0x01 )
|
135 | 135 |
|
| 136 | +/* The space on the stack required to hold the FPU registers. |
| 137 | + * There are 32 128-bit registers.*/ |
| 138 | +#define portFPU_REGISTER_WORDS ( 32 * 2 ) |
| 139 | + |
136 | 140 | /*-----------------------------------------------------------*/
|
137 | 141 |
|
138 | 142 | /*
|
@@ -244,23 +248,47 @@ StackType_t * pxPortInitialiseStack( StackType_t * pxTopOfStack,
|
244 | 248 | *pxTopOfStack = ( StackType_t ) 0x00; /* XZR - has no effect, used so there are an even number of registers. */
|
245 | 249 | pxTopOfStack--;
|
246 | 250 | *pxTopOfStack = ( StackType_t ) 0x00; /* R30 - procedure call link register. */
|
247 |
| - pxTopOfStack--; |
248 |
| - |
249 |
| - *pxTopOfStack = portINITIAL_PSTATE; |
250 |
| - pxTopOfStack--; |
251 | 251 |
|
252 |
| - *pxTopOfStack = ( StackType_t ) pxCode; /* Exception return address. */ |
253 | 252 | pxTopOfStack--;
|
| 253 | + *pxTopOfStack = portINITIAL_PSTATE; |
254 | 254 |
|
255 |
| - /* The task will start with a critical nesting count of 0 as interrupts are |
256 |
| - * enabled. */ |
257 |
| - *pxTopOfStack = portNO_CRITICAL_NESTING; |
258 | 255 | pxTopOfStack--;
|
| 256 | + *pxTopOfStack = ( StackType_t ) pxCode; /* Exception return address. */ |
259 | 257 |
|
260 |
| - /* The task will start without a floating point context. A task that uses |
261 |
| - * the floating point hardware must call vPortTaskUsesFPU() before executing |
262 |
| - * any floating point instructions. */ |
263 |
| - *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; |
| 258 | + #if ( configUSE_TASK_FPU_SUPPORT == 1 ) |
| 259 | + { |
| 260 | + /* The task will start with a critical nesting count of 0 as interrupts are |
| 261 | + * enabled. */ |
| 262 | + pxTopOfStack--; |
| 263 | + *pxTopOfStack = portNO_CRITICAL_NESTING; |
| 264 | + |
| 265 | + /* The task will start without a floating point context. A task that |
| 266 | + * uses the floating point hardware must call vPortTaskUsesFPU() before |
| 267 | + * executing any floating point instructions. */ |
| 268 | + pxTopOfStack--; |
| 269 | + *pxTopOfStack = portNO_FLOATING_POINT_CONTEXT; |
| 270 | + } |
| 271 | + #elif ( configUSE_TASK_FPU_SUPPORT == 2 ) |
| 272 | + { |
| 273 | + /* The task will start with a floating point context. Leave enough |
| 274 | + * space for the registers - and ensure they are initialised to 0. */ |
| 275 | + pxTopOfStack -= portFPU_REGISTER_WORDS; |
| 276 | + memset( pxTopOfStack, 0x00, portFPU_REGISTER_WORDS * sizeof( StackType_t ) ); |
| 277 | + |
| 278 | + /* The task will start with a critical nesting count of 0 as interrupts are |
| 279 | + * enabled. */ |
| 280 | + pxTopOfStack--; |
| 281 | + *pxTopOfStack = portNO_CRITICAL_NESTING; |
| 282 | + |
| 283 | + pxTopOfStack--; |
| 284 | + *pxTopOfStack = pdTRUE; |
| 285 | + ullPortTaskHasFPUContext = pdTRUE; |
| 286 | + } |
| 287 | + #else /* if ( configUSE_TASK_FPU_SUPPORT == 1 ) */ |
| 288 | + { |
| 289 | + #error "Invalid configUSE_TASK_FPU_SUPPORT setting - configUSE_TASK_FPU_SUPPORT must be set to 1, 2, or left undefined." |
| 290 | + } |
| 291 | + #endif /* if ( configUSE_TASK_FPU_SUPPORT == 1 ) */ |
264 | 292 |
|
265 | 293 | return pxTopOfStack;
|
266 | 294 | }
|
@@ -440,15 +468,19 @@ void FreeRTOS_Tick_Handler( void )
|
440 | 468 | }
|
441 | 469 | /*-----------------------------------------------------------*/
|
442 | 470 |
|
443 |
| -void vPortTaskUsesFPU( void ) |
444 |
| -{ |
445 |
| - /* A task is registering the fact that it needs an FPU context. Set the |
446 |
| - * FPU flag (which is saved as part of the task context). */ |
447 |
| - ullPortTaskHasFPUContext = pdTRUE; |
| 471 | +#if ( configUSE_TASK_FPU_SUPPORT != 2 ) |
448 | 472 |
|
449 |
| - /* Consider initialising the FPSR here - but probably not necessary in |
450 |
| - * AArch64. */ |
451 |
| -} |
| 473 | + void vPortTaskUsesFPU( void ) |
| 474 | + { |
| 475 | + /* A task is registering the fact that it needs an FPU context. Set the |
| 476 | + * FPU flag (which is saved as part of the task context). */ |
| 477 | + ullPortTaskHasFPUContext = pdTRUE; |
| 478 | + |
| 479 | + /* Consider initialising the FPSR here - but probably not necessary in |
| 480 | + * AArch64. */ |
| 481 | + } |
| 482 | + |
| 483 | +#endif /* configUSE_TASK_FPU_SUPPORT */ |
452 | 484 | /*-----------------------------------------------------------*/
|
453 | 485 |
|
454 | 486 | void vPortClearInterruptMask( UBaseType_t uxNewMaskValue )
|
|
0 commit comments