mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-10-25 06:07:49 -04:00
Add support to build Posix Demo with Dynamic Allocation (#1198)
Add support for dynamic allocation in posix demo
This commit is contained in:
parent
bc5587ce5f
commit
857962d638
5 changed files with 92 additions and 58 deletions
|
|
@ -58,7 +58,23 @@
|
||||||
#define configUSE_ALTERNATIVE_API 0
|
#define configUSE_ALTERNATIVE_API 0
|
||||||
#define configUSE_QUEUE_SETS 1
|
#define configUSE_QUEUE_SETS 1
|
||||||
#define configUSE_TASK_NOTIFICATIONS 1
|
#define configUSE_TASK_NOTIFICATIONS 1
|
||||||
|
|
||||||
|
/* The following 2 memory allocation schemes are possible for this demo:
|
||||||
|
*
|
||||||
|
* 1. Dynamic Only.
|
||||||
|
* #define configSUPPORT_STATIC_ALLOCATION 0
|
||||||
|
* #define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
|
*
|
||||||
|
* 2. Static and Dynamic.
|
||||||
|
* #define configSUPPORT_STATIC_ALLOCATION 1
|
||||||
|
* #define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
|
*
|
||||||
|
* Static only configuration is not possible for this demo as it utilizes
|
||||||
|
* dynamic allocation.
|
||||||
|
*/
|
||||||
#define configSUPPORT_STATIC_ALLOCATION 1
|
#define configSUPPORT_STATIC_ALLOCATION 1
|
||||||
|
#define configSUPPORT_DYNAMIC_ALLOCATION 1
|
||||||
|
|
||||||
#define configRECORD_STACK_HIGH_ADDRESS 1
|
#define configRECORD_STACK_HIGH_ADDRESS 1
|
||||||
|
|
||||||
/* Software timer related configuration options. The maximum possible task
|
/* Software timer related configuration options. The maximum possible task
|
||||||
|
|
|
||||||
|
|
@ -82,11 +82,11 @@ else
|
||||||
CPPFLAGS += -DprojENABLE_TRACING=0
|
CPPFLAGS += -DprojENABLE_TRACING=0
|
||||||
else
|
else
|
||||||
CPPFLAGS += -DprojENABLE_TRACING=1
|
CPPFLAGS += -DprojENABLE_TRACING=1
|
||||||
endif
|
# Trace Library.
|
||||||
CPPFLAGS += -DprojCOVERAGE_TEST=0
|
|
||||||
# Trace library.
|
|
||||||
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c
|
SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c
|
||||||
SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c )
|
SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c )
|
||||||
|
endif
|
||||||
|
CPPFLAGS += -DprojCOVERAGE_TEST=0
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef PROFILE
|
ifdef PROFILE
|
||||||
|
|
|
||||||
|
|
@ -86,15 +86,17 @@ static BaseType_t prvTimerQuery( void );
|
||||||
|
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
static BaseType_t prvStaticAllocationsWithNullBuffers( void )
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
{
|
|
||||||
|
static BaseType_t prvStaticAllocationsWithNullBuffers( void )
|
||||||
|
{
|
||||||
uintptr_t ulReturned = 0;
|
uintptr_t ulReturned = 0;
|
||||||
BaseType_t xReturn = pdPASS;
|
BaseType_t xReturn = pdPASS;
|
||||||
UBaseType_t uxDummy = 10;
|
UBaseType_t uxDummy = 10;
|
||||||
|
|
||||||
/* Don't expect to create any of the objects as a NULL parameter is always
|
/* Don't expect to create any of the objects as a NULL parameter is always
|
||||||
* passed in place of a required buffer. Hence if all passes then none of the
|
* passed in place of a required buffer. Hence if all passes then none of the
|
||||||
|= will be against 0, and ulReturned will still be zero at the end of this
|
* |= will be against 0, and ulReturned will still be zero at the end of this
|
||||||
* function. */
|
* function. */
|
||||||
ulReturned |= ( uintptr_t ) xEventGroupCreateStatic( NULL );
|
ulReturned |= ( uintptr_t ) xEventGroupCreateStatic( NULL );
|
||||||
|
|
||||||
|
|
@ -140,7 +142,9 @@ static BaseType_t prvStaticAllocationsWithNullBuffers( void )
|
||||||
}
|
}
|
||||||
|
|
||||||
return xReturn;
|
return xReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
#if( configUSE_TRACE_FACILITY == 1 )
|
#if( configUSE_TRACE_FACILITY == 1 )
|
||||||
|
|
@ -643,14 +647,18 @@ BaseType_t xRunCodeCoverageTestAdditions( void )
|
||||||
{
|
{
|
||||||
BaseType_t xReturn = pdPASS;
|
BaseType_t xReturn = pdPASS;
|
||||||
|
|
||||||
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
|
{
|
||||||
xReturn &= prvStaticAllocationsWithNullBuffers();
|
xReturn &= prvStaticAllocationsWithNullBuffers();
|
||||||
|
}
|
||||||
|
#endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
||||||
|
|
||||||
#if( configUSE_TRACE_FACILITY == 1 )
|
#if( configUSE_TRACE_FACILITY == 1 )
|
||||||
{
|
{
|
||||||
xReturn &= prvTraceUtils();
|
xReturn &= prvTraceUtils();
|
||||||
xReturn &= prvTaskQueryFunctions();
|
xReturn &= prvTaskQueryFunctions();
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* if( configUSE_TRACE_FACILITY == 1 ) */
|
||||||
|
|
||||||
xReturn &= prvPeekTimeout();
|
xReturn &= prvPeekTimeout();
|
||||||
xReturn &= prvQueueQueryFromISR();
|
xReturn &= prvQueueQueryFromISR();
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,15 @@ StaticSemaphore_t xStdioMutexBuffer;
|
||||||
|
|
||||||
void console_init( void )
|
void console_init( void )
|
||||||
{
|
{
|
||||||
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
|
{
|
||||||
xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer );
|
xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer );
|
||||||
|
}
|
||||||
|
#else /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
||||||
|
{
|
||||||
|
xStdioMutex = xSemaphoreCreateMutex( );
|
||||||
|
}
|
||||||
|
#endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */
|
||||||
}
|
}
|
||||||
|
|
||||||
void console_print( const char * fmt,
|
void console_print( const char * fmt,
|
||||||
|
|
|
||||||
|
|
@ -749,7 +749,9 @@ static void prvDemonstrateTaskStateAndHandleGetFunctions( void )
|
||||||
if( ( xTaskInfo.eCurrentState != eBlocked ) ||
|
if( ( xTaskInfo.eCurrentState != eBlocked ) ||
|
||||||
( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) ||
|
( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) ||
|
||||||
( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) ||
|
( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) ||
|
||||||
|
#if( configSUPPORT_STATIC_ALLOCATION == 1 )
|
||||||
( xTaskInfo.pxStackBase != uxTimerTaskStack ) ||
|
( xTaskInfo.pxStackBase != uxTimerTaskStack ) ||
|
||||||
|
#endif
|
||||||
( xTaskInfo.xHandle != xTimerTaskHandle ) )
|
( xTaskInfo.xHandle != xTimerTaskHandle ) )
|
||||||
{
|
{
|
||||||
pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";
|
pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue