diff --git a/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h index df561108f1..cc92b44778 100644 --- a/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h @@ -58,7 +58,23 @@ #define configUSE_ALTERNATIVE_API 0 #define configUSE_QUEUE_SETS 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_DYNAMIC_ALLOCATION 1 + #define configRECORD_STACK_HIGH_ADDRESS 1 /* Software timer related configuration options. The maximum possible task diff --git a/FreeRTOS/Demo/Posix_GCC/Makefile b/FreeRTOS/Demo/Posix_GCC/Makefile index a3f09b1f2f..de2f1a06d9 100644 --- a/FreeRTOS/Demo/Posix_GCC/Makefile +++ b/FreeRTOS/Demo/Posix_GCC/Makefile @@ -82,11 +82,11 @@ else CPPFLAGS += -DprojENABLE_TRACING=0 else CPPFLAGS += -DprojENABLE_TRACING=1 + # Trace Library. + SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c + SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c ) endif CPPFLAGS += -DprojCOVERAGE_TEST=0 -# Trace library. - SOURCE_FILES += ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/kernelports/FreeRTOS/trcKernelPort.c - SOURCE_FILES += $(wildcard ${FREERTOS_PLUS_DIR}/Source/FreeRTOS-Plus-Trace/*.c ) endif ifdef PROFILE diff --git a/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c b/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c index 00af569dff..daee341e8b 100644 --- a/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c +++ b/FreeRTOS/Demo/Posix_GCC/code_coverage_additions.c @@ -86,61 +86,65 @@ static BaseType_t prvTimerQuery( void ); /*-----------------------------------------------------------*/ -static BaseType_t prvStaticAllocationsWithNullBuffers( void ) -{ - uintptr_t ulReturned = 0; - BaseType_t xReturn = pdPASS; - UBaseType_t uxDummy = 10; - - /* 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 - |= will be against 0, and ulReturned will still be zero at the end of this - * function. */ - ulReturned |= ( uintptr_t ) xEventGroupCreateStatic( NULL ); - - /* Try creating a task twice, once with puxStackBuffer NULL, and once with - * pxTaskBuffer NULL. */ - ulReturned |= ( uintptr_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */ - "Dummy", /* Task name. */ - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY, - NULL, - ( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */ - - ulReturned |= ( uintptr_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */ - "Dummy", /* Task name. */ - configMINIMAL_STACK_SIZE, - NULL, - tskIDLE_PRIORITY, - ( StackType_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */ - NULL ); - - ulReturned |= ( uintptr_t ) xQueueCreateStatic( uxDummy, - uxDummy, - ( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */ - NULL ); - - /* Try creating a stream buffer twice, once with pucStreamBufferStorageArea - * set to NULL, and once with pxStaticStreamBuffer set to NULL. */ - ulReturned |= ( uintptr_t ) xStreamBufferCreateStatic( uxDummy, - uxDummy, - NULL, - ( StaticStreamBuffer_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */ - - ulReturned |= ( uintptr_t ) xStreamBufferCreateStatic( uxDummy, - uxDummy, - ( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */ - NULL ); - - if( ulReturned != 0 ) +#if( configSUPPORT_STATIC_ALLOCATION == 1 ) + + static BaseType_t prvStaticAllocationsWithNullBuffers( void ) { - /* Something returned a non-NULL value. */ - xReturn = pdFAIL; + uintptr_t ulReturned = 0; + BaseType_t xReturn = pdPASS; + UBaseType_t uxDummy = 10; + + /* 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 + * |= will be against 0, and ulReturned will still be zero at the end of this + * function. */ + ulReturned |= ( uintptr_t ) xEventGroupCreateStatic( NULL ); + + /* Try creating a task twice, once with puxStackBuffer NULL, and once with + * pxTaskBuffer NULL. */ + ulReturned |= ( uintptr_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */ + "Dummy", /* Task name. */ + configMINIMAL_STACK_SIZE, + NULL, + tskIDLE_PRIORITY, + NULL, + ( StaticTask_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */ + + ulReturned |= ( uintptr_t ) xTaskCreateStatic( NULL, /* Task to run, not needed as the task is not created. */ + "Dummy", /* Task name. */ + configMINIMAL_STACK_SIZE, + NULL, + tskIDLE_PRIORITY, + ( StackType_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */ + NULL ); + + ulReturned |= ( uintptr_t ) xQueueCreateStatic( uxDummy, + uxDummy, + ( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */ + NULL ); + + /* Try creating a stream buffer twice, once with pucStreamBufferStorageArea + * set to NULL, and once with pxStaticStreamBuffer set to NULL. */ + ulReturned |= ( uintptr_t ) xStreamBufferCreateStatic( uxDummy, + uxDummy, + NULL, + ( StaticStreamBuffer_t * ) &xReturn ); /* Dummy value just to pass a non NULL value in - won't get used. */ + + ulReturned |= ( uintptr_t ) xStreamBufferCreateStatic( uxDummy, + uxDummy, + ( uint8_t * ) &xReturn, /* Dummy value just to pass a non NULL value in - won't get used. */ + NULL ); + + if( ulReturned != 0 ) + { + /* Something returned a non-NULL value. */ + xReturn = pdFAIL; + } + + return xReturn; } - return xReturn; -} +#endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ /*-----------------------------------------------------------*/ #if( configUSE_TRACE_FACILITY == 1 ) @@ -643,14 +647,18 @@ BaseType_t xRunCodeCoverageTestAdditions( void ) { BaseType_t xReturn = pdPASS; - xReturn &= prvStaticAllocationsWithNullBuffers(); + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + xReturn &= prvStaticAllocationsWithNullBuffers(); + } + #endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ #if( configUSE_TRACE_FACILITY == 1 ) { xReturn &= prvTraceUtils(); xReturn &= prvTaskQueryFunctions(); } - #endif + #endif /* if( configUSE_TRACE_FACILITY == 1 ) */ xReturn &= prvPeekTimeout(); xReturn &= prvQueueQueryFromISR(); diff --git a/FreeRTOS/Demo/Posix_GCC/console.c b/FreeRTOS/Demo/Posix_GCC/console.c index ba26b3fe86..fb3d869bb1 100644 --- a/FreeRTOS/Demo/Posix_GCC/console.c +++ b/FreeRTOS/Demo/Posix_GCC/console.c @@ -39,7 +39,15 @@ StaticSemaphore_t xStdioMutexBuffer; void console_init( void ) { - xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer ); + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + xStdioMutex = xSemaphoreCreateMutexStatic( &xStdioMutexBuffer ); + } + #else /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ + { + xStdioMutex = xSemaphoreCreateMutex( ); + } + #endif /* if( configSUPPORT_STATIC_ALLOCATION == 1 ) */ } void console_print( const char * fmt, diff --git a/FreeRTOS/Demo/Posix_GCC/main_full.c b/FreeRTOS/Demo/Posix_GCC/main_full.c index fe395b2b84..49fa10617a 100644 --- a/FreeRTOS/Demo/Posix_GCC/main_full.c +++ b/FreeRTOS/Demo/Posix_GCC/main_full.c @@ -749,7 +749,9 @@ static void prvDemonstrateTaskStateAndHandleGetFunctions( void ) if( ( xTaskInfo.eCurrentState != eBlocked ) || ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) || ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) || - ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || + #endif ( xTaskInfo.xHandle != xTimerTaskHandle ) ) { pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";