Add xTaskGetIdleRunTimeCounter() API function to return the run time stats counter for the idle task - useful for POSIX time implementations.
diff --git a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx
index 85705cf..8721f4f 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx
+++ b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/GCC_Specific/RTOSDemo.uvoptx
@@ -152,7 +152,7 @@
           <Type>0</Type>
           <LineNumber>614</LineNumber>
           <EnabledFlag>1</EnabledFlag>
-          <Address>23132</Address>
+          <Address>23164</Address>
           <ByteObject>0</ByteObject>
           <HtxType>0</HtxType>
           <ManyObjects>0</ManyObjects>
@@ -237,7 +237,7 @@
 
   <Group>
     <GroupName>System</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -257,7 +257,7 @@
 
   <Group>
     <GroupName>application_and_config</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
@@ -301,7 +301,7 @@
 
   <Group>
     <GroupName>FreeRTOS_Source</GroupName>
-    <tvExp>1</tvExp>
+    <tvExp>0</tvExp>
     <tvExpOptDlg>0</tvExpOptDlg>
     <cbSel>0</cbSel>
     <RteFlg>0</RteFlg>
diff --git a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c
index a1e4ac6..bc2ac8b 100644
--- a/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c
+++ b/FreeRTOS/Demo/CORTEX_MPU_Simulator_Keil_GCC/main.c
@@ -776,6 +776,9 @@
 	/* For code coverage test purposes it is deleted by the Idle task. */

 	configASSERT( uxTaskGetStackHighWaterMark( NULL ) > 0 );

 	configASSERT( uxTaskGetStackHighWaterMark2( NULL ) > 0 );

+	/* Run time stats are not being gathered - this is just to exercise

+	API. */

+	configASSERT( xTaskGetIdleRunTimeCounter() == 0 ); 

 	vTaskSuspend( NULL );

 }

 /*-----------------------------------------------------------*/

diff --git a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml
index 7ac15d6..8ae7de9 100644
--- a/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml
+++ b/FreeRTOS/Demo/RISC-V-Qemu-sifive_e-FreedomStudio/.settings/language.settings.xml
@@ -5,7 +5,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>

 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>

 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>

-			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1688908204914985791" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">

+			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-838616105515603833" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">

 				<language-scope id="org.eclipse.cdt.core.gcc"/>

 				<language-scope id="org.eclipse.cdt.core.g++"/>

 			</provider>

@@ -16,7 +16,7 @@
 			<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>

 			<provider-reference id="org.eclipse.cdt.core.ReferencedProjectsLanguageSettingsProvider" ref="shared-provider"/>

 			<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>

-			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="1692822637120195189" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">

+			<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuiltinSpecsDetector" console="false" env-hash="-834701673310394435" id="ilg.gnumcueclipse.managedbuild.cross.riscv.GCCBuiltinSpecsDetector" keep-relative-paths="false" name="CDT RISC-V Cross GCC Built-in Compiler Settings" parameter="${COMMAND} ${FLAGS} ${cross_toolchain_flags} -E -P -v -dD &quot;${INPUTS}&quot;" prefer-non-shared="true">

 				<language-scope id="org.eclipse.cdt.core.gcc"/>

 				<language-scope id="org.eclipse.cdt.core.g++"/>

 			</provider>

diff --git a/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo b/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo
index 976c93a..7f5848d 100644
--- a/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo
+++ b/FreeRTOS/Demo/WIN32-MSVC/.vs/WIN32/v14/.suo
Binary files differ
diff --git a/FreeRTOS/Demo/WIN32-MingW/main_full.c b/FreeRTOS/Demo/WIN32-MingW/main_full.c
index 3b27f90..abd9bf5 100644
--- a/FreeRTOS/Demo/WIN32-MingW/main_full.c
+++ b/FreeRTOS/Demo/WIN32-MingW/main_full.c
@@ -617,6 +617,8 @@
 TaskHandle_t xTestTask;

 TaskStatus_t xTaskInfo;

 extern StackType_t uxTimerTaskStack[];

+static TickType_t xLastIdleExecutionTime = 0;

