mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-12-23 11:09:28 -05:00
Rename DummyTCB_t to StaticTCB_t.
Move structures used for static allocation of tasks and queues into FreeRTOS.h from their individual API header files. Add SAME70 Xplained Atmel Studio project. Update SAMV71 Atmel Studio project to use Studio 7. Revert some changes to GenQTest.c standard demo task which only function correctly when a queue registry was used.
This commit is contained in:
parent
41b5e486dd
commit
eae4815bf3
195 changed files with 65113 additions and 84 deletions
|
|
@ -778,7 +778,7 @@ extern "C" {
|
|||
|
||||
#if( ( configUSE_RECURSIVE_MUTEXES == 1 ) && ( configUSE_MUTEXES != 1 ) )
|
||||
#error configUSE_MUTEXES must be set to 1 to use recursive mutexes
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if( portTICK_TYPE_IS_ATOMIC == 0 )
|
||||
/* Either variables of tick type cannot be read atomically, or
|
||||
|
|
@ -836,6 +836,135 @@ point support. */
|
|||
#define configUSE_TASK_FPU_SUPPORT 1
|
||||
#endif
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, FreeRTOS implements a strict
|
||||
* data hiding policy, so the real structures used by FreeRTOS to maintain the
|
||||
* state of tasks, queues, semaphores, etc. are not accessible to the application
|
||||
* code. However, if the application writer wants to statically allocate such
|
||||
* an object then the size of the object needs to be know. Dummy structures
|
||||
* that are guaranteed to have the same size and alignment requirements of the
|
||||
* real objects are used for this purpose. The dummy list and list item
|
||||
* structures below are used for inclusion in such a dummy structure.
|
||||
*/
|
||||
struct xSTATIC_LIST_ITEM
|
||||
{
|
||||
TickType_t xDummy1;
|
||||
void *pvDummy2[ 4 ];
|
||||
};
|
||||
typedef struct xSTATIC_LIST_ITEM StaticListItem_t;
|
||||
|
||||
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */
|
||||
struct xSTATIC_MINI_LIST_ITEM
|
||||
{
|
||||
TickType_t xDummy1;
|
||||
void *pvDummy2[ 2 ];
|
||||
};
|
||||
typedef struct xSTATIC_MINI_LIST_ITEM StaticMiniListItem_t;
|
||||
|
||||
/* See the comments above the struct xSTATIC_LIST_ITEM definition. */
|
||||
typedef struct xSTATIC_LIST
|
||||
{
|
||||
UBaseType_t uxDummy1;
|
||||
void *pvDummy2;
|
||||
StaticMiniListItem_t xDummy3;
|
||||
} StaticList_t;
|
||||
|
||||
/* For data hiding purposes. */
|
||||
typedef enum
|
||||
{
|
||||
eNothing = 0
|
||||
} eDummy;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, FreeRTOS implements a strict
|
||||
* data hiding policy, so the real task control block (TCB) structure is not
|
||||
* accessible to the application code. However, if the application writer wants
|
||||
* to statically allocate a TCB then the size of the TCB needs to be know. The
|
||||
* dummy TCB structure below is used for this purpose. Its size will allows
|
||||
* match the size of the real TCB, no matter what the FreeRTOSConfig.h settings.
|
||||
*/
|
||||
typedef struct xSTATIC_TCB
|
||||
{
|
||||
void *pxDummy1;
|
||||
#if ( portUSING_MPU_WRAPPERS == 1 )
|
||||
xMPU_SETTINGS xDummy2;
|
||||
#endif
|
||||
StaticListItem_t xDummy3[ 2 ];
|
||||
UBaseType_t uxDummy5;
|
||||
void *pxDummy6;
|
||||
uint8_t ucDummy7[ configMAX_TASK_NAME_LEN ];
|
||||
#if ( portSTACK_GROWTH > 0 )
|
||||
void *pxDummy8;
|
||||
#endif
|
||||
#if ( portCRITICAL_NESTING_IN_TCB == 1 )
|
||||
UBaseType_t uxDummy9;
|
||||
#endif
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxDummy10[ 2 ];
|
||||
#endif
|
||||
#if ( configUSE_MUTEXES == 1 )
|
||||
UBaseType_t uxDummy12[ 2 ];
|
||||
#endif
|
||||
#if ( configUSE_APPLICATION_TASK_TAG == 1 )
|
||||
void *pxDummy14;
|
||||
#endif
|
||||
#if( configNUM_THREAD_LOCAL_STORAGE_POINTERS > 0 )
|
||||
void pvDummy15[ configNUM_THREAD_LOCAL_STORAGE_POINTERS ];
|
||||
#endif
|
||||
#if ( configGENERATE_RUN_TIME_STATS == 1 )
|
||||
uint32_t ulDummy16;
|
||||
#endif
|
||||
#if ( configUSE_NEWLIB_REENTRANT == 1 )
|
||||
struct _reent xDummy17;
|
||||
#endif
|
||||
#if ( configUSE_TASK_NOTIFICATIONS == 1 )
|
||||
uint32_t ulDummy18;
|
||||
eDummy eDummy19;
|
||||
#endif
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
UBaseType_t uxDummy20;
|
||||
#endif
|
||||
|
||||
} StaticTCB_t;
|
||||
|
||||
/*
|
||||
* In line with software engineering best practice, FreeRTOS implements a strict
|
||||
* data hiding policy, so the queue structure is not accessible to the
|
||||
* application code. However, if the application writer wants to statically
|
||||
* allocate a queue (or one of the other objects that uses a queue as its base
|
||||
* structure) then the size of the queue needs to be know. The dummy queue
|
||||
* structure below is used for this purpose. Its size will allows match the
|
||||
* size of the real queue, no matter what the FreeRTOSConfig.h settings.
|
||||
*/
|
||||
typedef struct xSTATIC_QUEUE
|
||||
{
|
||||
void *pvDummy1[ 3 ];
|
||||
|
||||
union
|
||||
{
|
||||
void *pvDummy2;
|
||||
UBaseType_t uxDummy2;
|
||||
} u;
|
||||
|
||||
StaticList_t xDummy3[ 2 ];
|
||||
UBaseType_t uxDummy4[ 5 ];
|
||||
|
||||
#if ( configUSE_QUEUE_SETS == 1 )
|
||||
void *pvDummy7;
|
||||
#endif
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxDummy5;
|
||||
uint8_t ucDummy6;
|
||||
#endif
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
uint8_t ucDummy7;
|
||||
#endif
|
||||
|
||||
} StaticQueue_t;
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ void vPortStartFirstTask( void )
|
|||
" cpsie i \n" /* The first task has its context and interrupts can be enabled. */
|
||||
" pop {pc} \n" /* Finally, pop the PC to jump to the user defined task code. */
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst2: .word pxCurrentTCB "
|
||||
);
|
||||
}
|
||||
|
|
@ -332,7 +332,7 @@ void xPortPendSVHandler( void )
|
|||
" \n"
|
||||
" bx r3 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst: .word pxCurrentTCB "
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -255,7 +255,7 @@ void vPortSVCHandler( void )
|
|||
" orr r14, #0xd \n"
|
||||
" bx r14 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
|
||||
);
|
||||
}
|
||||
|
|
@ -382,9 +382,9 @@ void vPortEnterCritical( void )
|
|||
uxCriticalNesting++;
|
||||
__asm volatile( "dsb" );
|
||||
__asm volatile( "isb" );
|
||||
|
||||
|
||||
/* This is not the interrupt safe version of the enter critical function so
|
||||
assert() if it is being called from an interrupt context. Only API
|
||||
assert() if it is being called from an interrupt context. Only API
|
||||
functions that end in "FromISR" can be used in an interrupt. Only assert if
|
||||
the critical nesting count is 1 to protect against recursive calls if the
|
||||
assert function also uses a critical section. */
|
||||
|
|
@ -467,7 +467,7 @@ void xPortPendSVHandler( void )
|
|||
" isb \n"
|
||||
" bx r14 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst: .word pxCurrentTCB \n"
|
||||
::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -334,7 +334,7 @@ static void prvRestoreContextOfFirstTask( void )
|
|||
" ldr r14, =0xfffffffd \n" /* Load exec return code. */
|
||||
" bx r14 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
|
||||
);
|
||||
}
|
||||
|
|
@ -440,7 +440,7 @@ void xPortPendSVHandler( void )
|
|||
" msr psp, r0 \n"
|
||||
" bx r14 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst: .word pxCurrentTCB \n"
|
||||
::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY)
|
||||
);
|
||||
|
|
@ -911,7 +911,7 @@ BaseType_t xRunningPrivileged = prvRaisePrivilege();
|
|||
|
||||
uxReturn = uxTaskGetSystemState( pxTaskStatusArray, uxArraySize, pulTotalRunTime );
|
||||
portRESET_PRIVILEGE( xRunningPrivileged );
|
||||
return xReturn;
|
||||
return uxReturn;
|
||||
}
|
||||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
|
|
|||
|
|
@ -273,7 +273,7 @@ void vPortSVCHandler( void )
|
|||
" msr basepri, r0 \n"
|
||||
" bx r14 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst2: .word pxCurrentTCB \n"
|
||||
);
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ void xPortPendSVHandler( void )
|
|||
" \n"
|
||||
" bx r14 \n"
|
||||
" \n"
|
||||
" .align 2 \n"
|
||||
" .align 4 \n"
|
||||
"pxCurrentTCBConst: .word pxCurrentTCB \n"
|
||||
::"i"(configMAX_SYSCALL_INTERRUPT_PRIORITY)
|
||||
);
|
||||
|
|
|
|||
|
|
@ -114,6 +114,13 @@ zero. */
|
|||
#define queueSEMAPHORE_QUEUE_ITEM_LENGTH ( ( UBaseType_t ) 0 )
|
||||
#define queueMUTEX_GIVE_BLOCK_TIME ( ( TickType_t ) 0U )
|
||||
|
||||
/* Bits that can be set in xQUEUE->ucStaticAllocationFlags to indicate that the
|
||||
queue storage area and queue structure were statically allocated respectively.
|
||||
When these are statically allocated they won't be freed if the queue gets
|
||||
deleted. */
|
||||
#define queueSTATICALLY_ALLOCATED_STORAGE ( ( uint8_t ) 0x01 )
|
||||
#define queueSTATICALLY_ALLOCATED_QUEUE_STRUCT ( ( uint8_t ) 0x02 )
|
||||
|
||||
#if( configUSE_PREEMPTION == 0 )
|
||||
/* If the cooperative scheduler is being used then a yield should not be
|
||||
performed just because a higher priority task has been woken. */
|
||||
|
|
@ -149,13 +156,17 @@ typedef struct QueueDefinition
|
|||
volatile BaseType_t 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. */
|
||||
volatile BaseType_t 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_QUEUE_SETS == 1 )
|
||||
struct QueueDefinition *pxQueueSetContainer;
|
||||
#endif
|
||||
|
||||
#if ( configUSE_TRACE_FACILITY == 1 )
|
||||
UBaseType_t uxQueueNumber;
|
||||
uint8_t ucQueueType;
|
||||
#endif
|
||||
|
||||
#if ( configUSE_QUEUE_SETS == 1 )
|
||||
struct QueueDefinition *pxQueueSetContainer;
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
uint8_t ucStaticAllocationFlags;
|
||||
#endif
|
||||
|
||||
} xQUEUE;
|
||||
|
|
@ -310,18 +321,23 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
|
|||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, const uint8_t ucQueueType )
|
||||
static Queue_t *prvAllocateQueueMemory( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t **ppucQueueStorage, StaticQueue_t *pxStaticQueue )
|
||||
{
|
||||
Queue_t *pxNewQueue;
|
||||
size_t xQueueSizeInBytes;
|
||||
QueueHandle_t xReturn = NULL;
|
||||
|
||||
/* Remove compiler warnings about unused parameters should
|
||||
configUSE_TRACE_FACILITY not be set to 1. */
|
||||
( void ) ucQueueType;
|
||||
|
||||
configASSERT( uxQueueLength > ( UBaseType_t ) 0 );
|
||||
|
||||
#if( ( configASSERT_DEFINED == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
|
||||
{
|
||||
/* Sanity check that the size of the structure used to declare a
|
||||
variable of type DummyQueue_t or DummySemaphore_t equals the size of the
|
||||
real queue and semaphore structures. */
|
||||
volatile size_t xSize = sizeof( StaticQueue_t );
|
||||
configASSERT( xSize == sizeof( Queue_t ) );
|
||||
}
|
||||
#endif /* configASSERT_DEFINED */
|
||||
|
||||
if( uxItemSize == ( UBaseType_t ) 0 )
|
||||
{
|
||||
/* There is not going to be a queue storage area. */
|
||||
|
|
@ -334,8 +350,86 @@ QueueHandle_t xReturn = NULL;
|
|||
xQueueSizeInBytes = ( size_t ) ( uxQueueLength * uxItemSize ) + ( size_t ) 1; /*lint !e961 MISRA exception as the casts are only redundant for some ports. */
|
||||
}
|
||||
|
||||
/* Allocate the new queue structure and storage area. */
|
||||
pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 0 )
|
||||
{
|
||||
/* Allocate the new queue structure and storage area. */
|
||||
pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) + xQueueSizeInBytes );
|
||||
|
||||
if( pxNewQueue != NULL )
|
||||
{
|
||||
/* Jump past the queue structure to find the location of the queue
|
||||
storage area. */
|
||||
*ppucQueueStorage = ( ( uint8_t * ) pxNewQueue ) + sizeof( Queue_t );
|
||||
}
|
||||
|
||||
/* The pxStaticQueue parameter is not used. Remove compiler warnings. */
|
||||
( void ) pxStaticQueue;
|
||||
}
|
||||
#else
|
||||
{
|
||||
if( pxStaticQueue == NULL )
|
||||
{
|
||||
/* A statically allocated queue was not passed in, so create one
|
||||
dynamically. */
|
||||
pxNewQueue = ( Queue_t * ) pvPortMalloc( sizeof( Queue_t ) );
|
||||
pxNewQueue->ucStaticAllocationFlags = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* The address of a statically allocated queue was passed in, use
|
||||
it and note that the queue was not dynamically allocated so there is
|
||||
no attempt to free it again should the queue be deleted. */
|
||||
pxNewQueue = ( Queue_t * ) pxStaticQueue;
|
||||
pxNewQueue->ucStaticAllocationFlags = queueSTATICALLY_ALLOCATED_QUEUE_STRUCT;
|
||||
}
|
||||
|
||||
if( pxNewQueue != NULL )
|
||||
{
|
||||
if( ( *ppucQueueStorage == NULL ) && ( xQueueSizeInBytes > 0 ) )
|
||||
{
|
||||
/* A statically allocated queue storage area was not passed in,
|
||||
so allocate the queue storage area dynamically. */
|
||||
*ppucQueueStorage = ( uint8_t * ) pvPortMalloc( xQueueSizeInBytes );
|
||||
|
||||
if( *ppucQueueStorage == NULL )
|
||||
{
|
||||
/* The queue storage area could not be created, so free the
|
||||
queue structure also. */
|
||||
if( ( pxNewQueue->ucStaticAllocationFlags & queueSTATICALLY_ALLOCATED_QUEUE_STRUCT ) == 0 )
|
||||
{
|
||||
vPortFree( ( void * ) pxNewQueue );
|
||||
}
|
||||
pxNewQueue = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Note the fact that either the queue storage area was passed
|
||||
into this function, or the size requirement for the queue
|
||||
storage area was zero - either way no attempt should be made to
|
||||
free the queue storage area if the queue is deleted. */
|
||||
pxNewQueue->ucStaticAllocationFlags |= queueSTATICALLY_ALLOCATED_STORAGE;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return pxNewQueue;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
QueueHandle_t xQueueGenericCreate( const UBaseType_t uxQueueLength, const UBaseType_t uxItemSize, uint8_t *pucQueueStorage, StaticQueue_t *pxStaticQueue, const uint8_t ucQueueType )
|
||||
{
|
||||
Queue_t *pxNewQueue;
|
||||
|
||||
/* Remove compiler warnings about unused parameters should
|
||||
configUSE_TRACE_FACILITY not be set to 1. */
|
||||
( void ) ucQueueType;
|
||||
|
||||
/* A queue requires a queue structure and a queue storage area. These may
|
||||
be allocated statically or dynamically, depending on the parameter
|
||||
values. */
|
||||
pxNewQueue = prvAllocateQueueMemory( uxQueueLength, uxItemSize, &pucQueueStorage, pxStaticQueue );
|
||||
|
||||
if( pxNewQueue != NULL )
|
||||
{
|
||||
|
|
@ -349,13 +443,12 @@ QueueHandle_t xReturn = NULL;
|
|||
}
|
||||
else
|
||||
{
|
||||
/* Jump past the queue structure to find the location of the queue
|
||||
storage area. */
|
||||
pxNewQueue->pcHead = ( ( int8_t * ) pxNewQueue ) + sizeof( Queue_t );
|
||||
/* Set the head to the start of the queue storage area. */
|
||||
pxNewQueue->pcHead = ( int8_t * ) pucQueueStorage;
|
||||
}
|
||||
|
||||
/* Initialise the queue members as described above where the queue type
|
||||
is defined. */
|
||||
/* Initialise the queue members as described where the queue type is
|
||||
defined. */
|
||||
pxNewQueue->uxLength = uxQueueLength;
|
||||
pxNewQueue->uxItemSize = uxItemSize;
|
||||
( void ) xQueueGenericReset( pxNewQueue, pdTRUE );
|
||||
|
|
@ -373,16 +466,15 @@ QueueHandle_t xReturn = NULL;
|
|||
#endif /* configUSE_QUEUE_SETS */
|
||||
|
||||
traceQUEUE_CREATE( pxNewQueue );
|
||||
xReturn = pxNewQueue;
|
||||
}
|
||||
else
|
||||
{
|
||||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
configASSERT( xReturn );
|
||||
configASSERT( pxNewQueue );
|
||||
|
||||
return xReturn;
|
||||
return ( QueueHandle_t ) pxNewQueue;
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -586,7 +678,7 @@ QueueHandle_t xReturn = NULL;
|
|||
configASSERT( uxMaxCount != 0 );
|
||||
configASSERT( uxInitialCount <= uxMaxCount );
|
||||
|
||||
xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
|
||||
xHandle = xQueueGenericCreate( uxMaxCount, queueSEMAPHORE_QUEUE_ITEM_LENGTH, NULL, NULL, queueQUEUE_TYPE_COUNTING_SEMAPHORE );
|
||||
|
||||
if( xHandle != NULL )
|
||||
{
|
||||
|
|
@ -1753,7 +1845,30 @@ Queue_t * const pxQueue = ( Queue_t * ) xQueue;
|
|||
vQueueUnregisterQueue( pxQueue );
|
||||
}
|
||||
#endif
|
||||
vPortFree( pxQueue );
|
||||
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 0 )
|
||||
{
|
||||
/* The queue and the queue storage area will have been dynamically
|
||||
allocated in one go. */
|
||||
vPortFree( pxQueue );
|
||||
}
|
||||
#else
|
||||
{
|
||||
if( ( pxQueue->ucStaticAllocationFlags & queueSTATICALLY_ALLOCATED_STORAGE ) == 0 )
|
||||
{
|
||||
/* The queue storage area was dynamically allocated, so must be
|
||||
freed. */
|
||||
vPortFree( pxQueue->pcHead );
|
||||
}
|
||||
|
||||
if( ( pxQueue->ucStaticAllocationFlags & queueSTATICALLY_ALLOCATED_QUEUE_STRUCT ) == 0 )
|
||||
{
|
||||
/* The queue structure was dynamically allocated, so must be
|
||||
free. */
|
||||
vPortFree( pxQueue );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
|
|
@ -2478,7 +2593,7 @@ BaseType_t xReturn;
|
|||
{
|
||||
QueueSetHandle_t pxQueue;
|
||||
|
||||
pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( Queue_t * ), queueQUEUE_TYPE_SET );
|
||||
pxQueue = xQueueGenericCreate( uxEventQueueLength, sizeof( Queue_t * ), NULL, NULL, queueQUEUE_TYPE_SET );
|
||||
|
||||
return pxQueue;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,12 +122,12 @@ functions but without including stdio.h here. */
|
|||
#define taskYIELD_IF_USING_PREEMPTION() portYIELD_WITHIN_API()
|
||||
#endif
|
||||
|
||||
/* Bits that can be set in tskTCB->uxStaticAllocationFlags to indicate that the
|
||||
/* Bits that can be set in tskTCB->ucStaticAllocationFlags to indicate that the
|
||||
stack and TCB were statically allocated respectively. When these are statically
|
||||
allocated they won't be freed if the task using the stack and TCB gets
|
||||
deleted. */
|
||||
#define taskSTATICALLY_ALLOCATED_STACK ( ( UBaseType_t ) 0x01 )
|
||||
#define taskSTATICALLY_ALLOCATED_TCB ( ( UBaseType_t ) 0x02 )
|
||||
#define taskSTATICALLY_ALLOCATED_STACK ( ( uint8_t ) 0x01 )
|
||||
#define taskSTATICALLY_ALLOCATED_TCB ( ( uint8_t ) 0x02 )
|
||||
|
||||
/*
|
||||
* Task control block. A task control block (TCB) is allocated for each task,
|
||||
|
|
@ -195,7 +195,7 @@ typedef struct tskTaskControlBlock
|
|||
#endif
|
||||
|
||||
#if ( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
UBaseType_t uxStaticAllocationFlags; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */
|
||||
uint8_t ucStaticAllocationFlags; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */
|
||||
#endif
|
||||
|
||||
} tskTCB;
|
||||
|
|
@ -426,7 +426,7 @@ to its original value when it is released. */
|
|||
#endif
|
||||
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
extern void vApplicationGetIdleTaskMemory( DummyTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize );
|
||||
extern void vApplicationGetIdleTaskMemory( StaticTCB_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint16_t *pusIdleTaskStackSize );
|
||||
#endif
|
||||
|
||||
/* File private functions. --------------------------------*/
|
||||
|
|
@ -554,7 +554,7 @@ static void prvResetNextTaskUnblockTime( void );
|
|||
#endif
|
||||
/*-----------------------------------------------------------*/
|
||||
|
||||
BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, DummyTCB_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcName, const uint16_t usStackDepth, void * const pvParameters, UBaseType_t uxPriority, TaskHandle_t * const pxCreatedTask, StackType_t * const puxStackBuffer, StaticTCB_t * const pxTCBBuffer, const MemoryRegion_t * const xRegions ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
TCB_t * pxNewTCB;
|
||||
|
|
@ -1546,7 +1546,7 @@ StackType_t *pxTopOfStack;
|
|||
void vTaskStartScheduler( void )
|
||||
{
|
||||
BaseType_t xReturn;
|
||||
DummyTCB_t *pxIdleTaskTCBBuffer = NULL;
|
||||
StaticTCB_t *pxIdleTaskTCBBuffer = NULL;
|
||||
StackType_t *pxIdleTaskStackBuffer = NULL;
|
||||
uint16_t usIdleTaskStackSize = tskIDLE_STACK_SIZE;
|
||||
|
||||
|
|
@ -3149,9 +3149,12 @@ static TCB_t *prvAllocateTCBAndStack( const uint16_t usStackDepth, StackType_t *
|
|||
{
|
||||
TCB_t *pxNewTCB;
|
||||
|
||||
#if( configASSERT_DEFINED == 1 )
|
||||
#if( ( configASSERT_DEFINED == 1 ) && ( configSUPPORT_STATIC_ALLOCATION == 1 ) )
|
||||
{
|
||||
volatile size_t xSize = sizeof( DummyTCB_t );
|
||||
/* Sanity check that the size of the structure used to declare a
|
||||
variable of type StaticTCB_t matches the size of the actual TCB_t
|
||||
structure. */
|
||||
volatile size_t xSize = sizeof( StaticTCB_t );
|
||||
configASSERT( xSize == sizeof( TCB_t ) );
|
||||
}
|
||||
#endif /* configASSERT_DEFINED */
|
||||
|
|
@ -3234,13 +3237,13 @@ TCB_t *pxNewTCB;
|
|||
|
||||
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||
{
|
||||
pxNewTCB->uxStaticAllocationFlags = 0;
|
||||
pxNewTCB->ucStaticAllocationFlags = 0;
|
||||
|
||||
if( puxStackBuffer != NULL )
|
||||
{
|
||||
/* The application provided its own stack - note the fact so no
|
||||
attempt is made to delete the stack if the task is deleted. */
|
||||
pxNewTCB->uxStaticAllocationFlags |= taskSTATICALLY_ALLOCATED_STACK;
|
||||
pxNewTCB->ucStaticAllocationFlags |= taskSTATICALLY_ALLOCATED_STACK;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3251,7 +3254,7 @@ TCB_t *pxNewTCB;
|
|||
{
|
||||
/* The application provided its own TCB. Note the fact so no
|
||||
attempt is made to delete the TCB if the task is deleted. */
|
||||
pxNewTCB->uxStaticAllocationFlags |= taskSTATICALLY_ALLOCATED_TCB;
|
||||
pxNewTCB->ucStaticAllocationFlags |= taskSTATICALLY_ALLOCATED_TCB;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -3419,7 +3422,7 @@ TCB_t *pxNewTCB;
|
|||
{
|
||||
/* Only free the stack and TCB if they were allocated dynamically in
|
||||
the first place. */
|
||||
if( ( pxTCB->uxStaticAllocationFlags & taskSTATICALLY_ALLOCATED_STACK ) == ( UBaseType_t ) 0 )
|
||||
if( ( pxTCB->ucStaticAllocationFlags & taskSTATICALLY_ALLOCATED_STACK ) == ( UBaseType_t ) 0 )
|
||||
{
|
||||
vPortFreeAligned( pxTCB->pxStack );
|
||||
}
|
||||
|
|
@ -3428,7 +3431,7 @@ TCB_t *pxNewTCB;
|
|||
mtCOVERAGE_TEST_MARKER();
|
||||
}
|
||||
|
||||
if( ( pxTCB->uxStaticAllocationFlags & taskSTATICALLY_ALLOCATED_TCB ) == ( UBaseType_t ) 0 )
|
||||
if( ( pxTCB->ucStaticAllocationFlags & taskSTATICALLY_ALLOCATED_TCB ) == ( UBaseType_t ) 0 )
|
||||
{
|
||||
vPortFreeAligned( pxTCB );
|
||||
}
|
||||
|
|
|
|||
|
|
@ -184,7 +184,7 @@ PRIVILEGED_DATA static QueueHandle_t xTimerQueue = NULL;
|
|||
following callback function - which enables the application to optionally
|
||||
provide the memory that will be used by the timer task as the task's stack
|
||||
and TCB. */
|
||||
extern void vApplicationGetTimerTaskMemory( DummyTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );
|
||||
extern void vApplicationGetTimerTaskMemory( StaticTCB_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint16_t *pusTimerTaskStackSize );
|
||||
|
||||
#endif
|
||||
|
||||
|
|
@ -250,7 +250,7 @@ static void prvProcessTimerOrBlockTask( const TickType_t xNextExpireTime, BaseTy
|
|||
BaseType_t xTimerCreateTimerTask( void )
|
||||
{
|
||||
BaseType_t xReturn = pdFAIL;
|
||||
DummyTCB_t *pxTimerTaskTCBBuffer = NULL;
|
||||
StaticTCB_t *pxTimerTaskTCBBuffer = NULL;
|
||||
StackType_t *pxTimerTaskStackBuffer = NULL;
|
||||
uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue