summaryrefslogtreecommitdiff
path: root/FreeRTOS/Source
diff options
context:
space:
mode:
authorrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2013-10-07 12:06:17 +0000
committerrichardbarry <richardbarry@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>2013-10-07 12:06:17 +0000
commit0a7ba424e73aa6bed19fa3fd85f5cdbc70965387 (patch)
tree4d7e5ae530171b8b6a53e864629e44036393cd54 /FreeRTOS/Source
parenta8fbde09bc009c2262d7e67d7af1ae2018cf69c1 (diff)
downloadfreertos-0a7ba424e73aa6bed19fa3fd85f5cdbc70965387.tar.gz
Clear up a few compiler warnings.
Correct header comments in the UARTCommandConsole.c file used in the SmartFusion2 demo. Exercise the new xQueueSpacesAvailable() function in the MSVC demo. Add defaults for the new traceMALLOC and traceFREE trace macros. Catch tasks trying to exit their functions in the Cortex-M0 ports. Add additional comments to timers.c in response to a support forum question. Initialise _impure_ptr prior to the first task being started. Prior to V7.5.0 a yield pended in the tick hook would have occurred during the same tick interrupt. Return pdTRUE from xTaskIncrementTick() if a yield is pending to revert to that behaviour. git-svn-id: http://svn.code.sf.net/p/freertos/code/trunk@2051 1d2547de-c912-0410-9cb9-b8ca96c0e9e2
Diffstat (limited to 'FreeRTOS/Source')
-rw-r--r--FreeRTOS/Source/include/FreeRTOS.h8
-rw-r--r--FreeRTOS/Source/portable/GCC/ARM_CM0/port.c26
-rw-r--r--FreeRTOS/Source/portable/IAR/ARM_CM0/port.c23
-rw-r--r--FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c23
-rw-r--r--FreeRTOS/Source/tasks.c57
-rw-r--r--FreeRTOS/Source/timers.c7
6 files changed, 123 insertions, 21 deletions
diff --git a/FreeRTOS/Source/include/FreeRTOS.h b/FreeRTOS/Source/include/FreeRTOS.h
index ee0a186cf..7b84e0a80 100644
--- a/FreeRTOS/Source/include/FreeRTOS.h
+++ b/FreeRTOS/Source/include/FreeRTOS.h
@@ -511,6 +511,14 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
#define traceTIMER_COMMAND_RECEIVED( pxTimer, xMessageID, xMessageValue )
#endif
+#ifndef traceMALLOC
+ #define traceMALLOC( pvAddress, uiSize )
+#endif
+
+#ifndef traceFREE
+ #define traceFREE( pvAddress, uiSize )
+#endif
+
#ifndef configGENERATE_RUN_TIME_STATS
#define configGENERATE_RUN_TIME_STATS 0
#endif
diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c
index 6966c848e..5aef176cf 100644
--- a/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c
+++ b/FreeRTOS/Source/portable/GCC/ARM_CM0/port.c
@@ -107,6 +107,11 @@ void vPortSVCHandler( void ) __attribute__ (( naked ));
*/
static void vPortStartFirstTask( void ) __attribute__ (( naked ));
+/*
+ * Used to catch tasks that attempt to return from their implementing function.
+ */
+static void prvTaskExitError( void );
+
/*-----------------------------------------------------------*/
/*
@@ -120,7 +125,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
*pxTopOfStack = portINITIAL_XPSR; /* xPSR */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
- pxTopOfStack -= 6; /* LR, R12, R3..R1 */
+ pxTopOfStack--;
+ *pxTopOfStack = ( portSTACK_TYPE ) prvTaskExitError; /* LR */
+ pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack -= 8; /* R11..R4. */
@@ -128,6 +135,20 @@ 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
+ should instead call vTaskDelete( NULL ).
+
+ 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();
+ for( ;; );
+}
+/*-----------------------------------------------------------*/
+
void vPortSVCHandler( void )
{
__asm volatile (
@@ -250,6 +271,9 @@ void vClearInterruptMaskFromISR( unsigned long ulMask )
" msr PRIMASK, r0 \n"
" bx lr "
);
+
+ /* Just to avoid compiler warning. */
+ ( void ) ulMask;
}
/*-----------------------------------------------------------*/
diff --git a/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c b/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c
index 6b3cc4162..bf5b33469 100644
--- a/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c
+++ b/FreeRTOS/Source/portable/IAR/ARM_CM0/port.c
@@ -113,6 +113,11 @@ void xPortSysTickHandler( void );
*/
extern void vPortStartFirstTask( void );
+/*
+ * Used to catch tasks that attempt to return from their implementing function.
+ */
+static void prvTaskExitError( void );
+
/*-----------------------------------------------------------*/
/*
@@ -126,7 +131,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
*pxTopOfStack = portINITIAL_XPSR; /* xPSR */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
- pxTopOfStack -= 6; /* LR, R12, R3..R1 */
+ pxTopOfStack--;
+ *pxTopOfStack = ( portSTACK_TYPE ) prvTaskExitError; /* LR */
+ pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack -= 8; /* R11..R4. */
@@ -134,6 +141,20 @@ 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
+ should instead call vTaskDelete( NULL ).
+
+ 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();
+ for( ;; );
+}
+/*-----------------------------------------------------------*/
+
/*
* See header file for description.
*/
diff --git a/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c b/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
index 2c0169f7e..86bbc7b13 100644
--- a/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
+++ b/FreeRTOS/Source/portable/RVDS/ARM_CM0/port.c
@@ -110,6 +110,11 @@ void vPortSVCHandler( void );
*/
static void prvPortStartFirstTask( void );
+/*
+ * Used to catch tasks that attempt to return from their implementing function.
+ */
+static void prvTaskExitError( void );
+
/*-----------------------------------------------------------*/
/*
@@ -123,7 +128,9 @@ portSTACK_TYPE *pxPortInitialiseStack( portSTACK_TYPE *pxTopOfStack, pdTASK_CODE
*pxTopOfStack = portINITIAL_XPSR; /* xPSR */
pxTopOfStack--;
*pxTopOfStack = ( portSTACK_TYPE ) pxCode; /* PC */
- pxTopOfStack -= 6; /* LR, R12, R3..R1 */
+ pxTopOfStack--;
+ *pxTopOfStack = ( portSTACK_TYPE ) prvTaskExitError; /* LR */
+ pxTopOfStack -= 5; /* R12, R3, R2 and R1. */
*pxTopOfStack = ( portSTACK_TYPE ) pvParameters; /* R0 */
pxTopOfStack -= 8; /* R11..R4. */
@@ -131,6 +138,20 @@ 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
+ should instead call vTaskDelete( NULL ).
+
+ 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();
+ for( ;; );
+}
+/*-----------------------------------------------------------*/
+
__asm void vPortSVCHandler( void )
{
extern pxCurrentTCB;
diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c
index 417ccd42a..359072964 100644
--- a/FreeRTOS/Source/tasks.c
+++ b/FreeRTOS/Source/tasks.c
@@ -89,7 +89,7 @@ privileged Vs unprivileged linkage and placement. */
uxTaskGetSystemState() function. Note the formatting functions are provided
for convenience only, and are NOT considered part of the kernel. */
#include <stdio.h>
-#endif /* ( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) ) */
+#endif /* configUSE_STATS_FORMATTING_FUNCTIONS == 1 ) */
/* Sanity check the configuration. */
#if configUSE_TICKLESS_IDLE != 0
@@ -1196,7 +1196,11 @@ tskTCB * pxNewTCB;
if( uxSchedulerSuspended == ( unsigned portBASE_TYPE ) pdFALSE )
{
- xYieldRequired = ( pxTCB->uxPriority >= pxCurrentTCB->uxPriority );
+ if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )
+ {
+ xYieldRequired = pdTRUE;
+ }
+
( void ) uxListRemove( &( pxTCB->xGenericListItem ) );
prvAddTaskToReadyList( pxTCB );
}
@@ -1250,12 +1254,17 @@ portBASE_TYPE xReturn;
before or during the call to xPortStartScheduler(). The stacks of
the created tasks contain a status word with interrupts switched on
so interrupts will automatically get re-enabled when the first task
- starts to run.
-
- STEPPING THROUGH HERE USING A DEBUGGER CAN CAUSE BIG PROBLEMS IF THE
- DEBUGGER ALLOWS INTERRUPTS TO BE PROCESSED. */
+ starts to run. */
portDISABLE_INTERRUPTS();
+ #if ( configUSE_NEWLIB_REENTRANT == 1 )
+ {
+ /* Switch Newlib's _impure_ptr variable to point to the _reent
+ structure specific to the task that will run first. */
+ _impure_ptr = &( pxCurrentTCB->xNewLib_reent );
+ }
+ #endif /* configUSE_NEWLIB_REENTRANT */
+
xSchedulerRunning = pdTRUE;
xTickCount = ( portTickType ) 0U;
@@ -1337,7 +1346,6 @@ signed portBASE_TYPE xTaskResumeAll( void )
{
tskTCB *pxTCB;
portBASE_TYPE xAlreadyYielded = pdFALSE;
-portBASE_TYPE xYieldRequired = pdFALSE;
/* If uxSchedulerSuspended is zero then this function does not match a
previous call to vTaskSuspendAll(). */
@@ -1369,7 +1377,7 @@ portBASE_TYPE xYieldRequired = pdFALSE;
the current task then we should yield. */
if( pxTCB->uxPriority >= pxCurrentTCB->uxPriority )
{
- xYieldRequired = pdTRUE;
+ xYieldPending = pdTRUE;
}
}
@@ -1382,16 +1390,15 @@ portBASE_TYPE xYieldRequired = pdFALSE;
{
if( xTaskIncrementTick() != pdFALSE )
{
- xYieldRequired = pdTRUE;
+ xYieldPending = pdTRUE;
}
--uxPendedTicks;
}
}
- if( ( xYieldRequired == pdTRUE ) || ( xYieldPending == pdTRUE ) )
+ if( xYieldPending == pdTRUE )
{
xAlreadyYielded = pdTRUE;
- xYieldPending = pdFALSE;
portYIELD_WITHIN_API();
}
}
@@ -1519,7 +1526,7 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
portALT_GET_RUN_TIME_COUNTER_VALUE( ( *pulTotalRunTime ) );
#else
*pulTotalRunTime = portGET_RUN_TIME_COUNTER_VALUE();
- #endif
+ #endif
}
}
#else
@@ -1678,6 +1685,17 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
}
}
#endif /* ( ( configUSE_PREEMPTION == 1 ) && ( configUSE_TIME_SLICING == 1 ) ) */
+
+ #if ( configUSE_TICK_HOOK == 1 )
+ {
+ /* Guard against the tick hook being called when the pended tick
+ count is being unwound (when the scheduler is being unlocked). */
+ if( uxPendedTicks == ( unsigned portBASE_TYPE ) 0U )
+ {
+ vApplicationTickHook();
+ }
+ }
+ #endif /* configUSE_TICK_HOOK */
}
else
{
@@ -1692,16 +1710,14 @@ portBASE_TYPE xSwitchRequired = pdFALSE;
#endif
}
- #if ( configUSE_TICK_HOOK == 1 )
+ #if ( configUSE_PREEMPTION == 1 )
{
- /* Guard against the tick hook being called when the missed tick
- count is being unwound (when the scheduler is being unlocked). */
- if( uxPendedTicks == ( unsigned portBASE_TYPE ) 0U )
+ if( xYieldPending != pdFALSE )
{
- vApplicationTickHook();
+ xSwitchRequired = pdTRUE;
}
}
- #endif /* configUSE_TICK_HOOK */
+ #endif /* configUSE_PREEMPTION */
return xSwitchRequired;
}
@@ -1804,6 +1820,7 @@ void vTaskSwitchContext( void )
}
else
{
+ xYieldPending = pdFALSE;
traceTASK_SWITCHED_OUT();
#if ( configGENERATE_RUN_TIME_STATS == 1 )
@@ -1981,6 +1998,10 @@ portBASE_TYPE xReturn;
the calling task to know if it should force a context
switch now. */
xReturn = pdTRUE;
+
+ /* Mark that a yield is pending in case the user is not using the
+ "xHigherPriorityTaskWoken" parameter to an ISR safe FreeRTOS function. */
+ xYieldPending = pdTRUE;
}
else
{
diff --git a/FreeRTOS/Source/timers.c b/FreeRTOS/Source/timers.c
index 0414604f1..f9f50b4bd 100644
--- a/FreeRTOS/Source/timers.c
+++ b/FreeRTOS/Source/timers.c
@@ -569,6 +569,13 @@ portTickType xTimeNow;
case tmrCOMMAND_CHANGE_PERIOD :
pxTimer->xTimerPeriodInTicks = xMessage.xMessageValue;
configASSERT( ( pxTimer->xTimerPeriodInTicks > 0 ) );
+
+ /* The new period does not really have a reference, and can be
+ longer or shorter than the old one. The command time is
+ therefore set to the current time, and as the period cannot be
+ zero the next expiry time can only be in the future, meaning
+ (unlike for the xTimerStart() case above) there is no fail case
+ that needs to be handled here. */
( void ) prvInsertTimerInActiveList( pxTimer, ( xTimeNow + pxTimer->xTimerPeriodInTicks ), xTimeNow, xTimeNow );
break;