mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-14 08:47:45 -04:00
Add uncrustify github workflow (#659)
* Add uncrustify github workflow * Fix exclusion pattern * fix find expression * exclude uncrustify files * Uncrustify common demo and test files * exlude white space checking files * Fix EOL whitespace checker * Remove whitespaces from EOL * Fix space at EOL * Fix find spaces at EOL Co-authored-by: Archit Aggarwal <architag@amazon.com>
This commit is contained in:
parent
dd80d615b5
commit
ae92d8c6ee
191 changed files with 17540 additions and 17102 deletions
|
@ -32,7 +32,7 @@
|
|||
/**
|
||||
* @brief Size of the shared memory region.
|
||||
*/
|
||||
#define SHARED_MEMORY_SIZE 32
|
||||
#define SHARED_MEMORY_SIZE 32
|
||||
|
||||
/**
|
||||
* @brief Memory region shared between two tasks.
|
||||
|
@ -74,153 +74,155 @@ static void prvRWAccessTask( void * pvParameters );
|
|||
|
||||
static void prvROAccessTask( void * pvParameters )
|
||||
{
|
||||
uint8_t ucVal;
|
||||
uint8_t ucVal;
|
||||
|
||||
/* Unused parameters. */
|
||||
( void ) pvParameters;
|
||||
/* Unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
/* This task has RO access to ucSharedMemory and therefore it can read
|
||||
* it but cannot modify it. */
|
||||
ucVal = ucSharedMemory[ 0 ];
|
||||
for( ; ; )
|
||||
{
|
||||
/* This task has RO access to ucSharedMemory and therefore it can read
|
||||
* it but cannot modify it. */
|
||||
ucVal = ucSharedMemory[ 0 ];
|
||||
|
||||
/* Silent compiler warnings about unused variables. */
|
||||
( void ) ucVal;
|
||||
/* Silent compiler warnings about unused variables. */
|
||||
( void ) ucVal;
|
||||
|
||||
/* Since this task has Read Only access to the ucSharedMemory region,
|
||||
* writing to it results in Memory Fault. Set ucROTaskFaultTracker[ 0 ]
|
||||
* to 1 to tell the Memory Fault Handler that this is an expected fault.
|
||||
* The handler will recover from this fault gracefully by jumping to the
|
||||
* next instruction. */
|
||||
ucROTaskFaultTracker[ 0 ] = 1;
|
||||
/* Since this task has Read Only access to the ucSharedMemory region,
|
||||
* writing to it results in Memory Fault. Set ucROTaskFaultTracker[ 0 ]
|
||||
* to 1 to tell the Memory Fault Handler that this is an expected fault.
|
||||
* The handler will recover from this fault gracefully by jumping to the
|
||||
* next instruction. */
|
||||
ucROTaskFaultTracker[ 0 ] = 1;
|
||||
|
||||
/* Illegal access to generate Memory Fault. */
|
||||
ucSharedMemory[ 0 ] = 0;
|
||||
/* Illegal access to generate Memory Fault. */
|
||||
ucSharedMemory[ 0 ] = 0;
|
||||
|
||||
/* Wait for a second. */
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
/* Wait for a second. */
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvRWAccessTask( void * pvParameters )
|
||||
{
|
||||
/* Unused parameters. */
|
||||
( void ) pvParameters;
|
||||
/* Unused parameters. */
|
||||
( void ) pvParameters;
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
/* This task has RW access to ucSharedMemory and therefore can write to
|
||||
* it. */
|
||||
ucSharedMemory[ 0 ] = 0;
|
||||
for( ; ; )
|
||||
{
|
||||
/* This task has RW access to ucSharedMemory and therefore can write to
|
||||
* it. */
|
||||
ucSharedMemory[ 0 ] = 0;
|
||||
|
||||
/* Wait for a second. */
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
/* Wait for a second. */
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void vStartMPUDemo( void )
|
||||
{
|
||||
static StackType_t xROAccessTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
static StackType_t xRWAccessTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
TaskParameters_t xROAccessTaskParameters =
|
||||
{
|
||||
.pvTaskCode = prvROAccessTask,
|
||||
.pcName = "ROAccess",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xROAccessTaskStack,
|
||||
.xRegions = {
|
||||
{ ucSharedMemory, 32, tskMPU_REGION_READ_ONLY | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ ucROTaskFaultTracker, 32, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
TaskParameters_t xRWAccessTaskParameters =
|
||||
{
|
||||
.pvTaskCode = prvRWAccessTask,
|
||||
.pcName = "RWAccess",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xRWAccessTaskStack,
|
||||
.xRegions = {
|
||||
{ ucSharedMemory, 32, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
static StackType_t xROAccessTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
static StackType_t xRWAccessTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
TaskParameters_t xROAccessTaskParameters =
|
||||
{
|
||||
.pvTaskCode = prvROAccessTask,
|
||||
.pcName = "ROAccess",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xROAccessTaskStack,
|
||||
.xRegions =
|
||||
{
|
||||
{ ucSharedMemory, 32, tskMPU_REGION_READ_ONLY | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ ucROTaskFaultTracker, 32, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
TaskParameters_t xRWAccessTaskParameters =
|
||||
{
|
||||
.pvTaskCode = prvRWAccessTask,
|
||||
.pcName = "RWAccess",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xRWAccessTaskStack,
|
||||
.xRegions =
|
||||
{
|
||||
{ ucSharedMemory, 32, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
|
||||
/* Create an unprivileged task with RO access to ucSharedMemory. */
|
||||
xTaskCreateRestricted( &( xROAccessTaskParameters ), NULL );
|
||||
/* Create an unprivileged task with RO access to ucSharedMemory. */
|
||||
xTaskCreateRestricted( &( xROAccessTaskParameters ), NULL );
|
||||
|
||||
/* Create an unprivileged task with RW access to ucSharedMemory. */
|
||||
xTaskCreateRestricted( &( xRWAccessTaskParameters ), NULL );
|
||||
/* Create an unprivileged task with RW access to ucSharedMemory. */
|
||||
xTaskCreateRestricted( &( xRWAccessTaskParameters ), NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
portDONT_DISCARD void vHandleMemoryFault( uint32_t * pulFaultStackAddress )
|
||||
{
|
||||
uint32_t ulPC;
|
||||
uint16_t usOffendingInstruction;
|
||||
uint32_t ulPC;
|
||||
uint16_t usOffendingInstruction;
|
||||
|
||||
/* Is this an expected fault? */
|
||||
if( ucROTaskFaultTracker[ 0 ] == 1 )
|
||||
{
|
||||
/* Read program counter. */
|
||||
ulPC = pulFaultStackAddress[ 6 ];
|
||||
/* Is this an expected fault? */
|
||||
if( ucROTaskFaultTracker[ 0 ] == 1 )
|
||||
{
|
||||
/* Read program counter. */
|
||||
ulPC = pulFaultStackAddress[ 6 ];
|
||||
|
||||
/* Read the offending instruction. */
|
||||
usOffendingInstruction = *( uint16_t * )ulPC;
|
||||
/* Read the offending instruction. */
|
||||
usOffendingInstruction = *( uint16_t * ) ulPC;
|
||||
|
||||
/* From ARM docs:
|
||||
* If the value of bits[15:11] of the halfword being decoded is one of
|
||||
* the following, the halfword is the first halfword of a 32-bit
|
||||
* instruction:
|
||||
* - 0b11101.
|
||||
* - 0b11110.
|
||||
* - 0b11111.
|
||||
* Otherwise, the halfword is a 16-bit instruction.
|
||||
*/
|
||||
/* From ARM docs:
|
||||
* If the value of bits[15:11] of the halfword being decoded is one of
|
||||
* the following, the halfword is the first halfword of a 32-bit
|
||||
* instruction:
|
||||
* - 0b11101.
|
||||
* - 0b11110.
|
||||
* - 0b11111.
|
||||
* Otherwise, the halfword is a 16-bit instruction.
|
||||
*/
|
||||
|
||||
/* Extract bits[15:11] of the offending instruction. */
|
||||
usOffendingInstruction = usOffendingInstruction & 0xF800;
|
||||
usOffendingInstruction = ( usOffendingInstruction >> 11 );
|
||||
/* Extract bits[15:11] of the offending instruction. */
|
||||
usOffendingInstruction = usOffendingInstruction & 0xF800;
|
||||
usOffendingInstruction = ( usOffendingInstruction >> 11 );
|
||||
|
||||
/* Determine if the offending instruction is a 32-bit instruction or
|
||||
* a 16-bit instruction. */
|
||||
if( usOffendingInstruction == 0x001F ||
|
||||
usOffendingInstruction == 0x001E ||
|
||||
usOffendingInstruction == 0x001D )
|
||||
{
|
||||
/* Since the offending instruction is a 32-bit instruction,
|
||||
* increment the program counter by 4 to move to the next
|
||||
* instruction. */
|
||||
ulPC += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Since the offending instruction is a 16-bit instruction,
|
||||
* increment the program counter by 2 to move to the next
|
||||
* instruction. */
|
||||
ulPC += 2;
|
||||
}
|
||||
/* Determine if the offending instruction is a 32-bit instruction or
|
||||
* a 16-bit instruction. */
|
||||
if( ( usOffendingInstruction == 0x001F ) ||
|
||||
( usOffendingInstruction == 0x001E ) ||
|
||||
( usOffendingInstruction == 0x001D ) )
|
||||
{
|
||||
/* Since the offending instruction is a 32-bit instruction,
|
||||
* increment the program counter by 4 to move to the next
|
||||
* instruction. */
|
||||
ulPC += 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Since the offending instruction is a 16-bit instruction,
|
||||
* increment the program counter by 2 to move to the next
|
||||
* instruction. */
|
||||
ulPC += 2;
|
||||
}
|
||||
|
||||
/* Save the new program counter on the stack. */
|
||||
pulFaultStackAddress[ 6 ] = ulPC;
|
||||
/* Save the new program counter on the stack. */
|
||||
pulFaultStackAddress[ 6 ] = ulPC;
|
||||
|
||||
/* Mark the fault as handled. */
|
||||
ucROTaskFaultTracker[ 0 ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an unexpected fault - loop forever. */
|
||||
for( ; ; )
|
||||
{
|
||||
}
|
||||
}
|
||||
/* Mark the fault as handled. */
|
||||
ucROTaskFaultTracker[ 0 ] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* This is an unexpected fault - loop forever. */
|
||||
for( ; ; )
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
|
@ -37,23 +37,23 @@ static uint32_t ulSecureCounter = 0;
|
|||
/**
|
||||
* @brief typedef for non-secure callback.
|
||||
*/
|
||||
typedef void ( *NonSecureCallback_t ) ( void ) __attribute__( ( cmse_nonsecure_call ) );
|
||||
typedef void ( *NonSecureCallback_t )( void ) __attribute__( ( cmse_nonsecure_call ) );
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
secureportNON_SECURE_CALLABLE uint32_t NSCFunction( Callback_t pxCallback )
|
||||
{
|
||||
NonSecureCallback_t pxNonSecureCallback;
|
||||
NonSecureCallback_t pxNonSecureCallback;
|
||||
|
||||
/* Return function pointer with cleared LSB. */
|
||||
pxNonSecureCallback = ( NonSecureCallback_t ) cmse_nsfptr_create( pxCallback );
|
||||
/* Return function pointer with cleared LSB. */
|
||||
pxNonSecureCallback = ( NonSecureCallback_t ) cmse_nsfptr_create( pxCallback );
|
||||
|
||||
/* Invoke the supplied callback. */
|
||||
pxNonSecureCallback();
|
||||
/* Invoke the supplied callback. */
|
||||
pxNonSecureCallback();
|
||||
|
||||
/* Increment the secure side counter. */
|
||||
ulSecureCounter += 1;
|
||||
/* Increment the secure side counter. */
|
||||
ulSecureCounter += 1;
|
||||
|
||||
/* Return the secure side counter. */
|
||||
return ulSecureCounter;
|
||||
/* Return the secure side counter. */
|
||||
return ulSecureCounter;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
/**
|
||||
* @brief Callback function pointer definition.
|
||||
*/
|
||||
typedef void ( *Callback_t ) ( void );
|
||||
typedef void ( * Callback_t ) ( void );
|
||||
|
||||
/**
|
||||
* @brief Invokes the supplied callback which is on the non-secure side.
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* 4 bytes and upto 32 bytes will also fall in the same MPU region and the task
|
||||
* having access to ulNonSecureCounter will also have access to all those items.
|
||||
*/
|
||||
static uint32_t ulNonSecureCounter[8] __attribute__( ( aligned( 32 ) ) ) = { 0 };
|
||||
static uint32_t ulNonSecureCounter[ 8 ] __attribute__( ( aligned( 32 ) ) ) = { 0 };
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/**
|
||||
|
@ -68,66 +68,67 @@ static void prvSecureCallingTask( void * pvParameters );
|
|||
|
||||
void vStartTZDemo( void )
|
||||
{
|
||||
static StackType_t xSecureCallingTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
TaskParameters_t xSecureCallingTaskParameters =
|
||||
{
|
||||
.pvTaskCode = prvSecureCallingTask,
|
||||
.pcName = "SecCalling",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xSecureCallingTaskStack,
|
||||
.xRegions = {
|
||||
{ ulNonSecureCounter, 32, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
static StackType_t xSecureCallingTaskStack[ configMINIMAL_STACK_SIZE ] __attribute__( ( aligned( 32 ) ) );
|
||||
TaskParameters_t xSecureCallingTaskParameters =
|
||||
{
|
||||
.pvTaskCode = prvSecureCallingTask,
|
||||
.pcName = "SecCalling",
|
||||
.usStackDepth = configMINIMAL_STACK_SIZE,
|
||||
.pvParameters = NULL,
|
||||
.uxPriority = tskIDLE_PRIORITY,
|
||||
.puxStackBuffer = xSecureCallingTaskStack,
|
||||
.xRegions =
|
||||
{
|
||||
{ ulNonSecureCounter, 32, tskMPU_REGION_READ_WRITE | tskMPU_REGION_EXECUTE_NEVER },
|
||||
{ 0, 0, 0 },
|
||||
{ 0, 0, 0 },
|
||||
}
|
||||
};
|
||||
|
||||
/* Create an unprivileged task which calls secure functions. */
|
||||
xTaskCreateRestricted( &( xSecureCallingTaskParameters ), NULL );
|
||||
/* Create an unprivileged task which calls secure functions. */
|
||||
xTaskCreateRestricted( &( xSecureCallingTaskParameters ), NULL );
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvCallback( void )
|
||||
{
|
||||
/* This function is called from the secure side. Just increment the counter
|
||||
* here. The check that this counter keeps incrementing is performed in the
|
||||
* prvSecureCallingTask. */
|
||||
ulNonSecureCounter[ 0 ] += 1;
|
||||
/* This function is called from the secure side. Just increment the counter
|
||||
* here. The check that this counter keeps incrementing is performed in the
|
||||
* prvSecureCallingTask. */
|
||||
ulNonSecureCounter[ 0 ] += 1;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
static void prvSecureCallingTask( void * pvParameters )
|
||||
{
|
||||
uint32_t ulLastSecureCounter = 0, ulLastNonSecureCounter = 0;
|
||||
uint32_t ulCurrentSecureCounter = 0;
|
||||
uint32_t ulLastSecureCounter = 0, ulLastNonSecureCounter = 0;
|
||||
uint32_t ulCurrentSecureCounter = 0;
|
||||
|
||||
/* This task calls secure side functions. So allocate a secure context for
|
||||
* it. */
|
||||
portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE );
|
||||
/* This task calls secure side functions. So allocate a secure context for
|
||||
* it. */
|
||||
portALLOCATE_SECURE_CONTEXT( configMINIMAL_SECURE_STACK_SIZE );
|
||||
|
||||
for( ; ; )
|
||||
{
|
||||
/* Call the secure side function. It does two things:
|
||||
* - It calls the supplied function (prvCallback) which in turn
|
||||
* increments the non-secure counter.
|
||||
* - It increments the secure counter and returns the incremented value.
|
||||
* Therefore at the end of this function call both the secure and
|
||||
* non-secure counters must have been incremented.
|
||||
*/
|
||||
ulCurrentSecureCounter = NSCFunction( prvCallback );
|
||||
for( ; ; )
|
||||
{
|
||||
/* Call the secure side function. It does two things:
|
||||
* - It calls the supplied function (prvCallback) which in turn
|
||||
* increments the non-secure counter.
|
||||
* - It increments the secure counter and returns the incremented value.
|
||||
* Therefore at the end of this function call both the secure and
|
||||
* non-secure counters must have been incremented.
|
||||
*/
|
||||
ulCurrentSecureCounter = NSCFunction( prvCallback );
|
||||
|
||||
/* Make sure that both the counters are incremented. */
|
||||
configASSERT( ulCurrentSecureCounter == ulLastSecureCounter + 1 );
|
||||
configASSERT( ulNonSecureCounter[ 0 ] == ulLastNonSecureCounter + 1 );
|
||||
/* Make sure that both the counters are incremented. */
|
||||
configASSERT( ulCurrentSecureCounter == ulLastSecureCounter + 1 );
|
||||
configASSERT( ulNonSecureCounter[ 0 ] == ulLastNonSecureCounter + 1 );
|
||||
|
||||
/* Update the last values for both the counters. */
|
||||
ulLastSecureCounter = ulCurrentSecureCounter;
|
||||
ulLastNonSecureCounter = ulNonSecureCounter[ 0 ];
|
||||
/* Update the last values for both the counters. */
|
||||
ulLastSecureCounter = ulCurrentSecureCounter;
|
||||
ulLastNonSecureCounter = ulNonSecureCounter[ 0 ];
|
||||
|
||||
/* Wait for a second. */
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
/* Wait for a second. */
|
||||
vTaskDelay( pdMS_TO_TICKS( 1000 ) );
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue