]> git.sur5r.net Git - freertos/commitdiff
Work in progress.
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 12 Feb 2008 17:47:34 +0000 (17:47 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Tue, 12 Feb 2008 17:47:34 +0000 (17:47 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@170 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/Softune/MB96340/port.c
Source/portable/Softune/MB96340/portmacro.h

index b7bbe3f22c46a4959057132926615d6608df5d57..bece34f9b6fa6d851bf2107d82f57eed8cf2f9f7 100644 (file)
  * 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
+#define configMEMMODEL portMEDIUM\r
 \r
 /*-----------------------------------------------------------*/\r
 \r
+/* \r
+ * Get current value of DPR and ADB registers \r
+ */\r
+portSTACK_TYPE xGet_DPR_ADB_bank( void ); \r
+\r
+/* \r
+ * Get current value of DTB and PCB registers \r
+ */\r
+portSTACK_TYPE xGet_DTB_PCB_bank( void );\r
+\r
+/* \r
+ * Get current register pointer \r
+ */ \r
+portCHAR xGet_RP( void );           \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
 /* \r
  * We require the address of the pxCurrentTCB variable, but don't want to know\r
  * any details of its type. \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
+/* Constants required to handle critical sections. */\r
+#define portNO_CRITICAL_NESTING                ( ( unsigned portBASE_TYPE ) 0x1234 )\r
+volatile unsigned portBASE_TYPE uxCriticalNesting = 9999UL;\r
 \r
-/*-----------------------------------------------------------*/                \r
+/*-----------------------------------------------------------*/\r
 \r
 /* \r
  * Macro to save a task context to the task stack. This macro  copies the \r
@@ -94,147 +103,156 @@ portCHAR    Get_RP(void);
  * 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
+#if( ( configMEMMODEL == portSMALL ) || ( configMEMMODEL == portMEDIUM ) )\r
+\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
       * Macro to restore a task context from the task stack.  This is effecti-\r
       * vely the reverse of SAVE_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
+       #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
+                                                                                                                                               \\r
+                               /* Load the saves uxCriticalNesting value into RW0. */  \\r
+                               __asm(" POPW (RW0) ");                                                                  \\r
+                                                                                                                                               \\r
+                               /* Save the loaded value into the uxCriticalNesting variable. */ \\r
+                               __asm(" MOVW _uxCriticalNesting, RW0 ");                                                                \\r
+                                                                                                                                               \\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
+#elif (configMEMMODEL == portCOMPACT || configMEMMODEL == portLARGE)                   \r
+\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
+       #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
@@ -245,50 +263,52 @@ portCHAR     Get_RP(void);
  */\r
  \r
 #pragma asm\r
-        .GLOBAL    _Get_DPR_ADB_bank\r
-        .GLOBAL    _Get_DTB_PCB_bank\r
-        .GLOBAL    _Get_RP\r
+\r
+        .GLOBAL    _xGet_DPR_ADB_bank\r
+        .GLOBAL    _xGet_DTB_PCB_bank\r
+        .GLOBAL    _xGet_RP\r
         .SECTION   CODE, CODE, ALIGN=1\r
-_Get_DPR_ADB_bank:\r
+\r
+_xGet_DPR_ADB_bank:\r
+\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
+       #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
+               RETP\r
+       #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
+               RET\r
+       #endif \r
+\r
+\r
+_xGet_DTB_PCB_bank:\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
+       #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
+               RETP\r
+       #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
+               RET\r
+       #endif \r
+\r
+\r
+_xGet_RP:\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
+       #if configMEMMODEL == portMEDIUM || configMEMMODEL == portLARGE\r
+               RETP\r
+       #elif configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT   \r
+               RET\r
+       #endif \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
+#pragma endasm\r
 /*-----------------------------------------------------------*/\r
 \r
 /* \r
@@ -301,7 +321,6 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
 {\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
@@ -309,69 +328,75 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
        *pxTopOfStack = 0x3333;\r
        pxTopOfStack--;\r
 \r
-       /* Once the task is called the called  would  push  the  pointer to the\r
+       /* Once the task is called the task  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
+       #if( ( configMEMMODEL == portCOMPACT ) || ( configMEMMODEL == portLARGE ) )\r
+       {\r
+               *pxTopOfStack = ( portSTACK_TYPE ) ( ( unsigned portLONG ) ( pvParameters ) >> 16 );\r
+               pxTopOfStack--;         \r
+       }\r
+       #endif\r
 \r
-    *pxTopOfStack = (portSTACK_TYPE)(pvParameters);\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
+       #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
+       {\r
+               *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );      \r
+               pxTopOfStack--;       \r
+       }\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 = ( 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
+       /* 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
+    /* DTB | PCB */\r
+       #if configMEMMODEL == portSMALL || configMEMMODEL == portCOMPACT\r
+       {\r
+               *pxTopOfStack = xGet_DTB_PCB_bank();            \r
+               pxTopOfStack--;\r
+       }\r
+       #endif\r
 \r
-       /* DTB | PCB, in case of MEDIUM or LARGE memory model PCB would be used\r
+       /* DTB | PCB, in case of portMEDIUM or portLARGE 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
+       #if( ( configMEMMODEL == portMEDIUM ) || ( configMEMMODEL == portLARGE ) )\r
+       {\r
+               *pxTopOfStack = ( xGet_DTB_PCB_bank() & 0xff00 ) | ( ( ( portLONG ) ( pxCode ) >> 16 ) & 0xff );\r
+               pxTopOfStack--;       \r
+       }\r
+       #endif\r
 \r
-       /* DPR | ADB                                                                              */\r
-       *pxTopOfStack = Get_DPR_ADB_bank();                             \r
+       /* DPR | ADB  */\r
+       *pxTopOfStack = xGet_DPR_ADB_bank();                            \r
        pxTopOfStack--;\r
     \r
-       /* AL                                                                                             */\r
+       /* AL */\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0x9999;              \r
        pxTopOfStack--;\r
 \r
-       /* AH                                                                                             */\r
+       /* AH */\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0xAAAA;              \r
        pxTopOfStack--;\r
        \r
-       /* Next the general purpose registers.                            */\r
+       /* Next the general purpose registers. */\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0x7777;      /* RW7 */\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0x6666;      /* RW6 */\r
@@ -387,13 +412,16 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
        *pxTopOfStack = ( portSTACK_TYPE ) 0x1111;      /* RW1 */\r
        pxTopOfStack--;\r
        *pxTopOfStack = ( portSTACK_TYPE ) 0x8888;      /* RW0 */\r
+       pxTopOfStack--;\r
+\r
+       /* The task starts with its uxCriticalNesting variable set to 0, interrupts\r
+       being enabled. */\r
+       *pxTopOfStack = portNO_CRITICAL_NESTING;\r
                \r
        return pxTopOfStack;\r
 }\r
 /*-----------------------------------------------------------*/\r
-/*\r
- * Setup RLT0 to generate a tick interrupt.\r
- */\r
+\r
 static void prvSetupRLT0Interrupt( void )\r
 {\r
        /* set reload value = 34999+1, TICK Interrupt after 10 ms @ 56MHz of CLKP1 */\r
@@ -403,9 +431,7 @@ static void prvSetupRLT0Interrupt( void )
     TMCSR0 = 0x041B;    \r
 }\r
 /*-----------------------------------------------------------*/\r
-/*\r
- * Start the scheduler.\r
- */\r
+\r
 portBASE_TYPE xPortStartScheduler( void )\r
 {\r
        /* Setup the hardware to generate the tick. */\r
@@ -427,8 +453,8 @@ portBASE_TYPE xPortStartScheduler( void )
 \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
+       /* Not implemented - unlikely to ever be required as there is nothing to\r
+       return to. */\r
 }\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -488,6 +514,7 @@ void vPortEndScheduler( void )
                \r
                vTaskIncrementTick();\r
        }\r
+\r
 #endif\r
 \r
 /*-----------------------------------------------------------*/\r
@@ -508,6 +535,7 @@ __nosavereg __interrupt void vPortYield( void )
        /* Restore the context of the new task. */\r
        portRESTORE_CONTEXT();\r
 }\r
+/*-----------------------------------------------------------*/\r
 \r
 __nosavereg __interrupt void vPortYieldDelayed( void )\r
 {    \r
@@ -535,3 +563,30 @@ __nosavereg __interrupt void vPortYieldDelayed( void )
        /* Enable interrupts */\r
        __EI();\r
 }      \r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortEnterCritical( void )\r
+{\r
+       /* Disable interrupts */\r
+       portDISABLE_INTERRUPTS();\r
+\r
+       /* Now interrupts are disabled uxCriticalNesting can be accessed\r
+        directly.  Increment uxCriticalNesting to keep a count of how many times\r
+        portENTER_CRITICAL() has been called. */\r
+       uxCriticalNesting++;\r
+}\r
+/*-----------------------------------------------------------*/\r
+\r
+void vPortExitCritical( void )\r
+{\r
+       if( uxCriticalNesting > portNO_CRITICAL_NESTING )\r
+       {\r
+               uxCriticalNesting--;\r
+               if( uxCriticalNesting == portNO_CRITICAL_NESTING )\r
+               {\r
+                       /* Enable all interrupt/exception. */\r
+                       portENABLE_INTERRUPTS();\r
+               }\r
+       }\r
+}\r
+/*-----------------------------------------------------------*/\r
index cc169382a717a85b0339d92f36ceed133710f225..09f1df19a127814180e0d6ddc6a9542809c04680 100644 (file)
 #ifndef PORTMACRO_H\r
 #define PORTMACRO_H\r
 \r
+#include "mb96348hs.h"\r
+#include <stddef.h>\r
+\r
+\r
 /*-----------------------------------------------------------\r
  * Port specific definitions.  \r
  *\r
 #define portFLOAT              float\r
 #define portDOUBLE             double\r
 #define portLONG               long\r
-#define portSHORT              int\r
+#define portSHORT              short\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
+#define portBASE_TYPE  portSHORT\r
 \r
 #if( configUSE_16_BIT_TICKS == 1 )\r
        typedef unsigned portSHORT portTickType;\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
+/* Critical section handling. */\r
+#define portDISABLE_INTERRUPTS()       __DI();\r
+#define portENABLE_INTERRUPTS()                __EI();\r
+#define portENTER_CRITICAL()           vPortEnterCritical()\r
+#define portEXIT_CRITICAL()                    vPortExitCritical()\r
 \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
+/* portYIELD_FROM_ISR() uses delayed interrupt */\r
+#define portYIELD_FROM_ISR()            __asm( " SETB  03A4H:0 " );\r
 /*-----------------------------------------------------------*/\r
 \r
 /* Task function macros as described on the FreeRTOS.org WEB site. */\r
 \r
 #define portMINIMAL_STACK_SIZE configMINIMAL_STACK_SIZE\r
 \r
+/* Remove the inline declaration from within the kernel code. */\r
+#define inline\r
+\r
 #endif /* PORTMACRO_H */\r
 \r