+TickType_t xIdleExecutionTime;

 

 	/* Demonstrate the use of the xTimerGetTimerDaemonTaskHandle() and

 	xTaskGetIdleTaskHandle() functions.  Also try using the function that sets

@@ -715,6 +717,13 @@
 			}

 		}

 	}

+

+	xIdleExecutionTime = xTaskGetIdleRunTimeCounter();

+	if( xIdleExecutionTime == xLastIdleExecutionTime )

+	{

+		pcStatusMessage = "Error: Total amount of Idle task execution time did not change";

+	}

+	xLastIdleExecutionTime = xIdleExecutionTime;

 }

 /*-----------------------------------------------------------*/

 

diff --git a/FreeRTOS/Source/include/mpu_prototypes.h b/FreeRTOS/Source/include/mpu_prototypes.h
index b4cc346..a8fe655 100644
--- a/FreeRTOS/Source/include/mpu_prototypes.h
+++ b/FreeRTOS/Source/include/mpu_prototypes.h
@@ -69,6 +69,7 @@
 BaseType_t MPU_xTaskCallApplicationTaskHook( TaskHandle_t xTask, void *pvParameter );

 TaskHandle_t MPU_xTaskGetIdleTaskHandle( void );

 UBaseType_t MPU_uxTaskGetSystemState( TaskStatus_t * const pxTaskStatusArray, const UBaseType_t uxArraySize, uint32_t * const pulTotalRunTime );

+TickType_t MPU_xTaskGetIdleRunTimeCounter( void );

 void MPU_vTaskList( char * pcWriteBuffer );

 void MPU_vTaskGetRunTimeStats( char *pcWriteBuffer );

 BaseType_t MPU_xTaskGenericNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction, uint32_t *pulPreviousNotificationValue );

diff --git a/FreeRTOS/Source/include/mpu_wrappers.h b/FreeRTOS/Source/include/mpu_wrappers.h
index 66e9a9f..220949c 100644
--- a/FreeRTOS/Source/include/mpu_wrappers.h
+++ b/FreeRTOS/Source/include/mpu_wrappers.h
@@ -77,6 +77,7 @@
 		#define uxTaskGetSystemState					MPU_uxTaskGetSystemState

 		#define vTaskList								MPU_vTaskList

 		#define vTaskGetRunTimeStats					MPU_vTaskGetRunTimeStats

+		#define xTaskGetIdleRunTimeCounter				MPU_xTaskGetIdleRunTimeCounter

 		#define xTaskGenericNotify						MPU_xTaskGenericNotify

 		#define xTaskNotifyWait							MPU_xTaskNotifyWait

 		#define ulTaskNotifyTake						MPU_ulTaskNotifyTake

diff --git a/FreeRTOS/Source/include/task.h b/FreeRTOS/Source/include/task.h
index b9c605b..43fcbee 100644
--- a/FreeRTOS/Source/include/task.h
+++ b/FreeRTOS/Source/include/task.h
@@ -1729,6 +1729,36 @@
 void vTaskGetRunTimeStats( char *pcWriteBuffer ) PRIVILEGED_FUNCTION; /*lint !e971 Unqualified char types are allowed for strings and single characters only. */

 

 /**

+* task. h

+* <PRE>TickType_t xTaskGetIdleRunTimeCounter( void );</PRE>

+*

+* configGENERATE_RUN_TIME_STATS and configUSE_STATS_FORMATTING_FUNCTIONS

+* must both be defined as 1 for this function to be available.  The application

+* must also then provide definitions for

+* portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and portGET_RUN_TIME_COUNTER_VALUE()

+* to configure a peripheral timer/counter and return the timers current count

+* value respectively.  The counter should be at least 10 times the frequency of

+* the tick count.

+*

+* Setting configGENERATE_RUN_TIME_STATS to 1 will result in a total

+* accumulated execution time being stored for each task.  The resolution

+* of the accumulated time value depends on the frequency of the timer

+* configured by the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() macro.

+* While uxTaskGetSystemState() and vTaskGetRunTimeStats() writes the total

+* execution time of each task into a buffer, xTaskGetIdleRunTimeCounter()

+* returns the total execution time of just the idle task.

+*

+* @return The total run time of the idle task.  This is the amount of time the

+* idle task has actually been executing.  The unit of time is dependent on the

+* frequency configured using the portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() and

+* portGET_RUN_TIME_COUNTER_VALUE() macros.

+*

+* \defgroup xTaskGetIdleRunTimeCounter xTaskGetIdleRunTimeCounter

+* \ingroup TaskUtils

+*/

