Merge branch 'feature/freertos-upgrade-to-10.4.3-extras' into 'master'

freertos: upgrade to 10.4.3 -- extras from SMP base

See merge request espressif/esp-idf!15144
This commit is contained in:
Zim Kalinowski
2021-09-13 03:44:18 +00:00
8 changed files with 78 additions and 45 deletions

View File

@@ -262,11 +262,11 @@
#define configASSERT_DEFINED 1 #define configASSERT_DEFINED 1
#endif #endif
/* configPRECONDITION should be resolve to configASSERT. /* configPRECONDITION should be defined as configASSERT.
* The CBMC proofs need a way to track assumptions and assertions. * The CBMC proofs need a way to track assumptions and assertions.
* A configPRECONDITION statement should express an implicit invariant or assumption made. * A configPRECONDITION statement should express an implicit invariant or
* A configASSERT statement should express an invariant that must hold explicit before calling * assumption made. A configASSERT statement should express an invariant that must
* the code. */ * hold explicit before calling the code. */
#ifndef configPRECONDITION #ifndef configPRECONDITION
#define configPRECONDITION( X ) configASSERT( X ) #define configPRECONDITION( X ) configASSERT( X )
#define configPRECONDITION_DEFINED 0 #define configPRECONDITION_DEFINED 0
@@ -925,6 +925,11 @@
#define configSUPPORT_DYNAMIC_ALLOCATION 1 #define configSUPPORT_DYNAMIC_ALLOCATION 1
#endif #endif
#ifndef configSTACK_ALLOCATION_FROM_SEPARATE_HEAP
/* Defaults to 0 for backward compatibility. */
#define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP 0
#endif
#ifndef configSTACK_DEPTH_TYPE #ifndef configSTACK_DEPTH_TYPE
/* Defaults to uint16_t for backward compatibility, but can be overridden /* Defaults to uint16_t for backward compatibility, but can be overridden
@@ -1008,7 +1013,7 @@
#ifndef configMIN #ifndef configMIN
/* The application writer has not provided their own MAX macro, so define /* The application writer has not provided their own MIN macro, so define
* the following generic implementation. */ * the following generic implementation. */
#define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) ) #define configMIN( a, b ) ( ( ( a ) < ( b ) ) ? ( a ) : ( b ) )
#endif #endif
@@ -1033,6 +1038,7 @@
#define pcTimerGetTimerName pcTimerGetName #define pcTimerGetTimerName pcTimerGetName
#define pcQueueGetQueueName pcQueueGetName #define pcQueueGetQueueName pcQueueGetName
#define vTaskGetTaskInfo vTaskGetInfo #define vTaskGetTaskInfo vTaskGetInfo
#define xTaskGetIdleRunTimeCounter ulTaskGetIdleRunTimeCounter
/* Backward compatibility within the scheduler code only - these definitions /* Backward compatibility within the scheduler code only - these definitions
* are not really required but are included for completeness. */ * are not really required but are included for completeness. */
@@ -1139,7 +1145,7 @@
* data hiding policy, so the real structures used by FreeRTOS to maintain the * data hiding policy, so the real structures used by FreeRTOS to maintain the
* state of tasks, queues, semaphores, etc. are not accessible to the application * state of tasks, queues, semaphores, etc. are not accessible to the application
* code. However, if the application writer wants to statically allocate such * code. However, if the application writer wants to statically allocate such
* an object then the size of the object needs to be know. Dummy structures * an object then the size of the object needs to be known. Dummy structures
* that are guaranteed to have the same size and alignment requirements of the * that are guaranteed to have the same size and alignment requirements of the
* real objects are used for this purpose. The dummy list and list item * real objects are used for this purpose. The dummy list and list item
* structures below are used for inclusion in such a dummy structure. * structures below are used for inclusion in such a dummy structure.
@@ -1188,7 +1194,7 @@ typedef struct xSTATIC_LIST
* strict data hiding policy. This means the Task structure used internally by * strict data hiding policy. This means the Task structure used internally by
* FreeRTOS is not accessible to application code. However, if the application * FreeRTOS is not accessible to application code. However, if the application
* writer wants to statically allocate the memory required to create a task then * writer wants to statically allocate the memory required to create a task then
* the size of the task object needs to be know. The StaticTask_t structure * the size of the task object needs to be known. The StaticTask_t structure
* below is provided for this purpose. Its sizes and alignment requirements are * below is provided for this purpose. Its sizes and alignment requirements are
* guaranteed to match those of the genuine structure, no matter which * guaranteed to match those of the genuine structure, no matter which
* architecture is being used, and no matter how the values in FreeRTOSConfig.h * architecture is being used, and no matter how the values in FreeRTOSConfig.h
@@ -1255,7 +1261,7 @@ typedef struct xSTATIC_TCB
* strict data hiding policy. This means the Queue structure used internally by * strict data hiding policy. This means the Queue structure used internally by
* FreeRTOS is not accessible to application code. However, if the application * FreeRTOS is not accessible to application code. However, if the application
* writer wants to statically allocate the memory required to create a queue * writer wants to statically allocate the memory required to create a queue
* then the size of the queue object needs to be know. The StaticQueue_t * then the size of the queue object needs to be known. The StaticQueue_t
* structure below is provided for this purpose. Its sizes and alignment * structure below is provided for this purpose. Its sizes and alignment
* requirements are guaranteed to match those of the genuine structure, no * requirements are guaranteed to match those of the genuine structure, no
* matter which architecture is being used, and no matter how the values in * matter which architecture is being used, and no matter how the values in
@@ -1328,7 +1334,7 @@ typedef struct xSTATIC_EVENT_GROUP
* strict data hiding policy. This means the software timer structure used * strict data hiding policy. This means the software timer structure used
* internally by FreeRTOS is not accessible to application code. However, if * internally by FreeRTOS is not accessible to application code. However, if
* the application writer wants to statically allocate the memory required to * the application writer wants to statically allocate the memory required to
* create a software timer then the size of the queue object needs to be know. * create a software timer then the size of the queue object needs to be known.
* The StaticTimer_t structure below is provided for this purpose. Its sizes * The StaticTimer_t structure below is provided for this purpose. Its sizes
* and alignment requirements are guaranteed to match those of the genuine * and alignment requirements are guaranteed to match those of the genuine
* structure, no matter which architecture is being used, and no matter how the * structure, no matter which architecture is being used, and no matter how the
@@ -1356,12 +1362,12 @@ typedef struct xSTATIC_TIMER
* internally by FreeRTOS is not accessible to application code. However, if * internally by FreeRTOS is not accessible to application code. However, if
* the application writer wants to statically allocate the memory required to * the application writer wants to statically allocate the memory required to
* create a stream buffer then the size of the stream buffer object needs to be * create a stream buffer then the size of the stream buffer object needs to be
* know. The StaticStreamBuffer_t structure below is provided for this purpose. * known. The StaticStreamBuffer_t structure below is provided for this
* Its size and alignment requirements are guaranteed to match those of the * purpose. Its size and alignment requirements are guaranteed to match those
* genuine structure, no matter which architecture is being used, and no matter * of the genuine structure, no matter which architecture is being used, and
* how the values in FreeRTOSConfig.h are set. Its contents are somewhat * no matter how the values in FreeRTOSConfig.h are set. Its contents are
* obfuscated in the hope users will recognise that it would be unwise to make * somewhat obfuscated in the hope users will recognise that it would be unwise
* direct use of the structure members. * to make direct use of the structure members.
*/ */
typedef struct xSTATIC_STREAM_BUFFER typedef struct xSTATIC_STREAM_BUFFER
{ {

View File

@@ -181,6 +181,13 @@ void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION; size_t xPortGetMinimumEverFreeHeapSize( void ) PRIVILEGED_FUNCTION;
#if( configSTACK_ALLOCATION_FROM_SEPARATE_HEAP == 1 )
void *pvPortMallocStack( size_t xSize ) PRIVILEGED_FUNCTION;
void vPortFreeStack( void *pv ) PRIVILEGED_FUNCTION;
#else
#define pvPortMallocStack pvPortMalloc
#define vPortFreeStack vPortFree
#endif
#else // configUSE_FREERTOS_PROVIDED_HEAP #else // configUSE_FREERTOS_PROVIDED_HEAP
/* /*

View File

@@ -1189,7 +1189,7 @@ void vQueueDelete( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
* void vFunction( void *pvParameters ) * void vFunction( void *pvParameters )
* { * {
* // Create a queue to hold one uint32_t value. It is strongly * // Create a queue to hold one uint32_t value. It is strongly
* // recommended \*not\* to use xQueueOverwriteFromISR() on queues that can * // recommended *not* to use xQueueOverwriteFromISR() on queues that can
* // contain more than one value, and doing so will trigger an assertion * // contain more than one value, and doing so will trigger an assertion
* // if configASSERT() is defined. * // if configASSERT() is defined.
* xQueue = xQueueCreate( 1, sizeof( uint32_t ) ); * xQueue = xQueueCreate( 1, sizeof( uint32_t ) );

View File

@@ -2328,7 +2328,7 @@ uint32_t ulTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;
* *
* eSetBits - * eSetBits -
* The target notification value is bitwise ORed with ulValue. * The target notification value is bitwise ORed with ulValue.
* xTaskNofifyIndexed() always returns pdPASS in this case. * xTaskNotifyIndexed() always returns pdPASS in this case.
* *
* eIncrement - * eIncrement -
* The target notification value is incremented. ulValue is not used and * The target notification value is incremented. ulValue is not used and
@@ -2475,7 +2475,7 @@ BaseType_t xTaskGenericNotify( TaskHandle_t xTaskToNotify,
* value, if at all. Valid values for eAction are as follows: * value, if at all. Valid values for eAction are as follows:
* *
* eSetBits - * eSetBits -
* The task's notification value is bitwise ORed with ulValue. xTaskNofify() * The task's notification value is bitwise ORed with ulValue. xTaskNotify()
* always returns pdPASS in this case. * always returns pdPASS in this case.
* *
* eIncrement - * eIncrement -
@@ -2647,7 +2647,7 @@ BaseType_t xTaskGenericNotifyFromISR( TaskHandle_t xTaskToNotify,
* the Blocked state for a notification to be received, should a notification * the Blocked state for a notification to be received, should a notification
* not already be pending when xTaskNotifyWait() was called. The task * not already be pending when xTaskNotifyWait() was called. The task
* will not consume any processing time while it is in the Blocked state. This * will not consume any processing time while it is in the Blocked state. This
* is specified in kernel ticks, the macro pdMS_TO_TICSK( value_in_ms ) can be * is specified in kernel ticks, the macro pdMS_TO_TICKS( value_in_ms ) can be
* used to convert a time specified in milliseconds to a time specified in * used to convert a time specified in milliseconds to a time specified in
* ticks. * ticks.
* *
@@ -2921,7 +2921,7 @@ void vTaskGenericNotifyGiveFromISR( TaskHandle_t xTaskToNotify,
* should the count not already be greater than zero when * should the count not already be greater than zero when
* ulTaskNotifyTake() was called. The task will not consume any processing * ulTaskNotifyTake() was called. The task will not consume any processing
* time while it is in the Blocked state. This is specified in kernel ticks, * time while it is in the Blocked state. This is specified in kernel ticks,
* the macro pdMS_TO_TICSK( value_in_ms ) can be used to convert a time * the macro pdMS_TO_TICKS( value_in_ms ) can be used to convert a time
* specified in milliseconds to a time specified in ticks. * specified in milliseconds to a time specified in ticks.
* *
* @return The task's notification count before it is either cleared to zero or * @return The task's notification count before it is either cleared to zero or
@@ -3106,7 +3106,7 @@ void vTaskSetTimeOutState( TimeOut_t * const pxTimeOut ) PRIVILEGED_FUNCTION;
* @param pxTicksToWait The number of ticks to check for timeout i.e. if * @param pxTicksToWait The number of ticks to check for timeout i.e. if
* pxTicksToWait ticks have passed since pxTimeOut was last updated (either by * pxTicksToWait ticks have passed since pxTimeOut was last updated (either by
* vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred. * vTaskSetTimeOutState() or xTaskCheckForTimeOut()), the timeout has occurred.
* If the timeout has not occurred, pxTIcksToWait is updated to reflect the * If the timeout has not occurred, pxTicksToWait is updated to reflect the
* number of remaining ticks. * number of remaining ticks.
* *
* @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is * @return If timeout has occurred, pdTRUE is returned. Otherwise pdFALSE is
@@ -3275,7 +3275,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
* xItemValue value, and inserts the list item at the end of the list. * xItemValue value, and inserts the list item at the end of the list.
* *
* The 'ordered' version uses the existing event list item value (which is the * The 'ordered' version uses the existing event list item value (which is the
* owning tasks priority) to insert the list item into the event list is task * owning task's priority) to insert the list item into the event list in task
* priority order. * priority order.
* *
* @param pxEventList The list containing tasks that are blocked waiting * @param pxEventList The list containing tasks that are blocked waiting
@@ -3285,7 +3285,7 @@ BaseType_t xTaskIncrementTick( void ) PRIVILEGED_FUNCTION;
* event list is not ordered by task priority. * event list is not ordered by task priority.
* *
* @param xTicksToWait The maximum amount of time that the task should wait * @param xTicksToWait The maximum amount of time that the task should wait
* for the event to occur. This is specified in kernel ticks,the constant * for the event to occur. This is specified in kernel ticks, the constant
* portTICK_PERIOD_MS can be used to convert kernel ticks into a real time * portTICK_PERIOD_MS can be used to convert kernel ticks into a real time
* period. * period.
*/ */

View File

@@ -26,9 +26,20 @@
#include <stdlib.h> #include <stdlib.h>
/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
* all the API functions to use the MPU wrappers. That should only be done when
* task.h is included from an application file. */
#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "list.h" #include "list.h"
/* Lint e9021, e961 and e750 are suppressed as a MISRA exception justified
* because the MPU ports require MPU_WRAPPERS_INCLUDED_FROM_API_FILE to be
* defined for the header files above, but not in this file, in order to
* generate the correct privileged Vs unprivileged linkage and placement. */
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021. */
/*----------------------------------------------------------- /*-----------------------------------------------------------
* PUBLIC LIST API documented in list.h * PUBLIC LIST API documented in list.h
@@ -147,6 +158,9 @@ void vListInsert( List_t * const pxList,
* 4) Using a queue or semaphore before it has been initialised or * 4) Using a queue or semaphore before it has been initialised or
* before the scheduler has been started (are interrupts firing * before the scheduler has been started (are interrupts firing
* before vTaskStartScheduler() has been called?). * before vTaskStartScheduler() has been called?).
* 5) If the FreeRTOS port supports interrupt nesting then ensure that
* the priority of the tick interrupt is at or below
* configMAX_SYSCALL_INTERRUPT_PRIORITY.
**********************************************************************/ **********************************************************************/
for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */ for( pxIterator = ( ListItem_t * ) &( pxList->xListEnd ); pxIterator->pxNext->xItemValue <= xValueOfInsertion; pxIterator = pxIterator->pxNext ) /*lint !e826 !e740 !e9087 The mini list structure is used as the list end to save RAM. This is checked and valid. *//*lint !e440 The iterator moves to a different value, not xValueOfInsertion. */

View File

@@ -62,6 +62,7 @@
/* Constants used with the cRxLock and cTxLock structure members. */ /* Constants used with the cRxLock and cTxLock structure members. */
#define queueUNLOCKED ( ( int8_t ) -1 ) #define queueUNLOCKED ( ( int8_t ) -1 )
#define queueLOCKED_UNMODIFIED ( ( int8_t ) 0 ) #define queueLOCKED_UNMODIFIED ( ( int8_t ) 0 )
#define queueINT8_MAX ( ( int8_t ) 127 )
/* When the Queue_t structure is used to represent a base queue its pcHead and /* When the Queue_t structure is used to represent a base queue its pcHead and
* pcTail members are used as pointers into the queue storage area. When the * pcTail members are used as pointers into the queue storage area. When the
@@ -366,7 +367,9 @@ BaseType_t xQueueGenericReset( QueueHandle_t xQueue,
* variable of type StaticQueue_t or StaticSemaphore_t equals the size of * variable of type StaticQueue_t or StaticSemaphore_t equals the size of
* the real queue and semaphore structures. */ * the real queue and semaphore structures. */
volatile size_t xSize = sizeof( StaticQueue_t ); volatile size_t xSize = sizeof( StaticQueue_t );
configASSERT( xSize == sizeof( Queue_t ) );
/* This assertion cannot be branch covered in unit tests */
configASSERT( xSize == sizeof( Queue_t ) ); /* LCOV_EXCL_BR_LINE */
( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */
} }
#endif /* configASSERT_DEFINED */ #endif /* configASSERT_DEFINED */
@@ -3087,7 +3090,10 @@ BaseType_t xQueueIsQueueFullFromISR( const QueueHandle_t xQueue )
/* This function must be called form a critical section. */ /* This function must be called form a critical section. */
configASSERT( pxQueueSetContainer ); /* The following line is not reachable in unit tests because every call
* to prvNotifyQueueSetContainer is preceded by a check that
* pxQueueSetContainer != NULL */
configASSERT( pxQueueSetContainer ); /* LCOV_EXCL_BR_LINE */
//Acquire the Queue set's spinlock //Acquire the Queue set's spinlock
portENTER_CRITICAL(&(pxQueueSetContainer->mux)); portENTER_CRITICAL(&(pxQueueSetContainer->mux));

View File

@@ -314,7 +314,6 @@ static void prvInitialiseNewStreamBuffer( StreamBuffer_t * const pxStreamBuffer,
pucAllocatedMemory = NULL; pucAllocatedMemory = NULL;
} }
if( pucAllocatedMemory != NULL ) if( pucAllocatedMemory != NULL )
{ {
prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */ prvInitialiseNewStreamBuffer( ( StreamBuffer_t * ) pucAllocatedMemory, /* Structure at the start of the allocated memory. */ /*lint !e9087 Safe cast as allocated memory is aligned. */ /*lint !e826 Area is not too small and alignment is guaranteed provided malloc() behaves as expected and returns aligned buffer. */
@@ -571,14 +570,15 @@ size_t xStreamBufferSend( StreamBufferHandle_t xStreamBuffer,
size_t xReturn, xSpace = 0; size_t xReturn, xSpace = 0;
size_t xRequiredSpace = xDataLengthBytes; size_t xRequiredSpace = xDataLengthBytes;
TimeOut_t xTimeOut; TimeOut_t xTimeOut;
size_t xMaxReportedSpace = 0;
/* The maximum amount of space a stream buffer will ever report is its length
* minus 1. */
const size_t xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
configASSERT( pvTxData ); configASSERT( pvTxData );
configASSERT( pxStreamBuffer ); configASSERT( pxStreamBuffer );
/* The maximum amount of space a stream buffer will ever report is its length
* minus 1. */
xMaxReportedSpace = pxStreamBuffer->xLength - ( size_t ) 1;
/* This send function is used to write to both message buffers and stream /* This send function is used to write to both message buffers and stream
* buffers. If this is a message buffer then the space needed must be * buffers. If this is a message buffer then the space needed must be
* increased by the amount of bytes needed to store the length of the * increased by the amount of bytes needed to store the length of the

View File

@@ -418,8 +418,8 @@ PRIVILEGED_DATA static volatile UBaseType_t uxSchedulerSuspended[portNUM_PROCESS
#if ( configGENERATE_RUN_TIME_STATS == 1 ) #if ( configGENERATE_RUN_TIME_STATS == 1 )
/* Do not move these variables to function scope as doing so prevents the /* Do not move these variables to function scope as doing so prevents the
code working with debuggers that need to remove the static qualifier. */ * code working with debuggers that need to remove the static qualifier. */
PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime[portNUM_PROCESSORS] = {0U}; /*< Holds the value of a timer/counter the last time a task was switched in. */ PRIVILEGED_DATA static uint32_t ulTaskSwitchedInTime[portNUM_PROCESSORS] = {0U}; /*< Holds the value of a timer/counter the last time a task was switched in. */
PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */ PRIVILEGED_DATA static uint32_t ulTotalRunTime = 0UL; /*< Holds the total amount of execution time as defined by the run time counter clock. */
@@ -483,7 +483,7 @@ static void prvInitialiseTaskLists( void ) PRIVILEGED_FUNCTION;
* void prvIdleTask( void *pvParameters ); * void prvIdleTask( void *pvParameters );
* *
*/ */
static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ); static portTASK_FUNCTION_PROTO( prvIdleTask, pvParameters ) PRIVILEGED_FUNCTION;
/* /*
* Utility to free all memory allocated by the scheduler to hold a TCB, * Utility to free all memory allocated by the scheduler to hold a TCB,
@@ -814,7 +814,7 @@ void taskYIELD_OTHER_CORE( BaseType_t xCoreID, UBaseType_t uxPriority )
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )
BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pvTaskCode, BaseType_t xTaskCreatePinnedToCore( TaskFunction_t pvTaskCode,
const char * const pcName, const char * const pcName, /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
const uint32_t usStackDepth, const uint32_t usStackDepth,
void * const pvParameters, void * const pvParameters,
UBaseType_t uxPriority, UBaseType_t uxPriority,
@@ -1906,7 +1906,7 @@ static void prvAddNewTaskToReadyList( TCB_t * pxNewTCB,
if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE ) if( listIS_CONTAINED_WITHIN( &( pxReadyTasksLists[ uxPriorityUsedOnEntry ] ), &( pxTCB->xStateListItem ) ) != pdFALSE )
{ {
/* The task is currently in its ready list - remove before /* The task is currently in its ready list - remove before
* adding it to it's new ready list. As we are in a critical * adding it to its new ready list. As we are in a critical
* section we can do this even if the scheduler is suspended. */ * section we can do this even if the scheduler is suspended. */
if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 ) if( uxListRemove( &( pxTCB->xStateListItem ) ) == ( UBaseType_t ) 0 )
{ {