]> git.sur5r.net Git - freertos/commitdiff
Replace the CLZ function with a CLZ intrinsic in the Cortex-R4 port layer.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 23 Jan 2013 16:06:45 +0000 (16:06 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Wed, 23 Jan 2013 16:06:45 +0000 (16:06 +0000)
Add EDS support in the PIC24 port layer.
Remove unnecessary EHB instructions from PIC32 port.
In the PIC32 port assembly code, replace the &= code with a single ins instruction.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1814 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portASM.asm
FreeRTOS/Source/portable/CCS/ARM_Cortex-R4/portmacro.h
FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/port.c
FreeRTOS/Source/portable/MPLAB/PIC24_dsPIC/portasm_PIC24.S
FreeRTOS/Source/portable/MPLAB/PIC32MX/ISR_Support.h
FreeRTOS/Source/portable/MPLAB/PIC32MX/port_asm.S

index 989e5dbb3c535bca85fdf8ed83a9efbb562c1df7..803cbd8509cd071ab376af9435234ac88e24639e 100644 (file)
@@ -233,15 +233,6 @@ vPortPreemptiveTick:
         ; Restore the context of the task selected to execute.\r
         portRESTORE_CONTEXT\r
 \r
-;-------------------------------------------------------------------------------\r
-\r
-               .def ulPortCountLeadingZeros\r
-\r
-ulPortCountLeadingZeros:\r
-\r
-               CLZ             R0, R0\r
-               BX              LR\r
-\r
 ;-------------------------------------------------------------------------------\r
 \r
        .if (__TI_VFP_SUPPORT__)\r
index b2315dfc22e56f93364ac96e2836b44caaa1675a..f11c38a2527e447b0c1cf1fa38c3bf4e05556549 100644 (file)
@@ -122,9 +122,6 @@ extern void vPortYield( void );
 /* Architecture specific optimisations. */\r
 #if configUSE_PORT_OPTIMISED_TASK_SELECTION == 1\r
 \r
-       /* Generic helper function. */\r
-       unsigned long ulPortCountLeadingZeros( unsigned long ulBitmap );\r
-\r
        /* Check the configuration. */\r
        #if( configMAX_PRIORITIES > 32 )\r
                #error configUSE_PORT_OPTIMISED_TASK_SELECTION can only be set to 1 when configMAX_PRIORITIES is less than or equal to 32.  It is very rare that a system requires more than 10 to 15 difference priorities as tasks that share a priority will time slice.\r
@@ -136,7 +133,7 @@ extern void vPortYield( void );
 \r
        /*-----------------------------------------------------------*/\r
 \r
-       #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - ulPortCountLeadingZeros( ( uxReadyPriorities ) ) )\r
+       #define portGET_HIGHEST_PRIORITY( uxTopPriority, uxReadyPriorities ) uxTopPriority = ( 31 - __clz( ( uxReadyPriorities ) ) )\r
 \r
 #endif /* configUSE_PORT_OPTIMISED_TASK_SELECTION */\r
 \r
index 297beee537c7f823fafc21995c2a7541379e32fc..fdd2fb202983ad678b676bd862dccb25819adbfe 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
     FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
 \r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT \r
+    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
     ***************************************************************************\r
@@ -42,7 +42,7 @@
     FreeRTOS WEB site.\r
 \r
     1 tab == 4 spaces!\r
-    \r
+\r
     ***************************************************************************\r
      *                                                                       *\r
      *    Having a problem?  Start by reading the FAQ "My application does   *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    \r
-    http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
-    and contact details.  \r
-    \r
+\r
+    http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+    and contact details.\r
+\r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool.\r
 \r
-    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
-    the code with commercial support, indemnification, and middleware, under \r
+    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+    the code with commercial support, indemnification, and middleware, under\r
     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
-    provide a safety engineered and independently SIL3 certified version under \r
+    provide a safety engineered and independently SIL3 certified version under\r
     the SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
 \r
@@ -85,7 +85,7 @@
 #define portTIMER_PRESCALE 8\r
 #define portINITIAL_SR 0\r
 \r
-/* Defined for backward compatability with project created prior to \r
+/* Defined for backward compatability with project created prior to\r
 FreeRTOS.org V4.3.0. */\r
 #ifndef configKERNEL_INTERRUPT_PRIORITY\r
        #define configKERNEL_INTERRUPT_PRIORITY 1\r
@@ -103,25 +103,46 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
 \r
 #ifdef MPLAB_PIC24_PORT\r
 \r
-       #define portRESTORE_CONTEXT()                                                                                                                                                                           \\r
-               asm volatile(   "MOV    _pxCurrentTCB, W0               \n"     /* Restore the stack pointer for the task. */                           \\r
-                                               "MOV    [W0], W15                               \n"                                                                                                                             \\r
-                                               "POP    W0                                              \n"     /* Restore the critical nesting counter for the task. */        \\r
-                                               "MOV    W0, _uxCriticalNesting  \n"                                                                                                                             \\r
-                                               "POP    PSVPAG                                  \n"                                                                                                                             \\r
-                                               "POP    CORCON                                  \n"                                                                                                                             \\r
-                                               "POP    TBLPAG                                  \n"                                                                                                                             \\r
-                                               "POP    RCOUNT                                  \n"     /* Restore the registers from the stack. */                                     \\r
-                                               "POP    W14                                             \n"                                                                                                                             \\r
-                                               "POP.D  W12                                             \n"                                                                                                                             \\r
-                                               "POP.D  W10                                             \n"                                                                                                                             \\r
-                                               "POP.D  W8                                              \n"                                                                                                                             \\r
-                                               "POP.D  W6                                              \n"                                                                                                                             \\r
-                                               "POP.D  W4                                              \n"                                                                                                                             \\r
-                                               "POP.D  W2                                              \n"                                                                                                                             \\r
-                                               "POP.D  W0                                              \n"                                                                                                                             \\r
-                                               "POP    SR                                                " );\r
-\r
+    #ifdef __HAS_EDS__\r
+               #define portRESTORE_CONTEXT()                                                                                                                   \\r
+                                       asm volatile(   "MOV    _pxCurrentTCB, W0               \n"     /* Restore the stack pointer for the task. */                           \\r
+                                                       "MOV    [W0], W15                               \n"                                                                                                                             \\r
+                                                       "POP    W0                                              \n"     /* Restore the critical nesting counter for the task. */        \\r
+                                                       "MOV    W0, _uxCriticalNesting  \n"                                                                                                                             \\r
+                                                       "POP    DSWPAG                                  \n"                                                                                                                             \\r
+                                                       "POP    DSRPAG                                  \n"                                             \\r
+                                                       "POP    CORCON                                  \n"                                                                                                                             \\r
+                                                       "POP    TBLPAG                                  \n"                                                                                                                             \\r
+                                                       "POP    RCOUNT                                  \n"     /* Restore the registers from the stack. */                                     \\r
+                                                       "POP    W14                                             \n"                                                                                                                             \\r
+                                                       "POP.D  W12                                             \n"                                                                                                                             \\r
+                                                       "POP.D  W10                                             \n"                                                                                                                             \\r
+                                                       "POP.D  W8                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W6                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W4                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W2                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W0                                              \n"                                                                                                                             \\r
+                                                       "POP    SR                                                " );\r
+       #else /* __HAS_EDS__ */\r
+               #define portRESTORE_CONTEXT()                                                                                                                                                                           \\r
+                       asm volatile(   "MOV    _pxCurrentTCB, W0               \n"     /* Restore the stack pointer for the task. */                           \\r
+                                                       "MOV    [W0], W15                               \n"                                                                                                                             \\r
+                                                       "POP    W0                                              \n"     /* Restore the critical nesting counter for the task. */        \\r
+                                                       "MOV    W0, _uxCriticalNesting  \n"                                                                                                                             \\r
+                                                       "POP    PSVPAG                                  \n"                                                                                                                             \\r
+                                                       "POP    CORCON                                  \n"                                                                                                                             \\r
+                                                       "POP    TBLPAG                                  \n"                                                                                                                             \\r
+                                                       "POP    RCOUNT                                  \n"     /* Restore the registers from the stack. */                                     \\r
+                                                       "POP    W14                                             \n"                                                                                                                             \\r
+                                                       "POP.D  W12                                             \n"                                                                                                                             \\r
+                                                       "POP.D  W10                                             \n"                                                                                                                             \\r
+                                                       "POP.D  W8                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W6                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W4                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W2                                              \n"                                                                                                                             \\r
+                                                       "POP.D  W0                                              \n"                                                                                                                             \\r
+                                                       "POP    SR                                                " );\r
+               #endif /* __HAS_EDS__ */\r
 #endif /* MPLAB_PIC24_PORT */\r
 \r
 #ifdef MPLAB_DSPIC_PORT\r
@@ -163,15 +184,15 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
  */\r
 static void prvSetupTimerInterrupt( void );\r
 \r
-/* \r
- * See header file for description. \r
+/*\r
+ * See header file for description.\r
  */\r
 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
 {\r
 unsigned short usCode;\r
 portBASE_TYPE i;\r
 \r
-const portSTACK_TYPE xInitialStack[] = \r
+const portSTACK_TYPE xInitialStack[] =\r
 {\r
        0x1111, /* W1 */\r
        0x2222, /* W2 */\r
@@ -235,8 +256,16 @@ const portSTACK_TYPE xInitialStack[] =
 \r
        *pxTopOfStack = CORCON;\r
        pxTopOfStack++;\r
-       *pxTopOfStack = PSVPAG;\r
-       pxTopOfStack++;\r
+\r
+       #if defined(__HAS_EDS__)\r
+               *pxTopOfStack = DSRPAG;\r
+               pxTopOfStack++;\r
+               *pxTopOfStack = DSWPAG;\r
+               pxTopOfStack++;\r
+       #else /* __HAS_EDS__ */\r
+               *pxTopOfStack = PSVPAG;\r
+               pxTopOfStack++;\r
+       #endif /* __HAS_EDS__ */\r
 \r
        /* Finally the critical nesting depth. */\r
        *pxTopOfStack = 0x00;\r
@@ -249,7 +278,7 @@ const portSTACK_TYPE xInitialStack[] =
 portBASE_TYPE xPortStartScheduler( void )\r
 {\r
        /* Setup a timer for the tick ISR. */\r
-       prvSetupTimerInterrupt(); \r
+       prvSetupTimerInterrupt();\r
 \r
        /* Restore the context of the first task to run. */\r
        portRESTORE_CONTEXT();\r
@@ -265,7 +294,7 @@ portBASE_TYPE xPortStartScheduler( void )
 void vPortEndScheduler( void )\r
 {\r
        /* It is unlikely that the scheduler for the PIC port will get stopped\r
-       once running.  If required disable the tick interrupt here, then return \r
+       once running.  If required disable the tick interrupt here, then return\r
        to xPortStartScheduler(). */\r
 }\r
 /*-----------------------------------------------------------*/\r
index 5fec0222bb3f21ba74997761a92d7371c36b6f2a..84926f1aa5b7e96d8193652bd9a78572079d7297 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
     FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
 \r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT \r
+    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
     ***************************************************************************\r
@@ -42,7 +42,7 @@
     FreeRTOS WEB site.\r
 \r
     1 tab == 4 spaces!\r
-    \r
+\r
     ***************************************************************************\r
      *                                                                       *\r
      *    Having a problem?  Start by reading the FAQ "My application does   *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    \r
-    http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
-    and contact details.  \r
-    \r
+\r
+    http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+    and contact details.\r
+\r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool.\r
 \r
-    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
-    the code with commercial support, indemnification, and middleware, under \r
+    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+    the code with commercial support, indemnification, and middleware, under\r
     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
-    provide a safety engineered and independently SIL3 certified version under \r
+    provide a safety engineered and independently SIL3 certified version under\r
     the SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
 \r
@@ -86,9 +86,14 @@ _vPortYield:
                PUSH    W14\r
                PUSH    RCOUNT\r
                PUSH    TBLPAG\r
-                                                                                                                                                                               \r
+\r
                PUSH    CORCON\r
-               PUSH    PSVPAG\r
+               #ifdef __HAS_EDS__\r
+                       PUSH    DSRPAG\r
+                       PUSH    DSWPAG\r
+               #else\r
+                       PUSH    PSVPAG\r
+               #endif /* __HAS_EDS__ */\r
                MOV             _uxCriticalNesting, W0          /* Save the critical nesting counter for the task. */\r
                PUSH    W0\r
                MOV             _pxCurrentTCB, W0                       /* Save the new top of stack into the TCB. */\r
@@ -100,7 +105,12 @@ _vPortYield:
                MOV             [W0], W15\r
                POP             W0                                                      /* Restore the critical nesting counter for the task. */\r
                MOV             W0, _uxCriticalNesting\r
+#ifdef __HAS_EDS__\r
+        POP     DSWPAG\r
+        POP     DSRPAG\r
+#else\r
                POP             PSVPAG\r
+#endif /* __HAS_EDS__ */\r
                POP             CORCON\r
                POP             TBLPAG\r
                POP             RCOUNT                                          /* Restore the registers from the stack. */\r
index 6f2d3710d39f00135ecb4746584da4e4b9e9f42d..229948de6f1ff31b238cb281ac0fe014413da7ca 100644 (file)
 \r
        mtc0            k0, _CP0_STATUS\r
        mtc0            k1, _CP0_EPC\r
-       ehb\r
        eret \r
        nop\r
 \r
index 9cfb9980c9c91b1b8a3e9066d369a255c3fccf31..c0ab86c748e21469fb8c4e98bab4c7de8009b490 100644 (file)
@@ -1,7 +1,7 @@
 /*\r
     FreeRTOS V7.3.0 - Copyright (C) 2012 Real Time Engineers Ltd.\r
 \r
-    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT \r
+    FEATURES AND PORTS ARE ADDED TO FREERTOS ALL THE TIME.  PLEASE VISIT\r
     http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION.\r
 \r
     ***************************************************************************\r
@@ -42,7 +42,7 @@
     FreeRTOS WEB site.\r
 \r
     1 tab == 4 spaces!\r
-    \r
+\r
     ***************************************************************************\r
      *                                                                       *\r
      *    Having a problem?  Start by reading the FAQ "My application does   *\r
      *                                                                       *\r
     ***************************************************************************\r
 \r
-    \r
-    http://www.FreeRTOS.org - Documentation, training, latest versions, license \r
-    and contact details.  \r
-    \r
+\r
+    http://www.FreeRTOS.org - Documentation, training, latest versions, license\r
+    and contact details.\r
+\r
     http://www.FreeRTOS.org/plus - A selection of FreeRTOS ecosystem products,\r
     including FreeRTOS+Trace - an indispensable productivity tool.\r
 \r
-    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell \r
-    the code with commercial support, indemnification, and middleware, under \r
+    Real Time Engineers ltd license FreeRTOS to High Integrity Systems, who sell\r
+    the code with commercial support, indemnification, and middleware, under\r
     the OpenRTOS brand: http://www.OpenRTOS.com.  High Integrity Systems also\r
-    provide a safety engineered and independently SIL3 certified version under \r
+    provide a safety engineered and independently SIL3 certified version under\r
     the SafeRTOS brand: http://www.SafeRTOS.com.\r
 */\r
\r
+\r
 #include <p32xxxx.h>\r
 #include <sys/asm.h>\r
 #include "ISR_Support.h"\r
\r
+\r
 \r
        .set    nomips16\r
        .set    noreorder\r
-       \r
+\r
        .extern pxCurrentTCB\r
        .extern vTaskSwitchContext\r
        .extern vPortIncrementTick\r
        .extern xISRStackTop\r
-       \r
+\r
        .global vPortStartFirstTask\r
        .global vPortYieldISR\r
        .global vPortTickInterruptHandler\r
@@ -89,7 +89,7 @@
        .set            noreorder\r
        .set            noat\r
        .ent            vPortTickInterruptHandler\r
-       \r
+\r
 vPortTickInterruptHandler:\r
 \r
        portSAVE_CONTEXT\r
@@ -125,8 +125,8 @@ vPortStartFirstTask:
 \r
 vPortYieldISR:\r
 \r
-       /* Make room for the context. First save the current status so we can \r
-       manipulate it, and the cause and EPC registers so we capture their \r
+       /* Make room for the context. First save the current status so we can\r
+       manipulate it, and the cause and EPC registers so we capture their\r
        original values in case of interrupt nesting. */\r
        mfc0            k0, _CP0_CAUSE\r
        addiu           sp,     sp, -portCONTEXT_SIZE\r
@@ -216,14 +216,13 @@ vPortYieldISR:
        ins             s7, $0, 10, 6\r
        ori                     s6, s7, ( configMAX_SYSCALL_INTERRUPT_PRIORITY << 10 ) | 1\r
 \r
-       /* This mtc0 re-enables interrupts, but only above \r
+       /* This mtc0 re-enables interrupts, but only above\r
        configMAX_SYSCALL_INTERRUPT_PRIORITY. */\r
        mtc0            s6, _CP0_STATUS\r
 \r
        /* Clear the software interrupt in the core. */\r
        mfc0            s6, _CP0_CAUSE\r
-       addiu       s4,zero,-257\r
-       and                     s6, s6, s4\r
+       ins                     s6, zero, 8, 1\r
        mtc0            s6, _CP0_CAUSE\r
 \r
        /* Clear the interrupt in the interrupt controller. */\r
@@ -296,10 +295,9 @@ vPortYieldISR:
        /* Remove stack frame. */\r
        addiu           sp,     sp,     portCONTEXT_SIZE\r
 \r
-       mtc0            k1, _CP0_STATUS \r
+       mtc0            k1, _CP0_STATUS\r
        mtc0            k0, _CP0_EPC\r
-       ehb\r
-       eret \r
+       eret\r
        nop\r
 \r
        .end            vPortYieldISR\r