From 1a53268be756e23cc6ff9e31f8f61dbbb248d898 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Mon, 25 Feb 2008 11:18:23 +0000 Subject: [PATCH] Basic cooperative reg test tasks working. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@219 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/GCC/PPC405/port.c | 4 ++-- Source/portable/GCC/PPC405/portasm.s | 21 +++++++++++++++------ Source/portable/GCC/PPC405/portmacro.h | 2 +- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Source/portable/GCC/PPC405/port.c b/Source/portable/GCC/PPC405/port.c index 1455b037b..774ad9285 100644 --- a/Source/portable/GCC/PPC405/port.c +++ b/Source/portable/GCC/PPC405/port.c @@ -162,9 +162,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxTopOfStack--; *pxTopOfStack = portINITIAL_MSR;/* SRR1. */ pxTopOfStack--; - *pxTopOfStack = 0x00000000UL;/* Next LR. */ + *pxTopOfStack = ( portSTACK_TYPE ) vStartFirstTask;/* Next LR. */ pxTopOfStack--; - *pxTopOfStack = portINITIAL_MSR;/* Backchain. */ + *pxTopOfStack = 0x00000000UL;;/* Backchain. */ // pxTopOfStack--; return pxTopOfStack; diff --git a/Source/portable/GCC/PPC405/portasm.s b/Source/portable/GCC/PPC405/portasm.s index 43dfeb221..da8d9f6d7 100644 --- a/Source/portable/GCC/PPC405/portasm.s +++ b/Source/portable/GCC/PPC405/portasm.s @@ -11,7 +11,7 @@ .set portGPR_OFFSET, 32 .set portCR_OFFSET, 28 .set portXER_OFFSET, 24 -.set portLR_OFFSET, 20 +.set portLR_OFFSET, 16 .set portCTR_OFFSET, 16 .set portUSPRG0_OFFSET, 12 .set portSRR0_OFFSET, 8 @@ -167,10 +167,24 @@ # Store the stack pointer into the TCB stw SP, 0( R2 ) + # Save the link register + stwu R1, -24( R1 ) + mflr R0 + stw R31, 20( R1 ) + stw R0, 28( R1 ) + mr R31, r1 + .endm .macro portEXIT_SWITCHING_ISR + # Restore the link register + lwz R11, 0( R1 ) + lwz R0, 4( R11 ) + mtlr R0 + lwz R31, -4( R11 ) + mr R1, R11 + # Get the address of the TCB. xor R0, R0, R0 addis SP, R0, pxCurrentTCB@ha @@ -179,11 +193,6 @@ # Get the task stack pointer from the TCB. lwz SP, 0( SP ) - # Load up the LR for the correct return. - lwz R0,LRField(R1) - mtlr R0 - - .endm diff --git a/Source/portable/GCC/PPC405/portmacro.h b/Source/portable/GCC/PPC405/portmacro.h index 478c1174e..dc895d215 100644 --- a/Source/portable/GCC/PPC405/portmacro.h +++ b/Source/portable/GCC/PPC405/portmacro.h @@ -90,7 +90,7 @@ void vPortExitCritical( void ); /* Task utilities. */ void vPortYield( void ); -#define portYIELD() asm volatile ( "SC" ) +#define portYIELD() asm volatile ( "SC \n\t NOP" ) #define portYIELD_FROM_ISR() /*-----------------------------------------------------------*/ -- 2.39.5