From 9da84ad61903f51213117867366f22c3f9e63c7e Mon Sep 17 00:00:00 2001 From: rtel Date: Fri, 19 Dec 2014 16:27:56 +0000 Subject: [PATCH] Kernel changes: + Do not attempt to free the stack of a deleted task if the stack was statically allocated. + Introduce configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES - which optionally writes known values into the list and list item data structures in order to assist with the detection of memory corruptions. Microblase port: +Change occurrences of #if XPAR_MICROBLAZE_0_USE_FPU == 1 to #if XPAR_MICROBLAZE_0_USE_FPU != 0 as the value can also be 2 or 3. Demo app modifications: + Update Zynq project to use the 2014.4 tools and add in tests for the new task notification feature. + Update SAM4S project to include tests for the new task notification feature. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2316 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../RTOSDemo/src/FreeRTOSConfig.h | 1 - .../RTOSDemo/src/Full_Demo/main_full.c | 45 ++++-- .../CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c | 8 + .../CreateProjectDirectoryStructure.bat | 5 + .../RTOSDemo.atsuo | Bin 61952 -> 62976 bytes .../RTOSDemo.cproj | 31 ++-- .../src/FreeRTOSConfig.h | 3 +- .../CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c | 14 +- .../src/main_full.c | 137 ++++++++++++++---- FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h | 2 +- FreeRTOS/Demo/WIN32-MSVC/main.c | 11 +- FreeRTOS/Source/include/list.h | 46 ++++++ FreeRTOS/Source/include/projdefs.h | 11 ++ FreeRTOS/Source/list.c | 22 +++ .../Source/portable/GCC/MicroBlazeV8/port.c | 2 +- .../GCC/MicroBlazeV8/port_exceptions.c | 28 ++-- .../portable/GCC/MicroBlazeV8/portasm.S | 14 +- FreeRTOS/Source/tasks.c | 45 +++++- 18 files changed, 327 insertions(+), 98 deletions(-) diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h index d0bf8b2ed..038fc6348 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/FreeRTOSConfig.h @@ -106,7 +106,6 @@ */ #define configMAX_API_CALL_INTERRUPT_PRIORITY 18 - #define configCPU_CLOCK_HZ 100000000UL #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 #define configUSE_TICKLESS_IDLE 0 diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c index 36cd22b0b..f11db5ac7 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/Full_Demo/main_full.c @@ -144,6 +144,8 @@ #include "QueueOverwrite.h" #include "IntQueue.h" #include "EventGroupsDemo.h" +#include "TaskNotify.h" +#include "IntSemTest.h" /* Priorities for the demo application tasks. */ #define mainSEM_TEST_PRIORITY ( tskIDLE_PRIORITY + 1UL ) @@ -250,6 +252,9 @@ void main_full( void ) vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); vStartQueueOverwriteTask( mainQUEUE_OVERWRITE_PRIORITY ); vStartEventGroupTasks(); + vStartTaskNotifyTask(); + vStartInterruptSemaphoreTasks(); + /* Start the tasks that implements the command console on the UART, as described above. */ @@ -318,80 +323,90 @@ unsigned long ulErrorFound = pdFALSE; that they are all still running, and that none have detected an error. */ if( xAreIntQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 0UL; } if( xAreMathsTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 1UL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 2UL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 3UL; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 4UL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 5UL; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 6UL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 7UL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 8UL; } if( xAreTimerDemoTasksStillRunning( ( TickType_t ) mainNO_ERROR_CHECK_TASK_PERIOD ) != pdPASS ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 9UL; } if( xAreCountingSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 10UL; } if( xIsQueueOverwriteTaskStillRunning() != pdPASS ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 11UL; } if( xAreEventGroupTasksStillRunning() != pdPASS ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 12UL; + } + + if( xAreTaskNotificationTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 13UL; + } + + if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 14UL; } /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1LoopCounter ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 15UL; } ulLastRegTest1Value = ulRegTest1LoopCounter; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2LoopCounter ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 16UL; } ulLastRegTest2Value = ulRegTest2LoopCounter; diff --git a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c index 108b39ee6..fe97be62e 100644 --- a/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c +++ b/FreeRTOS/Demo/CORTEX_A9_Zynq_ZC702/RTOSDemo/src/main.c @@ -105,6 +105,8 @@ #include "TimerDemo.h" #include "QueueOverwrite.h" #include "EventGroupsDemo.h" +#include "TaskNotify.h" +#include "IntSemTest.h" /* Xilinx includes. */ #include "platform.h" @@ -311,6 +313,12 @@ void vApplicationTickHook( void ) /* Call the periodic event group from ISR demo. */ vPeriodicEventGroupsProcessing(); + + /* Use task notifications from an interrupt. */ + xNotifyTaskFromISR(); + + /* Use mutexes from interrupts. */ + vInterruptSemaphorePeriodicTest(); } #endif } diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/CreateProjectDirectoryStructure.bat b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/CreateProjectDirectoryStructure.bat index 26df7ce1d..4150f521e 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/CreateProjectDirectoryStructure.bat +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/CreateProjectDirectoryStructure.bat @@ -24,6 +24,7 @@ IF EXIST src\asf\thirdparty\FreeRTOS Goto END copy %FREERTOS_SOURCE%\queue.c src\asf\thirdparty\FreeRTOS copy %FREERTOS_SOURCE%\list.c src\asf\thirdparty\FreeRTOS copy %FREERTOS_SOURCE%\timers.c src\asf\thirdparty\FreeRTOS + copy %FREERTOS_SOURCE%\event_groups.c src\asf\thirdparty\FreeRTOS REM Copy the common header files into the project directory copy %FREERTOS_SOURCE%\include\*.* src\asf\thirdparty\FreeRTOS\include @@ -48,6 +49,10 @@ IF EXIST src\asf\thirdparty\FreeRTOS Goto END copy %COMMON_SOURCE%\integer.c src\Common-Demo-Source copy %COMMON_SOURCE%\QueueSet.c src\Common-Demo-Source COPY %COMMON_SOURCE%\IntQueue.c src\Common-Demo-Source + COPY %COMMON_SOURCE%\TaskNotify.c src\Common-Demo-Source + COPY %COMMON_SOURCE%\TimerDemo.c src\Common-Demo-Source + COPY %COMMON_SOURCE%\EventGroupsDemo.c src\Common-Demo-Source + COPY %COMMON_SOURCE%\IntSemTest.c src\Common-Demo-Source REM Copy the common demo file headers. copy %COMMON_INCLUDE%\*.h src\Common-Demo-Source\include diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/RTOSDemo.atsuo b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/RTOSDemo.atsuo index e72f99e07a5dbf3d7453108ab8bd0f541b39d0ea..a19959c2db33b42d383adc4c5bb5a835049ac0bb 100644 GIT binary patch delta 3220 zcmai03slrq8voy!|4cJVIK%tR$SV-V!3Qc~i~?ym2_$J5PXPnvISlwH1HYS}=~8Ywn=t3q;$)**4E6``r;dyPfUqJ?D4+-~H})zx&U?x-%_`X#m zUrzthnC5F0i=A^qw*I``x0}gnO~{efiffrNiO7?IxTmNWxhU$C8Db6bFrd_l7EWj$ zG59}A1h;Alfm_6_TuOL>a33X)G>ElCwW$*2s!Srn3FvMNm&{}TqCkfj4YM{y%}D>S z)9BKWHbsUGO*}Tb%~f$9c#Nzl-I*Y~r^G$CWOQocQ0tzk8bfQ&BkKxpBC_zadj)iN zreT-IdRz=rK`*M%8RQ0or-jL+9#4}@&D==Rbz~dNJ}GL!k7k~uoFSi0GMOA}eV-yj zW?TKPvSUcw^bTtMJ2(Ti0jrr2KL;eM1#bG-(S7E?6m*PM|H+kS5H19V zu}fe}d+_P+oOKspHZEfyz0!2V-|abJ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OPrG5^ymE9tl8)~i2MBx4IWp<1N*%(MetXOgBT0$38P?R3(4Wdq zy4KQt9kHIsAvO@X#75#vB9F)?HW3D5GqHszAPNa1ArK&nh^@pn;wz$|~sbdw)1}6GOpfPXs-5$N5Ir-$m)Z))$RG&6BDEN`s1`Hwh;mO~5}Mbd$wMr#z9R z<8}BFF<-A>!ht%6INC=dA%$~y>jBoWGcDFYNVW$3RmPq_f)f zA;YIW^})&?=VC$07>s(NM*iQ`qVBj8`%Td-SmcAn$K~`=HXImUn)oG+qvDM(>I8857Mo@S{)(v>L6+zr(vG# zLeHfCgsLpQ`Nj~uc_pARUL$HQm>5Q13`Ik)J~&Y5kRHvC~e`YCFfJaDJN zQ)Xb)5l7Q50;(^WWWv_rXv~@=eG-&U&A*(FDvBv=n&@>aVYPa{KWdF0qUnl;7kV5} z`W9F1O=8<7j7?moA9J?NUWts$(bYFD+VM{GLe`SMebb(gwrOa+m%>kJS9CvEdUZz) z8U9Pqg{~XNV|d>Hf$37*Mc;MqSTQ8Hc ze?GOKSS&o&8-0H+qIs6vR$75p!)zoSokbDfN=cG|tHq`Gp{W4>e!dLy8mUcqVe~wI zF=J;0bDwS95&im^bT(Ni{az`z77JP4oDCvbhErvgxWNaoai~>|K)%WyuAO?}NkA8v cR>VtR1t``#p*nLAG>28 - + @@ -267,11 +267,6 @@ True -T../src/asf/sam/utils/linker_scripts/sam4s/sam4s16/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb - - - ../src/ASF/sam/drivers/tc - - -DARM_MATH_CM4=true -DBOARD=SAM4S_EK -D__SAM4S16C__ @@ -372,12 +367,8 @@ True + -T../src/asf/sam/utils/linker_scripts/sam4s/sam4s16/gcc/flash.ld -Wl,--cref -Wl,--entry=Reset_Handler -mthumb - - - ../src/ASF/sam/drivers/tc - - -DARM_MATH_CM4=true -DBOARD=SAM4S_EK -D__SAM4S16C__ @@ -423,18 +414,36 @@ compile + + compile + compile + + compile + compile + + compile + compile + + compile + compile + + compile + + + compile + compile diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h index f55e4c763..c0e105e37 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/FreeRTOSConfig.h @@ -91,7 +91,7 @@ extern uint32_t SystemCoreClock; #define configUSE_PREEMPTION 1 #define configUSE_PORT_OPTIMISED_TASK_SELECTION 1 -#define configUSE_IDLE_HOOK 0 +#define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 1 #define configCPU_CLOCK_HZ ( SystemCoreClock ) #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) @@ -132,6 +132,7 @@ to exclude the API function. */ #define INCLUDE_vTaskDelayUntil 1 #define INCLUDE_vTaskDelay 1 #define INCLUDE_eTaskGetState 1 +#define INCLUDE_xTimerPendFunctionCall 1 /* Cortex-M specific definitions. */ #ifdef __NVIC_PRIO_BITS diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c index ed98eb91f..ad69a329b 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main.c @@ -85,7 +85,6 @@ /* Standard demo includes. */ #include "partest.h" -#include "QueueSet.h" /* Atmel library includes. */ #include @@ -181,6 +180,14 @@ void vApplicationIdleHook( void ) important that vApplicationIdleHook() is permitted to return to its calling function, because it is the responsibility of the idle task to clean up memory allocated by the kernel to any task that has since been deleted. */ + + #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) + { + extern void vFullDemoIdleHook( void ); + + vFullDemoIdleHook(); + } + #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */ } /*-----------------------------------------------------------*/ @@ -207,8 +214,9 @@ void vApplicationTickHook( void ) #if ( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 0 ) { - /* In this case the tick hook is used as part of the queue set test. */ - vQueueSetAccessQueueSetFromISR(); + extern void vFullDemoTickHook( void ); + + vFullDemoTickHook(); } #endif /* mainCREATE_SIMPLE_BLINKY_DEMO_ONLY */ } diff --git a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c index 2067f66bb..4e4495cec 100644 --- a/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c +++ b/FreeRTOS/Demo/CORTEX_M4_ATSAM4S_Atmel_Studio/src/main_full.c @@ -124,6 +124,10 @@ #include "comtest2.h" #include "QueueSet.h" #include "IntQueue.h" +#include "TaskNotify.h" +#include "TimerDemo.h" +#include "EventGroupsDemo.h" +#include "IntSemTest.h" /* Atmel library includes. */ #include "asf.h" @@ -142,12 +146,12 @@ /* The period after which the check timer will expire, in ms, provided no errors have been reported by any of the standard demo tasks. ms are converted to the equivalent in ticks using the portTICK_PERIOD_MS constant. */ -#define mainCHECK_TIMER_PERIOD_MS ( 3000UL / portTICK_PERIOD_MS ) +#define mainCHECK_TIMER_PERIOD_MS ( pdMS_TO_TICKS( 3000UL ) ) /* The period at which the check timer will expire, in ms, if an error has been reported in one of the standard demo tasks. ms are converted to the equivalent in ticks using the portTICK_PERIOD_MS constant. */ -#define mainERROR_CHECK_TIMER_PERIOD_MS ( 200UL / portTICK_PERIOD_MS ) +#define mainERROR_CHECK_TIMER_PERIOD_MS ( pdMS_TO_TICKS( 200UL ) ) /* The standard demo flash timers can be used to flash any number of LEDs. In this case, because only three LEDs are available, and one is in use by the @@ -165,8 +169,23 @@ standard demo flash timers. */ for the comtest, so the LED number is deliberately out of range. */ #define mainCOM_TEST_LED ( 3 ) +/* Used by the standard demo timer tasks. */ +#define mainTIMER_TEST_PERIOD ( 50 ) + /*-----------------------------------------------------------*/ +/* + * Called by the idle hook function when the project is configured to run the + * full (as opposed to the blinky) demo. + */ +void vFullDemoIdleHook( void ); + +/* + * Called by the tick hook function when the project is configured to run the + * full (as opposed to the blinky) demo. + */ +void vFullDemoTickHook( void ); + /* * The check timer callback function, as described at the top of this file. */ @@ -176,8 +195,6 @@ static void prvCheckTimerCallback( TimerHandle_t xTimer ); void main_full( void ) { -TimerHandle_t xCheckTimer = NULL; - /* Start all the other standard demo/test tasks. The have not particular functionality, but do demonstrate how to use the FreeRTOS API and test the kernel port. */ @@ -191,23 +208,12 @@ TimerHandle_t xCheckTimer = NULL; vStartRecursiveMutexTasks(); vStartPolledQueueTasks( mainQUEUE_POLL_PRIORITY ); vStartSemaphoreTasks( mainSEM_TEST_PRIORITY ); - vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS ); vAltStartComTestTasks( mainCOM_TEST_PRIORITY, mainCOM_TEST_BAUD_RATE, mainCOM_TEST_LED ); vStartQueueSetTasks(); - - /* Create the software timer that performs the 'check' functionality, - as described at the top of this file. */ - xCheckTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */ - ( mainCHECK_TIMER_PERIOD_MS ), /* The timer period, in this case 3000ms (3s). */ - pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ - ( void * ) 0, /* The ID is not used, so can be set to anything. */ - prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ - ); - - if( xCheckTimer != NULL ) - { - xTimerStart( xCheckTimer, mainDONT_BLOCK ); - } + vStartTaskNotifyTask(); + vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); + vStartEventGroupTasks(); + vStartInterruptSemaphoreTasks(); /* The set of tasks created by the following function call have to be created last as they keep account of the number of tasks they expect to see @@ -236,63 +242,84 @@ unsigned long ulErrorFound = pdFALSE; if( xAreIntQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 0UL; } if( xAreIntegerMathsTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 1UL; } if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 2UL; } if( xAreBlockingQueuesStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 3UL; } if ( xAreBlockTimeTestTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 4UL; } if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 5UL; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 6UL; } if( xIsCreateTaskStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 7UL; } if( xArePollingQueuesStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 8UL; } if( xAreSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 9UL; } if( xAreComTestTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 10UL; } - if( xAreQueueSetTasksStillRunning() != pdPASS ) + if( xAreQueueSetTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 11UL; + } + + if( xAreTaskNotificationTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 12UL; + } + + if( xAreTimerDemoTasksStillRunning( mainCHECK_TIMER_PERIOD_MS ) != pdTRUE ) + { + ulErrorFound |= 1UL << 13UL; + } + + if( xAreEventGroupTasksStillRunning() != pdTRUE ) + { + ulErrorFound |= 1UL << 14UL; + } + + if( xAreInterruptSemaphoreTasksStillRunning() != pdTRUE ) { - ulErrorFound = pdTRUE; + ulErrorFound |= 1UL << 15UL; } + /* Toggle the check LED to give an indication of the system status. If the LED toggles every mainCHECK_TIMER_PERIOD_MS milliseconds then @@ -318,3 +345,49 @@ unsigned long ulErrorFound = pdFALSE; } /*-----------------------------------------------------------*/ +void vFullDemoIdleHook( void ) +{ +static TimerHandle_t xCheckTimer = NULL; + + if( xCheckTimer == NULL ) + { + /* Create the software timer that performs the 'check' + functionality, in the full demo. This is not done before the + scheduler is started as to do so would prevent the standard demo + timer tasks from passing their tests (they expect the timer + command queue to be empty. */ + xCheckTimer = xTimerCreate( "CheckTimer", /* A text name, purely to help debugging. */ + mainCHECK_TIMER_PERIOD_MS, /* The timer period, in this case 3000ms (3s). */ + pdTRUE, /* This is an auto-reload timer, so xAutoReload is set to pdTRUE. */ + ( void * ) 0, /* The ID is not used, so can be set to anything. */ + prvCheckTimerCallback /* The callback function that inspects the status of all the other tasks. */ + ); + + if( xCheckTimer != NULL ) + { + xTimerStart( xCheckTimer, mainDONT_BLOCK ); + } + + /* Also start some timers that just flash LEDs. */ + vStartLEDFlashTimers( mainNUMBER_OF_FLASH_TIMERS_LEDS ); + } +} +/*-----------------------------------------------------------*/ + +void vFullDemoTickHook( void ) +{ + /* In this case the tick hook is used as part of the queue set test. */ + vQueueSetAccessQueueSetFromISR(); + + /* Use task notifications from an interrupt. */ + xNotifyTaskFromISR(); + + /* Use timers from an interrupt. */ + vTimerPeriodicISRTests(); + + /* Use event groups from an interrupt. */ + vPeriodicEventGroupsProcessing(); + + /* Use mutexes from interrupts. */ + vInterruptSemaphorePeriodicTest(); +} diff --git a/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h b/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h index e4f6ce87b..03f9f68aa 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/WIN32-MSVC/FreeRTOSConfig.h @@ -83,7 +83,7 @@ #define configUSE_TICK_HOOK 1 #define configTICK_RATE_HZ ( 1000 ) /* In this non-real time simulated environment the tick frequency has to be at least a multiple of the Win32 tick frequency, and therefore very slow. */ #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 50 ) /* In this simulated case, the stack only has to hold one small structure as the real stack is part of the win32 thread. */ -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 23 * 1024 ) ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 24 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 12 ) #define configUSE_TRACE_FACILITY 1 #define configUSE_16_BIT_TICKS 0 diff --git a/FreeRTOS/Demo/WIN32-MSVC/main.c b/FreeRTOS/Demo/WIN32-MSVC/main.c index 6c10d8dde..21332acc3 100644 --- a/FreeRTOS/Demo/WIN32-MSVC/main.c +++ b/FreeRTOS/Demo/WIN32-MSVC/main.c @@ -112,9 +112,9 @@ that make up the total heap. This is only done to provide an example of heap_5 being used 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. */ -#define mainREGION_1_SIZE 3001 +#define mainREGION_1_SIZE 4001 #define mainREGION_2_SIZE 18105 -#define mainREGION_3_SIZE 1407 +#define mainREGION_3_SIZE 1807 /* * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1. @@ -228,10 +228,10 @@ void vApplicationIdleHook( void ) function, because it is the responsibility of the idle task to clean up memory allocated by the kernel to any task that has since been deleted. */ - /* Uncomment the following code to allow the trace to be stopped with any + /* Uncomment the following code to allow the trace to be stopped with any key press. The code is commented out by default as the kbhit() function interferes with the run time behaviour. */ - /* + /* if( _kbhit() != pdFALSE ) { if( xTraceRunning == pdTRUE ) @@ -367,6 +367,9 @@ const HeapRegion_t xHeapRegions[] = array. */ configASSERT( ( ulAdditionalOffset + mainREGION_1_SIZE + mainREGION_2_SIZE + mainREGION_3_SIZE ) < configTOTAL_HEAP_SIZE ); + /* Prevent compiler warnings when configASSERT() is not defined. */ + ( void ) ulAdditionalOffset; + vPortDefineHeapRegions( xHeapRegions ); } /*-----------------------------------------------------------*/ diff --git a/FreeRTOS/Source/include/list.h b/FreeRTOS/Source/include/list.h index 99be287fc..70d53da0a 100644 --- a/FreeRTOS/Source/include/list.h +++ b/FreeRTOS/Source/include/list.h @@ -91,6 +91,9 @@ * \ingroup FreeRTOSIntro */ +#ifndef INC_FREERTOS_H + #error FreeRTOS.h must be included before list.h +#endif #ifndef LIST_H #define LIST_H @@ -130,21 +133,62 @@ #ifdef __cplusplus extern "C" { #endif + +/* Macros that can be used to place known values within the list structures, +then check that the known values do not get corrupted during the execution of +the application. These may catch the list data structures being overwritten in +memory. They will not catch data errors caused by incorrect configuration or +use of FreeRTOS.*/ +#if( configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES == 0 ) + /* Define the macros to do nothing. */ + #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 + #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_2 + #define listLIST_INTEGRITY_CHECK_VALUE_1 + #define listLIST_INTEGRITY_CHECK_VALUE_2 + #define listSET_LIST_ITEM_INTEGRITY_CHECK_1_VALUE( pxItem ) + #define listSET_LIST_ITEM_INTEGRITY_CHECK_2_VALUE( pxItem ) + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) + #define listTEST_LIST_INTEGRITY( pxList ) +#else + /* Define macros that add new members into the list structures. */ + #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 TickType_t xListItemIntegrityValue1; + #define listLIST_ITEM_INTEGRITY_CHECK_VALUE_2 TickType_t xListItemIntegrityValue2; + #define listLIST_INTEGRITY_CHECK_VALUE_1 TickType_t xListIntegrityValue1; + #define listLIST_INTEGRITY_CHECK_VALUE_2 TickType_t xListIntegrityValue2; + + /* Define macros that set the new structure members to known values. */ + #define listSET_LIST_ITEM_INTEGRITY_CHECK_1_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_ITEM_INTEGRITY_CHECK_2_VALUE( pxItem ) ( pxItem )->xListItemIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ) ( pxList )->xListIntegrityValue1 = pdINTEGRITY_CHECK_VALUE + #define listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ) ( pxList )->xListIntegrityValue2 = pdINTEGRITY_CHECK_VALUE + + /* Define macros that will assert if one of the structure members does not + contain its expected value. */ + #define listTEST_LIST_ITEM_INTEGRITY( pxItem ) configASSERT( ( ( pxItem )->xListItemIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxItem )->xListItemIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) + #define listTEST_LIST_INTEGRITY( pxList ) configASSERT( ( ( pxList )->xListIntegrityValue1 == pdINTEGRITY_CHECK_VALUE ) && ( ( pxList )->xListIntegrityValue2 == pdINTEGRITY_CHECK_VALUE ) ) +#endif /* configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES */ + + /* * Definition of the only type of object that a list can contain. */ struct xLIST_ITEM { + listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ configLIST_VOLATILE TickType_t xItemValue; /*< The value being listed. In most cases this is used to sort the list in descending order. */ struct xLIST_ITEM * configLIST_VOLATILE pxNext; /*< Pointer to the next ListItem_t in the list. */ struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; /*< Pointer to the previous ListItem_t in the list. */ void * pvOwner; /*< Pointer to the object (normally a TCB) that contains the list item. There is therefore a two way link between the object containing the list item and the list item itself. */ void * configLIST_VOLATILE pvContainer; /*< Pointer to the list in which this list item is placed (if any). */ + listLIST_ITEM_INTEGRITY_CHECK_VALUE_2 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ }; typedef struct xLIST_ITEM ListItem_t; /* For some reason lint wants this as two separate definitions. */ struct xMINI_LIST_ITEM { + listLIST_ITEM_INTEGRITY_CHECK_VALUE_1 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ configLIST_VOLATILE TickType_t xItemValue; struct xLIST_ITEM * configLIST_VOLATILE pxNext; struct xLIST_ITEM * configLIST_VOLATILE pxPrevious; @@ -156,9 +200,11 @@ typedef struct xMINI_LIST_ITEM MiniListItem_t; */ typedef struct xLIST { + listLIST_INTEGRITY_CHECK_VALUE_1 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ configLIST_VOLATILE UBaseType_t uxNumberOfItems; ListItem_t * configLIST_VOLATILE pxIndex; /*< Used to walk through the list. Points to the last item returned by a call to listGET_OWNER_OF_NEXT_ENTRY (). */ MiniListItem_t xListEnd; /*< List item that contains the maximum possible item value meaning it is always at the end of the list and is therefore used as a marker. */ + listLIST_INTEGRITY_CHECK_VALUE_2 /*< Set to a known value if configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ } List_t; /* diff --git a/FreeRTOS/Source/include/projdefs.h b/FreeRTOS/Source/include/projdefs.h index 0062738af..8aa751255 100644 --- a/FreeRTOS/Source/include/projdefs.h +++ b/FreeRTOS/Source/include/projdefs.h @@ -88,6 +88,17 @@ typedef void (*TaskFunction_t)( void * ); #define errQUEUE_BLOCKED ( -4 ) #define errQUEUE_YIELD ( -5 ) +/* Macros used for basic data corruption checks. */ +#ifndef configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES + #define configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES 0 +#endif + +#if( configUSE_16_BIT_TICKS == 1 ) + #define pdINTEGRITY_CHECK_VALUE 0x5a5a +#else + #define pdINTEGRITY_CHECK_VALUE 0x5a5a5a5aUL +#endif + #endif /* PROJDEFS_H */ diff --git a/FreeRTOS/Source/list.c b/FreeRTOS/Source/list.c index a8d9d5b90..d256fae4c 100644 --- a/FreeRTOS/Source/list.c +++ b/FreeRTOS/Source/list.c @@ -89,6 +89,11 @@ void vListInitialise( List_t * const pxList ) pxList->xListEnd.pxPrevious = ( ListItem_t * ) &( pxList->xListEnd );/*lint !e826 !e740 The mini list structure is used as the list end to save RAM. This is checked and valid. */ pxList->uxNumberOfItems = ( UBaseType_t ) 0U; + + /* Write known values into the list if + configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listSET_LIST_INTEGRITY_CHECK_1_VALUE( pxList ); + listSET_LIST_INTEGRITY_CHECK_2_VALUE( pxList ); } /*-----------------------------------------------------------*/ @@ -96,6 +101,11 @@ void vListInitialiseItem( ListItem_t * const pxItem ) { /* Make sure the list item is not recorded as being on a list. */ pxItem->pvContainer = NULL; + + /* Write known values into the list item if + configUSE_LIST_DATA_INTEGRITY_CHECK_BYTES is set to 1. */ + listSET_LIST_ITEM_INTEGRITY_CHECK_1_VALUE( pxItem ); + listSET_LIST_ITEM_INTEGRITY_CHECK_2_VALUE( pxItem ); } /*-----------------------------------------------------------*/ @@ -103,6 +113,12 @@ void vListInsertEnd( List_t * const pxList, ListItem_t * const pxNewListItem ) { ListItem_t * const pxIndex = pxList->pxIndex; + /* Only effective when configASSERT() is also defined, these tests may catch + the list data structures being overwritten in memory. They will not catch + data errors caused by incorrect configuration or use of FreeRTOS. */ + listTEST_LIST_INTEGRITY( pxList ); + listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); + /* Insert a new list item into pxList, but rather than sort the list, makes the new list item the last item to be removed by a call to listGET_OWNER_OF_NEXT_ENTRY(). */ @@ -123,6 +139,12 @@ void vListInsert( List_t * const pxList, ListItem_t * const pxNewListItem ) ListItem_t *pxIterator; const TickType_t xValueOfInsertion = pxNewListItem->xItemValue; + /* Only effective when configASSERT() is also defined, these tests may catch + the list data structures being overwritten in memory. They will not catch + data errors caused by incorrect configuration or use of FreeRTOS. */ + listTEST_LIST_INTEGRITY( pxList ); + listTEST_LIST_ITEM_INTEGRITY( pxNewListItem ); + /* Insert the new list item into the list, sorted in xItemValue order. If the list already contains a list item with the same item value then the diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c index 25b04f49b..c4a24cbea 100644 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port.c @@ -155,7 +155,7 @@ const uint32_t ulR13 = ( uint32_t ) &_SDA_BASE_; *pxTopOfStack = ( StackType_t ) 0x00000000; pxTopOfStack--; - #if XPAR_MICROBLAZE_0_USE_FPU == 1 + #if XPAR_MICROBLAZE_0_USE_FPU != 0 /* The FSR value placed in the initial task context is just 0. */ *pxTopOfStack = portINITIAL_FSR; pxTopOfStack--; diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c index 800eaa203..d25fe5aee 100644 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/port_exceptions.c @@ -1,5 +1,5 @@ /* - FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. + FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -120,10 +120,10 @@ extern void vPortExceptionHandlerEntry( void *pvExceptionID ); /*-----------------------------------------------------------*/ -/* vApplicationExceptionRegisterDump() is a callback function that the +/* vApplicationExceptionRegisterDump() is a callback function that the application can optionally define to receive a populated xPortRegisterDump -structure. If the application chooses not to define a version of -vApplicationExceptionRegisterDump() then this weekly defined default +structure. If the application chooses not to define a version of +vApplicationExceptionRegisterDump() then this weekly defined default implementation will be called instead. */ extern void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump ) __attribute__((weak)); void vApplicationExceptionRegisterDump( xPortRegisterDump *xRegisterDump ) @@ -143,8 +143,8 @@ extern void *pxCurrentTCB; /* Fill an xPortRegisterDump structure with the MicroBlaze context as it was immediately before the exception occurrence. */ - - /* First fill in the name and handle of the task that was in the Running + + /* First fill in the name and handle of the task that was in the Running state when the exception occurred. */ xRegisterDump.xCurrentTaskHandle = pxCurrentTCB; xRegisterDump.pcCurrentTaskName = pcTaskGetTaskName( NULL ); @@ -167,7 +167,7 @@ extern void *pxCurrentTCB; xRegisterDump.ulR18 = pulStackPointerOnFunctionEntry[ portexR18_STACK_OFFSET ]; xRegisterDump.ulR19 = pulStackPointerOnFunctionEntry[ portexR19_STACK_OFFSET ]; xRegisterDump.ulMSR = pulStackPointerOnFunctionEntry[ portexMSR_STACK_OFFSET ]; - + /* Obtain the value of all other registers. */ xRegisterDump.ulR2_small_data_area = mfgpr( R2 ); xRegisterDump.ulR13_read_write_small_data_area = mfgpr( R13 ); @@ -190,13 +190,13 @@ extern void *pxCurrentTCB; xRegisterDump.ulEAR = mfear(); xRegisterDump.ulESR = mfesr(); xRegisterDump.ulEDR = mfedr(); - + /* Move the saved program counter back to the instruction that was executed when the exception occurred. This is only valid for certain types of exception. */ xRegisterDump.ulPC = xRegisterDump.ulR17_return_address_from_exceptions - portexINSTRUCTION_SIZE; - #if XPAR_MICROBLAZE_0_USE_FPU == 1 + #if XPAR_MICROBLAZE_0_USE_FPU != 0 { xRegisterDump.ulFSR = mffsr(); } @@ -239,7 +239,7 @@ extern void *pxCurrentTCB; xRegisterDump.pcExceptionCause = ( int8_t * const ) "XEXC_ID_STACK_VIOLATION or XEXC_ID_MMU"; break; - #if XPAR_MICROBLAZE_0_USE_FPU == 1 + #if XPAR_MICROBLAZE_0_USE_FPU != 0 case XEXC_ID_FPU : xRegisterDump.pcExceptionCause = ( int8_t * const ) "XEXC_ID_FPU see ulFSR value"; @@ -248,10 +248,10 @@ extern void *pxCurrentTCB; #endif /* XPAR_MICROBLAZE_0_USE_FPU */ } - /* vApplicationExceptionRegisterDump() is a callback function that the + /* vApplicationExceptionRegisterDump() is a callback function that the application can optionally define to receive the populated xPortRegisterDump - structure. If the application chooses not to define a version of - vApplicationExceptionRegisterDump() then the weekly defined default + structure. If the application chooses not to define a version of + vApplicationExceptionRegisterDump() then the weekly defined default implementation within this file will be called instead. */ vApplicationExceptionRegisterDump( &xRegisterDump ); @@ -310,7 +310,7 @@ static uint32_t ulHandlersAlreadyInstalled = pdFALSE; } /* Exclude the entire file if the MicroBlaze is not configured to handle -exceptions, or the application defined configuration item +exceptions, or the application defined configuration item configINSTALL_EXCEPTION_HANDLERS is not set to 1. */ #endif /* ( MICROBLAZE_EXCEPTIONS_ENABLED == 1 ) && ( configINSTALL_EXCEPTION_HANDLERS == 1 ) */ diff --git a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S index 44cc1ff31..cf5d3389a 100644 --- a/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S +++ b/FreeRTOS/Source/portable/GCC/MicroBlazeV8/portasm.S @@ -1,5 +1,5 @@ /* - FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. + FreeRTOS V8.1.2 - Copyright (C) 2014 Real Time Engineers Ltd. All rights reserved VISIT http://www.FreeRTOS.org TO ENSURE YOU ARE USING THE LATEST VERSION. @@ -72,7 +72,7 @@ /* The context is oversized to allow functions called from the ISR to write back into the caller stack. */ -#if XPAR_MICROBLAZE_0_USE_FPU == 1 +#if XPAR_MICROBLAZE_0_USE_FPU != 0 #define portCONTEXT_SIZE 136 #define portMINUS_CONTEXT_SIZE -136 #else @@ -175,7 +175,7 @@ back into the caller stack. */ mfs r18, rmsr swi r18, r1, portMSR_OFFSET - #if XPAR_MICROBLAZE_0_USE_FPU == 1 + #if XPAR_MICROBLAZE_0_USE_FPU != 0 /* Stack FSR. */ mfs r18, rfsr swi r18, r1, portFSR_OFFSET @@ -184,7 +184,7 @@ back into the caller stack. */ /* Save the top of stack value to the TCB. */ lwi r3, r0, pxCurrentTCB sw r1, r0, r3 - + .endm .macro portRESTORE_CONTEXT @@ -228,7 +228,7 @@ back into the caller stack. */ lwi r18, r1, portMSR_OFFSET mts rmsr, r18 - #if XPAR_MICROBLAZE_0_USE_FPU == 1 + #if XPAR_MICROBLAZE_0_USE_FPU != 0 /* Reload the FSR from the stack. */ lwi r18, r1, portFSR_OFFSET mts rfsr, r18 @@ -345,11 +345,11 @@ VPortYieldASM: vPortStartFirstTask: portRESTORE_CONTEXT - + #if MICROBLAZE_EXCEPTIONS_ENABLED == 1 - + .text .align 2 vPortExceptionHandlerEntry: diff --git a/FreeRTOS/Source/tasks.c b/FreeRTOS/Source/tasks.c index 99c005fcc..69aaebb76 100644 --- a/FreeRTOS/Source/tasks.c +++ b/FreeRTOS/Source/tasks.c @@ -133,6 +133,7 @@ typedef struct tskTaskControlBlock #if ( portUSING_MPU_WRAPPERS == 1 ) xMPU_SETTINGS xMPUSettings; /*< The MPU settings are defined as part of the port layer. THIS MUST BE THE SECOND MEMBER OF THE TCB STRUCT. */ + BaseType_t xUsingStaticallyAllocatedStack; /* Set to pdTRUE if the stack is a statically allocated array, and pdFALSE if the stack is dynamically allocated. */ #endif ListItem_t xGenericListItem; /*< The list that the state list item of a task is reference from denotes the state of that task (Ready, Blocked, Suspended ). */ @@ -543,6 +544,7 @@ BaseType_t xTaskGenericCreate( TaskFunction_t pxTaskCode, const char * const pcN { BaseType_t xReturn; TCB_t * pxNewTCB; +StackType_t *pxTopOfStack; configASSERT( pxTaskCode ); configASSERT( ( ( uxPriority & ( ~portPRIVILEGE_BIT ) ) < configMAX_PRIORITIES ) ); @@ -553,8 +555,6 @@ TCB_t * pxNewTCB; if( pxNewTCB != NULL ) { - StackType_t *pxTopOfStack; - #if( portUSING_MPU_WRAPPERS == 1 ) /* Should the task be created in privileged mode? */ BaseType_t xRunPrivileged; @@ -567,6 +567,20 @@ TCB_t * pxNewTCB; xRunPrivileged = pdFALSE; } uxPriority &= ~portPRIVILEGE_BIT; + + if( puxStackBuffer != NULL ) + { + /* The application provided its own stack. Note this so no + attempt is made to delete the stack should that task be + deleted. */ + pxNewTCB->xUsingStaticallyAllocatedStack = pdTRUE; + } + else + { + /* The stack was allocated dynamically. Note this so it can be + deleted again if the task is deleted. */ + pxNewTCB->xUsingStaticallyAllocatedStack = pdFALSE; + } #endif /* portUSING_MPU_WRAPPERS == 1 */ /* Calculate the top of stack address. This depends on whether the @@ -3222,7 +3236,22 @@ TCB_t *pxNewTCB; _reclaim_reent( &( pxTCB->xNewLib_reent ) ); } #endif /* configUSE_NEWLIB_REENTRANT */ - vPortFreeAligned( pxTCB->pxStack ); + + #if( portUSING_MPU_WRAPPERS == 1 ) + { + /* Only free the stack if it was allocated dynamically in the first + place. */ + if( pxTCB->xUsingStaticallyAllocatedStack == pdFALSE ) + { + vPortFreeAligned( pxTCB->pxStack ); + } + } + #else + { + vPortFreeAligned( pxTCB->pxStack ); + } + #endif + vPortFree( pxTCB ); } @@ -3601,7 +3630,7 @@ TCB_t *pxTCB; pcWriteBuffer = prvWriteNameToBuffer( pcWriteBuffer, pxTaskStatusArray[ x ].pcTaskName ); /* Write the rest of the string. */ - sprintf( pcWriteBuffer, "\t\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); + sprintf( pcWriteBuffer, "\t%c\t%u\t%u\t%u\r\n", cStatus, ( unsigned int ) pxTaskStatusArray[ x ].uxCurrentPriority, ( unsigned int ) pxTaskStatusArray[ x ].usStackHighWaterMark, ( unsigned int ) pxTaskStatusArray[ x ].xTaskNumber ); pcWriteBuffer += strlen( pcWriteBuffer ); } @@ -3694,13 +3723,13 @@ TCB_t *pxTCB; { #ifdef portLU_PRINTF_SPECIFIER_REQUIRED { - sprintf( pcWriteBuffer, "\t\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); + sprintf( pcWriteBuffer, "\t%lu\t\t%lu%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter, ulStatsAsPercentage ); } #else { /* sizeof( int ) == sizeof( long ) so a smaller printf() library can be used. */ - sprintf( pcWriteBuffer, "\t\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); + sprintf( pcWriteBuffer, "\t%u\t\t%u%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter, ( unsigned int ) ulStatsAsPercentage ); } #endif } @@ -3710,13 +3739,13 @@ TCB_t *pxTCB; consumed less than 1% of the total run time. */ #ifdef portLU_PRINTF_SPECIFIER_REQUIRED { - sprintf( pcWriteBuffer, "\t\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, pxTaskStatusArray[ x ].ulRunTimeCounter ); + sprintf( pcWriteBuffer, "\t%lu\t\t<1%%\r\n", pxTaskStatusArray[ x ].ulRunTimeCounter ); } #else { /* sizeof( int ) == sizeof( long ) so a smaller printf() library can be used. */ - sprintf( pcWriteBuffer, "\t\t%u\t\t<1%%\r\n", pxTaskStatusArray[ x ].pcTaskName, ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); + sprintf( pcWriteBuffer, "\t%u\t\t<1%%\r\n", ( unsigned int ) pxTaskStatusArray[ x ].ulRunTimeCounter ); } #endif } -- 2.39.5