summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2010-01-15 17:18:47 +0000
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2010-01-15 17:18:47 +0000
commit15d70523c68312833aa9be0d6846521e234b4d83 (patch)
tree767d6bb5c2b01201a352168ebfb647ac1b51c1d7
parent15af8d20603ca6f9bc274009cc65d7d033efb439 (diff)
downloadfreertos-15d70523c68312833aa9be0d6846521e234b4d83.tar.gz
Still a work in progress. Need to add flop support.
git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@956 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
-rw-r--r--Source/portable/Renesas/SH2A_FPU/port.c131
-rw-r--r--Source/portable/Renesas/SH2A_FPU/portasm.src114
-rw-r--r--Source/portable/Renesas/SH2A_FPU/portmacro.h9
3 files changed, 163 insertions, 91 deletions
diff --git a/Source/portable/Renesas/SH2A_FPU/port.c b/Source/portable/Renesas/SH2A_FPU/port.c
index a74097fc5..b6832f9c2 100644
--- a/Source/portable/Renesas/SH2A_FPU/port.c
+++ b/Source/portable/Renesas/SH2A_FPU/port.c
@@ -1,5 +1,5 @@
/*
- FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
+ FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.
***************************************************************************
* *
@@ -102,61 +102,85 @@ pxTopOfStack--;
*pxTopOfStack = portINITIAL_SR;
pxTopOfStack--;
- /* PC then MACL, MACH. */
-// *pxTopOfStack = ( unsigned long ) pxCode;
-// pxTopOfStack -= 3;
-*pxTopOfStack = ( unsigned long ) pxCode;
-pxTopOfStack--;
-*pxTopOfStack = 0xffffUL;
-pxTopOfStack--;
-*pxTopOfStack = 0xeeeeUL;
-pxTopOfStack--;
+ /* PC. */
+ *pxTopOfStack = ( unsigned long ) pxCode;
+ pxTopOfStack--;
- /* GBR then PR, R14-R5. */
-// *pxTopOfStack = ulPortGetGBR();
-// pxTopOfStack -= 12;
-*pxTopOfStack = 0x00UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x11UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x22UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x33UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x44UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x55UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x66UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x77UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x88UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x99UL;
-pxTopOfStack--;
-*pxTopOfStack = 0xaaUL;
-pxTopOfStack--;
-*pxTopOfStack = 0xbbUL;
-pxTopOfStack--;
+ /* PR. */
+ *pxTopOfStack = 15;
+ pxTopOfStack--;
+
+ /* 14. */
+ *pxTopOfStack = 14;
+ pxTopOfStack--;
-
- /* Parameters in R4 then R3-R0. */
-// *pxTopOfStack = ( unsigned long ) pvParameters;
-// pxTopOfStack -= 5;
+ /* R13. */
+ *pxTopOfStack = 13;
+ pxTopOfStack--;
-*pxTopOfStack = 0x1UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x2UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x3UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x4UL;
-pxTopOfStack--;
-*pxTopOfStack = 0x5UL;
-//pxTopOfStack--;
+ /* R12. */
+ *pxTopOfStack = 12;
+ pxTopOfStack--;
+
+ /* R11. */
+ *pxTopOfStack = 11;
+ pxTopOfStack--;
+
+ /* R10. */
+ *pxTopOfStack = 10;
+ pxTopOfStack--;
+
+ /* R9. */
+ *pxTopOfStack = 9;
+ pxTopOfStack--;
+
+ /* R8. */
+ *pxTopOfStack = 8;
+ pxTopOfStack--;
+
+ /* R7. */
+ *pxTopOfStack = 7;
+ pxTopOfStack--;
+
+ /* R6. */
+ *pxTopOfStack = 6;
+ pxTopOfStack--;
+
+ /* R5. */
+ *pxTopOfStack = 5;
+ pxTopOfStack--;
+
+ /* R4. */
+ *pxTopOfStack = ( unsigned long ) pvParameters;
+ pxTopOfStack--;
+
+ /* R3. */
+ *pxTopOfStack = 3;
+ pxTopOfStack--;
+ /* R2. */
+ *pxTopOfStack = 2;
+ pxTopOfStack--;
+ /* R1. */
+ *pxTopOfStack = 1;
+ pxTopOfStack--;
+
+ /* R0 */
+ *pxTopOfStack = 0;
+ pxTopOfStack--;
+
+ /* MACL. */
+ *pxTopOfStack = 16;
+ pxTopOfStack--;
+
+ /* MACH. */
+ *pxTopOfStack = 17;
+ pxTopOfStack--;
+
+ /* GBR. */
+ *pxTopOfStack = ulPortGetGBR();
+
/* GBR = global base register.
VBR = vector base register.
TBR = jump table base register.
@@ -169,7 +193,7 @@ pxTopOfStack--;
portBASE_TYPE xPortStartScheduler( void )
{
/* Start the tick interrupt. */
-// prvSetupTimerInterrupt();
+ prvSetupTimerInterrupt();
/* Start the first task. */
trapa( 32 );
@@ -207,3 +231,6 @@ extern void vApplicationSetupTimerInterrupt( void );
+
+
+
diff --git a/Source/portable/Renesas/SH2A_FPU/portasm.src b/Source/portable/Renesas/SH2A_FPU/portasm.src
index 30f80e6cb..5ab645a9b 100644
--- a/Source/portable/Renesas/SH2A_FPU/portasm.src
+++ b/Source/portable/Renesas/SH2A_FPU/portasm.src
@@ -1,5 +1,5 @@
;/*
-; FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
+; FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.
;
; ***************************************************************************
; * *
@@ -53,43 +53,25 @@
.import _pxCurrentTCB
.import _vTaskSwitchContext
+ .import _vTaskIncrementTick
.export _vPortStartFirstTask
.export _ulPortGetGBR
.export _vPortYield
+ .export _vPortPreemptiveTick
+ .export _vPortCooperativeTick
.section P
-
-_vPortStartFirstTask:
-
- ; Get the address of the pxCurrentTCB variable.
- mov.l #_pxCurrentTCB, r15
- ; Get the address of the task stack from pxCurrentTCB.
- mov.l @r15, r15
-
- ; Get the task stack itself into the stack pointer.
- mov.l @r15, r15
+ .macro portSAVE_CONTEXT
- ; Restore r0 to PR (PR is used in place of r15).
- movml.l @r15+, r15
+ ; Save r0 to r14 and pr.
+ movml.l r15, @-r15
- ; Restore system registers.
- ldc.l @r15+, gbr
- lds.l @r15+, mach
- lds.l @r15+, macl
-
- ; Pop the SR and PC to jump to the start of the task.
- rte
- nop
-
-_vPortYield:
-
- ; Save registers in the same order used by the CPU itself.
+ ; Save mac1, mach and gbr
sts.l macl, @-r15
sts.l mach, @-r15
stc.l gbr, @-r15
- movml.l r15, @-r15
; Get the address of pxCurrentTCB
mov.l #_pxCurrentTCB, r0
@@ -100,31 +82,93 @@ _vPortYield:
; Save the stack pointer in pxTopOfStack.
mov.l r15, @r0
- mov.l #_vTaskSwitchContext, r0
- jsr @r0
- nop
+ .endm
+
+;-----------------------------------------------------------
+
+ .macro portRESTORE_CONTEXT
; Get the address of the pxCurrentTCB variable.
- mov.l #_pxCurrentTCB, r15
+ mov.l #_pxCurrentTCB, r0
; Get the address of the task stack from pxCurrentTCB.
- mov.l @r15, r15
+ mov.l @r0, r0
; Get the task stack itself into the stack pointer.
- mov.l @r15, r15
+ mov.l @r0, r15
- ; Restore r0 to PR (PR is used in place of r15).
- movml.l @r15+, r15
-
; Restore system registers.
ldc.l @r15+, gbr
lds.l @r15+, mach
lds.l @r15+, macl
+
+ ; Restore r0 to r14 and PR
+ movml.l @r15+, r15
; Pop the SR and PC to jump to the start of the task.
rte
nop
+ .endm
+;-----------------------------------------------------------
+
+_vPortStartFirstTask:
+
+ portRESTORE_CONTEXT
+
+;-----------------------------------------------------------
+
+_vPortYield:
+
+ ; Push r0 so it can be used.
+ mov.l r0, @-r15
+
+ ; Set the interrupt mask in the status register.
+ stc sr, r0
+ or #240,r0
+ ldc r0, sr
+
+ ; Restore r0 so its original value can be saved by the movml.l instruction
+ ; below, without ending up with two copies on the stack.
+ mov.l @r15+, r0
+
+ portSAVE_CONTEXT
+
+ mov.l #_vTaskSwitchContext, r0
+ jsr @r0
+ nop
+
+ portRESTORE_CONTEXT
+
+;-----------------------------------------------------------
+
+_vPortPreemptiveTick
+
+ portSAVE_CONTEXT
+
+ mov.l #_vTaskIncrementTick, r0
+ jsr @r0
+ nop
+
+ mov.l #_vTaskSwitchContext, r0
+ jsr @r0
+ nop
+
+ portRESTORE_CONTEXT
+
+;-----------------------------------------------------------
+
+_vPortCooperativeTick
+
+ portSAVE_CONTEXT
+
+ mov.l #_vTaskIncrementTick, r0
+ jsr @r0
+ nop
+
+ portRESTORE_CONTEXT
+
+;-----------------------------------------------------------
_ulPortGetGBR:
diff --git a/Source/portable/Renesas/SH2A_FPU/portmacro.h b/Source/portable/Renesas/SH2A_FPU/portmacro.h
index bdc5fa416..b1c88de7d 100644
--- a/Source/portable/Renesas/SH2A_FPU/portmacro.h
+++ b/Source/portable/Renesas/SH2A_FPU/portmacro.h
@@ -1,5 +1,5 @@
/*
- FreeRTOS V6.0.1 - Copyright (C) 2009 Real Time Engineers Ltd.
+ FreeRTOS V6.0.2 - Copyright (C) 2009 Real Time Engineers Ltd.
***************************************************************************
* *
@@ -98,14 +98,15 @@ extern "C" {
/*-----------------------------------------------------------*/
#define portENABLE_INTERRUPTS() set_imask( 0x00 )
-#define portDISABLE_INTERRUPTS() set_imask( 0x0F )
+#define portDISABLE_INTERRUPTS() set_imask( configMAX_SYSCALL_INTERRUPT_PRIORITY )
/* Critical section handling. */
#define portCRITICAL_NESTING_IN_TCB ( 1 )
extern void vTaskEnterCritical( void );
extern void vTaskExitCritical( void );
-#define portENTER_CRITICAL() vTaskEnterCritical();
-#define portEXIT_CRITICAL() vTaskExitCritical();
+#define portENTER_CRITICAL() vTaskEnterCritical();
+#define portEXIT_CRITICAL() vTaskExitCritical();
+
/*-----------------------------------------------------------*/
/* Task function macros as described on the FreeRTOS.org WEB site. */