--- /dev/null
+/*\r
+ FreeRTOS.org V5.1.1 - Copyright (C) 2003-2008 Richard Barry.\r
+\r
+ This file is part of the FreeRTOS distribution.\r
+\r
+ FreeRTOS 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 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; 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, 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
+ * *\r
+ * SAVE TIME AND MONEY! We can port FreeRTOS.org to your own hardware, *\r
+ * and even write all or part of your application on your behalf. *\r
+ * See http://www.OpenRTOS.com for details of the services we provide to *\r
+ * expedite your project. *\r
+ * *\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 - 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
+\r
+ EXTERN pxCurrentTCB\r
+ EXTERN usCriticalNesting\r
+\r
+#include "FreeRTOSConfig.h"\r
+\r
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
+; Context save and restore macro definitions\r
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;\r
+\r
+portSAVE_CONTEXT MACRO\r
+\r
+ add -0x0C,sp ; prepare stack to save necessary values\r
+ st.w lp,8[sp] ; store LP to stack\r
+ stsr 0,r31\r
+ st.w lp,4[sp] ; store EIPC to stack\r
+ stsr 1,lp\r
+ st.w lp,0[sp] ; store EIPSW to stack\r
+#if configDATA_MODE == 1 ; Using the Tiny data model\r
+ prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30},76,sp ; save general purpose registers\r
+ sst.w r19,72[ep]\r
+ sst.w r18,68[ep]\r
+ sst.w r17,64[ep]\r
+ sst.w r16,60[ep]\r
+ sst.w r15,56[ep]\r
+ sst.w r14,52[ep]\r
+ sst.w r13,48[ep]\r
+ sst.w r12,44[ep]\r
+ sst.w r11,40[ep]\r
+ sst.w r10,36[ep]\r
+ sst.w r9,32[ep]\r
+ sst.w r8,28[ep]\r
+ sst.w r7,24[ep]\r
+ sst.w r6,20[ep]\r
+ sst.w r5,16[ep]\r
+ sst.w r4,12[ep]\r
+#else ; Using the Small/Large data model\r
+ prepare {r20,r21,r22,r23,r24,r26,r27,r28,r29,r30},72,sp ; save general purpose registers\r
+ sst.w r19,68[ep]\r
+ sst.w r18,64[ep]\r
+ sst.w r17,60[ep]\r
+ sst.w r16,56[ep]\r
+ sst.w r15,52[ep]\r
+ sst.w r14,48[ep]\r
+ sst.w r13,44[ep]\r
+ sst.w r12,40[ep]\r
+ sst.w r11,36[ep]\r
+ sst.w r10,32[ep]\r
+ sst.w r9,28[ep]\r
+ sst.w r8,24[ep]\r
+ sst.w r7,20[ep]\r
+ sst.w r6,16[ep]\r
+ sst.w r5,12[ep]\r
+#endif /* configDATA_MODE */\r
+ sst.w r2,8[ep]\r
+ sst.w r1,4[ep]\r
+ MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack\r
+ ld.w lw1(usCriticalNesting)[r1],r2\r
+ sst.w r2,0[ep]\r
+ MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB\r
+ ld.w lw1(pxCurrentTCB)[r1],r2\r
+ st.w sp,0[r2]\r
+ ENDM\r
+\r
+\r
+portRESTORE_CONTEXT MACRO\r
+\r
+ MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address\r
+ ld.w lw1(pxCurrentTCB)[r1],sp\r
+ MOV sp,r1\r
+ ld.w 0[r1],sp ; load stackpointer\r
+ MOV sp,ep ; set stack pointer to element pointer\r
+ sld.w 0[ep],r1 ; load usCriticalNesting value from stack\r
+ MOVHI hi1(usCriticalNesting),r0,r2\r
+ st.w r1,lw1(usCriticalNesting)[r2]\r
+ sld.w 4[ep],r1 ; restore general purpose registers\r
+ sld.w 8[ep],r2\r
+#if configDATA_MODE == 1 ; Using Tiny data model\r
+ sld.w 12[ep],r4\r
+ sld.w 16[ep],r5\r
+ sld.w 20[ep],r6\r
+ sld.w 24[ep],r7\r
+ sld.w 28[ep],r8\r
+ sld.w 32[ep],r9\r
+ sld.w 36[ep],r10\r
+ sld.w 40[ep],r11\r
+ sld.w 44[ep],r12\r
+ sld.w 48[ep],r13\r
+ sld.w 52[ep],r14\r
+ sld.w 56[ep],r15\r
+ sld.w 60[ep],r16\r
+ sld.w 64[ep],r17\r
+ sld.w 68[ep],r18\r
+ sld.w 72[ep],r19\r
+ dispose 76,{r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30}\r
+#else ; Using Small/Large data model\r
+ sld.w 12[ep],r5\r
+ sld.w 16[ep],r6\r
+ sld.w 20[ep],r7\r
+ sld.w 24[ep],r8\r
+ sld.w 28[ep],r9\r
+ sld.w 32[ep],r10\r
+ sld.w 36[ep],r11\r
+ sld.w 40[ep],r12\r
+ sld.w 44[ep],r13\r
+ sld.w 48[ep],r14\r
+ sld.w 52[ep],r15\r
+ sld.w 56[ep],r16\r
+ sld.w 60[ep],r17\r
+ sld.w 64[ep],r18\r
+ sld.w 68[ep],r19\r
+ dispose 72,{r20,r21,r22,r23,r24,r26,r27,r28,r29,r30}\r
+#endif /* configDATA_MODE */\r
+ ld.w 0[sp],lp ; restore EIPSW from stack\r
+ ldsr lp,1\r
+ ld.w 4[sp],lp ; restore EIPC from stack\r
+ ldsr lp,0\r
+ ld.w 8[sp],lp ; restore LP from stack\r
+ add 0x0C,sp ; set SP to right position\r
+\r
+ RETI\r
+\r
+ ENDM\r
; ***************************************************************************\r
;\r
;------------------------------------------------------------------------------\r
-; Note: Select the correct include files for the device used by the application. \r
+; Note: Select the correct include files for the device used by the application.\r
#include "FreeRTOSConfig.h"\r
;------------------------------------------------------------------------------\r
\r
; Functions used by scheduler\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
EXTERN vTaskSwitchContext\r
EXTERN vTaskIncrementTick\r
\r
; Variables used by scheduler\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
EXTERN pxCurrentTCB\r
EXTERN usCriticalNesting\r
\r
PUBLIC vPortStart\r
\r
; Security ID definition\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
#define CG_SECURITY0 0FFH\r
#define CG_SECURITY1 0FFH\r
#define CG_SECURITY2 0FFH\r
; and the usCriticalNesting Value of the active Task onto the task stack\r
; saves stack pointer to the TCB\r
;------------------------------------------------------------------------------\r
-portSAVE_CONTEXT MACRO \r
+portSAVE_CONTEXT MACRO\r
#if configDATA_MODE == 1 ; Using the Tiny data model\r
prepare {r20,r21,r22,r23,r24,r25,r26,r27,r28,r29,r30},76,sp ; save general purpose registers\r
sst.w r19,72[ep]\r
#endif /* configDATA_MODE */\r
sst.w r2,8[ep]\r
sst.w r1,4[ep]\r
- MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack \r
+ MOVHI hi1(usCriticalNesting),r0,r1 ; save usCriticalNesting value to stack\r
ld.w lw1(usCriticalNesting)[r1],r2\r
sst.w r2,0[ep]\r
MOVHI hi1(pxCurrentTCB),r0,r1 ; save SP to top of current TCB\r
; portRESTORE_CONTEXT MACRO\r
; Gets stack pointer from the current TCB\r
; Restores the context of the usCriticalNesting value and general purpose\r
-; registers of the selected task from the task stack \r
+; registers of the selected task from the task stack\r
;------------------------------------------------------------------------------\r
portRESTORE_CONTEXT MACRO\r
MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address\r
MOVHI hi1(usCriticalNesting),r0,r2\r
st.w r1,lw1(usCriticalNesting)[r2]\r
sld.w 4[ep],r1 ; restore general purpose registers\r
- sld.w 8[ep],r2 \r
+ sld.w 8[ep],r2\r
#if configDATA_MODE == 1 ; Using Tiny data model\r
sld.w 12[ep],r4\r
sld.w 16[ep],r5\r
sld.w 64[ep],r18\r
sld.w 68[ep],r19\r
dispose 72,{r20,r21,r22,r23,r24,r26,r27,r28,r29,r30}\r
-#endif /* configDATA_MODE */ \r
+#endif /* configDATA_MODE */\r
ENDM\r
;------------------------------------------------------------------------------\r
\r
RSEG CODE:CODE\r
vPortStart:\r
portRESTORE_CONTEXT ; Restore the context of whichever task the ...\r
- ld.w 0[sp],lp \r
+ ld.w 0[sp],lp\r
ldsr lp,5 ; restore PSW\r
DI\r
ld.w 4[sp],lp ; restore LP\r
ADD 0x0C,sp ; set SP to right position\r
EI\r
jmp [lp]\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
\r
;------------------------------------------------------------------------------\r
-; Port Yield function to check for a Task switch in the cooperative and \r
+; Port Yield function to check for a Task switch in the cooperative and\r
; preemptive mode\r
;\r
; Input: NONE\r
;\r
; Output: NONE\r
;------------------------------------------------------------------------------\r
+\r
+#if 0\r
+\r
RSEG CODE:CODE\r
vPortYield:\r
DI\r
ld.w 4[sp],lp ; restore PIPC\r
ldsr lp,0\r
ld.w 8[sp],lp ; restore LP\r
- add 0x0C,sp \r
+ add 0x0C,sp\r
RETI\r
+\r
+#else\r
+\r
+ RSEG CODE:CODE\r
+vPortYield:\r
+\r
+ add -0x0C,sp ; prepare stack to save necessary values\r
+ st.w lp,8[sp] ; store LP to stack\r
+ stsr 0,r31\r
+ st.w lp,4[sp] ; store EIPC to stack\r
+ stsr 1,lp\r
+ st.w lp,0[sp] ; store EIPSW to stack\r
+ portSAVE_CONTEXT ; Save the context of the current task.\r
+ jarl vTaskSwitchContext,lp ; Call the scheduler.\r
+ portRESTORE_CONTEXT ; Restore the context of whichever task the ...\r
+ ; ... scheduler decided should run.\r
+ ld.w 0[sp],lp ; restore EIPSW from stack\r
+ ldsr lp,1\r
+ ld.w 4[sp],lp ; restore EIPC from stack\r
+ ldsr lp,0\r
+ ld.w 8[sp],lp ; restore LP from stack\r
+ add 0x0C,sp ; set SP to right position\r
+\r
+ RETI\r
+\r
+#endif\r
;------------------------------------------------------------------------------\r
\r
;------------------------------------------------------------------------------\r
; Perform the necessary steps of the Tick Count Increment and Task Switch\r
-; depending on the chosen kernel configuration \r
+; depending on the chosen kernel configuration\r
;\r
; Input: NONE\r
;\r
-; Call: ISR \r
+; Call: ISR\r
;\r
; Output: NONE\r
;------------------------------------------------------------------------------ \r
#if configUSE_PREEMPTION == 1 ; use preemptive kernel mode\r
\r
MD_INTTM0EQ0:\r
- \r
+\r
add -0x0C,sp ; prepare stack to save necessary values\r
st.w lp,8[sp] ; store LP to stack\r
stsr 0,r31\r
ld.w 8[sp],lp ; restore LP from stack\r
add 0x0C,sp ; set SP to right position\r
\r
- RETI \r
-;------------------------------------------------------------------------------ \r
+ RETI\r
+;------------------------------------------------------------------------------\r
#else ; use cooperative kernel mode\r
\r
MD_INTTM0EQ0:\r
sld.w 0[ep],r5\r
sld.w 4[ep],r1\r
dispose 8,{lp,ep}\r
- RETI \r
+ RETI\r
#endif /* configUSE_PREEMPTION */\r
\r
;------------------------------------------------------------------------------\r
RSEG NEAR_ID:CONST:SORT:NOROOT(2)\r
`?<Initializer for usCriticalNesting>`:\r
DW 10\r
- \r
-;------------------------------------------------------------------------------ \r
+\r
+ COMMON INTVEC:CODE:ROOT(2)\r
+ ORG 40H\r
+`??vPortYield??INTVEC 40`:\r
+ JR vPortYield\r
+\r
+;------------------------------------------------------------------------------\r
; set microcontroller security ID\r
\r
COMMON INTVEC:CODE:ROOT(2)\r
DB CG_SECURITY8\r
DB CG_SECURITY9\r
\r
-;------------------------------------------------------------------------------ \r
+;------------------------------------------------------------------------------\r
; set microcontroller option bytes\r
\r
COMMON INTVEC:CODE:ROOT(2)\r
DB OPT7D\r
DB OPT7E\r
DB OPT7F\r
- \r
+\r
END
\ No newline at end of file
\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
+ 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
Please ensure to read the configuration and relevant port sections of the\r
online documentation.\r
\r
- http://www.FreeRTOS.org - Documentation, latest information, license and \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
+ 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
+ http://www.OpenRTOS.com - Commercial support, development, porting,\r
licensing and training services.\r
*/\r
\r
#endif\r
\r
/*-----------------------------------------------------------\r
- * Port specific definitions. \r
+ * Port specific definitions.\r
*\r
* The settings in this file configure FreeRTOS correctly for the\r
* given hardware and compiler.\r
extern void vPortStart( void );\r
extern void portSAVE_CONTEXT( void );\r
extern void portRESTORE_CONTEXT( void );\r
-#define portYIELD() vPortYield()\r
+//#define portYIELD() vPortYield()\r
+#define portYIELD() __asm ( "trap 0" )\r
#define portNOP() __asm ( "NOP" )\r
/*-----------------------------------------------------------*/\r
\r