Update core files to remove legacy trace and make necessary modifications to facilitate use with other trace tools.

This commit is contained in:
Richard Barry 2011-11-29 19:02:58 +00:00
parent 022bc78961
commit 7daebd9275
6 changed files with 160 additions and 114 deletions

View File

@ -272,6 +272,23 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
#define traceTASK_SWITCHED_OUT() #define traceTASK_SWITCHED_OUT()
#endif #endif
#ifndef traceTASK_PRIORITY_INHERIT
/* Called when a task attempts to take a mutex that is already held by a
lower priority task. pxTCBOfMutexHolder is a pointer to the TCB of the task
that holds the mutex. uxInheritedPriority is the priority the mutex holder
will inherit (the priority of the task that is attempting to obtain the
muted. */
#define traceTASK_PRIORITY_INHERIT( pxTCBOfMutexHolder, uxInheritedPriority )
#endif
#ifndef traceTASK_PRIORITY_DISINHERIT
/* Called when a task releases a mutex, the holding of which had resulted in
the task inheriting the priority of a higher priority task.
pxTCBOfMutexHolder is a pointer to the TCB of the task that is releasing the
mutex. uxOriginalPriority is the task's configured (base) priority. */
#define traceTASK_PRIORITY_DISINHERIT( pxTCBOfMutexHolder, uxOriginalPriority )
#endif
#ifndef traceBLOCKING_ON_QUEUE_RECEIVE #ifndef traceBLOCKING_ON_QUEUE_RECEIVE
/* Task is about to block because it cannot read from a /* Task is about to block because it cannot read from a
queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore queue/mutex/semaphore. pxQueue is a pointer to the queue/mutex/semaphore
@ -299,7 +316,7 @@ typedef portBASE_TYPE (*pdTASK_HOOK_CODE)( void * );
#endif #endif
#ifndef traceQUEUE_CREATE_FAILED #ifndef traceQUEUE_CREATE_FAILED
#define traceQUEUE_CREATE_FAILED() #define traceQUEUE_CREATE_FAILED( ucQueueType )
#endif #endif
#ifndef traceCREATE_MUTEX #ifndef traceCREATE_MUTEX

View File

@ -78,6 +78,12 @@ typedef void * xQueueHandle;
#define queueSEND_TO_BACK ( 0 ) #define queueSEND_TO_BACK ( 0 )
#define queueSEND_TO_FRONT ( 1 ) #define queueSEND_TO_FRONT ( 1 )
/* For internal use only. These definitions *must* match those in queue.c. */
#define queueQUEUE_TYPE_BASE ( 0U )
#define queueQUEUE_TYPE_MUTEX ( 1U )
#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( 2U )
#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( 3U )
#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( 4U )
/** /**
* queue. h * queue. h
@ -135,7 +141,7 @@ typedef void * xQueueHandle;
* \defgroup xQueueCreate xQueueCreate * \defgroup xQueueCreate xQueueCreate
* \ingroup QueueManagement * \ingroup QueueManagement
*/ */
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ); #define xQueueCreate( uxQueueLength, uxItemSize ) xQueueGenericCreate( uxQueueLength, uxItemSize, queueQUEUE_TYPE_BASE )
/** /**
* queue. h * queue. h
@ -1218,7 +1224,7 @@ signed portBASE_TYPE xQueueCRReceive( xQueueHandle pxQueue, void *pvBuffer, port
* For internal use only. Use xSemaphoreCreateMutex() or * For internal use only. Use xSemaphoreCreateMutex() or
* xSemaphoreCreateCounting() instead of calling these functions directly. * xSemaphoreCreateCounting() instead of calling these functions directly.
*/ */
xQueueHandle xQueueCreateMutex( void ); xQueueHandle xQueueCreateMutex( unsigned char ucQueueType );
xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ); xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount );
/* /*
@ -1252,7 +1258,15 @@ portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle pxMutex );
void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName ); void vQueueAddToRegistry( xQueueHandle xQueue, signed char *pcName );
#endif #endif
/* Not a public API function, hence the 'Restricted' in the name. */ /*
* Generic version of the queue creation function, which is in turn called by
* any queue, semaphore or mutex creation function or macro.
*/
xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType );
/*
* Not a public API function, hence the 'Restricted' in the name.
*/
void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ); void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait );

View File

@ -105,13 +105,14 @@ typedef xQueueHandle xSemaphoreHandle;
* \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary * \defgroup vSemaphoreCreateBinary vSemaphoreCreateBinary
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define vSemaphoreCreateBinary( xSemaphore ) { \ #define vSemaphoreCreateBinary( xSemaphore ) \
( xSemaphore ) = xQueueCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH ); \ { \
if( ( xSemaphore ) != NULL ) \ ( xSemaphore ) = xQueueGenericCreate( ( unsigned portBASE_TYPE ) 1, semSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_BINARY_SEMAPHORE ); \
{ \ if( ( xSemaphore ) != NULL ) \
xSemaphoreGive( ( xSemaphore ) ); \ { \
} \ xSemaphoreGive( ( xSemaphore ) ); \
} } \
}
/** /**
* semphr. h * semphr. h
@ -585,7 +586,7 @@ typedef xQueueHandle xSemaphoreHandle;
* \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreCreateMutex() xQueueCreateMutex() #define xSemaphoreCreateMutex() xQueueCreateMutex( queueQUEUE_TYPE_MUTEX )
/** /**
@ -640,7 +641,7 @@ typedef xQueueHandle xSemaphoreHandle;
* \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex * \defgroup vSemaphoreCreateMutex vSemaphoreCreateMutex
* \ingroup Semaphores * \ingroup Semaphores
*/ */
#define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex() #define xSemaphoreCreateRecursiveMutex() xQueueCreateMutex( queueQUEUE_TYPE_RECURSIVE_MUTEX )
/** /**
* semphr. h * semphr. h

View File

@ -1301,6 +1301,18 @@ void vTaskPriorityDisinherit( xTaskHandle * const pxMutexHolder ) PRIVILEGED_FUN
*/ */
signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xTaskGenericCreate( pdTASK_CODE pxTaskCode, const signed char * const pcName, unsigned short usStackDepth, void *pvParameters, unsigned portBASE_TYPE uxPriority, xTaskHandle *pxCreatedTask, portSTACK_TYPE *puxStackBuffer, const xMemoryRegion * const xRegions ) PRIVILEGED_FUNCTION;
/*
* Get the uxTCBNumber assigned to the task referenced by the xTask parameter.
*/
unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask );
/*
* Set the uxTCBNumber of the task referenced by the xTask parameter to
* ucHandle.
*/
void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle );
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View File

