licensing and training services.\r
*/\r
\r
+/*-----------------------------------------------------------\r
+ * Implementation of functions defined in portable.h for the SH2A port.\r
+ *----------------------------------------------------------*/\r
\r
/* Scheduler includes. */\r
#include "FreeRTOS.h"\r
#include "task.h"\r
\r
-\r
-/*-----------------------------------------------------------\r
- * Implementation of functions defined in portable.h for the SH2A port.\r
- *----------------------------------------------------------*/\r
+#define portINITIAL_SR 0UL /* No interrupts masked. */\r
\r
\r
/*-----------------------------------------------------------*/\r
*/\r
void vPortYield( void );\r
\r
+/*\r
+ * Function to start the first task executing - defined in portasm.src.\r
+ */\r
+extern void vPortStartFirstTask( void );\r
+\r
+/*\r
+ * Obtains the current GBR value - defined in portasm.src.\r
+ */\r
+extern unsigned long ulPortGetGBR( void );\r
+\r
/*-----------------------------------------------------------*/\r
\r
/* \r
*/\r
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )\r
{\r
-\r
+*pxTopOfStack = 0x11111111UL;\r
+pxTopOfStack--;\r
+*pxTopOfStack = 0x22222222UL;\r
+pxTopOfStack--;\r
+*pxTopOfStack = 0x33333333UL;\r
+pxTopOfStack--;\r
+\r
+ /* SR. */\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
+ \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
+\r
+ \r
+ /* Parameters in R4 then R3-R0. */\r
+// *pxTopOfStack = ( unsigned long ) pvParameters;\r
+// pxTopOfStack -= 5;\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
+\r
+\r
+ /* GBR = global base register.\r
+ VBR = vector base register.\r
+ TBR = jump table base register.\r
+ R15 is the stack pointer. */\r
+\r
+ return pxTopOfStack;\r
}\r
/*-----------------------------------------------------------*/\r
\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
/* Should not get here. */\r
return pdFAIL;\r
}\r
/*-----------------------------------------------------------*/\r
\r
-void vPortYield( void )\r
-{\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
void vPortTickInterrupt( void )\r
{\r
vTaskIncrementTick();\r
--- /dev/null
+;/*\r
+; FreeRTOS V6.0.1 - Copyright (C) 2009 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 eBook *\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
+\r
+ .import _pxCurrentTCB\r
+ .import _vTaskSwitchContext\r
+\r
+ .export _vPortStartFirstTask\r
+ .export _ulPortGetGBR\r
+ .export _vPortYield\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
+\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
+ ; 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
+ 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
+ \r
+ ; Get the address of pxTopOfStack from the TCB.\r
+ mov.l @r0, r0\r
+ \r
+ ; Save the stack pointer in pxTopOfStack.\r
+ mov.l r15, @r0\r
+\r
+ mov.l #_vTaskSwitchContext, r0\r
+ jsr @r0\r
+ nop\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
+\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
+ ; Pop the SR and PC to jump to the start of the task.\r
+ rte\r
+ nop\r
+\r
+\r
+_ulPortGetGBR:\r
+\r
+ stc.l gbr, r0\r
+ rts\r
+ nop\r
+\r
+ .end\r
+ \r
#define portBYTE_ALIGNMENT 4\r
#define portSTACK_GROWTH -1\r
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ ) \r
-#define portYIELD() trapa( 0 )\r
+#define portYIELD() trapa( 33 )\r
#define portNOP() nop()\r
/*-----------------------------------------------------------*/\r
\r