]> git.sur5r.net Git - freertos/commitdiff
Improve efficiency even further. Introduce the configMAX_SYSCALL_INTERRUPT_PRIORITY...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 25 Jul 2008 02:34:31 +0000 (02:34 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 25 Jul 2008 02:34:31 +0000 (02:34 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@416 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/IAR/ARM_CM3/port.c
Source/portable/IAR/ARM_CM3/portasm.s
Source/portable/IAR/ARM_CM3/portmacro.h

index 5d44458ea0ccef8826804b9bd6957ebc87f0617c..b6abebdc93814af3fcba7ac7ada1e5adfb16b1eb 100644 (file)
        Please ensure to read the configuration and relevant port sections of the\r
        online documentation.\r
 \r
-       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       http://www.FreeRTOS.org - Documentation, latest information, license and\r
        contact details.\r
 \r
-       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       http://www.SafeRTOS.com - A version that is certified for use in safety\r
        critical systems.\r
 \r
-       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       http://www.OpenRTOS.com - Commercial support, development, porting,\r
        licensing and training services.\r
 */\r
 \r
@@ -86,7 +86,7 @@ FreeRTOS.org versions prior to V4.3.0 did not include this definition. */
 \r
 /* Each task maintains its own interrupt status in the critical nesting\r
 variable. */\r
-unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa;\r
+static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa;\r
 \r
 /*\r
  * Setup the timer to generate the tick interrupts.\r
@@ -119,8 +119,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
        *pxTopOfStack = 0;      /* LR */\r
        pxTopOfStack -= 5;      /* R12, R3, R2 and R1. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;        /* R0 */\r
-       pxTopOfStack -= 9;      /* R11, R10, R9, R8, R7, R6, R5 and R4. */\r
-       *pxTopOfStack = 0x00000000; /* uxCriticalNesting. */\r
+       pxTopOfStack -= 8;      /* R11, R10, R9, R8, R7, R6, R5 and R4. */\r
 \r
        return pxTopOfStack;\r
 }\r
@@ -139,6 +138,9 @@ portBASE_TYPE xPortStartScheduler( void )
        here already. */\r
        prvSetupTimerInterrupt();\r
        \r
+       /* Initialise the critical nesting count ready for the first task. */\r
+       uxCriticalNesting = 0;\r
+\r
        /* Start the first task. */\r
        vPortStartFirstTask( *((unsigned portLONG *) 0 ) );\r
 \r
@@ -158,10 +160,6 @@ void vPortYieldFromISR( void )
 {\r
        /* Set a PendSV to request a context switch. */\r
        *(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;\r
-\r
-       /* This function is also called in response to a Yield(), so we want\r
-       the yield to occur immediately. */\r
-       portENABLE_INTERRUPTS();\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
@@ -184,12 +182,18 @@ void vPortExitCritical( void )
 \r
 void xPortSysTickHandler( void )\r
 {\r
+unsigned portLONG ulDummy;\r
+\r
        /* If using preemption, also force a context switch. */\r
        #if configUSE_PREEMPTION == 1\r
                *(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;     \r
        #endif\r
 \r
-       vTaskIncrementTick();\r
+       ulDummy = portSET_INTERRUPT_MASK_FROM_ISR();\r
+       {\r
+               vTaskIncrementTick();\r
+       }\r
+       portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
index 983ee210c1bf16a7ef90c41bbc6fa8ae048e1613..d4071e39ceb202e3f4d40b5c700204dc9a229880 100644 (file)
        Please ensure to read the configuration and relevant port sections of the\r
        online documentation.\r
 \r
-       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       http://www.FreeRTOS.org - Documentation, latest information, license and\r
        contact details.\r
 \r
-       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       http://www.SafeRTOS.com - A version that is certified for use in safety\r
        critical systems.\r
 \r
-       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       http://www.OpenRTOS.com - Commercial support, development, porting,\r
        licensing and training services.\r
 */\r
 \r
@@ -68,7 +68,6 @@ FreeRTOS.org versions prior to V4.3.0 did not include this definition. */
        thumb\r
 \r
        EXTERN vPortYieldFromISR\r
-       EXTERN uxCriticalNesting\r
        EXTERN pxCurrentTCB\r
        EXTERN vTaskSwitchContext\r
 \r
@@ -93,36 +92,29 @@ xPortPendSVHandler:
        ldr     r3, =pxCurrentTCB                       /* Get the location of the current TCB. */\r
        ldr     r2, [r3]                                                \r
 \r
-       ldr r1, =uxCriticalNesting              /* Save the remaining registers and the critical nesting count onto the task stack. */\r
-       ldr r1, [r1]                                    \r
-       stmdb r0!, {r1,r4-r11}                  \r
+       stmdb r0!, {r4-r11}                             /* Save the remaining registers. */\r
        str r0, [r2]                                    /* Save the new top of stack into the first member of the TCB. */\r
 \r
-       stmdb sp!, {r3, r14}                    \r
+       stmdb sp!, {r3, r14}\r
+       mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
+       msr basepri, r0\r
        bl vTaskSwitchContext                   \r
-       ldmia sp!, {r3, r14}                    \r
+       mov r0, #0\r
+       msr basepri, r0\r
+       ldmia sp!, {r3, r14}\r
 \r
        ldr r1, [r3]                                    \r
-       ldr r2, =uxCriticalNesting      \r
        ldr r0, [r1]                                    /* The first item in pxCurrentTCB is the task top of stack. */\r
-       ldmia r0!, {r1, r4-r11}                 /* Pop the registers and the critical nesting count. */\r
-       str r1, [r2]                                    /* Save the new critical nesting value into ulCriticalNesting. */\r
+       ldmia r0!, {r4-r11}                             /* Pop the registers. */\r
        msr psp, r0                                             \r
-       orr r14, r14, #13                       \r
-\r
-       cbnz r1, sv_disable_interrupts  /* If the nesting count is greater than 0 we need to exit with interrupts masked. */\r
        bx r14                                                  \r
 \r
-sv_disable_interrupts:                         \r
-       mov     r1, #configKERNEL_INTERRUPT_PRIORITY\r
-       msr     basepri, r1\r
-       bx r14                                                  \r
 \r
 /*-----------------------------------------------------------*/\r
 \r
 vPortSetInterruptMask:\r
        push { r0 }\r
-       mov R0, #configKERNEL_INTERRUPT_PRIORITY\r
+       mov R0, #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
        msr BASEPRI, R0\r
        pop { R0 }\r
 \r
@@ -144,9 +136,7 @@ vPortSVCHandler;
        ldr     r3, =pxCurrentTCB\r
        ldr r1, [r3]\r
        ldr r0, [r1]\r
-       ldmia r0!, {r1, r4-r11}\r
-       ldr r2, =uxCriticalNesting\r
-       str r1, [r2]\r
+       ldmia r0!, {r4-r11}\r
        msr psp, r0\r
        mov r0, #0\r
        msr     basepri, r0\r
index 866db7180990991d155e3f0e535ddb35d838387e..5ea632df7e1eb28ef495bb02beabde79862488ee 100644 (file)
        Please ensure to read the configuration and relevant port sections of the\r
        online documentation.\r
 \r
-       http://www.FreeRTOS.org - Documentation, latest information, license and \r
+       http://www.FreeRTOS.org - Documentation, latest information, license and\r
        contact details.\r
 \r
-       http://www.SafeRTOS.com - A version that is certified for use in safety \r
+       http://www.SafeRTOS.com - A version that is certified for use in safety\r
        critical systems.\r
 \r
-       http://www.OpenRTOS.com - Commercial support, development, porting, \r
+       http://www.OpenRTOS.com - Commercial support, development, porting,\r
        licensing and training services.\r
 */\r
 \r
@@ -93,7 +93,7 @@ extern "C" {
 /* Architecture specifics. */\r
 #define portSTACK_GROWTH                       ( -1 )\r
 #define portTICK_RATE_MS                       ( ( portTickType ) 1000 / configTICK_RATE_HZ )          \r
-#define portBYTE_ALIGNMENT                     4\r
+#define portBYTE_ALIGNMENT                     8\r
 /*-----------------------------------------------------------*/        \r
 \r
 \r
@@ -113,10 +113,13 @@ extern void vPortExitCritical( void );
 extern void vPortSetInterruptMask( void );\r
 extern void vPortClearInterruptMask( void );\r
 \r
-#define portDISABLE_INTERRUPTS()       vPortSetInterruptMask();\r
-#define portENABLE_INTERRUPTS()                vPortClearInterruptMask();\r
-#define portENTER_CRITICAL()           vPortEnterCritical()\r
-#define portEXIT_CRITICAL()                    vPortExitCritical()\r
+#define portDISABLE_INTERRUPTS()                               vPortSetInterruptMask();\r
+#define portENABLE_INTERRUPTS()                                        vPortClearInterruptMask();\r
+#define portENTER_CRITICAL()                                   vPortEnterCritical()\r
+#define portEXIT_CRITICAL()                                            vPortExitCritical()\r
+#define portSET_INTERRUPT_MASK_FROM_ISR()              0;vPortSetInterruptMask()\r
+#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x)   vPortClearInterruptMask()\r
+\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Task function macros as described on the FreeRTOS.org WEB site. */\r