@ -94,6 +94,13 @@ zero. */
#define queueDONT_BLOCK ( ( portTickType ) 0U ) #define queueDONT_BLOCK ( ( portTickType ) 0U )
#define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0U ) #define queueMUTEX_GIVE_BLOCK_TIME ( ( portTickType ) 0U )
/* These definitions *must* match those in queue.h. */
#define queueQUEUE_TYPE_BASE ( 0U )
#define queueQUEUE_TYPE_MUTEX ( 1U )
#define queueQUEUE_TYPE_COUNTING_SEMAPHORE ( 2U )
#define queueQUEUE_TYPE_BINARY_SEMAPHORE ( 3U )
#define queueQUEUE_TYPE_RECURSIVE_MUTEX ( 4U )
/* /*
* Definition of the queue used by the scheduler. * Definition of the queue used by the scheduler.
* Items are queued by copy, not reference. * Items are queued by copy, not reference.
@ -115,6 +122,11 @@ typedef struct QueueDefinition
signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ signed portBASE_TYPE xRxLock; /*< Stores the number of items received from the queue (removed from the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */ signed portBASE_TYPE xTxLock; /*< Stores the number of items transmitted to the queue (added to the queue) while the queue was locked. Set to queueUNLOCKED when the queue is not locked. */
#if ( configUSE_TRACE_FACILITY == 1 )
unsigned char ucQueueNumber;
unsigned char ucQueueType;
#endif
} xQUEUE; } xQUEUE;
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -131,14 +143,14 @@ 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 ) PRIVILEGED_FUNCTION; xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueueGenericSend( xQueueHandle xQueue, const void * const pvItemToQueue, portTickType xTicksToWait, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION;
unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; unsigned portBASE_TYPE uxQueueMessagesWaiting( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION; void vQueueDelete( xQueueHandle xQueue ) PRIVILEGED_FUNCTION;
signed portBASE_TYPE xQueueGenericSendFromISR( xQueueHandle pxQueue, const void * const pvItemToQueue, signed portBASE_TYPE *pxHigherPriorityTaskWoken, portBASE_TYPE xCopyPosition ) PRIVILEGED_FUNCTION; 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 ) PRIVILEGED_FUNCTION; 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 ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueueReceiveFromISR( xQueueHandle pxQueue, void * const pvBuffer, signed portBASE_TYPE *pxTaskWoken ) PRIVILEGED_FUNCTION;
xQueueHandle xQueueCreateMutex( void ) PRIVILEGED_FUNCTION; xQueueHandle xQueueCreateMutex( unsigned char ucQueueType ) PRIVILEGED_FUNCTION;
xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION; xQueueHandle xQueueCreateCountingSemaphore( unsigned portBASE_TYPE uxCountValue, unsigned portBASE_TYPE uxInitialCount ) PRIVILEGED_FUNCTION;
portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION; portBASE_TYPE xQueueTakeMutexRecursive( xQueueHandle xMutex, portTickType xBlockTime ) PRIVILEGED_FUNCTION;
portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION; portBASE_TYPE xQueueGiveMutexRecursive( xQueueHandle xMutex ) PRIVILEGED_FUNCTION;
@ -148,6 +160,8 @@ signed portBASE_TYPE xQueueIsQueueEmptyFromISR( const xQueueHandle pxQueue ) PRI
signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; signed portBASE_TYPE xQueueIsQueueFullFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION; unsigned portBASE_TYPE uxQueueMessagesWaitingFromISR( const xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION; void vQueueWaitForMessageRestricted( xQueueHandle pxQueue, portTickType xTicksToWait ) PRIVILEGED_FUNCTION;
unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue ) PRIVILEGED_FUNCTION;
unsigned char ucQueueGetQueueType( 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
@ -246,12 +260,16 @@ static void prvCopyDataFromQueue( xQUEUE * const pxQueue, const void *pvBuffer )
* PUBLIC QUEUE MANAGEMENT API documented in queue.h * PUBLIC QUEUE MANAGEMENT API documented in queue.h
*----------------------------------------------------------*/ *----------------------------------------------------------*/
xQueueHandle xQueueCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize ) xQueueHandle xQueueGenericCreate( unsigned portBASE_TYPE uxQueueLength, unsigned portBASE_TYPE uxItemSize, unsigned char ucQueueType )
{ {
xQUEUE *pxNewQueue; xQUEUE *pxNewQueue;
size_t xQueueSizeInBytes; size_t xQueueSizeInBytes;
xQueueHandle xReturn = NULL; xQueueHandle xReturn = NULL;
/* Remove compiler warnings about unused parameters should
configUSE_TRACE_FACILITY not be set to 1. */
( void ) ucQueueType;
/* Allocate the new queue structure. */ /* Allocate the new queue structure. */
if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 ) if( uxQueueLength > ( unsigned portBASE_TYPE ) 0 )
{ {
@ -275,6 +293,11 @@ xQueueHandle xReturn = NULL;
pxNewQueue->uxItemSize = uxItemSize; pxNewQueue->uxItemSize = uxItemSize;
pxNewQueue->xRxLock = queueUNLOCKED; pxNewQueue->xRxLock = queueUNLOCKED;
pxNewQueue->xTxLock = queueUNLOCKED; pxNewQueue->xTxLock = queueUNLOCKED;
#if ( configUSE_TRACE_FACILITY == 1 )
{
pxNewQueue->ucQueueType = ucQueueType;
}
#endif /* configUSE_TRACE_FACILITY */
/* Likewise ensure the event queues start with the correct state. */ /* Likewise ensure the event queues start with the correct state. */
vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
@ -285,7 +308,7 @@ xQueueHandle xReturn = NULL;
} }
else else
{ {
traceQUEUE_CREATE_FAILED(); traceQUEUE_CREATE_FAILED( ucQueueType );
vPortFree( pxNewQueue ); vPortFree( pxNewQueue );
} }
} }
@ -299,10 +322,14 @@ xQueueHandle xReturn = NULL;
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
xQueueHandle xQueueCreateMutex( void ) xQueueHandle xQueueCreateMutex( unsigned char ucQueueType )
{ {
xQUEUE *pxNewQueue; xQUEUE *pxNewQueue;
/* Prevent compiler warnings about unused parameters if
configUSE_TRACE_FACILITY does not equal 1. */
( void ) ucQueueType;
/* Allocate the new queue structure. */ /* Allocate the new queue structure. */
pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) ); pxNewQueue = ( xQUEUE * ) pvPortMalloc( sizeof( xQUEUE ) );
if( pxNewQueue != NULL ) if( pxNewQueue != NULL )
@ -324,15 +351,21 @@ xQueueHandle xReturn = NULL;
pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U; pxNewQueue->uxItemSize = ( unsigned portBASE_TYPE ) 0U;
pxNewQueue->xRxLock = queueUNLOCKED; pxNewQueue->xRxLock = queueUNLOCKED;
pxNewQueue->xTxLock = queueUNLOCKED; pxNewQueue->xTxLock = queueUNLOCKED;
#if ( configUSE_TRACE_FACILITY == 1 )
{
pxNewQueue->ucQueueType = ucQueueType;
}
#endif
/* Ensure the event queues start with the correct state. */ /* Ensure the event queues start with the correct state. */
vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) ); vListInitialise( &( pxNewQueue->xTasksWaitingToSend ) );
vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) ); vListInitialise( &( pxNewQueue->xTasksWaitingToReceive ) );
traceCREATE_MUTEX( pxNewQueue );
/* Start with the semaphore in the expected state. */ /* Start with the semaphore in the expected state. */
xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK ); xQueueGenericSend( pxNewQueue, NULL, ( portTickType ) 0U, queueSEND_TO_BACK );
traceCREATE_MUTEX( pxNewQueue );
} }
else else
{ {
@ -441,7 +474,7 @@ xQueueHandle xReturn = NULL;
{ {
xQueueHandle pxHandle; xQueueHandle pxHandle;
pxHandle = xQueueCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH ); pxHandle = xQueueGenericCreate( ( unsigned portBASE_TYPE ) uxCountValue, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
if( pxHandle != NULL ) if( pxHandle != NULL )
{ {
@ -1085,6 +1118,26 @@ void vQueueDelete( xQueueHandle pxQueue )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
unsigned char ucQueueGetQueueNumber( xQueueHandle pxQueue )
{
return pxQueue->ucQueueNumber;
}
#endif
/*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
unsigned char ucQueueGetQueueType( xQueueHandle pxQueue )
{
return pxQueue->ucQueueType;
}
#endif
/*-----------------------------------------------------------*/
static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition ) static void prvCopyDataToQueue( xQUEUE *pxQueue, const void *pvItemToQueue, portBASE_TYPE xPosition )
{ {
if( pxQueue->uxItemSize == ( unsigned portBASE_TYPE ) 0 ) if( pxQueue->uxItemSize == ( unsigned portBASE_TYPE ) 0 )

View File

@ -194,58 +194,6 @@ PRIVILEGED_DATA static portTickType xNextTaskUnblockTime = ( portTickType )
#define tskDELETED_CHAR ( ( signed char ) 'D' ) #define tskDELETED_CHAR ( ( signed char ) 'D' )
#define tskSUSPENDED_CHAR ( ( signed char ) 'S' ) #define tskSUSPENDED_CHAR ( ( signed char ) 'S' )
/*
* Macros and private variables used by the trace facility.
*/
#if ( configUSE_TRACE_FACILITY == 1 )
#define tskSIZE_OF_EACH_TRACE_LINE ( ( unsigned long ) ( sizeof( unsigned long ) + sizeof( unsigned long ) ) )
PRIVILEGED_DATA static volatile signed char * volatile pcTraceBuffer;
PRIVILEGED_DATA static signed char *pcTraceBufferStart;
PRIVILEGED_DATA static signed char *pcTraceBufferEnd;
PRIVILEGED_DATA static signed portBASE_TYPE xTracing = pdFALSE;
static unsigned portBASE_TYPE uxPreviousTask = 255U;
PRIVILEGED_DATA static char pcStatusString[ 50 ];
#endif
/*-----------------------------------------------------------*/
/*
* Macro that writes a trace of scheduler activity to a buffer. This trace
* shows which task is running when and is very useful as a debugging tool.
* As this macro is called each context switch it is a good idea to undefine
* it if not using the facility.
*/
#if ( configUSE_TRACE_FACILITY == 1 )
#define vWriteTraceToBuffer() \
{ \
if( xTracing != pdFALSE ) \
{ \
if( uxPreviousTask != pxCurrentTCB->uxTCBNumber ) \
{ \
if( ( pcTraceBuffer + tskSIZE_OF_EACH_TRACE_LINE ) < pcTraceBufferEnd ) \
{ \
uxPreviousTask = pxCurrentTCB->uxTCBNumber; \
*( unsigned long * ) pcTraceBuffer = ( unsigned long ) xTickCount; \
pcTraceBuffer += sizeof( unsigned long ); \
*( unsigned long * ) pcTraceBuffer = ( unsigned long ) uxPreviousTask; \
pcTraceBuffer += sizeof( unsigned long ); \
} \
else \
{ \
xTracing = pdFALSE; \
} \
} \
} \
}
#else
#define vWriteTraceToBuffer()
#endif
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* /*
@ -818,7 +766,7 @@ tskTCB * pxNewTCB;
priority of the calling function. */ priority of the calling function. */
pxTCB = prvGetTCBFromHandle( pxTask ); pxTCB = prvGetTCBFromHandle( pxTask );
traceTASK_PRIORITY_SET( pxTask, uxNewPriority ); traceTASK_PRIORITY_SET( pxTCB, uxNewPriority );
#if ( configUSE_MUTEXES == 1 ) #if ( configUSE_MUTEXES == 1 )
{ {
@ -1450,44 +1398,6 @@ unsigned portBASE_TYPE uxTaskGetNumberOfTasks( void )
#endif #endif
/*----------------------------------------------------------*/ /*----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
void vTaskStartTrace( signed char * pcBuffer, unsigned long ulBufferSize )
{
configASSERT( pcBuffer );
configASSERT( ulBufferSize );
taskENTER_CRITICAL();
{
pcTraceBuffer = ( signed char * )pcBuffer;
pcTraceBufferStart = pcBuffer;
pcTraceBufferEnd = pcBuffer + ( ulBufferSize - tskSIZE_OF_EACH_TRACE_LINE );
xTracing = pdTRUE;
}
taskEXIT_CRITICAL();
}
#endif
/*----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
unsigned long ulTaskEndTrace( void )
{
unsigned long ulBufferLength;
taskENTER_CRITICAL();
xTracing = pdFALSE;
taskEXIT_CRITICAL();
ulBufferLength = ( unsigned long ) ( pcTraceBuffer - pcTraceBufferStart );
return ulBufferLength;
}
#endif
/*----------------------------------------------------------*/
#if ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) #if ( INCLUDE_xTaskGetIdleTaskHandle == 1 )
xTaskHandle xTaskGetIdleTaskHandle( void ) xTaskHandle xTaskGetIdleTaskHandle( void )
@ -1714,7 +1624,6 @@ void vTaskSwitchContext( void )
listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) ); listGET_OWNER_OF_NEXT_ENTRY( pxCurrentTCB, &( pxReadyTasksLists[ uxTopReadyPriority ] ) );
traceTASK_SWITCHED_IN(); traceTASK_SWITCHED_IN();
vWriteTraceToBuffer();
} }
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
@ -1910,6 +1819,42 @@ void vTaskMissedYield( void )
{ {
xMissedYield = pdTRUE; xMissedYield = pdTRUE;
} }
/*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
unsigned portBASE_TYPE uxTaskGetTaskNumber( xTaskHandle xTask )
{
unsigned portBASE_TYPE uxReturn;
tskTCB *pxTCB;
if( xTask != NULL )
{
pxTCB = ( tskTCB * ) xTask;
uxReturn = pxTCB->uxTCBNumber;
}
else
{
uxReturn = 0U;
}
return uxReturn;
}
#endif
/*-----------------------------------------------------------*/
#if ( configUSE_TRACE_FACILITY == 1 )
void vTaskSetTaskNumber( xTaskHandle xTask, unsigned portBASE_TYPE uxHandle )
{
tskTCB *pxTCB;
if( xTask != NULL )
{
pxTCB = ( tskTCB * ) xTask;
pxTCB->uxTCBNumber = uxHandle;
}
}
#endif
/* /*
* ----------------------------------------------------------- * -----------------------------------------------------------
@ -2204,6 +2149,7 @@ tskTCB *pxNewTCB;
{ {
volatile tskTCB *pxNextTCB, *pxFirstTCB; volatile tskTCB *pxNextTCB, *pxFirstTCB;
unsigned short usStackRemaining; unsigned short usStackRemaining;
PRIVILEGED_DATA static char pcStatusString[ 50 ];
/* Write the details of all the TCB's in pxList into the buffer. */ /* Write the details of all the TCB's in pxList into the buffer. */
listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList ); listGET_OWNER_OF_NEXT_ENTRY( pxFirstTCB, pxList );
@ -2441,6 +2387,8 @@ tskTCB *pxNewTCB;
/* Just inherit the priority. */ /* Just inherit the priority. */
pxTCB->uxPriority = pxCurrentTCB->uxPriority; pxTCB->uxPriority = pxCurrentTCB->uxPriority;
} }
traceTASK_PRIORITY_INHERIT( pxTCB, pxCurrentTCB->uxPriority );
} }
} }
@ -2461,8 +2409,9 @@ tskTCB *pxNewTCB;
Remove ourselves from the ready list we currently appear in. */ Remove ourselves from the ready list we currently appear in. */
vListRemove( &( pxTCB->xGenericListItem ) ); vListRemove( &( pxTCB->xGenericListItem ) );
/* Disinherit the priority before adding ourselves into the new /* Disinherit the priority before adding the task into the new
ready list. */ ready list. */
traceTASK_PRIORITY_DISINHERIT( pxTCB, pxTCB->uxBasePriority );
pxTCB->uxPriority = pxTCB->uxBasePriority; pxTCB->uxPriority = pxTCB->uxBasePriority;
listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxTCB->uxPriority ); listSET_LIST_ITEM_VALUE( &( pxTCB->xEventListItem ), configMAX_PRIORITIES - ( portTickType ) pxTCB->uxPriority );
prvAddTaskToReadyQueue( pxTCB ); prvAddTaskToReadyQueue( pxTCB );