Skip to content

Commit

Permalink
Add more interrupt priority asserts for ARM_CM3, ARM_CM4, and ARM_CM7
Browse files Browse the repository at this point in the history
In the ARM_CM3, ARM_CM4, and ARM_CM7 ports, change the assertion that
configMAX_SYSCALL_INTERRUPT_PRIORITY is nonzero to account for the
number of priority bits implemented by the hardware, and add an
assertion that configKERNEL_INTERRUPT_PRIORITY is the maximum value,
also accounting for the supported priority bits.
  • Loading branch information
chrisnc committed Dec 16, 2022
1 parent 99d3d54 commit a59c8b0
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 20 deletions.
16 changes: 12 additions & 4 deletions portable/GCC/ARM_CM3/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,6 @@ static void prvPortStartFirstTask( void )
*/
BaseType_t xPortStartScheduler( void )
{
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );

#if ( configASSERT_DEFINED == 1 )
{
volatile uint32_t ulOriginalPriority;
Expand All @@ -293,6 +289,18 @@ BaseType_t xPortStartScheduler( void )
/* Use the same mask on the maximum system call priority. */
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;

/* Check that the maximum system call priority is nonzero after
* accounting for the number of priority bits supported by the
* hardware. A priority of 0 is invalid because setting the BASEPRI
* register to 0 unmasks all interrupts, and interrupts with priority 0
* cannot be masked using BASEPRI.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ucMaxSysCallPriority );

/* Check that the interrupt priority used for PendSV and SysTick is the
* lowest supported by the hardware. */
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );

/* Calculate the maximum acceptable priority group value for the number
* of bits read back. */
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;
Expand Down
16 changes: 12 additions & 4 deletions portable/GCC/ARM_CM3_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,10 +381,6 @@ static void prvRestoreContextOfFirstTask( void )
*/
BaseType_t xPortStartScheduler( void )
{
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );

#if ( configASSERT_DEFINED == 1 )
{
volatile uint32_t ulOriginalPriority;
Expand All @@ -409,6 +405,18 @@ BaseType_t xPortStartScheduler( void )
/* Use the same mask on the maximum system call priority. */
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;

/* Check that the maximum system call priority is nonzero after
* accounting for the number of priority bits supported by the
* hardware. A priority of 0 is invalid because setting the BASEPRI
* register to 0 unmasks all interrupts, and interrupts with priority 0
* cannot be masked using BASEPRI.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ucMaxSysCallPriority );

/* Check that the interrupt priority used for PendSV and SysTick is the
* lowest supported by the hardware. */
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );

/* Calculate the maximum acceptable priority group value for the number
* of bits read back. */
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;
Expand Down
16 changes: 12 additions & 4 deletions portable/GCC/ARM_CM4F/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ static void prvPortStartFirstTask( void )
*/
BaseType_t xPortStartScheduler( void )
{
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );

/* This port can be used on all revisions of the Cortex-M7 core other than
* the r0p1 parts. r0p1 parts should use the port from the
* /source/portable/GCC/ARM_CM7/r0p1 directory. */
Expand Down Expand Up @@ -329,6 +325,18 @@ BaseType_t xPortStartScheduler( void )
/* Use the same mask on the maximum system call priority. */
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;

/* Check that the maximum system call priority is nonzero after
* accounting for the number of priority bits supported by the
* hardware. A priority of 0 is invalid because setting the BASEPRI
* register to 0 unmasks all interrupts, and interrupts with priority 0
* cannot be masked using BASEPRI.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ucMaxSysCallPriority );

/* Check that the interrupt priority used for PendSV and SysTick is the
* lowest supported by the hardware. */
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );

/* Calculate the maximum acceptable priority group value for the number
* of bits read back. */
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;
Expand Down
16 changes: 12 additions & 4 deletions portable/GCC/ARM_CM4_MPU/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -412,10 +412,6 @@ static void prvRestoreContextOfFirstTask( void )
*/
BaseType_t xPortStartScheduler( void )
{
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );

/* Errata 837070 workaround must only be enabled on Cortex-M7 r0p0
* and r0p1 cores. */
#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )
Expand Down Expand Up @@ -452,6 +448,18 @@ BaseType_t xPortStartScheduler( void )
/* Use the same mask on the maximum system call priority. */
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;

/* Check that the maximum system call priority is nonzero after
* accounting for the number of priority bits supported by the
* hardware. A priority of 0 is invalid because setting the BASEPRI
* register to 0 unmasks all interrupts, and interrupts with priority 0
* cannot be masked using BASEPRI.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ucMaxSysCallPriority );

/* Check that the interrupt priority used for PendSV and SysTick is the
* lowest supported by the hardware. */
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );

/* Calculate the maximum acceptable priority group value for the number
* of bits read back. */
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;
Expand Down
16 changes: 12 additions & 4 deletions portable/GCC/ARM_CM7/r0p1/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,6 @@ static void prvPortStartFirstTask( void )
*/
BaseType_t xPortStartScheduler( void )
{
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );

#if ( configASSERT_DEFINED == 1 )
{
volatile uint32_t ulOriginalPriority;
Expand All @@ -317,6 +313,18 @@ BaseType_t xPortStartScheduler( void )
/* Use the same mask on the maximum system call priority. */
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;

/* Check that the maximum system call priority is nonzero after
* accounting for the number of priority bits supported by the
* hardware. A priority of 0 is invalid because setting the BASEPRI
* register to 0 unmasks all interrupts, and interrupts with priority 0
* cannot be masked using BASEPRI.
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
configASSERT( ucMaxSysCallPriority );

/* Check that the interrupt priority used for PendSV and SysTick is the
* lowest supported by the hardware. */
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );

/* Calculate the maximum acceptable priority group value for the number
* of bits read back. */
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;
Expand Down

0 comments on commit a59c8b0

Please sign in to comment.