mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-04-20 05:21:59 -04:00
Improve efficiency even further. Introduce the configMAX_SYSCALL_INTERRUPT_PRIORITY feature.
This commit is contained in:
parent
32592e1385
commit
794b6546b2
|
@ -86,7 +86,7 @@ FreeRTOS.org versions prior to V4.3.0 did not include this definition. */
|
||||||
|
|
||||||
/* Each task maintains its own interrupt status in the critical nesting
|
/* Each task maintains its own interrupt status in the critical nesting
|
||||||
variable. */
|
variable. */
|
||||||
unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa;
|
static unsigned portBASE_TYPE uxCriticalNesting = 0xaaaaaaaa;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Setup the timer to generate the tick interrupts.
|
* Setup the timer to generate the tick interrupts.
|
||||||
|
@ -119,8 +119,7 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
|
||||||
*pxTopOfStack = 0; /* LR */
|
*pxTopOfStack = 0; /* LR */
|
||||||
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
|
pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
|
||||||
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
|
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
|
||||||
pxTopOfStack -= 9; /* R11, R10, R9, R8, R7, R6, R5 and R4. */
|
pxTopOfStack -= 8; /* R11, R10, R9, R8, R7, R6, R5 and R4. */
|
||||||
*pxTopOfStack = 0x00000000; /* uxCriticalNesting. */
|
|
||||||
|
|
||||||
return pxTopOfStack;
|
return pxTopOfStack;
|
||||||
}
|
}
|
||||||
|
@ -139,6 +138,9 @@ portBASE_TYPE xPortStartScheduler( void )
|
||||||
here already. */
|
here already. */
|
||||||
prvSetupTimerInterrupt();
|
prvSetupTimerInterrupt();
|
||||||
|
|
||||||
|
/* Initialise the critical nesting count ready for the first task. */
|
||||||
|
uxCriticalNesting = 0;
|
||||||
|
|
||||||
/* Start the first task. */
|
/* Start the first task. */
|
||||||
vPortStartFirstTask( *((unsigned portLONG *) 0 ) );
|
vPortStartFirstTask( *((unsigned portLONG *) 0 ) );
|
||||||
|
|
||||||
|
@ -158,10 +160,6 @@ void vPortYieldFromISR( void )
|
||||||
{
|
{
|
||||||
/* Set a PendSV to request a context switch. */
|
/* Set a PendSV to request a context switch. */
|
||||||
*(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;
|
*(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;
|
||||||
|
|
||||||
/* This function is also called in response to a Yield(), so we want
|
|
||||||
the yield to occur immediately. */
|
|
||||||
portENABLE_INTERRUPTS();
|
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -184,13 +182,19 @@ void vPortExitCritical( void )
|
||||||
|
|
||||||
void xPortSysTickHandler( void )
|
void xPortSysTickHandler( void )
|
||||||
{
|
{
|
||||||
|
unsigned portLONG ulDummy;
|
||||||
|
|
||||||
/* If using preemption, also force a context switch. */
|
/* If using preemption, also force a context switch. */
|
||||||
#if configUSE_PREEMPTION == 1
|
#if configUSE_PREEMPTION == 1
|
||||||
*(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;
|
*(portNVIC_INT_CTRL) |= portNVIC_PENDSVSET;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ulDummy = portSET_INTERRUPT_MASK_FROM_ISR();
|
||||||
|
{
|
||||||
vTaskIncrementTick();
|
vTaskIncrementTick();
|
||||||
}
|
}
|
||||||
|
portCLEAR_INTERRUPT_MASK_FROM_ISR( ulDummy );
|
||||||
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -68,7 +68,6 @@ FreeRTOS.org versions prior to V4.3.0 did not include this definition. */
|
||||||
thumb
|
thumb
|
||||||
|
|
||||||
EXTERN vPortYieldFromISR
|
EXTERN vPortYieldFromISR
|
||||||
EXTERN uxCriticalNesting
|
|
||||||
EXTERN pxCurrentTCB
|
EXTERN pxCurrentTCB
|
||||||
EXTERN vTaskSwitchContext
|
EXTERN vTaskSwitchContext
|
||||||
|
|
||||||
|
@ -93,36 +92,29 @@ xPortPendSVHandler:
|
||||||
ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */
|
ldr r3, =pxCurrentTCB /* Get the location of the current TCB. */
|
||||||
ldr r2, [r3]
|
ldr r2, [r3]
|
||||||
|
|
||||||
ldr r1, =uxCriticalNesting /* Save the remaining registers and the critical nesting count onto the task stack. */
|
stmdb r0!, {r4-r11} /* Save the remaining registers. */
|
||||||
ldr r1, [r1]
|
|
||||||
stmdb r0!, {r1,r4-r11}
|
|
||||||
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
|
str r0, [r2] /* Save the new top of stack into the first member of the TCB. */
|
||||||
|
|
||||||
stmdb sp!, {r3, r14}
|
stmdb sp!, {r3, r14}
|
||||||
|
mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
|
||||||
|
msr basepri, r0
|
||||||
bl vTaskSwitchContext
|
bl vTaskSwitchContext
|
||||||
|
mov r0, #0
|
||||||
|
msr basepri, r0
|
||||||
ldmia sp!, {r3, r14}
|
ldmia sp!, {r3, r14}
|
||||||
|
|
||||||
ldr r1, [r3]
|
ldr r1, [r3]
|
||||||
ldr r2, =uxCriticalNesting
|
|
||||||
ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */
|
ldr r0, [r1] /* The first item in pxCurrentTCB is the task top of stack. */
|
||||||
ldmia r0!, {r1, r4-r11} /* Pop the registers and the critical nesting count. */
|
ldmia r0!, {r4-r11} /* Pop the registers. */
|
||||||
str r1, [r2] /* Save the new critical nesting value into ulCriticalNesting. */
|
|
||||||
msr psp, r0
|
msr psp, r0
|
||||||
orr r14, r14, #13
|
|
||||||
|
|
||||||
cbnz r1, sv_disable_interrupts /* If the nesting count is greater than 0 we need to exit with interrupts masked. */
|
|
||||||
bx r14
|
bx r14
|
||||||
|
|
||||||
sv_disable_interrupts:
|
|
||||||
mov r1, #configKERNEL_INTERRUPT_PRIORITY
|
|
||||||
msr basepri, r1
|
|
||||||
bx r14
|
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
vPortSetInterruptMask:
|
vPortSetInterruptMask:
|
||||||
push { r0 }
|
push { r0 }
|
||||||
mov R0, #configKERNEL_INTERRUPT_PRIORITY
|
mov R0, #configMAX_SYSCALL_INTERRUPT_PRIORITY
|
||||||
msr BASEPRI, R0
|
msr BASEPRI, R0
|
||||||
pop { R0 }
|
pop { R0 }
|
||||||
|
|
||||||
|
@ -144,9 +136,7 @@ vPortSVCHandler;
|
||||||
ldr r3, =pxCurrentTCB
|
ldr r3, =pxCurrentTCB
|
||||||
ldr r1, [r3]
|
ldr r1, [r3]
|
||||||
ldr r0, [r1]
|
ldr r0, [r1]
|
||||||
ldmia r0!, {r1, r4-r11}
|
ldmia r0!, {r4-r11}
|
||||||
ldr r2, =uxCriticalNesting
|
|
||||||
str r1, [r2]
|
|
||||||
msr psp, r0
|
msr psp, r0
|
||||||
mov r0, #0
|
mov r0, #0
|
||||||
msr basepri, r0
|
msr basepri, r0
|
||||||
|
|
|
@ -93,7 +93,7 @@ extern "C" {
|
||||||
/* Architecture specifics. */
|
/* Architecture specifics. */
|
||||||
#define portSTACK_GROWTH ( -1 )
|
#define portSTACK_GROWTH ( -1 )
|
||||||
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
#define portTICK_RATE_MS ( ( portTickType ) 1000 / configTICK_RATE_HZ )
|
||||||
#define portBYTE_ALIGNMENT 4
|
#define portBYTE_ALIGNMENT 8
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
@ -117,6 +117,9 @@ extern void vPortClearInterruptMask( void );
|
||||||
#define portENABLE_INTERRUPTS() vPortClearInterruptMask();
|
#define portENABLE_INTERRUPTS() vPortClearInterruptMask();
|
||||||
#define portENTER_CRITICAL() vPortEnterCritical()
|
#define portENTER_CRITICAL() vPortEnterCritical()
|
||||||
#define portEXIT_CRITICAL() vPortExitCritical()
|
#define portEXIT_CRITICAL() vPortExitCritical()
|
||||||
|
#define portSET_INTERRUPT_MASK_FROM_ISR() 0;vPortSetInterruptMask()
|
||||||
|
#define portCLEAR_INTERRUPT_MASK_FROM_ISR(x) vPortClearInterruptMask()
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
/* Task function macros as described on the FreeRTOS.org WEB site. */
|
||||||
|
|
Loading…
Reference in a new issue