]> git.sur5r.net Git - freertos/commitdiff
Add Fujitsu 16bit port files.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 12 Feb 2008 09:29:26 +0000 (09:29 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 12 Feb 2008 09:29:26 +0000 (09:29 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@165 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/Softune/MB96340/__STD_LIB_sbrk.c [new file with mode: 0644]
Source/portable/Softune/MB96340/port.c [new file with mode: 0644]
Source/portable/Softune/MB96340/portmacro.h [new file with mode: 0644]

diff --git a/Source/portable/Softune/MB96340/__STD_LIB_sbrk.c b/Source/portable/Softune/MB96340/__STD_LIB_sbrk.c
new file mode 100644 (file)
index 0000000..3e8f577
--- /dev/null
@@ -0,0 +1,33 @@
+/* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */\r
+/* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */\r
+/* ELIGIBILITY FOR ANY PURPOSES.                                             */\r
+/*                 (C) Fujitsu Microelectronics Europe GmbH                  */\r
+/*---------------------------------------------------------------------------\r
+  __STD_LIB_sbrk.C\r
+  - Used by heap_3.c for memory accocation and deletion.\r
+\r
+/*---------------------------------------------------------------------------*/\r
+\r
+#include "FreeRTOSConfig.h"\r
+#include <stdlib.h>\r
+\r
+       static  long         brk_siz  =  0;\r
+//     #if  configTOTAL_HEAP_SIZE != 0\r
+       typedef int          _heep_t;\r
+       #define ROUNDUP(s)   (((s)+sizeof(_heep_t)-1)&~(sizeof(_heep_t)-1))\r
+       static  _heep_t      _heep[ROUNDUP(configTOTAL_HEAP_SIZE)/sizeof(_heep_t)];\r
+       #define              _heep_size      ROUNDUP(configTOTAL_HEAP_SIZE)\r
+/*     #else\r
+       extern  char        *_heep;\r
+       extern  long        _heep_size;\r
+       #endif\r
+*/     \r
+       extern  char  *sbrk(int  size)\r
+       {\r
+          if  (brk_siz  +  size  >  _heep_size  ||  brk_siz  +  size  <  0)\r
+\r
+          return((char*)-1);\r
+          brk_siz  +=  size;\r
+          return(  (char*)_heep  +  brk_siz  -  size);\r
+       }\r
+\r
diff --git a/Source/portable/Softune/MB96340/port.c b/Source/portable/Softune/MB96340/port.c
new file mode 100644 (file)
index 0000000..b7bbe3f
--- /dev/null
@@ -0,0 +1,537 @@
+/*\r
+       FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+       This file is part of the FreeRTOS.org distribution.\r
+\r
+       FreeRTOS.org is free software; you can redistribute it and/or modify\r
+       it under the terms of the GNU General Public License as published by\r
+       the Free Software Foundation; either version 2 of the License, or\r
+       (at your option) any later version.\r
+\r
+       FreeRTOS.org is distributed in the hope that it will be useful,\r
+       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+       GNU General Public License for more details.\r
+\r
+       You should have received a copy of the GNU General Public License\r
+       along with FreeRTOS.org; if not, write to the Free Software\r
+       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+       A special exception to the GPL can be applied should you wish to distribute\r
+       a combined work that includes FreeRTOS.org, without being obliged to provide\r
+       the source code for any proprietary components.  See the licensing section\r
+       of http://www.FreeRTOS.org for full details of how and when the exception\r
+       can be applied.\r
+\r
+       ***************************************************************************\r
+\r
+       Please ensure to read the configuration and relevant port sections of the \r
+       online documentation.\r
+\r
+       +++ http://www.FreeRTOS.org +++\r
+       Documentation, latest information, license and contact details.  \r
+\r
+       +++ http://www.SafeRTOS.com +++\r
+       A version that is certified for use in safety critical systems.\r
+\r
+       +++ http://www.OpenRTOS.com +++\r
+       Commercial support, development, porting, licensing and training services.\r
+\r
+       ***************************************************************************\r
+*/\r
+\r
+#include "FreeRTOS.h"\r
+#include "task.h"\r
+#include "mb96348hs.h"\r
+\r
+/*-----------------------------------------------------------\r
+ * Implementation of functions defined in portable.h for the 16FX port.\r
+ *----------------------------------------------------------*/\r
+\r
+/* ------- Memory models ---------      default address size */\r
+                                 /*     data      code       */\r
+#define SMALL     0              /*    16 Bit    16 Bit      */\r
+#define MEDIUM    1              /*    16 Bit    24 Bit      */\r
+#define COMPACT   2              /*    24 Bit    16 Bit      */\r
+#define LARGE     3              /*    24 Bit    24 Bit      */\r
+\r
+/* \r
+ * The below define should be same as the option selected by the Memory \r
+ * Model (Project->Setup Project->C Compiler->Catagory->Target Depend ) \r
+ */\r
+#define MEMMODEL MEDIUM\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* \r
+ * We require the address of the pxCurrentTCB variable, but don't want to know\r
+ * any details of its type. \r
+ */\r
+typedef void tskTCB;\r
+extern volatile tskTCB * volatile pxCurrentTCB;\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Get current value of DPR and ADB registers */\r
+portSTACK_TYPE Get_DPR_ADB_bank(void); \r
+\r
+/* Get current value of DTB and PCB registers */\r
+portSTACK_TYPE Get_DTB_PCB_bank(void);\r
+\r
+/* Get current register pointer */ \r
+portCHAR          Get_RP(void);           \r
+\r
+/*-----------------------------------------------------------*/                \r
+\r
+/* \r
+ * Macro to save a task context to the task stack. This macro  copies the \r
+ * saved context (AH:AL, DPR:ADB, DTB:PCB , PC and PS) from  the   system \r
+ * stack to task stack pointed by user stack pointer ( USP  for SMALL and \r
+ * MEDIUM memory model amd USB:USP for COMPACT  and LARGE memory model ),\r
+ * then  it pushes the general purpose registers RW0-RW7  on  to the task \r
+ * stack. Finally the  resultant  stack  pointer  value is saved into the \r
+ * task  control  block  so  it  can  be retrieved the next time the task \r
+ * executes.\r
+ */\r
\r
+#if (MEMMODEL == SMALL || MEMMODEL == MEDIUM)                          \r
+#define portSAVE_CONTEXT()                                                                                     \\r
+           {   __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+               __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
+                       __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
+                       __asm(" MOVW A, SP ");                                                                  \\r
+                       __asm(" SWAPW ");                                                                               \\r
+                   __asm(" MOVW @AL, AH ");                                                            \\r
+                   __asm(" OR   CCR,#H'20 ");                                                          \\r
+               }\r
+\r
+/* \r
+ * Macro to restore a task context from the task stack.  This is effecti-\r
+ * vely the reverse of portSAVE_CONTEXT(). First the stack pointer  value\r
+ * (USP for SMALL and MEDIUM memory model amd  USB:USP  for  COMPACT  and \r
+ * LARGE memory model ) is loaded from the task  control block.  Next the \r
+ * value of all the general purpose registers RW0-RW7 is retrieved. Fina-\r
+ * lly it copies of the context ( AH:AL,  DPR:ADB, DTB:PCB, PC and PS) of \r
+ * the task to be executed upon RETI from user stack to system stack.  \r
+ */\r
\r
+#define portRESTORE_CONTEXT()                                                                          \\r
+               {       __asm(" MOVW A, _pxCurrentTCB ");                                               \\r
+                       __asm(" MOVW A, @A ");                                                                  \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" MOVW SP, A ");                                                                  \\r
+                       __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+               }\r
+               \r
+#elif (MEMMODEL == COMPACT || MEMMODEL == LARGE)                       \r
+#define portSAVE_CONTEXT()                                                                                     \\r
+           {   __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+               __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                   __asm(" AND  CCR,#H'DF ");                                                          \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" PUSHW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");             \\r
+                       __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
+                       __asm(" MOVL RL2, A ");                                                                 \\r
+                       __asm(" MOVW A, SP ");                                                                  \\r
+                   __asm(" MOVW @RL2+0, A ");                                                          \\r
+            __asm(" MOV A, USB ");                                                                     \\r
+            __asm(" MOV @RL2+2, A ");                                                          \\r
+               }       \r
+            \r
+#define portRESTORE_CONTEXT()                                                                          \\r
+               {       __asm(" MOVL A, _pxCurrentTCB ");                                               \\r
+                       __asm(" MOVL RL2, A ");                                                                 \\r
+                       __asm(" MOVW A, @RL2+0 ");                                                              \\r
+            __asm(" AND  CCR,#H'DF ");                                                         \\r
+            __asm(" MOVW SP, A ");                                                                     \\r
+            __asm(" MOV A, @RL2+2 ");                                                          \\r
+                       __asm(" MOV USB, A ");                                                                  \\r
+                       __asm(" POPW (RW0,RW1,RW2,RW3,RW4,RW5,RW6,RW7) ");              \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+                       __asm(" AND  CCR,#H'DF ");                                                      \\r
+                       __asm(" POPW  A ");                                                                             \\r
+                       __asm(" OR   CCR,#H'20 ");                                                              \\r
+                       __asm(" PUSHW  A ");                                                                    \\r
+               }\r
+#endif\r
+\r
+/*-----------------------------------------------------------*/        \r
+\r
+/* \r
+ * The below are the functions for getting the current value  of  DPR:ADB, \r
+ * DTB:PCB bank registers\r
+ */\r
\r
+#pragma asm\r
+        .GLOBAL    _Get_DPR_ADB_bank\r
+        .GLOBAL    _Get_DTB_PCB_bank\r
+        .GLOBAL    _Get_RP\r
+        .SECTION   CODE, CODE, ALIGN=1\r
+_Get_DPR_ADB_bank:\r
+    MOV A, DPR\r
+    SWAP\r
+    MOV A, ADB\r
+    ORW A\r
+#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
+    RETP\r
+#elif MEMMODEL == SMALL || MEMMODEL == COMPACT   \r
+    RET\r
+#endif \r
+\r
+_Get_DTB_PCB_bank:\r
+    MOV A, DTB\r
+    SWAP\r
+    MOV A, PCB\r
+    ORW A\r
+#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
+    RETP\r
+#elif MEMMODEL == SMALL || MEMMODEL == COMPACT   \r
+    RET\r
+#endif \r
+\r
+_Get_RP:\r
+    PUSHW PS\r
+    POPW  A\r
+    SWAP\r
+    ANDW  A,#0x1f\r
+ #if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
+    RETP\r
+#elif MEMMODEL == SMALL || MEMMODEL == COMPACT   \r
+    RET\r
+#endif \r
+#pragma endasm\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Sets up the periodic ISR used for the RTOS tick.  This uses RLT0, but\r
+ * can be done using any given RLT.\r
+ */\r
+static void prvSetupRLT0Interrupt( void );\r
+/*-----------------------------------------------------------*/\r
+\r
+/* \r
+ * Initialise the stack of a task to look exactly as if a call to \r
+ * portSAVE_CONTEXT had been called.\r
+ * \r
+ * See the header file portable.h.\r
+ */\r
+portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
+{\r
+       /* Place a few bytes of known values on the bottom of the stack. \r
+       This is just useful for debugging. */\r
+\r
+       *pxTopOfStack = 0x1111;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = 0x2222;\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = 0x3333;\r
+       pxTopOfStack--;\r
+\r
+       /* Once the task is called the called  would  push  the  pointer to the\r
+       parameter on to the stack. Hence here the pointer would be copied first\r
+       to  the  stack.  In  case of COMPACT or LARGE memory model such pointer \r
+       would be 24 bit and in  case of SMALL or MEDIUM memory model such pointer \r
+       would be 16 bit */ \r
+#if MEMMODEL == COMPACT || MEMMODEL == LARGE\r
+    *pxTopOfStack = (portSTACK_TYPE)((portLONG)(pvParameters)>>16);\r
+       pxTopOfStack--;         \r
+#endif\r
+\r
+    *pxTopOfStack = (portSTACK_TYPE)(pvParameters);\r
+    pxTopOfStack--;                  \r
+    \r
+    /* This is redundant push to the stack. This is required in order to introduce \r
+    an offset so that the task accesses a parameter correctly that is passed on to \r
+    the task stack. */\r
+#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
+    *pxTopOfStack = (Get_DTB_PCB_bank() & 0xff00) |\r
+           (((portLONG)(pxCode) >>16) & 0xff);      \r
+    pxTopOfStack--;       \r
+#endif\r
+\r
+    /* This is redundant push to the stack. This is required in order to introduce \r
+    an offset so that the task accesses a parameter correctly that is passed on to \r
+    the task stack. */\r
+    *pxTopOfStack = ( portSTACK_TYPE )(pxCode);\r
+    pxTopOfStack--;       \r
+\r
+    /* PS - User Mode, ILM=7, RB=0, Interrupts enabled,USP */\r
+    *pxTopOfStack = 0xE0C0;                                                    \r
+       pxTopOfStack--; \r
+\r
+       /* PC                                                                                              */\r
+       *pxTopOfStack = ( portSTACK_TYPE )(pxCode);     \r
+    pxTopOfStack--;      \r
+    \r
+    /* DTB | PCB                                                                                  */\r
+#if MEMMODEL == SMALL || MEMMODEL == COMPACT\r
+    *pxTopOfStack = Get_DTB_PCB_bank();                \r
+    pxTopOfStack--;\r
+#endif\r
+\r
+       /* DTB | PCB, in case of MEDIUM or LARGE memory model PCB would be used\r
+       along with PC to indicate the start address of the functiom */\r
+#if MEMMODEL == MEDIUM || MEMMODEL == LARGE\r
+    *pxTopOfStack = (Get_DTB_PCB_bank() & 0xff00) |\r
+           (((portLONG)(pxCode) >>16) & 0xff);      \r
+    pxTopOfStack--;       \r
+#endif\r
+\r
+       /* DPR | ADB                                                                              */\r
+       *pxTopOfStack = Get_DPR_ADB_bank();                             \r
+       pxTopOfStack--;\r
+    \r
+       /* AL                                                                                             */\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x9999;              \r
+       pxTopOfStack--;\r
+\r
+       /* AH                                                                                             */\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0xAAAA;              \r
+       pxTopOfStack--;\r
+       \r
+       /* Next the general purpose registers.                            */\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x7777;      /* RW7 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x6666;      /* RW6 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;      /* RW5 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x4444;      /* RW4 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x3333;      /* RW3 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x2222;      /* RW2 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x1111;      /* RW1 */\r
+       pxTopOfStack--;\r
+       *pxTopOfStack = ( portSTACK_TYPE ) 0x8888;      /* RW0 */\r
+               \r
+       return pxTopOfStack;\r
+}\r
+/*-----------------------------------------------------------*/\r
+/*\r
+ * Setup RLT0 to generate a tick interrupt.\r
+ */\r
+static void prvSetupRLT0Interrupt( void )\r
+{\r
+       /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
+       TMRLR0 = 0x88B7;    \r
+    \r
+    /* prescaler 1:16, reload, interrupt enable, count enable, trigger */\r
+    TMCSR0 = 0x041B;    \r
+}\r
+/*-----------------------------------------------------------*/\r
+/*\r
+ * Start the scheduler.\r
+ */\r
+portBASE_TYPE xPortStartScheduler( void )\r
+{\r
+       /* Setup the hardware to generate the tick. */\r
+       prvSetupRLT0Interrupt();\r
+       \r
+       /* Restore the context of the first task that is going to run. */\r
+       portRESTORE_CONTEXT();\r
+\r
+       /* Simulate a function call end as generated by the compiler.  We will now\r
+       jump to the start of the task the context of which we have just restored. */\r
+       \r
+       __asm(" reti ");\r
+\r
+\r
+       /* Should not get here. */\r
+       return pdTRUE;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEndScheduler( void )\r
+{\r
+       /* It is unlikely that the AVR port will get stopped.  If required simply\r
+       disable the tick interrupt here. */\r
+}\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* \r
+ * The interrupt service routine used depends on whether the pre-emptive\r
+ * scheduler is being used or not.\r
+ */\r
+\r
+#if configUSE_PREEMPTION == 1\r
+\r
+       /* \r
+        * Tick ISR for preemptive scheduler.  We can use a __nosavereg attribute\r
+        * as the context would be saved by PortSAVE_CONTEXT().  The tick count \r
+        * is incremented after the context is saved. \r
+        */\r
+       __nosavereg __interrupt void prvRLT0_TICKISR( void )\r
+       {\r
+               /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */\r
+               __DI();\r
+               \r
+               /* Save the context of the interrupted task. */\r
+               portSAVE_CONTEXT();\r
+               \r
+               /* Enable interrupts */\r
+               __EI();\r
+               \r
+               /* Clear RLT0 interrupt flag */\r
+               TMCSR0_UF = 0;      \r
+               \r
+               /* Increment the tick count then switch to the highest priority task\r
+               that is ready to run. */\r
+               vTaskIncrementTick();\r
+               vTaskSwitchContext();\r
+\r
+               /* Disable interrupts so that portRESTORE_CONTEXT() is not interrupted */\r
+               __DI();\r
+               \r
+               /* Restore the context of the new task. */\r
+               portRESTORE_CONTEXT();\r
+               \r
+               /* Enable interrupts */\r
+               __EI();\r
+       }\r
+\r
+#else\r
+\r
+       /*\r
+        * Tick ISR for the cooperative scheduler.  All this does is increment the\r
+        * tick count.  We don't need to switch context, this can only be done by\r
+        * manual calls to taskYIELD();\r
+        */\r
+       __interrupt void prvRLT0_TICKISR( void )\r
+       {\r
+               /* Clear RLT0 interrupt flag */\r
+               TMCSR0_UF = 0;  \r
+               \r
+               vTaskIncrementTick();\r
+       }\r
+#endif\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/*\r
+ * Manual context switch. We can use a __nosavereg attribute  as the context \r
+ * would be saved by PortSAVE_CONTEXT().  The context is switched and then \r
+ * the context of the new task is restored saved. \r
+ */\r
+__nosavereg __interrupt void vPortYield( void )\r
+{\r
+       /* Save the context of the interrupted task. */\r
+       portSAVE_CONTEXT();\r
+       \r
+       /* Switch to the highest priority task that is ready to run. */\r
+       vTaskSwitchContext();\r
+       \r
+       /* Restore the context of the new task. */\r
+       portRESTORE_CONTEXT();\r
+}\r
+\r
+__nosavereg __interrupt void vPortYieldDelayed( void )\r
+{    \r
+    /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */      \r
+       __DI();\r
+       \r
+       /* Save the context of the interrupted task. */\r
+       portSAVE_CONTEXT();\r
+       \r
+       /* Enable interrupts */\r
+       __EI();\r
+                               \r
+       /* Clear delayed interrupt flag */\r
+    __asm (" CLRB  03A4H:0 ");\r
+       \r
+       /* Switch to the highest priority task that is ready to run. */\r
+       vTaskSwitchContext();\r
+       \r
+       /* Disable interrupts so that portSAVE_CONTEXT() is not interrupted */   \r
+       __DI();\r
+       \r
+       /* Restore the context of the new task. */\r
+       portRESTORE_CONTEXT();\r
+\r
+       /* Enable interrupts */\r
+       __EI();\r
+}      \r
diff --git a/Source/portable/Softune/MB96340/portmacro.h b/Source/portable/Softune/MB96340/portmacro.h
new file mode 100644 (file)
index 0000000..cc16938
--- /dev/null
@@ -0,0 +1,117 @@
+/*\r
+       FreeRTOS.org V4.7.1 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+       This file is part of the FreeRTOS.org distribution.\r
+\r
+       FreeRTOS.org is free software; you can redistribute it and/or modify\r
+       it under the terms of the GNU General Public License as published by\r
+       the Free Software Foundation; either version 2 of the License, or\r
+       (at your option) any later version.\r
+\r
+       FreeRTOS.org is distributed in the hope that it will be useful,\r
+       but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+       GNU General Public License for more details.\r
+\r
+       You should have received a copy of the GNU General Public License\r
+       along with FreeRTOS.org; if not, write to the Free Software\r
+       Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA\r
+\r
+       A special exception to the GPL can be applied should you wish to distribute\r
+       a combined work that includes FreeRTOS.org, without being obliged to provide\r
+       the source code for any proprietary components.  See the licensing section\r
+       of http://www.FreeRTOS.org for full details of how and when the exception\r
+       can be applied.\r
+\r
+       ***************************************************************************\r
+\r
+       Please ensure to read the configuration and relevant port sections of the \r
+       online documentation.\r
+\r
+       +++ http://www.FreeRTOS.org +++\r
+       Documentation, latest information, license and contact details.  \r
+\r
+       +++ http://www.SafeRTOS.com +++\r
+       A version that is certified for use in safety critical systems.\r
+\r
+       +++ http://www.OpenRTOS.com +++\r
+       Commercial support, development, porting, licensing and training services.\r
+\r
+       ***************************************************************************\r
+*/\r
+\r
+\r
+#ifndef PORTMACRO_H\r
+#define PORTMACRO_H\r
+\r
+/*-----------------------------------------------------------\r
+ * Port specific definitions.  \r
+ *\r
+ * The settings in this file configure FreeRTOS correctly for the\r
+ * given hardware and compiler.\r
+ *\r
+ * These settings should not be altered.\r
+ *-----------------------------------------------------------\r
+ */\r
+\r
+/* Type definitions. */\r
+#define portCHAR               char\r
+#define portFLOAT              float\r
+#define portDOUBLE             double\r
+#define portLONG               long\r
+#define portSHORT              int\r
+#define portSTACK_TYPE unsigned portSHORT\r
+#define portBASE_TYPE  char\r
+\r
+/* This is required since SOFTUNE doesn't support inline directive as is. */\r
+#define inline\r
+\r
+#if( configUSE_16_BIT_TICKS == 1 )\r
+       typedef unsigned portSHORT portTickType;\r
+       #define portMAX_DELAY ( portTickType ) 0xffff\r
+#else\r
+       typedef unsigned portLONG portTickType;\r
+       #define portMAX_DELAY ( portTickType ) 0xffffffff\r
+#endif\r
+/*-----------------------------------------------------------*/        \r
+\r
+#define portDISABLE_INTERRUPTS()  __DI();\r
+\r
+#define portENABLE_INTERRUPTS()  __EI();\r
+\r
+/*-----------------------------------------------------------*/        \r
+\r
+#define portENTER_CRITICAL()                                                           \\r
+               {       __asm(" PUSHW PS ");                                                    \\r
+                       portDISABLE_INTERRUPTS();                                               \\r
+               }\r
+\r
+#define portEXIT_CRITICAL()                                                                    \\r
+               {       __asm(" POPW PS ");                                                             \\r
+               }\r
+\r
+\r
+/*-----------------------------------------------------------*/\r
+\r
+/* Architecture specifics. */\r
+#define portSTACK_GROWTH                       ( -1 )\r
+#define portTICK_RATE_MS                       ( ( portTickType ) 1000 / configTICK_RATE_HZ )          \r
+#define portBYTE_ALIGNMENT                     2\r
+#define portNOP()                                      __asm( " NOP " );\r
+/*-----------------------------------------------------------*/\r
+\r
+/* portYIELD() uses SW interrupt */\r
+#define portYIELD()                                    __asm( " INT #122 " );\r
+\r
+/* portYIELD() uses delayed interrupt */\r
+#define portYIELDFromISR()                      __asm (" SETB  03A4H:0 ");             \r
+/*-----------------------------------------------------------*/\r
+\r
+/* Task function macros as described on the FreeRTOS.org WEB site. */\r
+#define portTASK_FUNCTION_PROTO( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
+\r
+#define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE\r
+\r
+#endif /* PORTMACRO_H */\r
+\r