mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-19 21:11:57 -04:00
Update port layers to make better use of the xTaskIncrementTick() return value.
This commit is contained in:
parent
c75c01ffdf
commit
62c0ae0926
|
@ -166,11 +166,14 @@ void vTickISR( void )
|
|||
|
||||
/* Increment the RTOS tick count, then look for the highest priority
|
||||
task that is ready to run. */
|
||||
__asm volatile( "bl xTaskIncrementTick" );
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
__asm volatile( "bl vTaskSwitchContext" );
|
||||
#endif
|
||||
__asm volatile
|
||||
(
|
||||
" bl xTaskIncrementTick \t\n" \
|
||||
" cmp r0, #0 \t\n" \
|
||||
" beq SkipContextSwitch \t\n" \
|
||||
" bl vTaskSwitchContext \t\n" \
|
||||
"SkipContextSwitch: \t\n"
|
||||
);
|
||||
|
||||
/* Ready for the next interrupt. */
|
||||
T0_IR = portTIMER_MATCH_ISR_BIT;
|
||||
|
|
|
@ -167,8 +167,14 @@ void vPortYieldProcessor( void )
|
|||
|
||||
/* Increment the RTOS tick count, then look for the highest priority
|
||||
task that is ready to run. */
|
||||
__asm volatile( "bl xTaskIncrementTick" );
|
||||
__asm volatile( "bl vTaskSwitchContext" );
|
||||
__asm volatile
|
||||
(
|
||||
" bl xTaskIncrementTick \t\n" \
|
||||
" cmp r0, #0 \t\n" \
|
||||
" beq SkipContextSwitch \t\n" \
|
||||
" bl vTaskSwitchContext \t\n" \
|
||||
"SkipContextSwitch: \t\n"
|
||||
);
|
||||
|
||||
/* Ready for the next interrupt. */
|
||||
T0IR = 2;
|
||||
|
|
|
@ -94,10 +94,13 @@ vPortPreemptiveTick:
|
|||
LDR R0, =xTaskIncrementTick ; Increment the tick count - this may wake a task.
|
||||
mov lr, pc
|
||||
BX R0
|
||||
|
||||
CMP R0, #0
|
||||
BEQ SkipContextSwitch
|
||||
LDR R0, =vTaskSwitchContext ; Select the next task to execute.
|
||||
mov lr, pc
|
||||
BX R0
|
||||
|
||||
SkipContextSwitch
|
||||
LDR R14, =AT91C_BASE_PITC ; Clear the PIT interrupt
|
||||
LDR R0, [R14, #PITC_PIVR ]
|
||||
|
||||
|
|
|
@ -96,10 +96,10 @@ vTickISR:
|
|||
portSAVE_CONTEXT
|
||||
|
||||
call #xTaskIncrementTick
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
cmp.w #0x0, R12
|
||||
jeq SkipContextSwitch
|
||||
call #vTaskSwitchContext
|
||||
#endif
|
||||
SkipContextSwitch:
|
||||
|
||||
portRESTORE_CONTEXT
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
|
@ -131,11 +131,10 @@ vPortTickISR:
|
|||
portSAVE_CONTEXT
|
||||
|
||||
calla #xTaskIncrementTick
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
cmp.w #0x0, R12
|
||||
jeq SkipContextSwitch
|
||||
calla #vTaskSwitchContext
|
||||
#endif
|
||||
|
||||
SkipContextSwitch:
|
||||
portRESTORE_CONTEXT
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
|
@ -88,9 +88,9 @@ vPortTickISR:
|
|||
|
||||
portSAVE_CONTEXT ; Save the context of the current task.
|
||||
call xTaskIncrementTick ; Call the timer tick function.
|
||||
#if configUSE_PREEMPTION == 1
|
||||
cmpw ax, #0x00
|
||||
skz
|
||||
call vTaskSwitchContext ; Call the scheduler to select the next task.
|
||||
#endif
|
||||
portRESTORE_CONTEXT ; Restore the context of the next task to run.
|
||||
reti
|
||||
|
||||
|
|
|
@ -97,6 +97,12 @@ FreeRTOS.org V4.3.0. */
|
|||
#define configKERNEL_INTERRUPT_PRIORITY 1
|
||||
#endif
|
||||
|
||||
/* Use _T1Interrupt as the interrupt handler name if the application writer has
|
||||
not provided their own. */
|
||||
#ifndef configTICK_INTERRUPT_HANDLER
|
||||
#define configTICK_INTERRUPT_HANDLER _T1Interrupt
|
||||
#endif /* configTICK_INTERRUPT_HANDLER */
|
||||
|
||||
/* The program counter is only 23 bits. */
|
||||
#define portUNUSED_PR_BITS 0x7f
|
||||
|
||||
|
@ -107,7 +113,7 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
|
|||
#error If configKERNEL_INTERRUPT_PRIORITY is not 1 then the #32 in the following macros needs changing to equal the portINTERRUPT_BITS value, which is ( configKERNEL_INTERRUPT_PRIORITY << 5 )
|
||||
#endif
|
||||
|
||||
#ifdef MPLAB_PIC24_PORT
|
||||
#if defined( __PIC24E__ ) || defined ( __PIC24F__ ) || defined( __PIC24FK__ ) || defined( __PIC24H__ )
|
||||
|
||||
#ifdef __HAS_EDS__
|
||||
#define portRESTORE_CONTEXT() \
|
||||
|
@ -151,7 +157,7 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
|
|||
#endif /* __HAS_EDS__ */
|
||||
#endif /* MPLAB_PIC24_PORT */
|
||||
|
||||
#ifdef MPLAB_DSPIC_PORT
|
||||
#if defined( __dsPIC30F__ ) || defined ( __dsPIC33E__ ) || defined( __dsPIC33F__ )
|
||||
|
||||
#define portRESTORE_CONTEXT() \
|
||||
asm volatile( "MOV _pxCurrentTCB, W0 \n" /* Restore the stack pointer for the task. */ \
|
||||
|
@ -185,10 +191,14 @@ unsigned portBASE_TYPE uxCriticalNesting = 0xef;
|
|||
|
||||
#endif /* MPLAB_DSPIC_PORT */
|
||||
|
||||
#ifndef portRESTORE_CONTEXT
|
||||
#error Unrecognised device selected
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Setup the timer used to generate the tick interrupt.
|
||||
*/
|
||||
static void prvSetupTimerInterrupt( void );
|
||||
void vApplicationSetupTickTimerInterrupt( void );
|
||||
|
||||
/*
|
||||
* See header file for description.
|
||||
|
@ -196,7 +206,7 @@ static void prvSetupTimerInterrupt( void );
|
|||
portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE pxCode, void *pvParameters )
|
||||
{
|
||||
unsigned short usCode;
|
||||
portBASE_TYPE i;
|
||||
unsigned portBASE_TYPE i;
|
||||
|
||||
const portSTACK_TYPE xInitialStack[] =
|
||||
{
|
||||
|
@ -284,7 +294,7 @@ const portSTACK_TYPE xInitialStack[] =
|
|||
portBASE_TYPE xPortStartScheduler( void )
|
||||
{
|
||||
/* Setup a timer for the tick ISR. */
|
||||
prvSetupTimerInterrupt();
|
||||
vApplicationSetupTickTimerInterrupt();
|
||||
|
||||
/* Restore the context of the first task to run. */
|
||||
portRESTORE_CONTEXT();
|
||||
|
@ -308,7 +318,7 @@ void vPortEndScheduler( void )
|
|||
/*
|
||||
* Setup a timer for a regular tick.
|
||||
*/
|
||||
static void prvSetupTimerInterrupt( void )
|
||||
__attribute__(( weak )) void vApplicationSetupTickTimerInterrupt( void )
|
||||
{
|
||||
const unsigned long ulCompareMatch = ( ( configCPU_CLOCK_HZ / portTIMER_PRESCALE ) / configTICK_RATE_HZ ) - 1;
|
||||
|
||||
|
@ -353,7 +363,7 @@ void vPortExitCritical( void )
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
void __attribute__((__interrupt__, auto_psv)) _T1Interrupt( void )
|
||||
void __attribute__((__interrupt__, auto_psv)) configTICK_INTERRUPT_HANDLER( void )
|
||||
{
|
||||
/* Clear the timer interrupt. */
|
||||
IFS0bits.T1IF = 0;
|
||||
|
|
|
@ -131,10 +131,12 @@ vPreemptiveTick
|
|||
MOV LR, PC ; This may make a delayed task ready
|
||||
BX R0 ; to run.
|
||||
|
||||
CMP R0, #0
|
||||
BEQ SkipContextSwitch
|
||||
LDR R0, =vTaskSwitchContext ; Find the highest priority task that
|
||||
MOV LR, PC ; is ready to run.
|
||||
BX R0
|
||||
|
||||
SkipContextSwitch
|
||||
MOV R0, #T0MATCHBIT ; Clear the timer event
|
||||
LDR R1, =T0IR
|
||||
STR R0, [R1]
|
||||
|
|
|
@ -90,11 +90,10 @@ _vTickISR:
|
|||
portSAVE_CONTEXT
|
||||
|
||||
call #_xTaskIncrementTick
|
||||
|
||||
#if configUSE_PREEMPTION == 1
|
||||
cmp.w #0x00, r15
|
||||
jeq _SkipContextSwitch
|
||||
call #_vTaskSwitchContext
|
||||
#endif
|
||||
|
||||
_SkipContextSwitch:
|
||||
portRESTORE_CONTEXT
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
Loading…
Reference in a new issue