]> git.sur5r.net Git - freertos/commitdiff
Convert the CCS4 MSP430X port layer to permit large and small data models, and large...
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 3 Jan 2011 16:48:59 +0000 (16:48 +0000)
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Mon, 3 Jan 2011 16:48:59 +0000 (16:48 +0000)
git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1219 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

Source/portable/CCS4/MSP430X/data_model.h [new file with mode: 0644]
Source/portable/CCS4/MSP430X/port.c
Source/portable/CCS4/MSP430X/portext.asm
Source/portable/CCS4/MSP430X/portmacro.h

diff --git a/Source/portable/CCS4/MSP430X/data_model.h b/Source/portable/CCS4/MSP430X/data_model.h
new file mode 100644 (file)
index 0000000..4cc526e
--- /dev/null
@@ -0,0 +1,79 @@
+;    FreeRTOS V6.1.0 - Copyright (C) 2010 Real Time Engineers Ltd.\r
+;\r
+;    ***************************************************************************\r
+;    *                                                                         *\r
+;    * If you are:                                                             *\r
+;    *                                                                         *\r
+;    *    + New to FreeRTOS,                                                   *\r
+;    *    + Wanting to learn FreeRTOS or multitasking in general quickly       *\r
+;    *    + Looking for basic training,                                        *\r
+;    *    + Wanting to improve your FreeRTOS skills and productivity           *\r
+;    *                                                                         *\r
+;    * then take a look at the FreeRTOS books - available as PDF or paperback  *\r
+;    *                                                                         *\r
+;    *        "Using the FreeRTOS Real Time Kernel - a Practical Guide"        *\r
+;    *                  http://www.FreeRTOS.org/Documentation                  *\r
+;    *                                                                         *\r
+;    * A pdf reference manual is also available.  Both are usually delivered   *\r
+;    * to your inbox within 20 minutes to two hours when purchased between 8am *\r
+;    * and 8pm GMT (although please allow up to 24 hours in case of            *\r
+;    * exceptional circumstances).  Thank you for your support!                *\r
+;    *                                                                         *\r
+;    ***************************************************************************\r
+;\r
+;    This file is part of the FreeRTOS distribution.\r
+;\r
+;    FreeRTOS is free software; you can redistribute it and/or modify it under\r
+;    the terms of the GNU General Public License (version 2) as published by the\r
+;    Free Software Foundation AND MODIFIED BY the FreeRTOS exception.\r
+;    ***NOTE*** The exception to the GPL is included to allow you to distribute\r
+;    a combined work that includes FreeRTOS without being obliged to provide the\r
+;    source code for proprietary components outside of the FreeRTOS kernel.\r
+;    FreeRTOS is distributed in the hope that it will be useful, but WITHOUT\r
+;    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or\r
+;    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for\r
+;    more details. You should have received a copy of the GNU General Public\r
+;    License and the FreeRTOS license exception along with FreeRTOS; if not it\r
+;    can be viewed here: http://www.freertos.org/a00114.html and also obtained\r
+;    by writing to Richard Barry, contact details for whom are available on the\r
+;    FreeRTOS WEB site.\r
+;\r
+;    1 tab == 4 spaces!\r
+;\r
+;    http://www.FreeRTOS.org - Documentation, latest information, license and\r
+;    contact details.\r
+;\r
+;    http://www.SafeRTOS.com - A version that is certified for use in safety\r
+;    critical systems.\r
+;\r
+;    http://www.OpenRTOS.com - Commercial support, development, porting,\r
+;    licensing and training services.\r
+\r
+       .if $DEFINED( __LARGE_DATA_MODEL__ )\r
+               .define "pushm.a", pushm_x\r
+               .define "popm.a", popm_x\r
+               .define "push.a", push_x\r
+               .define "pop.a", pop_x\r
+               .define "mov.a", mov_x\r
+               .define "cmp.a", cmp_x\r
+       .else\r
+               .define "pushm.w", pushm_x\r
+               .define "popm.w", popm_x\r
+               .define "push.w", push_x\r
+               .define "pop.w", pop_x\r
+               .define "mov.w", mov_x\r
+               .define "cmp.w", cmp_x\r
+       .endif\r
+       \r
+       .if $DEFINED( __LARGE_CODE_MODEL__ )\r
+               .define "calla", call_x\r
+               .define "reta", ret_x\r
+       .else\r
+               .define "call", call_x\r
+               .define "ret", ret_x\r
+       .endif\r
+       \r
+\r
+\r
+\r
+\r
index 73af84f965df2e287bc4ab78726c222ae5ebbc4e..2ba97b0c9ccd6fa19c9db4374bd6108b232944a5 100644 (file)
@@ -98,6 +98,7 @@ void vPortSetupTimerInterrupt( void );
 portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
 {\r
 unsigned short *pusTopOfStack;\r
+unsigned long *pulTopOfStack;\r
 \r
        /*\r
                Place a few bytes of known values on the bottom of the stack.\r
@@ -111,38 +112,61 @@ unsigned short *pusTopOfStack;
                pxTopOfStack--;\r
        */\r
 \r
-       *pxTopOfStack = ( portSTACK_TYPE ) pxCode;\r
-       pusTopOfStack = ( unsigned short * ) pxTopOfStack;\r
+       /* Data types are need either 16 bits or 32 bits depending on the data \r
+       and code model used. */\r
+       if( sizeof( pxCode ) == sizeof( unsigned short ) )\r
+       {\r
+               pusTopOfStack = ( unsigned short * ) pxTopOfStack;\r
+               *pusTopOfStack = ( unsigned short ) pxCode;\r
+       }\r
+       else\r
+       {\r
+               /* Make room for a 20 bit value stored as a 32 bit value. */\r
+               pusTopOfStack = ( unsigned short * ) pxTopOfStack;              \r
+               pusTopOfStack--;\r
+               pulTopOfStack = ( unsigned long * ) pusTopOfStack;\r
+               *pulTopOfStack = ( unsigned long ) pxCode;\r
+               pusTopOfStack = ( unsigned short * ) pulTopOfStack;\r
+       }\r
+\r
        pusTopOfStack--;\r
        *pusTopOfStack = portFLAGS_INT_ENABLED;\r
-       pusTopOfStack -= 2;\r
+       pusTopOfStack -= ( sizeof( portSTACK_TYPE ) / 2 );\r
+       \r
+       /* From here on the size of stacked items depends on the memory model. */\r
        pxTopOfStack = ( portSTACK_TYPE * ) pusTopOfStack;\r
 \r
        /* Next the general purpose registers. */\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xffffff;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xeeeeee;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xdddddd;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xbbbbbb;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaaaa;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x999999;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x888888;\r
-       pxTopOfStack--; \r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x555555;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x666666;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x555555;\r
-       pxTopOfStack--;\r
-       *pxTopOfStack = ( portSTACK_TYPE ) 0x444444;\r
-       pxTopOfStack--;\r
+       #ifdef PRELOAD_REGISTER_VALUES\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0xffff;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0xeeee;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0xdddd;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0xbbbb;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0xaaaa;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0x9999;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0x8888;\r
+               pxTopOfStack--; \r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0x6666;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0x5555;\r
+               pxTopOfStack--;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) 0x4444;\r
+               pxTopOfStack--;\r
+       #else\r
+               pxTopOfStack -= 3;\r
+               *pxTopOfStack = ( portSTACK_TYPE ) pvParameters;\r
+               pxTopOfStack -= 9;\r
+       #endif\r
 \r
        /* A variable is used to keep track of the critical section nesting.\r
        This variable has to be stored as part of the task context and is\r
index 44ff501f25c5b0112b7710d472070ff439a02426..1e09101f7fe47a1f2bce5aba9497132c797bf862 100644 (file)
@@ -53,6 +53,8 @@
 ; * The definition of the "register test" tasks, as described at the top of\r
 ; * main.c\r
 \r
+       .include data_model.h\r
+\r
        .global vTaskIncrementTick\r
        .global vTaskSwitchContext\r
        .global vPortSetupTimerInterrupt\r
 portSAVE_CONTEXT .macro\r
 \r
        ;Save the remaining registers.\r
-       pushm.a #12, r15\r
-       movx.w  &usCriticalNesting, r14\r
-       pushx.a r14\r
-       movx.a  &pxCurrentTCB, r12\r
-       movx.a  sp, 0( r12 )\r
+       pushm_x #12, r15\r
+       mov.w   &usCriticalNesting, r14\r
+       push_x r14\r
+       mov_x   &pxCurrentTCB, r12\r
+       mov_x   sp, 0( r12 )\r
        .endm\r
 ;-----------------------------------------------------------\r
                \r
 portRESTORE_CONTEXT .macro\r
 \r
-       movx.a  &pxCurrentTCB, r12\r
-       movx.a  @r12, sp\r
-       popx.a  r15\r
-       movx.w  r15, &usCriticalNesting\r
-       popm.a  #12, r15\r
+       mov_x   &pxCurrentTCB, r12\r
+       mov_x   @r12, sp\r
+       pop_x   r15\r
+       mov.w   r15, &usCriticalNesting\r
+       popm_x  #12, r15\r
                \r
        ;The last thing on the stack will be the status register.\r
     ;Ensure the power down bits are clear ready for the next\r
@@ -91,7 +93,7 @@ portRESTORE_CONTEXT .macro
        bic.w   #0xf0, 0( sp )\r
                \r
        pop.w   sr\r
-       reta\r
+       ret_x\r
        .endm\r
 ;-----------------------------------------------------------\r
 \r
@@ -113,8 +115,8 @@ vPortPreemptiveTickISR:
        push.w sr\r
        portSAVE_CONTEXT\r
                                \r
-       call  #vTaskIncrementTick\r
-       call  #vTaskSwitchContext\r
+       call_x  #vTaskIncrementTick\r
+       call_x  #vTaskSwitchContext\r
                \r
        portRESTORE_CONTEXT\r
 ;-----------------------------------------------------------\r
@@ -126,7 +128,7 @@ vPortCooperativeTickISR:
        push.w sr\r
        portSAVE_CONTEXT\r
                                \r
-       call  #vTaskIncrementTick\r
+       call_x  #vTaskIncrementTick\r
                \r
        portRESTORE_CONTEXT\r
 ;-----------------------------------------------------------\r
@@ -147,7 +149,7 @@ vPortYield:
        portSAVE_CONTEXT                        \r
 \r
        ; Select the next task to run.\r
-       call  #vTaskSwitchContext             \r
+       call_x  #vTaskSwitchContext             \r
 \r
        ; Restore the context of the new task.\r
        portRESTORE_CONTEXT\r
@@ -162,7 +164,7 @@ xPortStartScheduler:
 \r
        ; Setup the hardware to generate the tick.  Interrupts are disabled\r
        ; when this function is called.\r
-       call  #vPortSetupTimerInterrupt\r
+       call_x  #vPortSetupTimerInterrupt\r
 \r
        ; Restore the context of the first task that is going to run.\r
        portRESTORE_CONTEXT\r
index 3929bffdf4c9bd480dd2e6ed2a8dc6a89aae3a0d..d4422d9ec03e4752fc594b688fb3d5be84f08f32 100644 (file)
 #define portDOUBLE             double\r
 #define portLONG               long\r
 #define portSHORT              int\r
-#define portSTACK_TYPE unsigned portLONG\r
 #define portBASE_TYPE  portSHORT\r
 \r
+/* The stack type changes depending on the data model. */\r
+#ifdef __LARGE_DATA_MODEL__\r
+       #define portSTACK_TYPE unsigned long\r
+#else\r
+       #define portSTACK_TYPE unsigned short\r
+#endif\r
+\r
 #if( configUSE_16_BIT_TICKS == 1 )\r
        typedef unsigned portSHORT portTickType;\r
        #define portMAX_DELAY ( portTickType ) 0xffff\r