Skip to content

Commit a59c8b0

Browse files
committed
Add more interrupt priority asserts for ARM_CM3, ARM_CM4, and ARM_CM7
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.
1 parent 99d3d54 commit a59c8b0

File tree

5 files changed

+60
-20
lines changed

5 files changed

+60
-20
lines changed

portable/GCC/ARM_CM3/port.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -265,10 +265,6 @@ static void prvPortStartFirstTask( void )
265265
*/
266266
BaseType_t xPortStartScheduler( void )
267267
{
268-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
269-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
270-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
271-
272268
#if ( configASSERT_DEFINED == 1 )
273269
{
274270
volatile uint32_t ulOriginalPriority;
@@ -293,6 +289,18 @@ BaseType_t xPortStartScheduler( void )
293289
/* Use the same mask on the maximum system call priority. */
294290
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
295291

292+
/* Check that the maximum system call priority is nonzero after
293+
* accounting for the number of priority bits supported by the
294+
* hardware. A priority of 0 is invalid because setting the BASEPRI
295+
* register to 0 unmasks all interrupts, and interrupts with priority 0
296+
* cannot be masked using BASEPRI.
297+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
298+
configASSERT( ucMaxSysCallPriority );
299+
300+
/* Check that the interrupt priority used for PendSV and SysTick is the
301+
* lowest supported by the hardware. */
302+
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );
303+
296304
/* Calculate the maximum acceptable priority group value for the number
297305
* of bits read back. */
298306
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM3_MPU/port.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,6 @@ static void prvRestoreContextOfFirstTask( void )
381381
*/
382382
BaseType_t xPortStartScheduler( void )
383383
{
384-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See
385-
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
386-
configASSERT( ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );
387-
388384
#if ( configASSERT_DEFINED == 1 )
389385
{
390386
volatile uint32_t ulOriginalPriority;
@@ -409,6 +405,18 @@ BaseType_t xPortStartScheduler( void )
409405
/* Use the same mask on the maximum system call priority. */
410406
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
411407

408+
/* Check that the maximum system call priority is nonzero after
409+
* accounting for the number of priority bits supported by the
410+
* hardware. A priority of 0 is invalid because setting the BASEPRI
411+
* register to 0 unmasks all interrupts, and interrupts with priority 0
412+
* cannot be masked using BASEPRI.
413+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
414+
configASSERT( ucMaxSysCallPriority );
415+
416+
/* Check that the interrupt priority used for PendSV and SysTick is the
417+
* lowest supported by the hardware. */
418+
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );
419+
412420
/* Calculate the maximum acceptable priority group value for the number
413421
* of bits read back. */
414422
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM4F/port.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -295,10 +295,6 @@ static void prvPortStartFirstTask( void )
295295
*/
296296
BaseType_t xPortStartScheduler( void )
297297
{
298-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
299-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
300-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
301-
302298
/* This port can be used on all revisions of the Cortex-M7 core other than
303299
* the r0p1 parts. r0p1 parts should use the port from the
304300
* /source/portable/GCC/ARM_CM7/r0p1 directory. */
@@ -329,6 +325,18 @@ BaseType_t xPortStartScheduler( void )
329325
/* Use the same mask on the maximum system call priority. */
330326
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
331327

328+
/* Check that the maximum system call priority is nonzero after
329+
* accounting for the number of priority bits supported by the
330+
* hardware. A priority of 0 is invalid because setting the BASEPRI
331+
* register to 0 unmasks all interrupts, and interrupts with priority 0
332+
* cannot be masked using BASEPRI.
333+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
334+
configASSERT( ucMaxSysCallPriority );
335+
336+
/* Check that the interrupt priority used for PendSV and SysTick is the
337+
* lowest supported by the hardware. */
338+
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );
339+
332340
/* Calculate the maximum acceptable priority group value for the number
333341
* of bits read back. */
334342
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM4_MPU/port.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -412,10 +412,6 @@ static void prvRestoreContextOfFirstTask( void )
412412
*/
413413
BaseType_t xPortStartScheduler( void )
414414
{
415-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0. See
416-
* https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
417-
configASSERT( ( configMAX_SYSCALL_INTERRUPT_PRIORITY ) );
418-
419415
/* Errata 837070 workaround must only be enabled on Cortex-M7 r0p0
420416
* and r0p1 cores. */
421417
#if ( configENABLE_ERRATA_837070_WORKAROUND == 1 )
@@ -452,6 +448,18 @@ BaseType_t xPortStartScheduler( void )
452448
/* Use the same mask on the maximum system call priority. */
453449
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
454450

451+
/* Check that the maximum system call priority is nonzero after
452+
* accounting for the number of priority bits supported by the
453+
* hardware. A priority of 0 is invalid because setting the BASEPRI
454+
* register to 0 unmasks all interrupts, and interrupts with priority 0
455+
* cannot be masked using BASEPRI.
456+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
457+
configASSERT( ucMaxSysCallPriority );
458+
459+
/* Check that the interrupt priority used for PendSV and SysTick is the
460+
* lowest supported by the hardware. */
461+
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );
462+
455463
/* Calculate the maximum acceptable priority group value for the number
456464
* of bits read back. */
457465
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

portable/GCC/ARM_CM7/r0p1/port.c

+12-4
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,6 @@ static void prvPortStartFirstTask( void )
289289
*/
290290
BaseType_t xPortStartScheduler( void )
291291
{
292-
/* configMAX_SYSCALL_INTERRUPT_PRIORITY must not be set to 0.
293-
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
294-
configASSERT( configMAX_SYSCALL_INTERRUPT_PRIORITY );
295-
296292
#if ( configASSERT_DEFINED == 1 )
297293
{
298294
volatile uint32_t ulOriginalPriority;
@@ -317,6 +313,18 @@ BaseType_t xPortStartScheduler( void )
317313
/* Use the same mask on the maximum system call priority. */
318314
ucMaxSysCallPriority = configMAX_SYSCALL_INTERRUPT_PRIORITY & ucMaxPriorityValue;
319315

316+
/* Check that the maximum system call priority is nonzero after
317+
* accounting for the number of priority bits supported by the
318+
* hardware. A priority of 0 is invalid because setting the BASEPRI
319+
* register to 0 unmasks all interrupts, and interrupts with priority 0
320+
* cannot be masked using BASEPRI.
321+
* See https://www.FreeRTOS.org/RTOS-Cortex-M3-M4.html */
322+
configASSERT( ucMaxSysCallPriority );
323+
324+
/* Check that the interrupt priority used for PendSV and SysTick is the
325+
* lowest supported by the hardware. */
326+
configASSERT( (configKERNEL_INTERRUPT_PRIORITY & ucMaxPriorityValue) == ucMaxPriorityValue );
327+
320328
/* Calculate the maximum acceptable priority group value for the number
321329
* of bits read back. */
322330
ulMaxPRIGROUPValue = portMAX_PRIGROUP_BITS;

0 commit comments

Comments
 (0)