--- /dev/null
+; 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
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
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
; * 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
bic.w #0xf0, 0( sp )\r
\r
pop.w sr\r
- reta\r
+ ret_x\r
.endm\r
;-----------------------------------------------------------\r
\r
push.w sr\r
portSAVE_CONTEXT\r
\r
- calla #vTaskIncrementTick\r
- calla #vTaskSwitchContext\r
+ call_x #vTaskIncrementTick\r
+ call_x #vTaskSwitchContext\r
\r
portRESTORE_CONTEXT\r
;-----------------------------------------------------------\r
push.w sr\r
portSAVE_CONTEXT\r
\r
- calla #vTaskIncrementTick\r
+ call_x #vTaskIncrementTick\r
\r
portRESTORE_CONTEXT\r
;-----------------------------------------------------------\r
portSAVE_CONTEXT \r
\r
; Select the next task to run.\r
- calla #vTaskSwitchContext \r
+ call_x #vTaskSwitchContext \r
\r
; Restore the context of the new task.\r
portRESTORE_CONTEXT\r
\r
; Setup the hardware to generate the tick. Interrupts are disabled\r
; when this function is called.\r
- calla #vPortSetupTimerInterrupt\r
+ call_x #vPortSetupTimerInterrupt\r
\r
; Restore the context of the first task that is going to run.\r
portRESTORE_CONTEXT\r
#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