Add runtime parameter checks (#758)

* Add runtime parameter checks

This commit adds runtime checks for function parameters
to mpu_wrappers_v2 file. The same checks are performed
in the API implementation using asserts.

Signed-off-by: kar-rahul-aws <karahulx@amazon.com>
This commit is contained in:
kar-rahul-aws 2023-08-17 18:53:42 +05:30 committed by GitHub
parent 0d871946ab
commit ace6b39fa0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 273 additions and 179 deletions

1
.github/lexicon.txt vendored
View file

@ -2469,6 +2469,7 @@ uxpriority
uxprioritytouse uxprioritytouse
uxqueue uxqueue
uxqueuegetqueueitemsize uxqueuegetqueueitemsize
uxqueuegetqueuelength
uxqueuelength uxqueuelength
uxqueuemessageswaiting uxqueuemessageswaiting
uxqueuespacesavailable uxqueuespacesavailable

View file

@ -46,26 +46,6 @@
* correct privileged Vs unprivileged linkage and placement. */ * correct privileged Vs unprivileged linkage and placement. */
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021 See comment above. */ #undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE /*lint !e961 !e750 !e9021 See comment above. */
/* The following bit fields convey control information in a task's event list
* item value. It is important they don't clash with the
* taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100U
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200U
#define eventWAIT_FOR_ALL_BITS 0x0400U
#define eventEVENT_BITS_CONTROL_BYTES 0xff00U
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x01000000UL
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL
#define eventWAIT_FOR_ALL_BITS 0x04000000UL
#define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100000000000000ULL
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200000000000000ULL
#define eventWAIT_FOR_ALL_BITS 0x0400000000000000ULL
#define eventEVENT_BITS_CONTROL_BYTES 0xff00000000000000ULL
#endif /* if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) */
typedef struct EventGroupDef_t typedef struct EventGroupDef_t
{ {
EventBits_t uxEventBits; EventBits_t uxEventBits;

View file

@ -36,6 +36,26 @@
/* FreeRTOS includes. */ /* FreeRTOS includes. */
#include "timers.h" #include "timers.h"
/* The following bit fields convey control information in a task's event list
* item value. It is important they don't clash with the
* taskEVENT_LIST_ITEM_VALUE_IN_USE definition. */
#if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100U
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200U
#define eventWAIT_FOR_ALL_BITS 0x0400U
#define eventEVENT_BITS_CONTROL_BYTES 0xff00U
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_32_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x01000000UL
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x02000000UL
#define eventWAIT_FOR_ALL_BITS 0x04000000UL
#define eventEVENT_BITS_CONTROL_BYTES 0xff000000UL
#elif ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_64_BITS )
#define eventCLEAR_EVENTS_ON_EXIT_BIT 0x0100000000000000ULL
#define eventUNBLOCKED_DUE_TO_BIT_SET 0x0200000000000000ULL
#define eventWAIT_FOR_ALL_BITS 0x0400000000000000ULL
#define eventEVENT_BITS_CONTROL_BYTES 0xff00000000000000ULL
#endif /* if ( configTICK_TYPE_WIDTH_IN_BITS == TICK_TYPE_WIDTH_16_BITS ) */
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View file

@ -1753,6 +1753,7 @@ void vQueueSetQueueNumber( QueueHandle_t xQueue,
UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueGetQueueNumber( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; uint8_t ucQueueGetQueueType( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
UBaseType_t uxQueueGetQueueItemSize( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION; UBaseType_t uxQueueGetQueueItemSize( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
UBaseType_t uxQueueGetQueueLength( QueueHandle_t xQueue ) PRIVILEGED_FUNCTION;
/* *INDENT-OFF* */ /* *INDENT-OFF* */
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -366,13 +366,16 @@
BaseType_t xReturn = pdFAIL; BaseType_t xReturn = pdFAIL;
BaseType_t xIsPreviousWakeTimeAccessible = pdFALSE; BaseType_t xIsPreviousWakeTimeAccessible = pdFALSE;
xIsPreviousWakeTimeAccessible = xPortIsAuthorizedToAccessBuffer( pxPreviousWakeTime, if( ( pxPreviousWakeTime != NULL ) && ( xTimeIncrement > 0U ) )
sizeof( TickType_t ),
( tskMPU_WRITE_PERMISSION | tskMPU_READ_PERMISSION ) );
if( xIsPreviousWakeTimeAccessible == pdTRUE )
{ {
xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement ); xIsPreviousWakeTimeAccessible = xPortIsAuthorizedToAccessBuffer( pxPreviousWakeTime,
sizeof( TickType_t ),
( tskMPU_WRITE_PERMISSION | tskMPU_READ_PERMISSION ) );
if( xIsPreviousWakeTimeAccessible == pdTRUE )
{
xReturn = xTaskDelayUntil( pxPreviousWakeTime, xTimeIncrement );
}
} }
return xReturn; return xReturn;
@ -391,22 +394,15 @@
TaskHandle_t xInternalTaskHandle = NULL; TaskHandle_t xInternalTaskHandle = NULL;
int32_t lIndex; int32_t lIndex;
if( xTask == NULL ) lIndex = ( int32_t ) xTask;
{
xReturn = xTaskAbortDelay( xTask );
}
else
{
lIndex = ( int32_t ) xTask;
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalTaskHandle != NULL )
{ {
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); xReturn = xTaskAbortDelay( xInternalTaskHandle );
if( xInternalTaskHandle != NULL )
{
xReturn = xTaskAbortDelay( xInternalTaskHandle );
}
} }
} }
@ -473,22 +469,15 @@
TaskHandle_t xInternalTaskHandle = NULL; TaskHandle_t xInternalTaskHandle = NULL;
int32_t lIndex; int32_t lIndex;
if( pxTask == NULL ) lIndex = ( int32_t ) pxTask;
{
eReturn = eTaskGetState( pxTask );
}
else
{
lIndex = ( int32_t ) pxTask;
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalTaskHandle != NULL )
{ {
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); eReturn = eTaskGetState( xInternalTaskHandle );
if( xInternalTaskHandle != NULL )
{
eReturn = eTaskGetState( xInternalTaskHandle );
}
} }
} }
@ -577,7 +566,11 @@
{ {
/* After the scheduler starts, only privileged tasks are allowed /* After the scheduler starts, only privileged tasks are allowed
* to suspend other tasks. */ * to suspend other tasks. */
if( ( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED ) || ( portIS_TASK_PRIVILEGED() == pdTRUE ) ) #if ( INCLUDE_xTaskGetSchedulerState == 1 )
if( ( xTaskGetSchedulerState() == taskSCHEDULER_NOT_STARTED ) || ( portIS_TASK_PRIVILEGED() == pdTRUE ) )
#else
if( portIS_TASK_PRIVILEGED() == pdTRUE )
#endif
{ {
lIndex = ( int32_t ) pxTaskToSuspend; lIndex = ( int32_t ) pxTaskToSuspend;
@ -1078,13 +1071,16 @@
{ {
BaseType_t xIsTimeOutWriteable = pdFALSE; BaseType_t xIsTimeOutWriteable = pdFALSE;
xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut, if( pxTimeOut != NULL )
sizeof( TimeOut_t ),
tskMPU_WRITE_PERMISSION );
if( xIsTimeOutWriteable == pdTRUE )
{ {
vTaskSetTimeOutState( pxTimeOut ); xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut,
sizeof( TimeOut_t ),
tskMPU_WRITE_PERMISSION );
if( xIsTimeOutWriteable == pdTRUE )
{
vTaskSetTimeOutState( pxTimeOut );
}
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -1099,16 +1095,19 @@
BaseType_t xIsTimeOutWriteable = pdFALSE; BaseType_t xIsTimeOutWriteable = pdFALSE;
BaseType_t xIsTicksToWaitWriteable = pdFALSE; BaseType_t xIsTicksToWaitWriteable = pdFALSE;
xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut, if( ( pxTimeOut != NULL ) && ( pxTicksToWait != NULL ) )
sizeof( TimeOut_t ),
tskMPU_WRITE_PERMISSION );
xIsTicksToWaitWriteable = xPortIsAuthorizedToAccessBuffer( pxTicksToWait,
sizeof( TickType_t ),
tskMPU_WRITE_PERMISSION );
if( ( xIsTimeOutWriteable == pdTRUE ) && ( xIsTicksToWaitWriteable == pdTRUE ) )
{ {
xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait ); xIsTimeOutWriteable = xPortIsAuthorizedToAccessBuffer( pxTimeOut,
sizeof( TimeOut_t ),
tskMPU_WRITE_PERMISSION );
xIsTicksToWaitWriteable = xPortIsAuthorizedToAccessBuffer( pxTicksToWait,
sizeof( TickType_t ),
tskMPU_WRITE_PERMISSION );
if( ( xIsTimeOutWriteable == pdTRUE ) && ( xIsTicksToWaitWriteable == pdTRUE ) )
{
xReturn = xTaskCheckForTimeOut( pxTimeOut, pxTicksToWait );
}
} }
return xReturn; return xReturn;
@ -1134,24 +1133,27 @@
TaskHandle_t xInternalTaskHandle = NULL; TaskHandle_t xInternalTaskHandle = NULL;
BaseType_t xIsPreviousNotificationValueWriteable = pdFALSE; BaseType_t xIsPreviousNotificationValueWriteable = pdFALSE;
if( pulPreviousNotificationValue != NULL ) if( uxIndexToNotify < configTASK_NOTIFICATION_ARRAY_ENTRIES )
{ {
xIsPreviousNotificationValueWriteable = xPortIsAuthorizedToAccessBuffer( pulPreviousNotificationValue, if( pulPreviousNotificationValue != NULL )
sizeof( uint32_t ),
tskMPU_WRITE_PERMISSION );
}
if( ( pulPreviousNotificationValue == NULL ) || ( xIsPreviousNotificationValueWriteable == pdTRUE ) )
{
lIndex = ( int32_t ) xTaskToNotify;
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); xIsPreviousNotificationValueWriteable = xPortIsAuthorizedToAccessBuffer( pulPreviousNotificationValue,
sizeof( uint32_t ),
tskMPU_WRITE_PERMISSION );
}
if( xInternalTaskHandle != NULL ) if( ( pulPreviousNotificationValue == NULL ) || ( xIsPreviousNotificationValueWriteable == pdTRUE ) )
{
lIndex = ( int32_t ) xTaskToNotify;
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xTaskGenericNotify( xInternalTaskHandle, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue ); xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalTaskHandle != NULL )
{
xReturn = xTaskGenericNotify( xInternalTaskHandle, uxIndexToNotify, ulValue, eAction, pulPreviousNotificationValue );
}
} }
} }
} }
@ -1179,16 +1181,19 @@
BaseType_t xReturn = pdFAIL; BaseType_t xReturn = pdFAIL;
BaseType_t xIsNotificationValueWritable = pdFALSE; BaseType_t xIsNotificationValueWritable = pdFALSE;
if( pulNotificationValue != NULL ) if( uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES )
{ {
xIsNotificationValueWritable = xPortIsAuthorizedToAccessBuffer( pulNotificationValue, if( pulNotificationValue != NULL )
sizeof( uint32_t ), {
tskMPU_WRITE_PERMISSION ); xIsNotificationValueWritable = xPortIsAuthorizedToAccessBuffer( pulNotificationValue,
} sizeof( uint32_t ),
tskMPU_WRITE_PERMISSION );
}
if( ( pulNotificationValue == NULL ) || ( xIsNotificationValueWritable == pdTRUE ) ) if( ( pulNotificationValue == NULL ) || ( xIsNotificationValueWritable == pdTRUE ) )
{ {
xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait ); xReturn = xTaskGenericNotifyWait( uxIndexToWaitOn, ulBitsToClearOnEntry, ulBitsToClearOnExit, pulNotificationValue, xTicksToWait );
}
} }
return xReturn; return xReturn;
@ -1207,9 +1212,12 @@
BaseType_t xClearCountOnExit, BaseType_t xClearCountOnExit,
TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */ TickType_t xTicksToWait ) /* PRIVILEGED_FUNCTION */
{ {
uint32_t ulReturn; uint32_t ulReturn = 0;
ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait ); if( uxIndexToWaitOn < configTASK_NOTIFICATION_ARRAY_ENTRIES )
{
ulReturn = ulTaskGenericNotifyTake( uxIndexToWaitOn, xClearCountOnExit, xTicksToWait );
}
return ulReturn; return ulReturn;
} }
@ -1229,21 +1237,24 @@
int32_t lIndex; int32_t lIndex;
TaskHandle_t xInternalTaskHandle = NULL; TaskHandle_t xInternalTaskHandle = NULL;
if( xTask == NULL ) if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES )
{ {
xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear ); if( xTask == NULL )
}
else
{
lIndex = ( int32_t ) xTask;
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); xReturn = xTaskGenericNotifyStateClear( xTask, uxIndexToClear );
}
else
{
lIndex = ( int32_t ) xTask;
if( xInternalTaskHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xTaskGenericNotifyStateClear( xInternalTaskHandle, uxIndexToClear ); xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalTaskHandle != NULL )
{
xReturn = xTaskGenericNotifyStateClear( xInternalTaskHandle, uxIndexToClear );
}
} }
} }
} }
@ -1268,21 +1279,24 @@
int32_t lIndex; int32_t lIndex;
TaskHandle_t xInternalTaskHandle = NULL; TaskHandle_t xInternalTaskHandle = NULL;
if( xTask == NULL ) if( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES )
{ {
ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear ); if( xTask == NULL )
}
else
{
lIndex = ( int32_t ) xTask;
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); ulReturn = ulTaskGenericNotifyValueClear( xTask, uxIndexToClear, ulBitsToClear );
}
else
{
lIndex = ( int32_t ) xTask;
if( xInternalTaskHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
ulReturn = ulTaskGenericNotifyValueClear( xInternalTaskHandle, uxIndexToClear, ulBitsToClear ); xInternalTaskHandle = MPU_GetTaskHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalTaskHandle != NULL )
{
ulReturn = ulTaskGenericNotifyValueClear( xInternalTaskHandle, uxIndexToClear, ulBitsToClear );
}
} }
} }
} }
@ -1811,6 +1825,7 @@
QueueHandle_t xInternalQueueHandle = NULL; QueueHandle_t xInternalQueueHandle = NULL;
BaseType_t xReturn = pdFAIL; BaseType_t xReturn = pdFAIL;
BaseType_t xIsItemToQueueReadable = pdFALSE; BaseType_t xIsItemToQueueReadable = pdFALSE;
UBaseType_t uxQueueItemSize, uxQueueLength;
lIndex = ( int32_t ) xQueue; lIndex = ( int32_t ) xQueue;
@ -1820,16 +1835,27 @@
if( xInternalQueueHandle != NULL ) if( xInternalQueueHandle != NULL )
{ {
if( pvItemToQueue != NULL ) uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
{ uxQueueLength = uxQueueGetQueueLength( xInternalQueueHandle );
xIsItemToQueueReadable = xPortIsAuthorizedToAccessBuffer( pvItemToQueue,
uxQueueGetQueueItemSize( xInternalQueueHandle ),
tskMPU_READ_PERMISSION );
}
if( ( pvItemToQueue == NULL ) || ( xIsItemToQueueReadable == pdTRUE ) ) if( ( !( ( pvItemToQueue == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) ) &&
( !( ( xCopyPosition == queueOVERWRITE ) && ( uxQueueLength != ( UBaseType_t ) 1U ) ) )
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
&& ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
#endif
)
{ {
xReturn = xQueueGenericSend( xInternalQueueHandle, pvItemToQueue, xTicksToWait, xCopyPosition ); if( pvItemToQueue != NULL )
{
xIsItemToQueueReadable = xPortIsAuthorizedToAccessBuffer( pvItemToQueue,
uxQueueGetQueueItemSize( xInternalQueueHandle ),
tskMPU_READ_PERMISSION );
}
if( ( pvItemToQueue == NULL ) || ( xIsItemToQueueReadable == pdTRUE ) )
{
xReturn = xQueueGenericSend( xInternalQueueHandle, pvItemToQueue, xTicksToWait, xCopyPosition );
}
} }
} }
} }
@ -1898,6 +1924,7 @@
QueueHandle_t xInternalQueueHandle = NULL; QueueHandle_t xInternalQueueHandle = NULL;
BaseType_t xReturn = pdFAIL; BaseType_t xReturn = pdFAIL;
BaseType_t xIsReceiveBufferWritable = pdFALSE; BaseType_t xIsReceiveBufferWritable = pdFALSE;
UBaseType_t uxQueueItemSize;
lIndex = ( int32_t ) pxQueue; lIndex = ( int32_t ) pxQueue;
@ -1907,13 +1934,22 @@
if( xInternalQueueHandle != NULL ) if( xInternalQueueHandle != NULL )
{ {
xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer, uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
uxQueueGetQueueItemSize( xInternalQueueHandle ),
tskMPU_WRITE_PERMISSION );
if( xIsReceiveBufferWritable == pdTRUE ) if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) )
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
&& ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
#endif
)
{ {
xReturn = xQueueReceive( xInternalQueueHandle, pvBuffer, xTicksToWait ); xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer,
uxQueueGetQueueItemSize( xInternalQueueHandle ),
tskMPU_WRITE_PERMISSION );
if( xIsReceiveBufferWritable == pdTRUE )
{
xReturn = xQueueReceive( xInternalQueueHandle, pvBuffer, xTicksToWait );
}
} }
} }
} }
@ -1934,6 +1970,7 @@
QueueHandle_t xInternalQueueHandle = NULL; QueueHandle_t xInternalQueueHandle = NULL;
BaseType_t xReturn = pdFAIL; BaseType_t xReturn = pdFAIL;
BaseType_t xIsReceiveBufferWritable = pdFALSE; BaseType_t xIsReceiveBufferWritable = pdFALSE;
UBaseType_t uxQueueItemSize;
lIndex = ( int32_t ) xQueue; lIndex = ( int32_t ) xQueue;
@ -1943,13 +1980,22 @@
if( xInternalQueueHandle != NULL ) if( xInternalQueueHandle != NULL )
{ {
xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer, uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
uxQueueGetQueueItemSize( xInternalQueueHandle ),
tskMPU_WRITE_PERMISSION );
if( xIsReceiveBufferWritable == pdTRUE ) if( ( !( ( ( pvBuffer ) == NULL ) && ( uxQueueItemSize != ( UBaseType_t ) 0U ) ) )
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
&& ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
#endif
)
{ {
xReturn = xQueuePeek( xInternalQueueHandle, pvBuffer, xTicksToWait ); xIsReceiveBufferWritable = xPortIsAuthorizedToAccessBuffer( pvBuffer,
uxQueueGetQueueItemSize( xInternalQueueHandle ),
tskMPU_WRITE_PERMISSION );
if( xIsReceiveBufferWritable == pdTRUE )
{
xReturn = xQueuePeek( xInternalQueueHandle, pvBuffer, xTicksToWait );
}
} }
} }
} }
@ -1967,6 +2013,7 @@
int32_t lIndex; int32_t lIndex;
QueueHandle_t xInternalQueueHandle = NULL; QueueHandle_t xInternalQueueHandle = NULL;
BaseType_t xReturn = pdFAIL; BaseType_t xReturn = pdFAIL;
UBaseType_t uxQueueItemSize;
lIndex = ( int32_t ) xQueue; lIndex = ( int32_t ) xQueue;
@ -1976,7 +2023,16 @@
if( xInternalQueueHandle != NULL ) if( xInternalQueueHandle != NULL )
{ {
xReturn = xQueueSemaphoreTake( xInternalQueueHandle, xTicksToWait ); uxQueueItemSize = uxQueueGetQueueItemSize( xInternalQueueHandle );
if( ( uxQueueItemSize == 0 )
#if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
&& ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
#endif
)
{
xReturn = xQueueSemaphoreTake( xInternalQueueHandle, xTicksToWait );
}
} }
} }
@ -3252,15 +3308,23 @@
EventGroupHandle_t xInternalEventGroupHandle = NULL; EventGroupHandle_t xInternalEventGroupHandle = NULL;
int32_t lIndex; int32_t lIndex;
lIndex = ( int32_t ) xEventGroup; if( ( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) &&
( uxBitsToWaitFor != 0 )
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
&& ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
#endif
)
{ {
xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); lIndex = ( int32_t ) xEventGroup;
if( xInternalEventGroupHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xEventGroupWaitBits( xInternalEventGroupHandle, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait ); xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalEventGroupHandle != NULL )
{
xReturn = xEventGroupWaitBits( xInternalEventGroupHandle, uxBitsToWaitFor, xClearOnExit, xWaitForAllBits, xTicksToWait );
}
} }
} }
@ -3278,15 +3342,18 @@
EventGroupHandle_t xInternalEventGroupHandle = NULL; EventGroupHandle_t xInternalEventGroupHandle = NULL;
int32_t lIndex; int32_t lIndex;
lIndex = ( int32_t ) xEventGroup; if( ( uxBitsToClear & eventEVENT_BITS_CONTROL_BYTES ) == 0 )
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); lIndex = ( int32_t ) xEventGroup;
if( xInternalEventGroupHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xEventGroupClearBits( xInternalEventGroupHandle, uxBitsToClear ); xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalEventGroupHandle != NULL )
{
xReturn = xEventGroupClearBits( xInternalEventGroupHandle, uxBitsToClear );
}
} }
} }
@ -3304,15 +3371,18 @@
EventGroupHandle_t xInternalEventGroupHandle = NULL; EventGroupHandle_t xInternalEventGroupHandle = NULL;
int32_t lIndex; int32_t lIndex;
lIndex = ( int32_t ) xEventGroup; if( ( uxBitsToSet & eventEVENT_BITS_CONTROL_BYTES ) == 0 )
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); lIndex = ( int32_t ) xEventGroup;
if( xInternalEventGroupHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xEventGroupSetBits( xInternalEventGroupHandle, uxBitsToSet ); xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalEventGroupHandle != NULL )
{
xReturn = xEventGroupSetBits( xInternalEventGroupHandle, uxBitsToSet );
}
} }
} }
@ -3334,15 +3404,23 @@
EventGroupHandle_t xInternalEventGroupHandle = NULL; EventGroupHandle_t xInternalEventGroupHandle = NULL;
int32_t lIndex; int32_t lIndex;
lIndex = ( int32_t ) xEventGroup; if( ( ( uxBitsToWaitFor & eventEVENT_BITS_CONTROL_BYTES ) == 0 ) &&
( uxBitsToWaitFor != 0 )
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) #if ( ( INCLUDE_xTaskGetSchedulerState == 1 ) || ( configUSE_TIMERS == 1 ) )
&& ( !( ( xTaskGetSchedulerState() == taskSCHEDULER_SUSPENDED ) && ( xTicksToWait != 0 ) ) )
#endif
)
{ {
xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); lIndex = ( int32_t ) xEventGroup;
if( xInternalEventGroupHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xEventGroupSync( xInternalEventGroupHandle, uxBitsToSet, uxBitsToWaitFor, xTicksToWait ); xInternalEventGroupHandle = MPU_GetEventGroupHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalEventGroupHandle != NULL )
{
xReturn = xEventGroupSync( xInternalEventGroupHandle, uxBitsToSet, uxBitsToWaitFor, xTicksToWait );
}
} }
} }
@ -3615,21 +3693,24 @@
int32_t lIndex; int32_t lIndex;
BaseType_t xIsTxDataBufferReadable = pdFALSE; BaseType_t xIsTxDataBufferReadable = pdFALSE;
xIsTxDataBufferReadable = xPortIsAuthorizedToAccessBuffer( pvTxData, if( pvTxData != NULL )
xDataLengthBytes,
tskMPU_READ_PERMISSION );
if( xIsTxDataBufferReadable == pdTRUE )
{ {
lIndex = ( int32_t ) xStreamBuffer; xIsTxDataBufferReadable = xPortIsAuthorizedToAccessBuffer( pvTxData,
xDataLengthBytes,
tskMPU_READ_PERMISSION );
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) if( xIsTxDataBufferReadable == pdTRUE )
{ {
xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); lIndex = ( int32_t ) xStreamBuffer;
if( xInternalStreamBufferHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xStreamBufferSend( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, xTicksToWait ); xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalStreamBufferHandle != NULL )
{
xReturn = xStreamBufferSend( xInternalStreamBufferHandle, pvTxData, xDataLengthBytes, xTicksToWait );
}
} }
} }
} }
@ -3653,21 +3734,24 @@
int32_t lIndex; int32_t lIndex;
BaseType_t xIsRxDataBufferWriteable = pdFALSE; BaseType_t xIsRxDataBufferWriteable = pdFALSE;
xIsRxDataBufferWriteable = xPortIsAuthorizedToAccessBuffer( pvRxData, if( pvRxData != NULL )
xBufferLengthBytes,
tskMPU_WRITE_PERMISSION );
if( xIsRxDataBufferWriteable == pdTRUE )
{ {
lIndex = ( int32_t ) xStreamBuffer; xIsRxDataBufferWriteable = xPortIsAuthorizedToAccessBuffer( pvRxData,
xBufferLengthBytes,
tskMPU_WRITE_PERMISSION );
if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE ) if( xIsRxDataBufferWriteable == pdTRUE )
{ {
xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) ); lIndex = ( int32_t ) xStreamBuffer;
if( xInternalStreamBufferHandle != NULL ) if( IS_EXTERNAL_INDEX_VALID( lIndex ) != pdFALSE )
{ {
xReturn = xStreamBufferReceive( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, xTicksToWait ); xInternalStreamBufferHandle = MPU_GetStreamBufferHandleAtIndex( CONVERT_TO_INTERNAL_INDEX( lIndex ) );
if( xInternalStreamBufferHandle != NULL )
{
xReturn = xStreamBufferReceive( xInternalStreamBufferHandle, pvRxData, xBufferLengthBytes, xTicksToWait );
}
} }
} }
} }

View file

@ -2200,6 +2200,12 @@ UBaseType_t uxQueueGetQueueItemSize( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTI
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
UBaseType_t uxQueueGetQueueLength( QueueHandle_t xQueue ) /* PRIVILEGED_FUNCTION */
{
return ( ( Queue_t * ) xQueue )->uxLength;
}
/*-----------------------------------------------------------*/
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue ) static UBaseType_t prvGetDisinheritPriorityAfterTimeout( const Queue_t * const pxQueue )

View file

@ -5306,6 +5306,8 @@ TickType_t uxTaskResetEventItemValue( void )
TCB_t * pxTCB; TCB_t * pxTCB;
uint32_t ulReturn; uint32_t ulReturn;
configASSERT( uxIndexToClear < configTASK_NOTIFICATION_ARRAY_ENTRIES );
/* If null is passed in here then it is the calling task that is having /* If null is passed in here then it is the calling task that is having
* its notification state cleared. */ * its notification state cleared. */
pxTCB = prvGetTCBFromHandle( xTask ); pxTCB = prvGetTCBFromHandle( xTask );