From 6590cc7616b96a6d030e295ae02a40d280c5d8f1 Mon Sep 17 00:00:00 2001 From: Zim Kalinowski Date: Thu, 9 Sep 2021 14:13:07 +0800 Subject: [PATCH] freertos: upgrade to 10.4.3 - rename xaskRemoveFromUnorderedEventList (cherry picked from commit e91586b57e19a3776c7c675f62c0afeebd19c294) --- components/freertos/event_groups.c | 4 +- .../esp_additions/freertos/FreeRTOSConfig.h | 3 ++ components/freertos/include/freertos/task.h | 41 ++++++++--------- components/freertos/linker.lf | 2 +- components/freertos/tasks.c | 44 +++++++++---------- 5 files changed, 45 insertions(+), 49 deletions(-) diff --git a/components/freertos/event_groups.c b/components/freertos/event_groups.c index 445edfa337..6a4dbf886e 100644 --- a/components/freertos/event_groups.c +++ b/components/freertos/event_groups.c @@ -661,7 +661,7 @@ EventBits_t xEventGroupSetBits( EventGroupHandle_t xEventGroup, * eventUNBLOCKED_DUE_TO_BIT_SET bit is set so the task knows * that is was unblocked due to its required bits matching, rather * than because it timed out. */ - xTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET ); + vTaskRemoveFromUnorderedEventList( pxListItem, pxEventBits->uxEventBits | eventUNBLOCKED_DUE_TO_BIT_SET ); } /* Move onto the next list item. Note pxListItem->pxNext is not @@ -699,7 +699,7 @@ void vEventGroupDelete( EventGroupHandle_t xEventGroup ) /* Unblock the task, returning 0 as the event list is being deleted * and cannot therefore have any bits set. */ configASSERT( pxTasksWaitingForBits->xListEnd.pxNext != ( const ListItem_t * ) &( pxTasksWaitingForBits->xListEnd ) ); - xTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET ); + vTaskRemoveFromUnorderedEventList( pxTasksWaitingForBits->xListEnd.pxNext, eventUNBLOCKED_DUE_TO_BIT_SET ); } } taskEXIT_CRITICAL(); diff --git a/components/freertos/include/esp_additions/freertos/FreeRTOSConfig.h b/components/freertos/include/esp_additions/freertos/FreeRTOSConfig.h index 90a0b6ac23..39ffb5daf5 100644 --- a/components/freertos/include/esp_additions/freertos/FreeRTOSConfig.h +++ b/components/freertos/include/esp_additions/freertos/FreeRTOSConfig.h @@ -304,4 +304,7 @@ extern void vPortCleanUpTCB ( void *pxTCB ); #define configTASK_NOTIFICATION_ARRAY_ENTRIES 1 +// backward compatibility for 4.4 +#define xTaskRemoveFromUnorderedEventList vTaskRemoveFromUnorderedEventList + #endif /* FREERTOS_CONFIG_H */ diff --git a/components/freertos/include/freertos/task.h b/components/freertos/include/freertos/task.h index 9135b76f01..df88c074fb 100644 --- a/components/freertos/include/freertos/task.h +++ b/components/freertos/include/freertos/task.h @@ -430,14 +430,14 @@ typedef enum #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) static inline IRAM_ATTR BaseType_t xTaskCreate( - TaskFunction_t pvTaskCode, - const char * const pcName, - const uint32_t usStackDepth, - void * const pvParameters, - UBaseType_t uxPriority, - TaskHandle_t * const pvCreatedTask) + TaskFunction_t pvTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t usStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + TaskHandle_t * const pxCreatedTask) PRIVILEGED_FUNCTION { - return xTaskCreatePinnedToCore( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pvCreatedTask, tskNO_AFFINITY ); + return xTaskCreatePinnedToCore( pvTaskCode, pcName, usStackDepth, pvParameters, uxPriority, pxCreatedTask, tskNO_AFFINITY ); } #endif @@ -599,15 +599,15 @@ typedef enum #if( configSUPPORT_STATIC_ALLOCATION == 1 ) static inline IRAM_ATTR TaskHandle_t xTaskCreateStatic( - TaskFunction_t pvTaskCode, - const char * const pcName, - const uint32_t ulStackDepth, - void * const pvParameters, - UBaseType_t uxPriority, - StackType_t * const pxStackBuffer, - StaticTask_t * const pxTaskBuffer) + TaskFunction_t pvTaskCode, + const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */ + const uint32_t ulStackDepth, + void * const pvParameters, + UBaseType_t uxPriority, + StackType_t * const puxStackBuffer, + StaticTask_t * const pxTaskBuffer) PRIVILEGED_FUNCTION { - return xTaskCreateStaticPinnedToCore( pvTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, pxStackBuffer, pxTaskBuffer, tskNO_AFFINITY ); + return xTaskCreateStaticPinnedToCore( pvTaskCode, pcName, ulStackDepth, pvParameters, uxPriority, puxStackBuffer, pxTaskBuffer, tskNO_AFFINITY ); } #endif /* configSUPPORT_STATIC_ALLOCATION */ @@ -690,7 +690,7 @@ typedef enum */ #if ( portUSING_MPU_WRAPPERS == 1 ) BaseType_t xTaskCreateRestricted( const TaskParameters_t * const pxTaskDefinition, - TaskHandle_t * pxCreatedTask ); + TaskHandle_t * pxCreatedTask ) PRIVILEGED_FUNCTION; #endif /** @@ -3335,8 +3335,8 @@ void vTaskPlaceOnEventListRestricted( List_t * const pxEventList, * making the call, otherwise pdFALSE. */ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) PRIVILEGED_FUNCTION; -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, - const TickType_t xItemValue ) PRIVILEGED_FUNCTION; +void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) PRIVILEGED_FUNCTION; /* * THIS FUNCTION MUST NOT BE USED FROM APPLICATION CODE. IT IS ONLY @@ -3399,11 +3399,6 @@ void vTaskPriorityDisinheritAfterTimeout( TaskHandle_t const pxMutexHolder, */ UBaseType_t uxTaskGetTaskNumber( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; -/* - * Get the current core affinity of a task - */ -BaseType_t xTaskGetAffinity( TaskHandle_t xTask ) PRIVILEGED_FUNCTION; - /* * Set the uxTaskNumber of the task referenced by the xTask parameter to * uxHandle. diff --git a/components/freertos/linker.lf b/components/freertos/linker.lf index a9aeec7d6b..8473d52605 100644 --- a/components/freertos/linker.lf +++ b/components/freertos/linker.lf @@ -26,7 +26,7 @@ entries: tasks: vTaskSuspendAll (default) tasks: uxTaskGetNumberOfTasks (default) tasks: xTaskGetIdleTaskHandle (default) - tasks: xTaskRemoveFromUnorderedEventList (default) + tasks: vTaskRemoveFromUnorderedEventList (default) tasks: uxTaskPriorityGet (default) tasks: vTaskPrioritySet (default) tasks: vTaskSetThreadLocalStoragePointerAndDelCallback (default) diff --git a/components/freertos/tasks.c b/components/freertos/tasks.c index a8da2be63d..01bde4506b 100644 --- a/components/freertos/tasks.c +++ b/components/freertos/tasks.c @@ -2347,11 +2347,13 @@ void vTaskStartScheduler( void ) portDISABLE_INTERRUPTS(); #if ( configUSE_NEWLIB_REENTRANT == 1 ) - { - // /* Switch Newlib's _impure_ptr variable to point to the _reent - // structure specific to the task that will run first. */ + { + /* Switch Newlib's _impure_ptr variable to point to the _reent + * structure specific to the task that will run first. + * See the third party link http://www.nadler.com/embedded/newlibAndFreeRTOS.html + * for additional information. */ // _impure_ptr = &( pxCurrentTCB[xPortGetCoreID()]->xNewLib_reent ); - } + } #endif /* configUSE_NEWLIB_REENTRANT */ xNextTaskUnblockTime = portMAX_DELAY; @@ -3105,6 +3107,7 @@ BaseType_t xTaskIncrementTick( void ) * Increments the tick then checks to see if the new tick value will cause any * tasks to be unblocked. */ traceTASK_INCREMENT_TICK( xTickCount ); + if( uxSchedulerSuspended[xPortGetCoreID()] == ( UBaseType_t ) pdFALSE ) { taskENTER_CRITICAL_ISR(); @@ -3326,7 +3329,8 @@ BaseType_t xTaskIncrementTick( void ) #if ( configUSE_APPLICATION_TASK_TAG == 1 ) - BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter ) + BaseType_t xTaskCallApplicationTaskHook( TaskHandle_t xTask, + void * pvParameter ) { TCB_t * xTCB; BaseType_t xReturn; @@ -3529,7 +3533,8 @@ void vTaskSwitchContext( void ) } /*-----------------------------------------------------------*/ -void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksToWait ) +void vTaskPlaceOnEventList( List_t * const pxEventList, + const TickType_t xTicksToWait ) { configASSERT( pxEventList ); taskENTER_CRITICAL(); @@ -3548,7 +3553,9 @@ void vTaskPlaceOnEventList( List_t * const pxEventList, const TickType_t xTicksT } /*-----------------------------------------------------------*/ -void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, const TickType_t xItemValue, const TickType_t xTicksToWait ) +void vTaskPlaceOnUnorderedEventList( List_t * pxEventList, + const TickType_t xItemValue, + const TickType_t xTicksToWait ) { configASSERT( pxEventList ); taskENTER_CRITICAL(); @@ -3709,10 +3716,10 @@ BaseType_t xTaskRemoveFromEventList( const List_t * const pxEventList ) } /*-----------------------------------------------------------*/ -BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, const TickType_t xItemValue ) +void vTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, + const TickType_t xItemValue ) { TCB_t * pxUnblockedTCB; - BaseType_t xReturn; taskENTER_CRITICAL(); @@ -3733,12 +3740,6 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons if ( tskCAN_RUN_HERE(pxUnblockedTCB->xCoreID) && pxUnblockedTCB->uxPriority >= pxCurrentTCB[ xPortGetCoreID() ]->uxPriority ) { - /* Return true if the task removed from the event list has - * a higher priority than the calling task. This allows - * the calling task to know if it should force a context - * switch now. */ - xReturn = pdTRUE; - /* Mark that a yield is pending in case the user is not using the * "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */ xYieldPending[ xPortGetCoreID() ] = pdTRUE; @@ -3746,15 +3747,9 @@ BaseType_t xTaskRemoveFromUnorderedEventList( ListItem_t * pxEventListItem, cons else if ( pxUnblockedTCB->xCoreID != xPortGetCoreID() ) { taskYIELD_OTHER_CORE( pxUnblockedTCB->xCoreID, pxUnblockedTCB->uxPriority ); - xReturn = pdFALSE; - } - else - { - xReturn = pdFALSE; } taskEXIT_CRITICAL(); - return xReturn; } /*-----------------------------------------------------------*/ @@ -3778,7 +3773,8 @@ void vTaskInternalSetTimeOutState( TimeOut_t * const pxTimeOut ) } /*-----------------------------------------------------------*/ -BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, TickType_t * const pxTicksToWait ) +BaseType_t xTaskCheckForTimeOut( TimeOut_t * const pxTimeOut, + TickType_t * const pxTicksToWait ) { BaseType_t xReturn; @@ -3872,7 +3868,8 @@ void vTaskMissedYield( void ) #if ( configUSE_TRACE_FACILITY == 1 ) - void vTaskSetTaskNumber( TaskHandle_t xTask, const UBaseType_t uxHandle ) + void vTaskSetTaskNumber( TaskHandle_t xTask, + const UBaseType_t uxHandle ) { TCB_t * pxTCB; @@ -5423,6 +5420,7 @@ TickType_t uxTaskResetEventItemValue( void ) BaseType_t xReturn; configASSERT( uxIndexToWait < configTASK_NOTIFICATION_ARRAY_ENTRIES ); + taskENTER_CRITICAL(); { /* Only block if a notification is not already pending. */