Prepare for V6.

This commit is contained in:
Richard Barry 2009-09-29 20:11:12 +00:00
parent b7da8d7a1b
commit 6b7397ee92

View File

@ -24,10 +24,10 @@
*************************************************************************** ***************************************************************************
* * * *
* Looking for a quick start? Then check out the FreeRTOS eBook! * * Looking for a quick start? Then check out the FreeRTOS eBook! *
* See http://www.FreeRTOS.org/Documentation for details * * See http://www.FreeRTOS.org/Documentation for details *
* * * *
*************************************************************************** ***************************************************************************
1 tab == 4 spaces! 1 tab == 4 spaces!
@ -47,10 +47,18 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
/* Defining MPU_WRAPPERS_INCLUDED_FROM_API_FILE prevents task.h from redefining
all the API functions to use the MPU wrappers. That should only be done when
task.h is included from an application file. */
#define MPU_WRAPPERS_INCLUDED_FROM_API_FILE
#include "FreeRTOS.h" #include "FreeRTOS.h"
#include "task.h" #include "task.h"
#include "croutine.h" #include "croutine.h"
#undef MPU_WRAPPERS_INCLUDED_FROM_API_FILE
/*----------------------------------------------------------- /*-----------------------------------------------------------
* PUBLIC LIST API documented in list.h * PUBLIC LIST API documented in list.h
*----------------------------------------------------------*/ *----------------------------------------------------------*/
@ -114,32 +122,32 @@ typedef xQUEUE * xQueueHandle;
* include the API header file (as it defines xQueueHandle differently). These * include the API header file (as it defines xQueueHandle differently). These
* functions are documented in the API header file. * functions are documented in the API header file.
*/ */
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ); xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ); unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
void vQueueDelete( xQueueHandle xQueue ); void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); signed portBASE_TYPE xQueueGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ); signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;
xQueueHandle xQueueCreateMutex( void ); xQueueHandle xQueueCreateMutex( void ) PRIVILEGED_FUNCTION;
xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ); xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;
portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ); portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION;
portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ); portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ); signed portBASE_TYPE xQueueAltGenericSend( xQueueHandle pxQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ); signed portBASE_TYPE xQueueAltGenericReceive( xQueueHandle pxQueue, void * const pvBuffer, portTickType xTicksToWait, portBASE_TYPE xJustPeeking ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ); signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ); signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ); unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
/* /*
* Co-routine queue functions differ from task queue functions. Co-routines are * Co-routine queue functions differ from task queue functions. Co-routines are
* an optional component. * an optional component.
*/ */
#if configUSE_CO_ROUTINES == 1 #if configUSE_CO_ROUTINES == 1
signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ); signed portBASE_TYPE xQueueCRSendFromISR( xQueueHandle pxQueue, const void *pvItemToQueue, signed portBASE_TYPE xCoRoutinePreviouslyWoken ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ); signed portBASE_TYPE xQueueCRReceiveFromISR( xQueueHandle pxQueue, void *pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ); signed portBASE_TYPE xQueueCRSend( xQueueHandle pxQueue, const void *pvItemToQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ); signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;
#endif #endif
/* /*
@ -164,8 +172,8 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
/* Removes a queue from the registry by simply setting the pcQueueName /* Removes a queue from the registry by simply setting the pcQueueName
member to NULL. */ member to NULL. */
static void vQueueUnregisterQueue( xQueueHandle xQueue ); static void vQueueUnregisterQueue( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
void vQueueAddToRegistry( xQueueHandle xQueue, signed portCHAR *pcQueueName ); void vQueueAddToRegistry( xQueueHandle xQueue, signed portCHAR *pcQueueName ) PRIVILEGED_FUNCTION;
#endif #endif
/* /*
@ -176,32 +184,32 @@ unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue
* to indicate that a task may require unblocking. When the queue in unlocked * to indicate that a task may require unblocking. When the queue in unlocked
* these lock counts are inspected, and the appropriate action taken. * these lock counts are inspected, and the appropriate action taken.
*/ */
static void prvUnlockQueue( xQueueHandle pxQueue ); static void prvUnlockQueue( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
/* /*
* Uses a critical section to determine if there is any data in a queue. * Uses a critical section to determine if there is any data in a queue.
* *
* @return pdTRUE if the queue contains no items, otherwise pdFALSE. * @return pdTRUE if the queue contains no items, otherwise pdFALSE.
*/ */
static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ); static signed portBASE_TYPE prvIsQueueEmpty( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
/* /*
* Uses a critical section to determine if there is any space in a queue. * Uses a critical section to determine if there is any space in a queue.
* *
* @return pdTRUE if there is no space, otherwise pdFALSE; * @return pdTRUE if there is no space, otherwise pdFALSE;
*/ */
static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ); static signed portBASE_TYPE prvIsQueueFull( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
/* /*
* Copies an item into the queue, either at the front of the queue or the * Copies an item into the queue, either at the front of the queue or the
* back of the queue. * back of the queue.
*/ */
static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ); static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) PRIVILEGED_FUNCTION;
/* /*
* Copies an item out of a queue. * Copies an item out of a queue.
*/ */
static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ); static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer ) PRIVILEGED_FUNCTION;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* /*
@ -264,7 +272,6 @@ size_t xQueueSizeInBytes;
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );
traceQUEUE_CREATE( pxNewQueue ); traceQUEUE_CREATE( pxNewQueue );
return pxNewQueue; return pxNewQueue;
} }
else else
@ -357,7 +364,7 @@ size_t xQueueSizeInBytes;
{ {
/* Return the mutex. This will automatically unblock any other /* Return the mutex. This will automatically unblock any other
task that might be waiting to access the mutex. */ task that might be waiting to access the mutex. */
xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK ); xQueueGenericSend( pxMutex, NULL, queueMUTEX_GIVE_BLOCK_TIME, queueSEND_TO_BACK );
} }
xReturn = pdPASS; xReturn = pdPASS;
@ -394,7 +401,7 @@ size_t xQueueSizeInBytes;
} }
else else
{ {
xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE ); xReturn = xQueueGenericReceive( pxMutex, NULL, xBlockTime, pdFALSE );
/* pdPASS will only be returned if we successfully obtained the mutex, /* pdPASS will only be returned if we successfully obtained the mutex,
we may have blocked to reach here. */ we may have blocked to reach here. */
@ -443,13 +450,12 @@ xTimeOutType xTimeOut;
/* This function relaxes the coding standard somewhat to allow return /* This function relaxes the coding standard somewhat to allow return
statements within the function itself. This is done in the interest statements within the function itself. This is done in the interest
of execution time efficiency. */ of execution time efficiency. */
for( ;; ) for( ;; )
{ {
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
/* Is there room on the queue now? To be running we must be /* Is there room on the queue now? To be running we must be
the highest priority task wanting to access the queue. */ the highest priority task wanting to access the queue. */
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
{ {
traceQUEUE_SEND( pxQueue ); traceQUEUE_SEND( pxQueue );
@ -465,11 +471,14 @@ xTimeOutType xTimeOut;
our own so yield immediately. Yes it is ok to do our own so yield immediately. Yes it is ok to do
this from within the critical section - the kernel this from within the critical section - the kernel
takes care of that. */ takes care of that. */
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
/* Return to the original privilege level before exiting the
function. */
return pdPASS; return pdPASS;
} }
else else
@ -479,6 +488,9 @@ xTimeOutType xTimeOut;
/* The queue was full and no block time is specified (or /* The queue was full and no block time is specified (or
the block time has expired) so leave now. */ the block time has expired) so leave now. */
taskEXIT_CRITICAL(); taskEXIT_CRITICAL();
/* Return to the original privilege level before exiting
the function. */
traceQUEUE_SEND_FAILED( pxQueue ); traceQUEUE_SEND_FAILED( pxQueue );
return errQUEUE_FULL; return errQUEUE_FULL;
} }
@ -521,7 +533,7 @@ xTimeOutType xTimeOut;
is also a higher priority task in the pending ready list. */ is also a higher priority task in the pending ready list. */
if( !xTaskResumeAll() ) if( !xTaskResumeAll() )
{ {
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
else else
@ -536,6 +548,9 @@ xTimeOutType xTimeOut;
/* The timeout has expired. */ /* The timeout has expired. */
prvUnlockQueue( pxQueue ); prvUnlockQueue( pxQueue );
( void ) xTaskResumeAll(); ( void ) xTaskResumeAll();
/* Return to the original privilege level before exiting the
function. */
traceQUEUE_SEND_FAILED( pxQueue ); traceQUEUE_SEND_FAILED( pxQueue );
return errQUEUE_FULL; return errQUEUE_FULL;
} }
@ -554,8 +569,8 @@ xTimeOutType xTimeOut;
{ {
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
/* Is there room on the queue now? To be running we must be /* Is there room on the queue now? To be running we must be
the highest priority task wanting to access the queue. */ the highest priority task wanting to access the queue. */
if( pxQueue->uxMessagesWaiting < pxQueue->uxLength ) if( pxQueue->uxMessagesWaiting < pxQueue->uxLength )
{ {
traceQUEUE_SEND( pxQueue ); traceQUEUE_SEND( pxQueue );
@ -569,7 +584,7 @@ xTimeOutType xTimeOut;
{ {
/* The unblocked task has a priority higher than /* The unblocked task has a priority higher than
our own so yield immediately. */ our own so yield immediately. */
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
@ -600,7 +615,7 @@ xTimeOutType xTimeOut;
{ {
traceBLOCKING_ON_QUEUE_SEND( pxQueue ); traceBLOCKING_ON_QUEUE_SEND( pxQueue );
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait ); vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToSend ), xTicksToWait );
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
else else
@ -658,7 +673,7 @@ xTimeOutType xTimeOut;
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
{ {
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
} }
@ -679,7 +694,7 @@ xTimeOutType xTimeOut;
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The task waiting has a higher priority than this task. */ /* The task waiting has a higher priority than this task. */
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
@ -725,7 +740,7 @@ xTimeOutType xTimeOut;
#endif #endif
vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait ); vTaskPlaceOnEventList( &( pxQueue->xTasksWaitingToReceive ), xTicksToWait );
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
else else
@ -810,8 +825,8 @@ signed portCHAR *pcOriginalReadPosition;
{ {
taskENTER_CRITICAL(); taskENTER_CRITICAL();
{ {
/* Is there data in the queue now? To be running we must be /* Is there data in the queue now? To be running we must be
the highest priority task wanting to access the queue. */ the highest priority task wanting to access the queue. */
if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 ) if( pxQueue->uxMessagesWaiting > ( unsigned portBASE_TYPE ) 0 )
{ {
/* Remember our read position in case we are just peeking. */ /* Remember our read position in case we are just peeking. */
@ -841,7 +856,7 @@ signed portCHAR *pcOriginalReadPosition;
{ {
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToSend ) ) == pdTRUE )
{ {
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
} }
@ -862,7 +877,7 @@ signed portCHAR *pcOriginalReadPosition;
if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE ) if( xTaskRemoveFromEventList( &( pxQueue->xTasksWaitingToReceive ) ) != pdFALSE )
{ {
/* The task waiting has a higher priority than this task. */ /* The task waiting has a higher priority than this task. */
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
@ -922,7 +937,7 @@ signed portCHAR *pcOriginalReadPosition;
prvUnlockQueue( pxQueue ); prvUnlockQueue( pxQueue );
if( !xTaskResumeAll() ) if( !xTaskResumeAll() )
{ {
taskYIELD(); portYIELD_WITHIN_API();
} }
} }
else else
@ -1035,7 +1050,7 @@ static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, port
{ {
/* The mutex is no longer being held. */ /* The mutex is no longer being held. */
vTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder ); vTaskPriorityDisinherit( ( void * ) pxQueue->pxMutexHolder );
pxQueue->pxMutexHolder = NULL; pxQueue->pxMutexHolder = NULL;
} }
} }
#endif #endif
@ -1437,6 +1452,7 @@ signed portBASE_TYPE xReturn;
break; break;
} }
} }
} }
#endif #endif