+TickType_t xTaskGetIdleRunTimeCounter( void ) PRIVILEGED_FUNCTION;

+

+/**

  * task. h

  * <PRE>BaseType_t xTaskNotify( TaskHandle_t xTaskToNotify, uint32_t ulValue, eNotifyAction eAction );</PRE>

  *

@@ -2346,7 +2376,7 @@
 void vTaskStepTick( const TickType_t xTicksToJump ) PRIVILEGED_FUNCTION;

 

 /*

- * Only avilable when configUSE_TICKLESS_IDLE is set to 1.

+ * Only available when configUSE_TICKLESS_IDLE is set to 1.

  * Provided for use within portSUPPRESS_TICKS_AND_SLEEP() to allow the port

  * specific sleep function to determine if it is ok to proceed with the sleep,

  * and if it is ok to proceed, if it is ok to sleep indefinitely.

@@ -2367,10 +2397,6 @@
  */

 TaskHandle_t pvTaskIncrementMutexHeldCount( void ) PRIVILEGED_FUNCTION;

 

-#if( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )

-	TickType_t xTaskGetIdleRunTimeCounter( void );

-#endif

-

 /*

  * For internal use only.  Same as vTaskSetTimeOutState(), but without a critial

  * section.

diff --git a/FreeRTOS/Source/portable/Common/mpu_wrappers.c b/FreeRTOS/Source/portable/Common/mpu_wrappers.c
index 0cb79c4..d5aa0e9 100644
--- a/FreeRTOS/Source/portable/Common/mpu_wrappers.c
+++ b/FreeRTOS/Source/portable/Common/mpu_wrappers.c
@@ -333,6 +333,19 @@
 #endif

 /*-----------------------------------------------------------*/

 

+#if( ( configGENERATE_RUN_TIME_STATS == 1 ) && ( INCLUDE_xTaskGetIdleTaskHandle == 1 ) )

+	TickType_t MPU_xTaskGetIdleRunTimeCounter( void )

+	{

+	TickType_t xReturn;

+	BaseType_t xRunningPrivileged = xPortRaisePrivilege();

+

+		xReturn = xTaskGetIdleRunTimeCounter();

+		vPortResetPrivilege( xRunningPrivileged );

+		return xReturn;

+	}

+#endif

+/*-----------------------------------------------------------*/

+

 #if ( configUSE_APPLICATION_TASK_TAG == 1 )

 	void MPU_vTaskSetApplicationTaskTag( TaskHandle_t xTask, TaskHookFunction_t pxTagValue )

 	{

diff --git a/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c b/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c
index 8f7eee5..6f61eee 100644
--- a/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c
+++ b/FreeRTOS/Source/portable/GCC/ARM_CM4_MPU/port.c
@@ -573,7 +573,7 @@
 										( prvGetMPURegionSizeSetting( ( uint32_t ) __FLASH_segment_end__ - ( uint32_t ) __FLASH_segment_start__ ) ) |

 										( portMPU_REGION_ENABLE );

 

-		/* Setup the first 16K for privileged only access (even though less

+		/* Setup the first nK for privileged only access (even though less

 		than 10K is actually being used).  This is where the kernel code is

 		placed. */

 		portMPU_REGION_BASE_ADDRESS_REG =	( ( uint32_t ) __FLASH_segment_start__ ) | /* Base address. */

diff --git a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c b/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c
index a8b4928..8793ee6 100644
--- a/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c
+++ b/FreeRTOS/Source/portable/GCC/RISC-V-RV32/port.c
@@ -34,6 +34,10 @@
 #include "task.h"

 #include "portmacro.h"

 

+#ifndef configCLINT_BASE_ADDRESS

+	#warning configCLINT_BASE_ADDRESS must be defined in FreeRTOSConfig.h.  If the target chip includes a Core Local Interrupter (CLINT) then set configCLINT_BASE_ADDRESS to the CLINT's base address.  Otherwise set configCLINT_BASE_ADDRESS to 0.

+#endif

+

 /* Let the user override the pre-loading of the initial LR with the address of

 prvTaskExitError() in case it messes up unwinding of the stack in the

 debugger. */