/*\r
- FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.\r
+ FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
\r
***************************************************************************\r
* *\r
*pxTopOfStack = portINITIAL_SR; \r
pxTopOfStack--;\r
\r
- /* PC then MACL, MACH. */\r
-// *pxTopOfStack = ( unsigned long ) pxCode;\r
-// pxTopOfStack -= 3;\r
-*pxTopOfStack = ( unsigned long ) pxCode;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0xffffUL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0xeeeeUL;\r
-pxTopOfStack--;\r
+ /* PC. */\r
+ *pxTopOfStack = ( unsigned long ) pxCode;\r
+ pxTopOfStack--;\r
\r
- /* GBR then PR, R14-R5. */\r
-// *pxTopOfStack = ulPortGetGBR();\r
-// pxTopOfStack -= 12;\r
-*pxTopOfStack = 0x00UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x11UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x22UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x33UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x44UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x55UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x66UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x77UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x88UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x99UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0xaaUL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0xbbUL;\r
-pxTopOfStack--;\r
+ /* PR. */\r
+ *pxTopOfStack = 15;\r
+ pxTopOfStack--;\r
+ \r
+ /* 14. */\r
+ *pxTopOfStack = 14;\r
+ pxTopOfStack--;\r
\r
- \r
- /* Parameters in R4 then R3-R0. */\r
-// *pxTopOfStack = ( unsigned long ) pvParameters;\r
-// pxTopOfStack -= 5;\r
+ /* R13. */\r
+ *pxTopOfStack = 13;\r
+ pxTopOfStack--;\r
\r
-*pxTopOfStack = 0x1UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x2UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x3UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x4UL;\r
-pxTopOfStack--;\r
-*pxTopOfStack = 0x5UL;\r
-//pxTopOfStack--;\r
+ /* R12. */\r
+ *pxTopOfStack = 12;\r
+ pxTopOfStack--;\r
+\r
+ /* R11. */\r
+ *pxTopOfStack = 11;\r
+ pxTopOfStack--;\r
+\r
+ /* R10. */\r
+ *pxTopOfStack = 10;\r
+ pxTopOfStack--;\r
+\r
+ /* R9. */\r
+ *pxTopOfStack = 9;\r
+ pxTopOfStack--;\r
+\r
+ /* R8. */\r
+ *pxTopOfStack = 8;\r
+ pxTopOfStack--;\r
+\r
+ /* R7. */\r
+ *pxTopOfStack = 7;\r
+ pxTopOfStack--;\r
+\r
+ /* R6. */\r
+ *pxTopOfStack = 6;\r
+ pxTopOfStack--;\r
+\r
+ /* R5. */\r
+ *pxTopOfStack = 5;\r
+ pxTopOfStack--;\r
+\r
+ /* R4. */\r
+ *pxTopOfStack = ( unsigned long ) pvParameters;\r
+ pxTopOfStack--;\r
+\r
+ /* R3. */\r
+ *pxTopOfStack = 3;\r
+ pxTopOfStack--;\r
\r
+ /* R2. */\r
+ *pxTopOfStack = 2;\r
+ pxTopOfStack--;\r
\r
+ /* R1. */\r
+ *pxTopOfStack = 1;\r
+ pxTopOfStack--;\r
+ \r
+ /* R0 */\r
+ *pxTopOfStack = 0;\r
+ pxTopOfStack--;\r
+ \r
+ /* MACL. */\r
+ *pxTopOfStack = 16;\r
+ pxTopOfStack--;\r
+ \r
+ /* MACH. */\r
+ *pxTopOfStack = 17;\r
+ pxTopOfStack--;\r
+ \r
+ /* GBR. */\r
+ *pxTopOfStack = ulPortGetGBR();\r
+ \r
/* GBR = global base register.\r
VBR = vector base register.\r
TBR = jump table base register.\r
portBASE_TYPE xPortStartScheduler( void )\r
{\r
/* Start the tick interrupt. */\r
-// prvSetupTimerInterrupt();\r
+ prvSetupTimerInterrupt();\r
\r
/* Start the first task. */\r
trapa( 32 );\r
\r
\r
\r
+\r
+\r
+\r
;/*\r
-; FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.\r
+; FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
;\r
; ***************************************************************************\r
; * *\r
\r
.import _pxCurrentTCB\r
.import _vTaskSwitchContext\r
+ .import _vTaskIncrementTick\r
\r
.export _vPortStartFirstTask\r
.export _ulPortGetGBR\r
.export _vPortYield\r
+ .export _vPortPreemptiveTick\r
+ .export _vPortCooperativeTick\r
\r
.section P\r
- \r
-_vPortStartFirstTask:\r
- \r
- ; Get the address of the pxCurrentTCB variable.\r
- mov.l #_pxCurrentTCB, r15\r
\r
- ; Get the address of the task stack from pxCurrentTCB.\r
- mov.l @r15, r15\r
-\r
- ; Get the task stack itself into the stack pointer. \r
- mov.l @r15, r15 \r
+ .macro portSAVE_CONTEXT\r
\r
- ; Restore r0 to PR (PR is used in place of r15).\r
- movml.l @r15+, r15\r
+ ; Save r0 to r14 and pr.\r
+ movml.l r15, @-r15\r
\r
- ; Restore system registers.\r
- ldc.l @r15+, gbr\r
- lds.l @r15+, mach\r
- lds.l @r15+, macl\r
- \r
- ; Pop the SR and PC to jump to the start of the task.\r
- rte\r
- nop\r
-\r
-_vPortYield:\r
-\r
- ; Save registers in the same order used by the CPU itself.\r
+ ; Save mac1, mach and gbr\r
sts.l macl, @-r15\r
sts.l mach, @-r15\r
stc.l gbr, @-r15\r
- movml.l r15, @-r15\r
\r
; Get the address of pxCurrentTCB\r
mov.l #_pxCurrentTCB, r0\r
; Save the stack pointer in pxTopOfStack.\r
mov.l r15, @r0\r
\r
- mov.l #_vTaskSwitchContext, r0\r
- jsr @r0\r
- nop\r
+ .endm\r
+\r
+;-----------------------------------------------------------\r
+\r
+ .macro portRESTORE_CONTEXT\r
\r
; Get the address of the pxCurrentTCB variable.\r
- mov.l #_pxCurrentTCB, r15\r
+ mov.l #_pxCurrentTCB, r0\r
\r
; Get the address of the task stack from pxCurrentTCB.\r
- mov.l @r15, r15\r
+ mov.l @r0, r0\r
\r
; Get the task stack itself into the stack pointer. \r
- mov.l @r15, r15 \r
+ mov.l @r0, r15 \r
\r
- ; Restore r0 to PR (PR is used in place of r15).\r
- movml.l @r15+, r15\r
- \r
; Restore system registers.\r
ldc.l @r15+, gbr\r
lds.l @r15+, mach\r
lds.l @r15+, macl\r
+\r
+ ; Restore r0 to r14 and PR\r
+ movml.l @r15+, r15\r
\r
; Pop the SR and PC to jump to the start of the task.\r
rte\r
nop\r
\r
+ .endm\r
+;-----------------------------------------------------------\r
+ \r
+_vPortStartFirstTask:\r
+ \r
+ portRESTORE_CONTEXT\r
+ \r
+;-----------------------------------------------------------\r
+\r
+_vPortYield:\r
+\r
+ ; Push r0 so it can be used.\r
+ mov.l r0, @-r15\r
+ \r
+ ; Set the interrupt mask in the status register.\r
+ stc sr, r0\r
+ or #240,r0\r
+ ldc r0, sr\r
+ \r
+ ; Restore r0 so its original value can be saved by the movml.l instruction \r
+ ; below, without ending up with two copies on the stack.\r
+ mov.l @r15+, r0\r
+\r
+ portSAVE_CONTEXT\r
+\r
+ mov.l #_vTaskSwitchContext, r0\r
+ jsr @r0\r
+ nop\r
+\r
+ portRESTORE_CONTEXT\r
+ \r
+;-----------------------------------------------------------\r
+\r
+_vPortPreemptiveTick\r
+\r
+ portSAVE_CONTEXT\r
+ \r
+ mov.l #_vTaskIncrementTick, r0\r
+ jsr @r0\r
+ nop\r
+\r
+ mov.l #_vTaskSwitchContext, r0\r
+ jsr @r0\r
+ nop\r
+\r
+ portRESTORE_CONTEXT\r
+ \r
+;-----------------------------------------------------------\r
+\r
+_vPortCooperativeTick\r
+\r
+ portSAVE_CONTEXT\r
+ \r
+ mov.l #_vTaskIncrementTick, r0\r
+ jsr @r0\r
+ nop\r
+\r
+ portRESTORE_CONTEXT\r
+ \r
+;-----------------------------------------------------------\r
\r
_ulPortGetGBR:\r
\r
/*\r
- FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.\r
+ FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.\r
\r
***************************************************************************\r
* *\r
/*-----------------------------------------------------------*/\r
\r
#define portENABLE_INTERRUPTS() set_imask( 0x00 )\r
-#define portDISABLE_INTERRUPTS() set_imask( 0x0F )\r
+#define portDISABLE_INTERRUPTS() set_imask( configMAX_SYSCALL_INTERRUPT_PRIORITY )\r
\r
/* Critical section handling. */\r
#define portCRITICAL_NESTING_IN_TCB ( 1 )\r
extern void vTaskEnterCritical( void );\r
extern void vTaskExitCritical( void );\r
-#define portENTER_CRITICAL() vTaskEnterCritical();\r
-#define portEXIT_CRITICAL() vTaskExitCritical();\r
+#define portENTER_CRITICAL() vTaskEnterCritical();\r
+#define portEXIT_CRITICAL() vTaskExitCritical();\r
+\r
/*-----------------------------------------------------------*/\r
\r
/* Task function macros as described on the FreeRTOS.org WEB site. */\r