]> git.sur5r.net Git - freertos/blobdiff - Source/portable/Renesas/SH2A_FPU/portasm.src
Still a work in progress. Need to add flop support.
[freertos] / Source / portable / Renesas / SH2A_FPU / portasm.src
index 30f80e6cb885474ad48ac2bdfb1d1843fe0fa587..5ab645a9b67520c10892d0ddd8757a8bc8b74f1e 100644 (file)
@@ -1,5 +1,5 @@
 ;/*\r
-;    FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.\r
+;    FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
 ;\r
 ;    ***************************************************************************\r
 ;    *                                                                         *\r
 \r
        .import _pxCurrentTCB\r
        .import _vTaskSwitchContext\r
+       .import _vTaskIncrementTick\r
 \r
        .export _vPortStartFirstTask\r
        .export _ulPortGetGBR\r
        .export _vPortYield\r
+       .export _vPortPreemptiveTick\r
+       .export _vPortCooperativeTick\r
 \r
     .section    P\r
-       \r
-_vPortStartFirstTask:\r
-               \r
-       ; Get the address of the pxCurrentTCB variable.\r
-       mov.l   #_pxCurrentTCB, r15\r
 \r
-       ; Get the address of the task stack from pxCurrentTCB.\r
-       mov.l   @r15, r15\r
-\r
-       ; Get the task stack itself into the stack pointer. \r
-       mov.l   @r15, r15               \r
+       .macro portSAVE_CONTEXT\r
 \r
-       ; Restore r0 to PR (PR is used in place of r15).\r
-       movml.l @r15+, r15\r
+       ; Save r0 to r14 and pr.\r
+       movml.l r15, @-r15\r
        \r
-       ; Restore system registers.\r
-       ldc.l   @r15+, gbr\r
-       lds.l   @r15+, mach\r
-       lds.l   @r15+, macl\r
-       \r
-       ; Pop the SR and PC to jump to the start of the task.\r
-       rte\r
-       nop\r
-\r
-_vPortYield:\r
-\r
-       ; Save registers in the same order used by the CPU itself.\r
+       ; Save mac1, mach and gbr\r
        sts.l   macl, @-r15\r
        sts.l   mach, @-r15\r
        stc.l   gbr, @-r15\r
-       movml.l r15, @-r15\r
        \r
        ; Get the address of pxCurrentTCB\r
        mov.l   #_pxCurrentTCB, r0\r
@@ -100,31 +82,93 @@ _vPortYield:
        ; Save the stack pointer in pxTopOfStack.\r
        mov.l   r15, @r0\r
 \r
-       mov.l   #_vTaskSwitchContext, r0\r
-       jsr             @r0\r
-       nop\r
+       .endm\r
+\r
+;-----------------------------------------------------------\r
+\r
+       .macro portRESTORE_CONTEXT\r
 \r
        ; Get the address of the pxCurrentTCB variable.\r
-       mov.l   #_pxCurrentTCB, r15\r
+       mov.l   #_pxCurrentTCB, r0\r
 \r
        ; Get the address of the task stack from pxCurrentTCB.\r
-       mov.l   @r15, r15\r
+       mov.l   @r0, r0\r
 \r
        ; Get the task stack itself into the stack pointer. \r
-       mov.l   @r15, r15               \r
+       mov.l   @r0, r15                \r
 \r
-       ; Restore r0 to PR (PR is used in place of r15).\r
-       movml.l @r15+, r15\r
-       \r
        ; Restore system registers.\r
        ldc.l   @r15+, gbr\r
        lds.l   @r15+, mach\r
        lds.l   @r15+, macl\r
+\r
+       ; Restore r0 to r14 and PR\r
+       movml.l @r15+, r15\r
        \r
        ; Pop the SR and PC to jump to the start of the task.\r
        rte\r
        nop\r
 \r
+       .endm\r
+;-----------------------------------------------------------\r
+       \r
+_vPortStartFirstTask:\r
+               \r
+       portRESTORE_CONTEXT\r
+       \r
+;-----------------------------------------------------------\r
+\r
+_vPortYield:\r
+\r
+       ; Push r0 so it can be used.\r
+       mov.l   r0, @-r15\r
+       \r
+       ; Set the interrupt mask in the status register.\r
+       stc             sr, r0\r
+       or              #240,r0\r
+       ldc             r0, sr\r
+       \r
+       ; Restore r0 so its original value can be saved by the movml.l instruction \r
+       ; below, without ending up with two copies on the stack.\r
+       mov.l   @r15+, r0\r
+\r
+       portSAVE_CONTEXT\r
+\r
+       mov.l   #_vTaskSwitchContext, r0\r
+       jsr             @r0\r
+       nop\r
+\r
+       portRESTORE_CONTEXT\r
+       \r
+;-----------------------------------------------------------\r
+\r
+_vPortPreemptiveTick\r
+\r
+       portSAVE_CONTEXT\r
+       \r
+       mov.l   #_vTaskIncrementTick, r0\r
+       jsr             @r0\r
+       nop\r
+\r
+       mov.l   #_vTaskSwitchContext, r0\r
+       jsr             @r0\r
+       nop\r
+\r
+       portRESTORE_CONTEXT\r
+       \r
+;-----------------------------------------------------------\r
+\r
+_vPortCooperativeTick\r
+\r
+       portSAVE_CONTEXT\r
+       \r
+       mov.l   #_vTaskIncrementTick, r0\r
+       jsr             @r0\r
+       nop\r
+\r
+       portRESTORE_CONTEXT\r
+       \r
+;-----------------------------------------------------------\r
 \r
 _ulPortGetGBR:\r
 \r