From: rtel Date: Mon, 5 Mar 2018 21:35:50 +0000 (+0000) Subject: Complete testing of changes that allow xQueueOverwrite() to be used on a queue that... X-Git-Tag: V10.1.0~33 X-Git-Url: https://git.sur5r.net/?p=freertos;a=commitdiff_plain;h=66f8bfece5a732fb150c520f18d32d179b2d6a1a Complete testing of changes that allow xQueueOverwrite() to be used on a queue that is part of a queue set. Fix some compiler warnings in stream_buffer.c. Update the MingW/Eclipse project so it also includes static allocation tests. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2532 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/Common/Minimal/QueueSet.c b/FreeRTOS/Demo/Common/Minimal/QueueSet.c index 528ec06c0..2bd0cf60f 100644 --- a/FreeRTOS/Demo/Common/Minimal/QueueSet.c +++ b/FreeRTOS/Demo/Common/Minimal/QueueSet.c @@ -624,7 +624,7 @@ const UBaseType_t xLengthOfOne = ( UBaseType_t ) 1; /* Add an item to the queue then ensure the queue set correctly indicates that one item is available, and that that item is indeed the queue written to. */ - xQueueSend( xQueueHandle, ( void * ) &ulValueToSend, 0 ); + xQueueOverwrite( xQueueHandle, ( void * ) &ulValueToSend ); if( uxQueueMessagesWaiting( xQueueSet ) != ( UBaseType_t ) 1 ) { /* Expected one item in the queue set. */ diff --git a/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c b/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c index 0c812ac8a..a0cdda6c4 100644 --- a/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c +++ b/FreeRTOS/Demo/Common/Minimal/StreamBufferDemo.c @@ -600,7 +600,7 @@ BaseType_t xNonBlockingReceiveError = pdFALSE; xBytesToSend = xStringLength - xNextChar; /* Attempt to send right up to the end of the string. */ - xBytesActuallySent = xStreamBufferSend( xStreamBuffer, ( void * ) &( pc55ByteString[ xNextChar ] ), xBytesToSend, xTicksToWait ); + xBytesActuallySent = xStreamBufferSend( xStreamBuffer, ( const void * ) &( pc55ByteString[ xNextChar ] ), xBytesToSend, xTicksToWait ); configASSERT( xBytesActuallySent <= xBytesToSend ); /* Move the index up the string to the next character to be sent, @@ -661,7 +661,7 @@ BaseType_t xNonBlockingReceiveError = pdFALSE; } while( xReceivedLength == 0 ); /* Ensure the received string matches the expected string. */ - configASSERT( memcmp( ( void * ) cRxString, ( void * ) &( pc55ByteString[ xNextChar ] ), xReceivedLength ) == 0 ); + configASSERT( memcmp( ( void * ) cRxString, ( const void * ) &( pc55ByteString[ xNextChar ] ), xReceivedLength ) == 0 ); /* Move the index into the string up to the end of the bytes received so far - wrapping if the end of the string has been diff --git a/FreeRTOS/Demo/WIN32-MingW/.cproject b/FreeRTOS/Demo/WIN32-MingW/.cproject index b49c52a21..c4882f3f4 100644 --- a/FreeRTOS/Demo/WIN32-MingW/.cproject +++ b/FreeRTOS/Demo/WIN32-MingW/.cproject @@ -2,7 +2,7 @@ - + @@ -12,7 +12,7 @@ - + @@ -64,16 +64,6 @@ - - - - - - - - - - diff --git a/FreeRTOS/Demo/WIN32-MingW/.project b/FreeRTOS/Demo/WIN32-MingW/.project index 07f94ab4e..f23f16227 100644 --- a/FreeRTOS/Demo/WIN32-MingW/.project +++ b/FreeRTOS/Demo/WIN32-MingW/.project @@ -56,7 +56,7 @@ - 1519407948166 + 1520280722235 Standard_Demo_Tasks 5 @@ -65,7 +65,7 @@ - 1519407948169 + 1520280722238 Standard_Demo_Tasks 5 @@ -74,7 +74,7 @@ - 1519407948172 + 1520280722242 Standard_Demo_Tasks 5 @@ -83,7 +83,7 @@ - 1519407948176 + 1520280722245 Standard_Demo_Tasks 5 @@ -92,7 +92,7 @@ - 1519407948179 + 1520280722248 Standard_Demo_Tasks 5 @@ -101,7 +101,7 @@ - 1519407948183 + 1520280722252 Standard_Demo_Tasks 5 @@ -110,7 +110,7 @@ - 1519407948186 + 1520280722255 Standard_Demo_Tasks 5 @@ -119,7 +119,7 @@ - 1519407948190 + 1520280722260 Standard_Demo_Tasks 5 @@ -128,7 +128,7 @@ - 1519407948195 + 1520280722266 Standard_Demo_Tasks 5 @@ -137,7 +137,7 @@ - 1519407948199 + 1520280722269 Standard_Demo_Tasks 5 @@ -146,7 +146,7 @@ - 1519407948202 + 1520280722274 Standard_Demo_Tasks 5 @@ -155,7 +155,7 @@ - 1519407948213 + 1520280722279 Standard_Demo_Tasks 5 @@ -164,7 +164,7 @@ - 1519407948216 + 1520280722282 Standard_Demo_Tasks 5 @@ -173,7 +173,7 @@ - 1519407948224 + 1520280722286 Standard_Demo_Tasks 5 @@ -182,7 +182,7 @@ - 1519407948228 + 1520280722289 Standard_Demo_Tasks 5 @@ -191,7 +191,7 @@ - 1519407948231 + 1520280722292 Standard_Demo_Tasks 5 @@ -200,7 +200,7 @@ - 1519407948235 + 1520280722296 Standard_Demo_Tasks 5 @@ -209,7 +209,7 @@ - 1519407948237 + 1520280722342 Standard_Demo_Tasks 5 @@ -218,7 +218,7 @@ - 1519407948240 + 1520280722367 Standard_Demo_Tasks 5 @@ -227,7 +227,7 @@ - 1519407948242 + 1520280722370 Standard_Demo_Tasks 5 @@ -236,7 +236,7 @@ - 1519407948269 + 1520280722374 Standard_Demo_Tasks 5 @@ -245,7 +245,7 @@ - 1519407948274 + 1520280722380 Standard_Demo_Tasks 5 @@ -254,7 +254,7 @@ - 1519407948277 + 1520280722384 Standard_Demo_Tasks 5 @@ -263,7 +263,7 @@ - 1519407948281 + 1520280722388 Standard_Demo_Tasks 5 @@ -272,7 +272,7 @@ - 1519407948286 + 1520280722391 Standard_Demo_Tasks 5 @@ -280,6 +280,15 @@ 1.0-name-matches-false-false-MessageBufferAMP.c + + 1520280722395 + Standard_Demo_Tasks + 5 + + org.eclipse.ui.ide.multiFilter + 1.0-name-matches-false-false-StaticAllocation.c + + 0 FreeRTOS_Source/portable diff --git a/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h b/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h index f25119d49..671508c9a 100644 --- a/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/WIN32-MingW/FreeRTOSConfig.h @@ -62,7 +62,7 @@ #define configUSE_ALTERNATIVE_API 0 #define configUSE_QUEUE_SETS 1 #define configUSE_TASK_NOTIFICATIONS 1 -#define configSUPPORT_STATIC_ALLOCATION 0 +#define configSUPPORT_STATIC_ALLOCATION 1 /* Software timer related configuration options. */ #define configUSE_TIMERS 1 @@ -114,7 +114,7 @@ uses the same semantics as the standard C assert() macro. */ extern void vAssertCalled( unsigned long ulLine, const char * const pcFileName ); #define configASSERT( x ) if( ( x ) == 0 ) vAssertCalled( __LINE__, __FILE__ ) -#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 1 +#define configINCLUDE_MESSAGE_BUFFER_AMP_DEMO 0 #if ( configINCLUDE_MESSAGE_BUFFER_AMP_DEMO == 1 ) extern void vGenerateCoreBInterrupt( void * xUpdatedMessageBuffer ); #define sbSEND_COMPLETED( pxStreamBuffer ) vGenerateCoreBInterrupt( pxStreamBuffer ) diff --git a/FreeRTOS/Demo/WIN32-MingW/main.c b/FreeRTOS/Demo/WIN32-MingW/main.c index 1c994bcb7..cfb16a4b0 100644 --- a/FreeRTOS/Demo/WIN32-MingW/main.c +++ b/FreeRTOS/Demo/WIN32-MingW/main.c @@ -75,9 +75,9 @@ that make up the total heap. heap_5 is only used for test and example purposes as this demo could easily create one large heap region instead of multiple smaller heap regions - in which case heap_4.c would be the more appropriate choice. See http://www.freertos.org/a00111.html for an explanation. */ -#define mainREGION_1_SIZE 7201 +#define mainREGION_1_SIZE 8201 #define mainREGION_2_SIZE 29905 -#define mainREGION_3_SIZE 6407 +#define mainREGION_3_SIZE 6007 /*-----------------------------------------------------------*/ @@ -111,6 +111,8 @@ void vApplicationMallocFailedHook( void ); void vApplicationIdleHook( void ); void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationTickHook( void ); +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ); +void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ); /* * Writes trace data to a disk file when the trace recording is stopped. @@ -118,6 +120,15 @@ void vApplicationTickHook( void ); */ static void prvSaveTraceFile( void ); +/*-----------------------------------------------------------*/ + +/* When configSUPPORT_STATIC_ALLOCATION is set to 1 the application writer can +use a callback function to optionally provide the memory required by the idle +and timer tasks. This is the stack that will be used by the timer task. It is +declared here, as a global, so it can be checked by a test that is implemented +in a different file. */ +StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ]; + /* Notes if the trace is running or not. */ static BaseType_t xTraceRunning = pdTRUE; @@ -341,3 +352,52 @@ const HeapRegion_t xHeapRegions[] = vPortDefineHeapRegions( xHeapRegions ); } /*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION is set to 1, so the application must provide an +implementation of vApplicationGetIdleTaskMemory() to provide the memory that is +used by the Idle task. */ +void vApplicationGetIdleTaskMemory( StaticTask_t **ppxIdleTaskTCBBuffer, StackType_t **ppxIdleTaskStackBuffer, uint32_t *pulIdleTaskStackSize ) +{ +/* If the buffers to be provided to the Idle task are declared inside this +function then they must be declared static - otherwise they will be allocated on +the stack and so not exists after this function exits. */ +static StaticTask_t xIdleTaskTCB; +static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ]; + + /* Pass out a pointer to the StaticTask_t structure in which the Idle task's + state will be stored. */ + *ppxIdleTaskTCBBuffer = &xIdleTaskTCB; + + /* Pass out the array that will be used as the Idle task's stack. */ + *ppxIdleTaskStackBuffer = uxIdleTaskStack; + + /* Pass out the size of the array pointed to by *ppxIdleTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulIdleTaskStackSize = configMINIMAL_STACK_SIZE; +} +/*-----------------------------------------------------------*/ + +/* configUSE_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the +application must provide an implementation of vApplicationGetTimerTaskMemory() +to provide the memory that is used by the Timer service task. */ +void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer, StackType_t **ppxTimerTaskStackBuffer, uint32_t *pulTimerTaskStackSize ) +{ +/* If the buffers to be provided to the Timer task are declared inside this +function then they must be declared static - otherwise they will be allocated on +the stack and so not exists after this function exits. */ +static StaticTask_t xTimerTaskTCB; + + /* Pass out a pointer to the StaticTask_t structure in which the Timer + task's state will be stored. */ + *ppxTimerTaskTCBBuffer = &xTimerTaskTCB; + + /* Pass out the array that will be used as the Timer task's stack. */ + *ppxTimerTaskStackBuffer = uxTimerTaskStack; + + /* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer. + Note that, as the array is necessarily of type StackType_t, + configMINIMAL_STACK_SIZE is specified in words, not bytes. */ + *pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH; +} + diff --git a/FreeRTOS/Demo/WIN32-MingW/main_full.c b/FreeRTOS/Demo/WIN32-MingW/main_full.c index b67a6fd0c..38e303521 100644 --- a/FreeRTOS/Demo/WIN32-MingW/main_full.c +++ b/FreeRTOS/Demo/WIN32-MingW/main_full.c @@ -74,10 +74,10 @@ /* Kernel includes. */ #include -#include "task.h" -#include "queue.h" -#include "timers.h" -#include "semphr.h" +#include +#include +#include +#include /* Standard demo includes. */ #include "BlockQ.h" @@ -98,6 +98,7 @@ #include "IntSemTest.h" #include "TaskNotify.h" #include "QueueSetPolling.h" +#include "StaticAllocation.h" #include "blocktim.h" #include "AbortDelay.h" #include "MessageBufferDemo.h" @@ -209,6 +210,12 @@ int main_full( void ) vStartStreamBufferInterruptDemo(); vStartMessageBufferAMPTasks(); + #if( configSUPPORT_STATIC_ALLOCATION == 1 ) + { + vStartStaticallyAllocatedTasks(); + } + #endif + #if( configUSE_PREEMPTION != 0 ) { /* Don't expect these tasks to pass when preemption is not used. */ @@ -577,6 +584,7 @@ char *pcTaskName; static portBASE_TYPE xPerformedOneShotTests = pdFALSE; TaskHandle_t xTestTask; TaskStatus_t xTaskInfo; +extern StackType_t uxTimerTaskStack[]; /* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and xTaskGetIdleTaskHandle() functions. Also try using the function that sets @@ -637,6 +645,7 @@ TaskStatus_t xTaskInfo; if( ( xTaskInfo.eCurrentState != eBlocked ) || ( strcmp( xTaskInfo.pcTaskName, "Tmr Svc" ) != 0 ) || ( xTaskInfo.uxCurrentPriority != configTIMER_TASK_PRIORITY ) || + ( xTaskInfo.pxStackBase != uxTimerTaskStack ) || ( xTaskInfo.xHandle != xTimerTaskHandle ) ) { pcStatusMessage = "Error: vTaskGetInfo() returned incorrect information about the timer task";