X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=Source%2Fportable%2FRenesas%2FSH2A_FPU%2Fport.c;h=7ce291939c3a14b446ec696741fb274c3db18907;hb=8370f5cefe1ba2dd685cd1b7618fa8ca7168710e;hp=c52485c8169ae1cb327ded740db0b6dbc23f3e4d;hpb=abf2e1b1eb921b0c7690c571e29ae2d64b82ac48;p=freertos diff --git a/Source/portable/Renesas/SH2A_FPU/port.c b/Source/portable/Renesas/SH2A_FPU/port.c index c52485c81..7ce291939 100644 --- a/Source/portable/Renesas/SH2A_FPU/port.c +++ b/Source/portable/Renesas/SH2A_FPU/port.c @@ -62,9 +62,14 @@ /* Library includes. */ #include "string.h" -#define portINITIAL_SR 0UL /* No interrupts masked. */ +/*-----------------------------------------------------------*/ + +/* The SR assigned to a newly created task. The only important thing in this +value is for all interrupts to be enabled. */ +#define portINITIAL_SR ( 0UL ) -/* Allocate enough space for FPR0 to FPR15, FPUL and FPSCR, each of which is 4 +/* Dimensions the array into which the floating point context is saved. +Allocate enough space for FPR0 to FPR15, FPUL and FPSCR, each of which is 4 bytes big. If this number is changed then the 72 in portasm.src also needs changing. */ #define portFLOP_REGISTERS_TO_STORE ( 18 ) @@ -72,11 +77,6 @@ changing. */ /*-----------------------------------------------------------*/ -/* - * Setup a peripheral timer to generate the RTOS tick interrupt. - */ -static void prvSetupTimerInterrupt( void ); - /* * The TRAPA handler used to force a context switch. */ @@ -200,10 +200,18 @@ pxTopOfStack--; portBASE_TYPE xPortStartScheduler( void ) { - /* Start the tick interrupt. */ - prvSetupTimerInterrupt(); - - /* Start the first task. */ +extern void vApplicationSetupTimerInterrupt( void ); + + /* Call an application function to set up the timer that will generate the + tick interrupt. This way the application can decide which peripheral to + use. A demo application is provided to show a suitable example. */ + vApplicationSetupTimerInterrupt(); + + /* Start the first task. This will only restore the standard registers and + not the flop registers. This does not really matter though because the only + flop register that is initialised to a particular value is fpscr, and it is + only initialised to the current value, which will still be the current value + when the first task starts executing. */ trapa( portSTART_SCHEDULER_TRAP_NO ); /* Should not get here. */ @@ -217,30 +225,12 @@ void vPortEndScheduler( void ) } /*-----------------------------------------------------------*/ -void vPortTickInterrupt( void ) -{ - vTaskIncrementTick(); - #if configUSE_PREEMPTION == 1 - vTaskSwitchContext(); - #endif -} -/*-----------------------------------------------------------*/ - -static void prvSetupTimerInterrupt( void ) -{ -extern void vApplicationSetupTimerInterrupt( void ); - - /* Call an application function to set up the timer. This way the application - can decide which peripheral to use. A demo application is provided to show a - suitable example. */ - vApplicationSetupTimerInterrupt(); -} -/*-----------------------------------------------------------*/ - void vPortYield( void ) { long lInterruptMask; + /* Ensure the yield trap runs at the same priority as the other interrupts + that can cause a context switch. */ lInterruptMask = get_imask(); /* taskYIELD() can only be called from a task, not an interrupt, so the @@ -250,6 +240,8 @@ long lInterruptMask; trapa( portYIELD_TRAP_NO ); + /* Restore the interrupt mask to whatever it was previously (when the + function was entered. */ set_imask( ( int ) lInterruptMask ); } /*-----------------------------------------------------------*/ @@ -260,9 +252,15 @@ 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 = pxCurrentTCB; + xTask = ( xTaskHandle ) pxCurrentTCB; } /* Allocate a buffer large enough to hold all the flop registers. */ @@ -270,12 +268,15 @@ extern void * volatile pxCurrentTCB; 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. */ *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. */ + /* 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; }