Skip to content

Commit

Permalink
Merge branch 'main' into fixParadigmFormatting
Browse files Browse the repository at this point in the history
  • Loading branch information
Skptak authored Oct 18, 2023
2 parents a4e4bb9 + 4ada1d7 commit 0c2ba43
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 18 deletions.
14 changes: 10 additions & 4 deletions cmake_example/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,17 @@ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];

void exampleTask( void * parameters )
{
/* Unused parameters. */
( void ) parameters;

for( ; ; )
{
/* Example Task Code */
vTaskDelay( 100 ); /* delay 100 ticks */
}
}

int main( void )
void main( void )
{
printf( "Example FreeRTOS Project\n" );

Expand All @@ -71,19 +74,22 @@ int main( void )
exampleTaskStack,
&exampleTaskTCB );

/* Start the scheduler. */
vTaskStartScheduler();

/* should never get here. */
for( ; ; )
{
/* Should not reach here. */
}

return 0;
}

void vApplicationStackOverflowHook( TaskHandle_t xTask,
char * pcTaskName )
{
/* Check pcTaskName for the name of the offending task,
* or pxCurrentTCB if pcTaskName has itself been corrupted. */
( void ) xTask;
( void ) pcTaskName;
}

void vApplicationGetTimerTaskMemory( StaticTask_t ** ppxTimerTaskTCBBuffer,
Expand Down
41 changes: 27 additions & 14 deletions portable/Common/mpu_wrappers_v2.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@
*/
#define CONVERT_TO_INTERNAL_INDEX( lIndex ) ( ( lIndex ) - INDEX_OFFSET )

/**
* @brief Max value that fits in a size_t type.
*/
#define mpuSIZE_MAX ( ~( ( size_t ) 0 ) )

/**
* @brief Check if multiplying a and b will result in overflow.
*/
#define mpuMULTIPLY_WILL_OVERFLOW( a, b ) ( ( ( a ) > 0 ) && ( ( b ) > ( mpuSIZE_MAX / ( a ) ) ) )

/**
* @brief Get the index of a free slot in the kernel object pool.
*
Expand Down Expand Up @@ -1035,25 +1045,28 @@
UBaseType_t uxArraySize,
configRUN_TIME_COUNTER_TYPE * pulTotalRunTime ) /* PRIVILEGED_FUNCTION */
{
UBaseType_t uxReturn = pdFALSE;
UBaseType_t uxReturn = 0;
UBaseType_t xIsTaskStatusArrayWriteable = pdFALSE;
UBaseType_t xIsTotalRunTimeWriteable = pdFALSE;

xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray,
sizeof( TaskStatus_t ) * uxArraySize,
tskMPU_WRITE_PERMISSION );

if( pulTotalRunTime != NULL )
if( mpuMULTIPLY_WILL_OVERFLOW( sizeof( TaskStatus_t ), uxArraySize ) == 0 )
{
xIsTotalRunTimeWriteable = xPortIsAuthorizedToAccessBuffer( pulTotalRunTime,
sizeof( configRUN_TIME_COUNTER_TYPE ),
tskMPU_WRITE_PERMISSION );
}
xIsTaskStatusArrayWriteable = xPortIsAuthorizedToAccessBuffer( pxTaskStatusArray,
sizeof( TaskStatus_t ) * uxArraySize,
tskMPU_WRITE_PERMISSION );

if( ( xIsTaskStatusArrayWriteable == pdTRUE ) &&
( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) )
{
uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
if( pulTotalRunTime != NULL )
{
xIsTotalRunTimeWriteable = xPortIsAuthorizedToAccessBuffer( pulTotalRunTime,
sizeof( configRUN_TIME_COUNTER_TYPE ),
tskMPU_WRITE_PERMISSION );
}

if( ( xIsTaskStatusArrayWriteable == pdTRUE ) &&
( ( pulTotalRunTime == NULL ) || ( xIsTotalRunTimeWriteable == pdTRUE ) ) )
{
uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
}
}

return uxReturn;
Expand Down

0 comments on commit 0c2ba43

Please sign in to comment.