mirror of
https://github.com/espressif/esp-idf.git
synced 2025-10-02 10:00:57 +02:00
refactor(freertos): Moved FreeRTOS Run Time Stats gathering to port.c
This commit creates a new port layer API xPortGetRunTimeCounterValue() in port.c files. This helps to remove inclusion of header files such as esp_timer.h and xtensa/hal.h from portmacro.h
This commit is contained in:
@@ -254,11 +254,10 @@ extern void vTaskExitCritical( void );
|
|||||||
// ------------------- Run Time Stats ----------------------
|
// ------------------- Run Time Stats ----------------------
|
||||||
|
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||||
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void );
|
||||||
#else
|
#define portGET_RUN_TIME_COUNTER_VALUE() xPortGetRunTimeCounterValue()
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() 0
|
#endif
|
||||||
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
|
|
||||||
// --------------------- TCB Cleanup -----------------------
|
// --------------------- TCB Cleanup -----------------------
|
||||||
|
|
||||||
@@ -420,19 +419,13 @@ portmacro.h. Therefore, we need to keep these headers around for now to allow th
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <limits.h>
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_newlib.h"
|
#include "esp_newlib.h"
|
||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
#include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */
|
#include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */
|
||||||
|
|
||||||
/* [refactor-todo] These includes are not directly used in this file. They are kept into to prevent a breaking change. Remove these. */
|
|
||||||
#include <limits.h>
|
|
||||||
|
|
||||||
/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */
|
|
||||||
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
#include "esp_timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
@@ -31,6 +31,9 @@
|
|||||||
#include "port_systick.h"
|
#include "port_systick.h"
|
||||||
#include "portmacro.h"
|
#include "portmacro.h"
|
||||||
#include "esp_memory_utils.h"
|
#include "esp_memory_utils.h"
|
||||||
|
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER
|
#ifdef CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER
|
||||||
#include "soc/periph_defs.h"
|
#include "soc/periph_defs.h"
|
||||||
#include "soc/system_reg.h"
|
#include "soc/system_reg.h"
|
||||||
@@ -516,3 +519,18 @@ void vApplicationPassiveIdleHook( void )
|
|||||||
esp_vApplicationIdleHook(); //Run IDF style hooks
|
esp_vApplicationIdleHook(); //Run IDF style hooks
|
||||||
}
|
}
|
||||||
#endif // CONFIG_FREERTOS_USE_PASSIVE_IDLE_HOOK
|
#endif // CONFIG_FREERTOS_USE_PASSIVE_IDLE_HOOK
|
||||||
|
|
||||||
|
/* ------------------------------------------------ Run Time Stats ------------------------------------------------- */
|
||||||
|
|
||||||
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
|
|
||||||
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void )
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE) esp_timer_get_time();
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS */
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -239,11 +239,10 @@ extern void vTaskExitCriticalFromISR( UBaseType_t uxSavedInterruptStatus );
|
|||||||
|
|
||||||
//Timers are already configured, so nothing to do for configuration of run time stats timer
|
//Timers are already configured, so nothing to do for configuration of run time stats timer
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||||
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void );
|
||||||
#else // Uses CCOUNT
|
#define portGET_RUN_TIME_COUNTER_VALUE() xPortGetRunTimeCounterValue()
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) xthal_get_ccount())
|
#endif
|
||||||
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
|
|
||||||
// --------------------- TCB Cleanup -----------------------
|
// --------------------- TCB Cleanup -----------------------
|
||||||
|
|
||||||
@@ -451,11 +450,6 @@ portmacro.h. Therefore, we need to keep these headers around for now to allow th
|
|||||||
#include <xtensa/config/system.h>
|
#include <xtensa/config/system.h>
|
||||||
#include <xtensa_api.h>
|
#include <xtensa_api.h>
|
||||||
|
|
||||||
/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */
|
|
||||||
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
#include "esp_timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -34,6 +34,10 @@
|
|||||||
#include "esp_freertos_hooks.h"
|
#include "esp_freertos_hooks.h"
|
||||||
#include "esp_intr_alloc.h"
|
#include "esp_intr_alloc.h"
|
||||||
#include "esp_memory_utils.h"
|
#include "esp_memory_utils.h"
|
||||||
|
#include <xtensa/hal.h> /* required for xthal_get_ccount() */
|
||||||
|
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER
|
#ifdef CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER
|
||||||
#include "soc/periph_defs.h"
|
#include "soc/periph_defs.h"
|
||||||
#include "soc/system_reg.h"
|
#include "soc/system_reg.h"
|
||||||
@@ -695,3 +699,18 @@ void vApplicationPassiveIdleHook( void )
|
|||||||
esp_vApplicationIdleHook(); //Run IDF style hooks
|
esp_vApplicationIdleHook(); //Run IDF style hooks
|
||||||
}
|
}
|
||||||
#endif // CONFIG_FREERTOS_USE_PASSIVE_IDLE_HOOK
|
#endif // CONFIG_FREERTOS_USE_PASSIVE_IDLE_HOOK
|
||||||
|
|
||||||
|
/* ------------------------------------------------ Run Time Stats ------------------------------------------------- */
|
||||||
|
|
||||||
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
|
|
||||||
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void )
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE) esp_timer_get_time();
|
||||||
|
#else // Uses CCOUNT
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE) xthal_get_ccount();
|
||||||
|
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS */
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
*
|
*
|
||||||
* SPDX-License-Identifier: MIT
|
* SPDX-License-Identifier: MIT
|
||||||
*
|
*
|
||||||
* SPDX-FileContributor: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileContributor: 2023-2025 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
* 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
|
* this software and associated documentation files (the "Software"), to deal in
|
||||||
@@ -71,15 +71,8 @@
|
|||||||
#include "esp_heap_caps.h"
|
#include "esp_heap_caps.h"
|
||||||
#include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */
|
#include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */
|
||||||
#include "esp_newlib.h"
|
#include "esp_newlib.h"
|
||||||
|
|
||||||
/* [refactor-todo] These includes are not directly used in this file. They are kept into to prevent a breaking change. Remove these. */
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */
|
|
||||||
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
#include "esp_timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@@ -603,11 +596,10 @@ void vPortTCBPreDeleteHook( void *pxTCB );
|
|||||||
// ------------------- Run Time Stats ----------------------
|
// ------------------- Run Time Stats ----------------------
|
||||||
|
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||||
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void );
|
||||||
#else
|
#define portGET_RUN_TIME_COUNTER_VALUE() xPortGetRunTimeCounterValue()
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() 0
|
#endif
|
||||||
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
|
|
||||||
// --------------------- TCB Cleanup -----------------------
|
// --------------------- TCB Cleanup -----------------------
|
||||||
|
|
||||||
|
@@ -56,6 +56,9 @@
|
|||||||
#include "portmacro.h"
|
#include "portmacro.h"
|
||||||
#include "port_systick.h"
|
#include "port_systick.h"
|
||||||
#include "esp_memory_utils.h"
|
#include "esp_memory_utils.h"
|
||||||
|
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if SOC_CPU_HAS_HWLOOP
|
#if SOC_CPU_HAS_HWLOOP
|
||||||
#include "riscv/csr.h"
|
#include "riscv/csr.h"
|
||||||
@@ -874,6 +877,21 @@ void vPortCoprocUsedInISR(void* frame)
|
|||||||
|
|
||||||
#endif /* SOC_CPU_COPROC_NUM > 0 */
|
#endif /* SOC_CPU_COPROC_NUM > 0 */
|
||||||
|
|
||||||
|
/* ------------------------------------------------ Run Time Stats ------------------------------------------------- */
|
||||||
|
|
||||||
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
|
|
||||||
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void )
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE) esp_timer_get_time();
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS */
|
||||||
|
|
||||||
/* ---------------------------------------------- Misc Implementations -------------------------------------------------
|
/* ---------------------------------------------- Misc Implementations -------------------------------------------------
|
||||||
*
|
*
|
||||||
* ------------------------------------------------------------------------------------------------------------------ */
|
* ------------------------------------------------------------------------------------------------------------------ */
|
||||||
|
@@ -43,7 +43,6 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <xtensa/config/core.h>
|
#include <xtensa/config/core.h>
|
||||||
#include <xtensa/hal.h> /* required for xthal_get_ccount. [refactor-todo] use cpu_hal instead */
|
|
||||||
#include <xtensa/xtruntime.h> /* required for XTOS_SET_INTLEVEL. [refactor-todo] add common intr functions to esp_hw_support */
|
#include <xtensa/xtruntime.h> /* required for XTOS_SET_INTLEVEL. [refactor-todo] add common intr functions to esp_hw_support */
|
||||||
#include "xt_instr_macros.h"
|
#include "xt_instr_macros.h"
|
||||||
#include "spinlock.h"
|
#include "spinlock.h"
|
||||||
@@ -57,16 +56,7 @@
|
|||||||
#include "esp_rom_sys.h"
|
#include "esp_rom_sys.h"
|
||||||
#include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */
|
#include "esp_system.h" /* required by esp_get_...() functions in portable.h. [refactor-todo] Update portable.h */
|
||||||
#include "portbenchmark.h"
|
#include "portbenchmark.h"
|
||||||
|
|
||||||
/* [refactor-todo] These includes are not directly used in this file. They are kept into to prevent a breaking change. Remove these. */
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <xtensa/config/system.h>
|
|
||||||
#include <xtensa_api.h>
|
|
||||||
|
|
||||||
/* [refactor-todo] introduce a port wrapper function to avoid including esp_timer.h into the public header */
|
|
||||||
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
#include "esp_timer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
@@ -510,11 +500,10 @@ extern void _frxt_setup_switch( void ); //Defined in portasm.S
|
|||||||
|
|
||||||
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS()
|
||||||
|
|
||||||
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) esp_timer_get_time())
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void );
|
||||||
#else // Uses CCOUNT
|
#define portGET_RUN_TIME_COUNTER_VALUE() xPortGetRunTimeCounterValue()
|
||||||
#define portGET_RUN_TIME_COUNTER_VALUE() ((configRUN_TIME_COUNTER_TYPE) xthal_get_ccount())
|
#endif
|
||||||
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
|
||||||
|
|
||||||
// --------------------- TCB Cleanup -----------------------
|
// --------------------- TCB Cleanup -----------------------
|
||||||
|
|
||||||
|
@@ -48,6 +48,10 @@
|
|||||||
#include "task.h" /* Required for TaskHandle_t, tskNO_AFFINITY, and vTaskStartScheduler */
|
#include "task.h" /* Required for TaskHandle_t, tskNO_AFFINITY, and vTaskStartScheduler */
|
||||||
#include "port_systick.h"
|
#include "port_systick.h"
|
||||||
#include "esp_cpu.h"
|
#include "esp_cpu.h"
|
||||||
|
#include <xtensa/hal.h> /* required for xthal_get_ccount() */
|
||||||
|
#if CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
#include "esp_timer.h"
|
||||||
|
#endif
|
||||||
#include "esp_memory_utils.h"
|
#include "esp_memory_utils.h"
|
||||||
|
|
||||||
_Static_assert(portBYTE_ALIGNMENT == 16, "portBYTE_ALIGNMENT must be set to 16");
|
_Static_assert(portBYTE_ALIGNMENT == 16, "portBYTE_ALIGNMENT must be set to 16");
|
||||||
@@ -659,3 +663,18 @@ void vPortTCBPreDeleteHook( void *pxTCB )
|
|||||||
vPortCleanUpCoprocArea( pxTCB );
|
vPortCleanUpCoprocArea( pxTCB );
|
||||||
#endif /* XCHAL_CP_NUM > 0 */
|
#endif /* XCHAL_CP_NUM > 0 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* ------------------------------------------------ Run Time Stats ------------------------------------------------- */
|
||||||
|
|
||||||
|
#if ( CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS )
|
||||||
|
|
||||||
|
configRUN_TIME_COUNTER_TYPE xPortGetRunTimeCounterValue( void )
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE) esp_timer_get_time();
|
||||||
|
#else // Uses CCOUNT
|
||||||
|
return (configRUN_TIME_COUNTER_TYPE) xthal_get_ccount();
|
||||||
|
#endif // CONFIG_FREERTOS_RUN_TIME_STATS_USING_ESP_TIMER
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS */
|
||||||
|
Reference in New Issue
Block a user