]> git.sur5r.net Git - freertos/commitdiff
A little optimisation.
authorRichardBarry <RichardBarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 23 May 2008 15:16:25 +0000 (15:16 +0000)
committerRichardBarry <RichardBarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Fri, 23 May 2008 15:16:25 +0000 (15:16 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@377 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/MPLAB/PIC32MX/port.c
Source/portable/MPLAB/PIC32MX/port_asm.S
Source/portable/MPLAB/PIC32MX/portmacro.h

index e170709b557d5e40832e1a38d46d5d8a5b593eb7..85dbda615eee662f6f426f16d9585065d21cc61b 100644 (file)
@@ -167,19 +167,6 @@ extern void *pxCurrentTCB;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vPortYield( void )\r
-{\r
-unsigned portLONG ulStatus;\r
-\r
-       SetCoreSW0();\r
-\r
-       /* Unmask all interrupts. */\r
-       ulStatus = _CP0_GET_STATUS();\r
-       ulStatus &= ~portALL_IPL_BITS;\r
-       _CP0_SET_STATUS( ulStatus );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 void vPortIncrementTick( void )\r
 {\r
 unsigned portBASE_TYPE uxSavedStatus;\r
index 0a02935d523c798df1b66822d781daa791dd41d2..4acaae90672fae543fcbde768440440df3a5a1c4 100644 (file)
@@ -51,7 +51,6 @@
 #include <sys/asm.h>\r
 #include "ISR_Support.h"\r
  \r
-#define portEXC_CODE_MASK ( 0x1f << 2 )\r
 \r
        .set    nomips16\r
        .set    noreorder\r
@@ -138,10 +137,9 @@ vPortYieldISR:
        la                      sp, xISRStackTop\r
        lw                      sp, (sp)\r
 \r
-       /* Increment and save the nesting count in case this gets preempted. */\r
+       /* Set the nesting count. */\r
        la                      k0, uxInterruptNesting\r
-       lw                      s6, (k0)\r
-       addiu           s6, s6, 1\r
+       addiu           s6, zero, 1\r
        sw                      s6, 0(k0)\r
 \r
        /* s6 holds the EPC value, this is saved with the rest of the context\r
@@ -261,11 +259,10 @@ vPortYieldISR:
        /* Protect access to the k registers, and others. */\r
        di\r
 \r
-       /* Decrement the nesting count. */\r
+       /* Set nesting back to zero.  As the lowest priority interrupt this\r
+       interrupt cannot have nested. */\r
        la                      k0, uxInterruptNesting\r
-       lw                      k1, (k0)\r
-       addiu           k1, k1, -1\r
-       sw                      k1, 0(k0)\r
+       sw                      zero, 0(k0)\r
 \r
        /* Switch back to use the real stack pointer. */\r
        add                     sp, zero, s5\r
@@ -273,8 +270,7 @@ vPortYieldISR:
        /* Restore the real s5 value. */\r
        lw                      s5, 40(sp)\r
 \r
-       /* If the critical nesting is not zero and a yield is not pended\r
-       then set status as if within a critical section. */\r
+       /* Pop the status and epc values. */\r
        lw                      k1, portSTATUS_STACK_LOCATION(sp)\r
        lw                      k0, portEPC_STACK_LOCATION(sp)\r
 \r
index cb5911b3f63418afaff24f3572adcce4503a2b9c..a04cad68dcb66939e64e4768254e771a047cdddf 100644 (file)
@@ -94,6 +94,7 @@ extern "C" {
 /* Critical section management. */\r
 #define portIPL_SHIFT                          ( 10 )\r
 #define portALL_IPL_BITS                       ( 0x3f << portIPL_SHIFT )\r
+#define portSW0_BIT                                    ( 0x01 << 8 )\r
 \r
 #define portDISABLE_INTERRUPTS()                                                                                       \\r
 {                                                                                                                                                      \\r
@@ -130,10 +131,19 @@ extern void vPortClearInterruptMaskFromISR( unsigned portBASE_TYPE );
 /*-----------------------------------------------------------*/\r
 \r
 /* Task utilities. */\r
-extern void vPortYield( void );\r
-#define portYIELD()    vPortYield()\r
 \r
-#define portNOP()                              asm volatile (  "nop" )\r
+#define portYIELD()                                                            \\r
+{                                                                                              \\r
+unsigned portLONG ulStatus;                                            \\r
+                                                                                               \\r
+       /* Unmask all interrupts. */                            \\r
+       ulStatus = _CP0_GET_CAUSE();                            \\r
+       ulStatus |= portSW0_BIT;                                        \\r
+       _CP0_SET_CAUSE( ulStatus );                                     \\r
+}\r
+\r
+\r
+#define portNOP()      asm volatile (  "nop" )\r
 \r
 /*-----------------------------------------------------------*/\r
 \r