]> git.sur5r.net Git - freertos/blobdiff - Source/portable/GCC/RX600/port.c
Update RX GCC port - including extracting all inline asm into separate asm file.
[freertos] / Source / portable / GCC / RX600 / port.c
index 37e6243460219d381cd7c85a0303f417b325a893..c5d4b69b4539a69b7ff2527bff5f76706020d0bc 100644 (file)
@@ -78,7 +78,7 @@ PSW is set with U and I set, and PM and IPL clear. */
  * Function to start the first task executing - written in asm code as direct\r
  * access to registers is required. \r
  */\r
-static void prvStartFirstTask( void ) __attribute__((naked));\r
+extern void prvStartFirstTask( void );\r
 \r
 /*\r
  * Software interrupt handler.  Performs the actual context switch (saving and\r
@@ -88,19 +88,14 @@ static void prvStartFirstTask( void ) __attribute__((naked));
 static void prvYieldHandler( void );\r
 \r
 /*\r
- * The entry point for the software interrupt handler.  This is the function\r
- * that calls the inline asm function prvYieldHandler().  It is installed in \r
- * the vector table, but the code that installs it is in prvYieldHandler rather\r
- * than using a #pragma.\r
+ * The tick ISR handler.  The peripheral used is configured by the application\r
+ * via a hook/callback function.\r
  */\r
-void vSoftwareInterruptISR( void );\r
+void vTickISR( void ) __attribute__((interrupt));\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
-/* This is accessed by the inline assembler functions so is file scope for\r
-convenience. */\r
 extern void *pxCurrentTCB;\r
-extern void vTaskSwitchContext( void );\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
@@ -190,65 +185,24 @@ extern void vApplicationSetupTimerInterrupt( void );
                \r
                /* Ensure the software interrupt is set to the kernel priority. */\r
                _IPR( _ICU_SWINT ) = configKERNEL_INTERRUPT_PRIORITY;\r
-       \r
+\r
                /* Start the first task. */\r
                prvStartFirstTask();\r
        }\r
 \r
-       /* Just to make sure the function is not optimised away. */\r
-       ( void ) vSoftwareInterruptISR();\r
-\r
        /* Should not get here. */\r
        return pdFAIL;\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-static void prvStartFirstTask( void )\r
