diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c index 181c48dc1b..cd62e8e598 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/port.c @@ -721,21 +721,21 @@ void _xt_coproc_release(volatile void *coproc_sa_base, BaseType_t xCoreID); void vPortCleanUpCoprocArea( void *pxTCB ) { - StackType_t *coproc_area; + UBaseType_t uxCoprocArea; BaseType_t xCoreID; - /* Calculate the coproc save area in the stack from the TCB base */ - coproc_area = ( StackType_t * ) ( ( uint32_t ) ( pxTCB + offset_pxEndOfStack )); - coproc_area = ( StackType_t * ) ( ( ( portPOINTER_SIZE_TYPE ) coproc_area ) & ( ~( ( portPOINTER_SIZE_TYPE ) portBYTE_ALIGNMENT_MASK ) ) ); - coproc_area = ( StackType_t * ) ( ( ( uint32_t ) coproc_area - XT_CP_SIZE ) & ~0xf ); + /* Get pointer to the task's coprocessor save area from TCB->pxEndOfStack. See uxInitialiseStackCPSA() */ + uxCoprocArea = ( UBaseType_t ) ( ( ( StaticTask_t * ) pxTCB )->pxDummy8 ); /* Get TCB_t.pxEndOfStack */ + uxCoprocArea = STACKPTR_ALIGN_DOWN(16, uxCoprocArea - XT_CP_SIZE); /* Extract core ID from the affinity mask */ - xCoreID = __builtin_ffs( * ( UBaseType_t * ) ( pxTCB + offset_uxCoreAffinityMask ) ); - assert( xCoreID >= 1 ); + xCoreID = ( ( StaticTask_t * ) pxTCB )->uxDummy25 ; + xCoreID = ( BaseType_t ) __builtin_ffs( ( int ) xCoreID ); + assert( xCoreID >= 1 ); // __builtin_ffs always returns first set index + 1 xCoreID -= 1; /* If task has live floating point registers somewhere, release them */ - _xt_coproc_release( coproc_area, xCoreID ); + _xt_coproc_release( (void *)uxCoprocArea, xCoreID ); } #endif // ( XCHAL_CP_NUM > 0 && configUSE_CORE_AFFINITY == 1 && configNUM_CORES > 1 ) diff --git a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/xtensa_context.S b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/xtensa_context.S index 044a4c7677..546fbd073e 100644 --- a/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/xtensa_context.S +++ b/components/freertos/FreeRTOS-Kernel-SMP/portable/xtensa/xtensa_context.S @@ -449,7 +449,7 @@ _xt_coproc_release: 1: l32i a8, a4, 0 /* a8 = owner at a4 */ bne a2, a8, 2f /* if (coproc_sa_base == owner) */ - s32i a3, a4, 0 /* owner = unowned */ + s32i a6, a4, 0 /* owner = unowned */ 2: addi a4, a4, 1<<2 /* a4 = next entry in owner array */ bltu a4, a5, 1b /* repeat until end of array */