From 5190fea1bb27f51ef8d8757ef043be9e366a5c0f Mon Sep 17 00:00:00 2001 From: richardbarry Date: Thu, 7 Nov 2013 16:43:54 +0000 Subject: [PATCH] Ensure the definition of prvTaskExitError()does not result in a compiler warning in ports where its use can be overridden (GCC Cortex-M ports). Remove duplicate save/restore of r14 in Cortex-M4F ports. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2089 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- FreeRTOS/Source/portable/GCC/ARM_CM0/port.c | 6 ++++ FreeRTOS/Source/portable/GCC/ARM_CM3/port.c | 30 +++++++++------- FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c | 22 +++++++----- .../Source/portable/IAR/ARM_CM4F/portasm.s | 6 ++-- FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c | 36 +++++++++---------- .../portable/Tasking/ARM_CM4F/port_asm.asm | 12 +++---- 6 files changed, 65 insertions(+), 47 deletions(-) diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c index 0f99dd5f9..e638d2898 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c @@ -208,6 +208,12 @@ portBASE_TYPE xPortStartScheduler( void ) /* Start the first task. */ vPortStartFirstTask(); + + /* Should never get here as the tasks will now be executing! Call the task + exit error function to prevent compiler warnings about a static function + not being called in the case that the application writer overrides this + functionality by defining configTASK_RETURN_ADDRESS. */ + prvTaskExitError(); /* Should not get here! */ return 0; diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c index ed15b927c..3967a6a88 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM3/port.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -218,13 +218,13 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE static void prvTaskExitError( void ) { /* A function that implements a task must not exit or attempt to return to - its caller as there is nothing to return to. If a task wants to exit it + its caller as there is nothing to return to. If a task wants to exit it should instead call vTaskDelete( NULL ). - - Artificially force an assert() to be triggered if configASSERT() is + + Artificially force an assert() to be triggered if configASSERT() is defined, then stop here so application writers can catch the error. */ configASSERT( uxCriticalNesting == ~0UL ); - portDISABLE_INTERRUPTS(); + portDISABLE_INTERRUPTS(); for( ;; ); } /*-----------------------------------------------------------*/ @@ -329,6 +329,12 @@ portBASE_TYPE xPortStartScheduler( void ) /* Start the first task. */ prvPortStartFirstTask(); + /* Should never get here as the tasks will now be executing! Call the task + exit error function to prevent compiler warnings about a static function + not being called in the case that the application writer overrides this + functionality by defining configTASK_RETURN_ADDRESS. */ + prvTaskExitError(); + /* Should not get here! */ return 0; } @@ -497,10 +503,10 @@ void xPortSysTickHandler( void ) /* Restart from whatever is left in the count register to complete this tick period. */ portNVIC_SYSTICK_LOAD_REG = portNVIC_SYSTICK_CURRENT_VALUE_REG; - + /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - + /* Reset the reload register to the value required for normal tick periods. */ portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL; @@ -549,23 +555,23 @@ void xPortSysTickHandler( void ) if( ( portNVIC_SYSTICK_CTRL_REG & portNVIC_SYSTICK_COUNT_FLAG_BIT ) != 0 ) { unsigned long ulCalculatedLoadValue; - + /* The tick interrupt has already executed, and the SysTick count reloaded with ulReloadValue. Reset the portNVIC_SYSTICK_LOAD_REG with whatever remains of this tick period. */ ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ) - ( ulReloadValue - portNVIC_SYSTICK_CURRENT_VALUE_REG ); - /* Don't allow a tiny value, or values that have somehow - underflowed because the post sleep hook did something + /* Don't allow a tiny value, or values that have somehow + underflowed because the post sleep hook did something that took too long. */ if( ( ulCalculatedLoadValue < ulStoppedTimerCompensation ) || ( ulCalculatedLoadValue > ulTimerCountsForOneTick ) ) { ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ); } - + portNVIC_SYSTICK_LOAD_REG = ulCalculatedLoadValue; - + /* The tick interrupt handler will already have pended the tick processing in the kernel. As the pending tick will be processed as soon as this function exits, the tick value diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c index 852a6bc7a..6069cdcb8 100644 --- a/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -353,6 +353,12 @@ portBASE_TYPE xPortStartScheduler( void ) /* Start the first task. */ prvPortStartFirstTask(); + /* Should never get here as the tasks will now be executing! Call the task + exit error function to prevent compiler warnings about a static function + not being called in the case that the application writer overrides this + functionality by defining configTASK_RETURN_ADDRESS. */ + prvTaskExitError(); + /* Should not get here! */ return 0; } @@ -446,13 +452,13 @@ void xPortPendSVHandler( void ) " \n" " str r0, [r2] \n" /* Save the new top of stack into the first member of the TCB. */ " \n" - " stmdb sp!, {r3, r14} \n" + " stmdb sp!, {r3} \n" " mov r0, %0 \n" " msr basepri, r0 \n" " bl vTaskSwitchContext \n" " mov r0, #0 \n" " msr basepri, r0 \n" - " ldmia sp!, {r3, r14} \n" + " ldmia sp!, {r3} \n" " \n" " ldr r1, [r3] \n" /* The first item in pxCurrentTCB is the task top of stack. */ " ldr r0, [r1] \n" @@ -592,23 +598,23 @@ void xPortSysTickHandler( void ) if( ( portNVIC_SYSTICK_CTRL_REG & portNVIC_SYSTICK_COUNT_FLAG_BIT ) != 0 ) { unsigned long ulCalculatedLoadValue; - + /* The tick interrupt has already executed, and the SysTick count reloaded with ulReloadValue. Reset the portNVIC_SYSTICK_LOAD_REG with whatever remains of this tick period. */ ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ) - ( ulReloadValue - portNVIC_SYSTICK_CURRENT_VALUE_REG ); - /* Don't allow a tiny value, or values that have somehow - underflowed because the post sleep hook did something + /* Don't allow a tiny value, or values that have somehow + underflowed because the post sleep hook did something that took too long. */ if( ( ulCalculatedLoadValue < ulStoppedTimerCompensation ) || ( ulCalculatedLoadValue > ulTimerCountsForOneTick ) ) { ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ); } - + portNVIC_SYSTICK_LOAD_REG = ulCalculatedLoadValue; - + /* The tick interrupt handler will already have pended the tick processing in the kernel. As the pending tick will be processed as soon as this function exits, the tick value diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s b/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s index 862ea15ac..4e5ed520d 100644 --- a/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s +++ b/FreeRTOS/Source/portable/IAR/ARM_CM4F/portasm.s @@ -1,5 +1,5 @@ /* - FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -99,13 +99,13 @@ xPortPendSVHandler: /* Save the new top of stack into the first member of the TCB. */ str r0, [r2] - stmdb sp!, {r3, r14} + stmdb sp!, {r3} mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY msr basepri, r0 bl vTaskSwitchContext mov r0, #0 msr basepri, r0 - ldmia sp!, {r3, r14} + ldmia sp!, {r3} /* The first item in pxCurrentTCB is the task top of stack. */ ldr r1, [r3] diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c index 845bbcc53..09f284b23 100644 --- a/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c +++ b/FreeRTOS/Source/portable/RVDS/ARM_CM4F/port.c @@ -1,5 +1,5 @@ /* - FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. + FreeRTOS V7.5.3 - Copyright (C) 2013 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -196,7 +196,7 @@ static void prvTaskExitError( void ); #endif /* configUSE_TICKLESS_IDLE */ /* - * Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure + * Used by the portASSERT_IF_INTERRUPT_PRIORITY_INVALID() macro to ensure * FreeRTOS API functions are not called from interrupts that have been assigned * a priority above configMAX_SYSCALL_INTERRUPT_PRIORITY. */ @@ -244,13 +244,13 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE static void prvTaskExitError( void ) { /* A function that implements a task must not exit or attempt to return to - its caller as there is nothing to return to. If a task wants to exit it + its caller as there is nothing to return to. If a task wants to exit it should instead call vTaskDelete( NULL ). - - Artificially force an assert() to be triggered if configASSERT() is + + Artificially force an assert() to be triggered if configASSERT() is defined, then stop here so application writers can catch the error. */ configASSERT( uxCriticalNesting == ~0UL ); - portDISABLE_INTERRUPTS(); + portDISABLE_INTERRUPTS(); for( ;; ); } /*-----------------------------------------------------------*/ @@ -443,13 +443,13 @@ __asm void xPortPendSVHandler( void ) /* Save the new top of stack into the first member of the TCB. */ str r0, [r2] - stmdb sp!, {r3, r14} + stmdb sp!, {r3} mov r0, #configMAX_SYSCALL_INTERRUPT_PRIORITY msr basepri, r0 bl vTaskSwitchContext mov r0, #0 msr basepri, r0 - ldmia sp!, {r3, r14} + ldmia sp!, {r3} /* The first item in pxCurrentTCB is the task top of stack. */ ldr r1, [r3] @@ -465,14 +465,14 @@ __asm void xPortPendSVHandler( void ) vldmiaeq r0!, {s16-s31} msr psp, r0 - + #ifdef WORKAROUND_PMU_CM001 /* XMC4000 specific errata */ #if WORKAROUND_PMU_CM001 == 1 push { r14 } pop { pc } #endif #endif - + bx r14 nop } @@ -537,10 +537,10 @@ void xPortSysTickHandler( void ) /* Restart from whatever is left in the count register to complete this tick period. */ portNVIC_SYSTICK_LOAD_REG = portNVIC_SYSTICK_CURRENT_VALUE_REG; - + /* Restart SysTick. */ portNVIC_SYSTICK_CTRL_REG = portNVIC_SYSTICK_CLK_BIT | portNVIC_SYSTICK_INT_BIT | portNVIC_SYSTICK_ENABLE_BIT; - + /* Reset the reload register to the value required for normal tick periods. */ portNVIC_SYSTICK_LOAD_REG = ulTimerCountsForOneTick - 1UL; @@ -589,23 +589,23 @@ void xPortSysTickHandler( void ) if( ( portNVIC_SYSTICK_CTRL_REG & portNVIC_SYSTICK_COUNT_FLAG_BIT ) != 0 ) { unsigned long ulCalculatedLoadValue; - + /* The tick interrupt has already executed, and the SysTick count reloaded with ulReloadValue. Reset the portNVIC_SYSTICK_LOAD_REG with whatever remains of this tick period. */ ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ) - ( ulReloadValue - portNVIC_SYSTICK_CURRENT_VALUE_REG ); - /* Don't allow a tiny value, or values that have somehow - underflowed because the post sleep hook did something + /* Don't allow a tiny value, or values that have somehow + underflowed because the post sleep hook did something that took too long. */ if( ( ulCalculatedLoadValue < ulStoppedTimerCompensation ) || ( ulCalculatedLoadValue > ulTimerCountsForOneTick ) ) { ulCalculatedLoadValue = ( ulTimerCountsForOneTick - 1UL ); } - + portNVIC_SYSTICK_LOAD_REG = ulCalculatedLoadValue; - + /* The tick interrupt handler will already have pended the tick processing in the kernel. As the pending tick will be processed as soon as this function exits, the tick value @@ -698,7 +698,7 @@ __asm void vPortClearInterruptMask( unsigned long ulNewMask ) __asm unsigned long vPortGetIPSR( void ) { PRESERVE8 - + mrs r0, ipsr bx r14 } diff --git a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm index 9d9c42074..87cba440b 100644 --- a/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm +++ b/FreeRTOS/Source/portable/Tasking/ARM_CM4F/port_asm.asm @@ -64,7 +64,7 @@ .global vPortEnableVFP .global ulPortSetInterruptMask .global vPortClearInterruptMask - + ;----------------------------------------------------------- .section .text @@ -89,13 +89,13 @@ _vector_14: .type func ;Save the new top of stack into the first member of the TCB. str r0, [r2] - stmdb sp!, {r3, r14} + stmdb sp!, {r3} ldr.w r0, =ulMaxSyscallInterruptPriorityConst msr basepri, r0 bl vTaskSwitchContext mov r0, #0 msr basepri, r0 - ldmia sp!, {r3, r14} + ldmia sp!, {r3} ;The first item in pxCurrentTCB is the task top of stack. ldr r1, [r3] @@ -141,13 +141,13 @@ _lc_ref__vector_pp_14: .type func ;Save the new top of stack into the first member of the TCB. str r0, [r2] - stmdb sp!, {r3, r14} + stmdb sp!, {r3} ldr.w r0, =ulMaxSyscallInterruptPriorityConst msr basepri, r0 bl vTaskSwitchContext mov r0, #0 msr basepri, r0 - ldmia sp!, {r3, r14} + ldmia sp!, {r3} ;The first item in pxCurrentTCB is the task top of stack. ldr r1, [r3] @@ -249,4 +249,4 @@ vPortClearInterruptMask: ;----------------------------------------------------------- .end - + -- 2.39.5