diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h index 5a19389fcf..6a44c2817a 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h @@ -647,13 +647,6 @@ FORCE_INLINE_ATTR BaseType_t xPortGetCoreID(void) * - These are not part of the FreeRTOS porting interface, but are used by other FreeRTOS dependent components * ------------------------------------------------------------------------------------------------------------------ */ -// -------------------- Co-Processor ----------------------- - -#if XCHAL_CP_NUM > 0 -void vPortCleanUpCoprocArea(void *pvTCB); -#define portCLEAN_UP_COPROC(pvTCB) vPortCleanUpCoprocArea(pvTCB) -#endif - // -------------------- Heap Related ----------------------- /** diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c b/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c index ab4120e267..5ab57f22d0 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c @@ -607,6 +607,25 @@ void vPortSetStackWatchpoint( void *pxStackStart ) // --------------------- TCB Cleanup ----------------------- +#if ( XCHAL_CP_NUM > 0 ) +static void vPortCleanUpCoprocArea(void *pvTCB) +{ + UBaseType_t uxCoprocArea; + BaseType_t xTargetCoreID; + + /* Get a pointer to the task's coprocessor save area */ + uxCoprocArea = ( UBaseType_t ) ( ( ( StaticTask_t * ) pvTCB )->pxDummy8 ); /* Get TCB_t.pxEndOfStack */ + uxCoprocArea = STACKPTR_ALIGN_DOWN(16, uxCoprocArea - XT_CP_SIZE); + + /* Get xTargetCoreID from the TCB.xCoreID */ + xTargetCoreID = ( ( StaticTask_t * ) pvTCB )->xDummyCoreID; + + /* If task has live floating point registers somewhere, release them */ + void _xt_coproc_release(volatile void *coproc_sa_base, BaseType_t xTargetCoreID); + _xt_coproc_release( (void *)uxCoprocArea, xTargetCoreID ); +} +#endif /* XCHAL_CP_NUM > 0 */ + void vPortTCBPreDeleteHook( void *pxTCB ) { #if ( CONFIG_FREERTOS_TASK_PRE_DELETION_HOOK ) @@ -624,26 +643,9 @@ void vPortTCBPreDeleteHook( void *pxTCB ) extern void vPortCleanUpTCB( void * pxTCB ); vPortCleanUpTCB( pxTCB ); #endif /* CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP */ + + #if ( XCHAL_CP_NUM > 0 ) + /* Cleanup coproc save area */ + vPortCleanUpCoprocArea( pxTCB ); + #endif /* XCHAL_CP_NUM > 0 */ } - -// -------------------- Co-Processor ----------------------- - -#if XCHAL_CP_NUM > 0 -void _xt_coproc_release(volatile void *coproc_sa_base, BaseType_t xTargetCoreID); - -void vPortCleanUpCoprocArea(void *pvTCB) -{ - UBaseType_t uxCoprocArea; - BaseType_t xTargetCoreID; - - /* Get a pointer to the task's coprocessor save area */ - uxCoprocArea = ( UBaseType_t ) ( ( ( StaticTask_t * ) pvTCB )->pxDummy8 ); /* Get TCB_t.pxEndOfStack */ - uxCoprocArea = STACKPTR_ALIGN_DOWN(16, uxCoprocArea - XT_CP_SIZE); - - /* Get xTargetCoreID from the TCB.xCoreID */ - xTargetCoreID = ( ( StaticTask_t * ) pvTCB )->xDummyCoreID; - - /* If task has live floating point registers somewhere, release them */ - _xt_coproc_release( (void *)uxCoprocArea, xTargetCoreID ); -} -#endif /* XCHAL_CP_NUM > 0 */ diff --git a/components/freertos/FreeRTOS-Kernel/tasks.c b/components/freertos/FreeRTOS-Kernel/tasks.c index 0c68ee8357..88fd618de6 100644 --- a/components/freertos/FreeRTOS-Kernel/tasks.c +++ b/components/freertos/FreeRTOS-Kernel/tasks.c @@ -4951,10 +4951,6 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) vPortReleaseTaskMPUSettings( &( pxTCB->xMPUSettings ) ); #endif - #ifdef portCLEAN_UP_COPROC - portCLEAN_UP_COPROC( ( void * ) pxTCB ); - #endif - #if ( ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 0 ) && ( portUSING_MPU_WRAPPERS == 0 ) ) { /* The task can only have been allocated dynamically - free both diff --git a/components/freertos/linker.lf b/components/freertos/linker.lf index 9e83b142fa..e7e75a3845 100644 --- a/components/freertos/linker.lf +++ b/components/freertos/linker.lf @@ -233,9 +233,10 @@ entries: port:xPortStartScheduler (default) port:vPortEndScheduler (default) port:pxPortInitialiseStack (default) + port:xPortGetTickRateHz (default) if IDF_TARGET_ESP32 = y || IDF_TARGET_ESP32S3 = y : port:vPortCleanUpCoprocArea (default) - port:xPortGetTickRateHz (default) + port:vPortTCBPreDeleteHook (default) # -------------------------------------------------------------------------------------------------------------- # portable/riscv/port.c # - Most functions are called from an ISR context, except for scheduler/task init/deinit functions @@ -245,3 +246,4 @@ entries: port:vPortEndScheduler (default) port:pxPortInitialiseStack (default) port:xPortGetTickRateHz (default) + port:vPortTCBPreDeleteHook (default)