-{\r
-       __asm\r
-       (       \r
-               /* When starting the scheduler there is nothing that needs moving to the\r
-               interrupt stack because the function is not called from an interrupt.\r
-               Just ensure the current stack is the user stack. */\r
-               "SETPSW U                                               \n" \\r
-\r
-               /* Obtain the location of the stack associated with which ever task \r
-               pxCurrentTCB is currently pointing to. */\r
-               "MOV.L  #_pxCurrentTCB, R15             \n" \\r
-               "MOV.L  [R15], R15                              \n" \\r
-               "MOV.L  [R15], R0                               \n" \\r
-\r
-               /* Restore the registers from the stack of the task pointed to by \r
-               pxCurrentTCB. */\r
-           "POP                R15                                     \n" \\r
-               \r
-               /* Accumulator low 32 bits. */\r
-           "MVTACLO    R15                             \n" \\r
-           "POP                R15                                     \n" \\r
-               \r
-               /* Accumulator high 32 bits. */\r
-           "MVTACHI    R15                             \n" \\r
-           "POP                R15                                     \n" \\r
-               \r
-               /* Floating point status word. */\r
-           "MVTC               R15, FPSW                       \n" \\r
-               \r
-               /* R1 to R15 - R0 is not included as it is the SP. */\r
-           "POPM               R1-R15                          \n" \\r
-               \r
-               /* This pops the remaining registers. */\r
-           "RTE                                                        \n" \\r
-           "NOP                                                        \n" \\r
-           "NOP                                                        \n"\r
-       );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 void vTickISR( void )\r
 {\r
+       /* Re-enable interrupts. */\r
+       __asm volatile( "SETPSW         I" );\r
+       \r
        /* Increment the tick, and perform any processing the new tick value\r
        necessitates. */\r
-       vTaskIncrementTick();\r
+       vTaskIncrementTick(); \r
        \r
        /* Only select a new task if the preemptive scheduler is being used. */\r
        #if( configUSE_PREEMPTION == 1 )\r
@@ -257,124 +211,9 @@ void vTickISR( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-void vSoftwareInterruptISR( void )\r
-{\r
-//     prvYieldHandler();\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-#if 0\r
-#pragma inline_asm prvYieldHandler\r
-static void prvYieldHandler( void )\r
-{\r
-       /* Install as the software interrupt handler. */\r
-       .RVECTOR    _VECT( _ICU_SWINT ), _vSoftwareInterruptISR\r
-\r
-       /* Re-enable interrupts. */\r
-       SETPSW  I\r
-\r
-       /* Move the data that was automatically pushed onto the interrupt stack when\r
-       the interrupt occurred from the interrupt stack to the user stack.  \r
-       \r
-       R15 is saved before it is clobbered. */\r
-       PUSH.L  R15\r
-       \r
-       /* Read the user stack pointer. */\r
-       MVFC    USP, R15\r
-       \r
-       /* Move the address down to the data being moved. */\r
-       SUB             #12, R15\r
-       MVTC    R15, USP\r
-       \r
-       /* Copy the data across. */\r
-       MOV.L   [ R0 ], [ R15 ] ; R15\r
-       MOV.L   4[ R0 ], 4[ R15 ]  ; PC\r
-       MOV.L   8[ R0 ], 8[ R15 ]  ; PSW\r
-\r
-       /* Move the interrupt stack pointer to its new correct position. */\r
-       ADD     #12, R0\r
-       \r
-       /* All the rest of the registers are saved directly to the user stack. */\r
-       SETPSW  U\r
-\r
-       /* Save the rest of the general registers (R15 has been saved already). */\r
-       PUSHM   R1-R14\r
-       \r
-       /* Save the FPSW and accumulator. */\r
-       MVFC    FPSW, R15\r
-       PUSH.L  R15\r
-       MVFACHI R15\r
-       PUSH.L  R15\r
-       MVFACMI R15     ; Middle order word.\r
-       SHLL    #16, R15 ; Shifted left as it is restored to the low order word.\r
-       PUSH.L  R15\r
-\r
-       /* Save the stack pointer to the TCB. */\r
-       MOV.L   #_pxCurrentTCB, R15\r
-       MOV.L   [ R15 ], R15\r
-       MOV.L   R0, [ R15 ]\r
-                       \r
-       /* Ensure the interrupt mask is set to the syscall priority while the kernel\r
-       structures are being accessed. */\r
-       MVTIPL  #configMAX_SYSCALL_INTERRUPT_PRIORITY\r
-\r
-       /* Select the next task to run. */\r
-       BSR.A   _vTaskSwitchContext\r
-\r
-       /* Reset the interrupt mask as no more data structure access is required. */\r
-       MVTIPL  #configKERNEL_INTERRUPT_PRIORITY\r
-\r
-       /* Load the stack pointer of the task that is now selected as the Running\r
-       state task from its TCB. */\r
-       MOV.L   #_pxCurrentTCB,R15\r
-       MOV.L   [ R15 ], R15\r
-       MOV.L   [ R15 ], R0\r
-\r
-       /* Restore the context of the new task.  The PSW (Program Status Word) and\r
-       PC will be popped by the RTE instruction. */\r
-       POP             R15\r
-       MVTACLO R15\r
-       POP             R15\r
-       MVTACHI R15\r
-       POP             R15\r
-       MVTC    R15,FPSW\r
-       POPM    R1-R15\r
-       RTE\r
-       NOP\r
-       NOP\r
-}\r
-#endif\r
-/*-----------------------------------------------------------*/\r
-\r
 void vPortEndScheduler( void )\r
 {\r
        /* Not implemented as there is nothing to return to. */\r
-       \r
-       /* The following line is just to prevent the symbol getting optimised away. */\r
-       ( void ) vTaskSwitchContext();\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-unsigned long ulPortGetIPL( void )\r
-{\r
-       __asm( \r
-                       "MVFC   PSW, R1                 \n"     \\r
-                       "SHLR   #28, R1                 \n"     \\r
-                       "RTS                                      "\r
-                );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vPortSetIPL( unsigned long ulNewIPL )\r
-{\r
-       __asm( \r
-                       "MVFC   PSW, R5                 \n"     \\r
-                       "SHLL   #28, R1                 \n" \\r
-                       "AND    #-0F000001H, R5 \n" \\r
-                       "OR             R1, R5                  \n" \\r
-                       "MVTC   R5, PSW                 \n" \\r
-                       "RTS                                      "\r
-                );\r
 }\r
 /*-----------------------------------------------------------*/\r
 \r