mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-01 11:53:53 -04:00
General tidy up of SH files.
This commit is contained in:
parent
99cc14b365
commit
9849c9ccab
2 changed files with 61 additions and 39 deletions
|
@ -62,9 +62,14 @@
|
|||
/* Library includes. */
|
||||
#include "string.h"
|
||||
|
||||
#define portINITIAL_SR 0UL /* No interrupts masked. */
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
/* Allocate enough space for FPR0 to FPR15, FPUL and FPSCR, each of which is 4
|
||||
/* 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 )
|
||||
|
||||
/* 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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue