\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
+ 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
+ st.w lp,4[sp] ; store EIPC to stack\r
stsr 1,lp\r
- st.w lp,0[sp] ; store EIPSW to stack\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
#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
+ 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
portRESTORE_CONTEXT MACRO\r
\r
- MOVHI hi1(pxCurrentTCB),r0,r1 ; get Stackpointer address\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
+ 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 4[ep],r1 ; restore general purpose registers\r
sld.w 8[ep],r2\r
-#if configDATA_MODE == 1 ; Using Tiny data model\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 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
+#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 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
+ ld.w 0[sp],lp ; restore EIPSW from stack\r
ldsr lp,1\r
- ld.w 4[sp],lp ; restore EIPC from stack\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
+ ld.w 8[sp],lp ; restore LP from stack\r
+ add 0x0C,sp ; set SP to right position\r
\r
RETI\r
\r
#include "FreeRTOS.h"\r
#include "task.h"\r
\r
+/* Critical nesting should be initialised to a non zero value so interrupts don't\r
+accidentally get enabled before the scheduler is started. */\r
#define portINITIAL_CRITICAL_NESTING (( portSTACK_TYPE ) 10)\r
\r
+/* The PSW value assigned to tasks when they start to run for the first time. */\r
#define portPSW (( portSTACK_TYPE ) 0x00000000)\r
\r
/* We require the address of the pxCurrentTCB variable, but don't want to know\r
typedef void tskTCB;\r
extern volatile tskTCB * volatile pxCurrentTCB;\r
\r
+/* Keeps track of the nesting level of critical sections. */\r
volatile portSTACK_TYPE usCriticalNesting = portINITIAL_CRITICAL_NESTING;\r
/*-----------------------------------------------------------*/\r
\r
+/* Sets up the timer to generate the tick interrupt. */\r
static void prvSetupTimerInterrupt( void );\r
\r
+/*-----------------------------------------------------------*/\r
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
{\r
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* Task function start address */\r
/* Critical section control macros. */\r
#define portNO_CRITICAL_SECTION_NESTING ( ( unsigned portBASE_TYPE ) 0 )\r
\r
-#define portENTER_CRITICAL() \\r
-{ \\r
-extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \\r
- \\r
- portDISABLE_INTERRUPTS(); \\r
- \\r
- /* Now interrupts are disabled ulCriticalNesting can be accessed */ \\r
- /* directly. Increment ulCriticalNesting to keep a count of how many */ \\r
- /* times portENTER_CRITICAL() has been called. */ \\r
- usCriticalNesting++; \\r
+#define portENTER_CRITICAL() \\r
+{ \\r
+extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \\r
+ \\r
+ portDISABLE_INTERRUPTS(); \\r
+ \\r
+ /* Now interrupts are disabled ulCriticalNesting can be accessed */ \\r
+ /* directly. Increment ulCriticalNesting to keep a count of how many */ \\r
+ /* times portENTER_CRITICAL() has been called. */ \\r
+ usCriticalNesting++; \\r
}\r
\r
-#define portEXIT_CRITICAL() \\r
-{ \\r
-extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \\r
- \\r
- if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \\r
- { \\r
- /* Decrement the nesting count as we are leaving a critical section. */ \\r
- usCriticalNesting--; \\r
- \\r
- /* If the nesting level has reached zero then interrupts should be */ \\r
- /* re-enabled. */ \\r
- if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \\r
- { \\r
- portENABLE_INTERRUPTS(); \\r
- } \\r
- } \\r
+#define portEXIT_CRITICAL() \\r
+{ \\r
+extern volatile /*unsigned portSHORT*/ portSTACK_TYPE usCriticalNesting; \\r
+ \\r
+ if( usCriticalNesting > portNO_CRITICAL_SECTION_NESTING ) \\r
+ { \\r
+ /* Decrement the nesting count as we are leaving a critical section. */ \\r
+ usCriticalNesting--; \\r
+ \\r
+ /* If the nesting level has reached zero then interrupts should be */ \\r
+ /* re-enabled. */ \\r
+ if( usCriticalNesting == portNO_CRITICAL_SECTION_NESTING ) \\r
+ { \\r
+ portENABLE_INTERRUPTS(); \\r
+ } \\r
+ } \\r
}\r
/*-----------------------------------------------------------*/\r
\r
extern void vPortStart( void );\r
extern void portSAVE_CONTEXT( void );\r
extern void portRESTORE_CONTEXT( void );\r
-//#define portYIELD() vPortYield()\r
#define portYIELD() __asm ( "trap 0" )\r
#define portNOP() __asm ( "NOP" )\r
extern void vTaskSwitchContext( void );\r
#define portTASK_FUNCTION( vFunction, pvParameters ) void vFunction( void *pvParameters )\r
\r
\r
-static __interrupt void MD_INTP0(void);\r
-\r
-\r
#ifdef __cplusplus\r
}\r
#endif\r