feat(freertos): Runtime Counter support

Closes https://github.com/espressif/esp-idf/issues/13120
pull/13557/merge
Konstantin Kondrashov 2024-04-09 22:12:05 +03:00
rodzic 324dcbc080
commit 66e6a48efd
5 zmienionych plików z 29 dodań i 29 usunięć

Wyświetl plik

@ -239,11 +239,11 @@ extern void vTaskExitCritical( void );
// ------------------- Run Time Stats ----------------------
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE() 0
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
/* Coarse resolution time (us) */
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0)
#endif
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
#else
#define portGET_RUN_TIME_COUNTER_VALUE() 0
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
// --------------------- TCB Cleanup -----------------------

Wyświetl plik

@ -227,11 +227,11 @@ extern void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
//Timers are already configured, so nothing to do for configuration of run time stats timer
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
//We define get run time counter value regardless because the rest of ESP-IDF uses it
#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount()
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) ({x = (uint32_t)esp_timer_get_time();})
#endif
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
#else // Uses CCOUNT
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) xthal_get_ccount())
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
// --------------------- TCB Cleanup -----------------------

Wyświetl plik

@ -146,7 +146,7 @@ typedef uint32_t TickType_t;
UBaseType_t xPortSetInterruptMaskFromISR(void);
/**
* @brief Reenable interrupts in a nested manner (meant to be called from ISRs)
* @brief Re-enable interrupts in a nested manner (meant to be called from ISRs)
*
* @warning Only applies to current CPU.
* @param prev_int_level Previous interrupt level
@ -589,11 +589,11 @@ void vPortTCBPreDeleteHook( void *pxTCB );
// ------------------- Run Time Stats ----------------------
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
#define portGET_RUN_TIME_COUNTER_VALUE() 0
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
/* Coarse resolution time (us) */
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0)
#endif
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
#else
#define portGET_RUN_TIME_COUNTER_VALUE() 0
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
// --------------------- TCB Cleanup -----------------------

Wyświetl plik

@ -8,7 +8,7 @@
*
* SPDX-License-Identifier: MIT
*
* SPDX-FileContributor: 2023 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@ -172,7 +172,7 @@ BaseType_t xPortInterruptedFromISRContext(void);
static inline UBaseType_t xPortSetInterruptMaskFromISR(void);
/**
* @brief Reenable interrupts in a nested manner (meant to be called from ISRs)
* @brief Re-enable interrupts in a nested manner (meant to be called from ISRs)
*
* @warning Only applies to current CPU.
* @param prev_level Previous interrupt level
@ -513,15 +513,11 @@ extern void _frxt_setup_switch( void ); //Defined in portasm.S
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
/**
* - Fine resolution uses ccount
* - ALT is coarse and uses esp_timer
* @note [refactor-todo] Make fine and alt timers mutually exclusive
*/
#define portGET_RUN_TIME_COUNTER_VALUE() xthal_get_ccount()
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
#define portALT_GET_RUN_TIME_COUNTER_VALUE(x) do {x = (uint32_t)esp_timer_get_time();} while(0)
#endif
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
#else // Uses CCOUNT
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) xthal_get_ccount())
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
// --------------------- TCB Cleanup -----------------------

Wyświetl plik

@ -408,7 +408,7 @@ BaseType_t xTaskGetCoreID( TaskHandle_t xTask )
#if CONFIG_FREERTOS_SMP
UBaseType_t uxCoreAffinityMask;
/* Get the core affinity mask and covert it to an ID */
/* Get the core affinity mask and convert it to an ID */
uxCoreAffinityMask = vTaskCoreAffinityGet( xTask );
/* If the task is not pinned to a particular core, treat it as tskNO_AFFINITY */
@ -487,7 +487,7 @@ BaseType_t xTaskGetCoreID( TaskHandle_t xTask )
configRUN_TIME_COUNTER_TYPE ulTaskGetIdleRunTimeCounterForCore( BaseType_t xCoreID )
{
uint32_t ulRunTimeCounter;
configRUN_TIME_COUNTER_TYPE ulRunTimeCounter;
configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
@ -514,7 +514,11 @@ BaseType_t xTaskGetCoreID( TaskHandle_t xTask )
configASSERT( taskVALID_CORE_ID( xCoreID ) == pdTRUE );
ulTotalTime = portGET_RUN_TIME_COUNTER_VALUE();
#ifdef portALT_GET_RUN_TIME_COUNTER_VALUE
portALT_GET_RUN_TIME_COUNTER_VALUE( ulTotalTime );
#else
ulTotalTime = portGET_RUN_TIME_COUNTER_VALUE();
#endif
/* For percentage calculations. */
ulTotalTime /= ( configRUN_TIME_COUNTER_TYPE ) 100;
@ -836,11 +840,11 @@ uint8_t * pxTaskGetStackStart( TaskHandle_t xTask )
/**
* @brief Get reentrancy structure of the current task
*
* - This funciton is required by newlib (when __DYNAMIC_REENT__ is enabled)
* - This function is required by newlib (when __DYNAMIC_REENT__ is enabled)
* - It will return a pointer to the current task's reent struct
* - If FreeRTOS is not running, it will return the global reent struct
*
* @return Pointer to a the (current taks's)/(globa) reent struct
* @return Pointer to a the (current taks's)/(global) reent struct
*/
struct _reent * __getreent( void )
{
@ -1000,7 +1004,7 @@ int xTaskGetNext( TaskIterator_t * xIterator )
if( !portVALID_LIST_MEM( pxNextListItem ) )
{
/* Nothing to do with the corrupted list item. We will skip to the next task state list.
* pxNextListItem should be NULL at the beggining of each task list.
* pxNextListItem should be NULL at the beginning of each task list.
*/
pxNextListItem = NULL;
continue;