]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/portable/GCC/ARM_CM3/port.c
Add code to assert() if non ISR safe API function is called from ISR in IAR and GCC...
[freertos] / FreeRTOS / Source / portable / GCC / ARM_CM3 / port.c
index 01956f5484eea49393ebc8c05feda190fdd946ec..0ba306c6f5df8a759fd74d65081e03ae63128ac7 100644 (file)
@@ -113,6 +113,9 @@ FreeRTOS.org versions prior to V4.4.0 did not include this definition. */
 #define portPRIORITY_GROUP_MASK                                ( 0x07UL << 8UL )\r
 #define portPRIGROUP_SHIFT                                     ( 8UL )\r
 \r
+/* Masks off all bits but the VECTACTIVE bits in the ICSR register. */\r
+#define portVECTACTIVE_MASK                                    ( 0x1FUL )\r
+\r
 /* Constants required to set up the initial stack. */\r
 #define portINITIAL_XPSR                                       ( 0x01000000UL )\r
 \r
@@ -262,6 +265,7 @@ static void prvPortStartFirstTask( void )
                                        " ldr r0, [r0]                  \n"\r
                                        " msr msp, r0                   \n" /* Set the msp back to the start of the stack. */\r
                                        " cpsie i                               \n" /* Globally enable interrupts. */\r
+                                       " cpsie f                               \n"\r
                                        " dsb                                   \n"\r
                                        " isb                                   \n"\r
                                        " svc 0                                 \n" /* System call to start first task. */\r
@@ -374,6 +378,16 @@ void vPortEnterCritical( void )
        uxCriticalNesting++;\r
        __asm volatile( "dsb" );\r
        __asm volatile( "isb" );\r
+       \r
+       /* This is not the interrupt safe version of the enter critical function so\r
+       assert() if it is being called from an interrupt context.  Only API \r
+       functions that end in "FromISR" can be used in an interrupt.  Only assert if\r
+       the critical nesting count is 1 to protect against recursive calls if the\r
+       assert function also uses a critical section. */\r
+       if( uxCriticalNesting == 1 )\r
+       {\r
+               configASSERT( ( portNVIC_INT_CTRL_REG & portVECTACTIVE_MASK ) == 0 );\r
+       }\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r