From 1f3ada07f5b04a87936e908d5f75081966303102 Mon Sep 17 00:00:00 2001 From: richardbarry Date: Fri, 13 Aug 2010 07:17:30 +0000 Subject: [PATCH] Continue work on RX600 port - work in progress. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@1041 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- Source/portable/Renesas/RX600/port.c | 103 +++++++++++----------- Source/portable/Renesas/RX600/portmacro.h | 22 ----- 2 files changed, 50 insertions(+), 75 deletions(-) diff --git a/Source/portable/Renesas/RX600/port.c b/Source/portable/Renesas/RX600/port.c index 30531ac67..b7cf7ffe9 100644 --- a/Source/portable/Renesas/RX600/port.c +++ b/Source/portable/Renesas/RX600/port.c @@ -71,6 +71,12 @@ changing. */ #define portFLOP_REGISTERS_TO_STORE ( 18 ) #define portFLOP_STORAGE_SIZE ( portFLOP_REGISTERS_TO_STORE * 4 ) +/* Tasks should start with interrupts enabled, therefore PSW is set with U,I,PM +flags set and IPL clear. */ +#define portINITIAL_PSW ( ( portSTACK_TYPE ) 0x00130000 ) +#define portINITIAL_FPSW ( ( portSTACK_TYPE ) 0x00000100 ) + + /*-----------------------------------------------------------*/ /* @@ -90,6 +96,50 @@ void vPortStartFirstTask( void ); */ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters ) { + /* R0 is not included as it is the stack pointer. */ + + *pxTopOfStack = 0xdeadbeef; + pxTopOfStack--; + *pxTopOfStack = portINITIAL_PSW; + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) pxCode; + pxTopOfStack--; + *pxTopOfStack = 0xffffffff; /* r15. */ + pxTopOfStack--; + *pxTopOfStack = 0xeeeeeeee; + pxTopOfStack--; + *pxTopOfStack = 0xdddddddd; + pxTopOfStack--; + *pxTopOfStack = 0xcccccccc; + pxTopOfStack--; + *pxTopOfStack = 0xbbbbbbbb; + pxTopOfStack--; + *pxTopOfStack = 0xaaaaaaaa; + pxTopOfStack--; + *pxTopOfStack = 0x99999999; + pxTopOfStack--; + *pxTopOfStack = 0x88888888; + pxTopOfStack--; + *pxTopOfStack = 0x77777777; + pxTopOfStack--; + *pxTopOfStack = 0x66666666; + pxTopOfStack--; + *pxTopOfStack = 0x55555555; + pxTopOfStack--; + *pxTopOfStack = 0x44444444; + pxTopOfStack--; + *pxTopOfStack = 0x33333333; + pxTopOfStack--; + *pxTopOfStack = 0x22222222; + pxTopOfStack--; + *pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R1 */ + pxTopOfStack--; + *pxTopOfStack = portINITIAL_FPSW; + pxTopOfStack--; + *pxTopOfStack = 0x12345678; /* Accumulator. */ + pxTopOfStack--; + *pxTopOfStack = 0x87654321; /* Accumulator. */ + return pxTopOfStack; } /*-----------------------------------------------------------*/ @@ -126,56 +176,3 @@ void vPortYield( void ) } /*-----------------------------------------------------------*/ -portBASE_TYPE xPortUsesFloatingPoint( xTaskHandle xTask ) -{ -unsigned long *pulFlopBuffer; -portBASE_TYPE xReturn; -extern void * volatile pxCurrentTCB; - - /* This function tells the kernel that the task referenced by xTask is - going to use the floating point registers and therefore requires the - floating point registers saved as part of its context. */ - - /* Passing NULL as xTask is used to indicate that the calling task is the - subject task - so pxCurrentTCB is the task handle. */ - if( xTask == NULL ) - { - xTask = ( xTaskHandle ) pxCurrentTCB; - } - - /* Allocate a buffer large enough to hold all the flop registers. */ - pulFlopBuffer = ( unsigned long * ) pvPortMalloc( portFLOP_STORAGE_SIZE ); - - if( pulFlopBuffer != NULL ) - { - /* Start with the registers in a benign state. */ - memset( ( void * ) pulFlopBuffer, 0x00, portFLOP_STORAGE_SIZE ); - - /* The first thing to get saved in the buffer is the FPSCR value - - initialise this to the current FPSCR value. */ -//_RB_ *pulFlopBuffer = get_fpscr(); - - /* Use the task tag to point to the flop buffer. Pass pointer to just - above the buffer because the flop save routine uses a pre-decrement. */ - vTaskSetApplicationTaskTag( xTask, ( void * ) ( pulFlopBuffer + portFLOP_REGISTERS_TO_STORE ) ); - xReturn = pdPASS; - } - else - { - xReturn = pdFAIL; - } - - return xReturn; -} -/*-----------------------------------------------------------*/ - -void vPortSaveFlopRegisters( void *pvBuffer ) -{ -} -/*-----------------------------------------------------------*/ - -void vPortRestoreFlopRegisters( void *pvBuffer ) -{ -} -/*-----------------------------------------------------------*/ - diff --git a/Source/portable/Renesas/RX600/portmacro.h b/Source/portable/Renesas/RX600/portmacro.h index 149889ee8..4702fc5d6 100644 --- a/Source/portable/Renesas/RX600/portmacro.h +++ b/Source/portable/Renesas/RX600/portmacro.h @@ -102,28 +102,6 @@ void vPortYield( void ); extern void vTaskSwitchContext( void ); #define portYIELD_FROM_ISR( x ) if( x != pdFALSE ) vTaskSwitchContext() -/* - * This function tells the kernel that the task referenced by xTask is going to - * use the floating point registers and therefore requires the floating point - * registers saved as part of its context. - */ -portBASE_TYPE xPortUsesFloatingPoint( void* xTask ); - -/* - * The flop save and restore functions are defined in portasm.src and called by - * the trace "task switched in" and "trace task switched out" macros. - */ -void vPortSaveFlopRegisters( void *pulBuffer ); -void vPortRestoreFlopRegisters( void *pulBuffer ); - -/* - * pxTaskTag is used to point to the buffer into which the floating point - * context should be saved. If pxTaskTag is NULL then the task does not use - * a floating point context. - */ -#define traceTASK_SWITCHED_OUT() if( pxCurrentTCB->pxTaskTag != NULL ) vPortSaveFlopRegisters( pxCurrentTCB->pxTaskTag ) -#define traceTASK_SWITCHED_IN() if( pxCurrentTCB->pxTaskTag != NULL ) vPortRestoreFlopRegisters( pxCurrentTCB->pxTaskTag ) - /* * These macros should be called directly, but through the taskENTER_CRITICAL() * and taskEXIT_CRITICAL() macros. -- 2.39.5