diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index ec244fc76b..903c69f851 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -37,6 +37,8 @@ set(include_dirs "esp_additions/include/freertos" # For files with #include "FreeRTOSConfig.h" "esp_additions/include" # For files with #include "freertos/FreeRTOSConfig.h" # or #include "freertos/task_snapshot.h" + # or #include "freertos/idf_additions.h" + # or #include "esp_private/freertos_idf_additions_priv.h" "esp_additions/arch/${arch}/include") # For #include "freertos/FreeRTOSConfig_arch.h" set(private_include_dirs diff --git a/components/freertos/esp_additions/freertos_tasks_c_additions.h b/components/freertos/esp_additions/freertos_tasks_c_additions.h index 526581d3bd..5abbcc5207 100644 --- a/components/freertos/esp_additions/freertos_tasks_c_additions.h +++ b/components/freertos/esp_additions/freertos_tasks_c_additions.h @@ -7,7 +7,8 @@ #pragma once #include "sdkconfig.h" -#include "idf_additions_inc.h" +#include "idf_additions.h" +#include "esp_private/freertos_idf_additions_priv.h" /** * This file will be included in `tasks.c` file, thus, it is treated as a source diff --git a/components/freertos/esp_additions/include/esp_private/freertos_idf_additions_priv.h b/components/freertos/esp_additions/include/esp_private/freertos_idf_additions_priv.h new file mode 100644 index 0000000000..c6e6ba81c0 --- /dev/null +++ b/components/freertos/esp_additions/include/esp_private/freertos_idf_additions_priv.h @@ -0,0 +1,99 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* + * This file is like "idf_additions.h" but for private API (i.e., only meant to + * be called by other internally by other + * ESP-IDF components. + */ + +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* ----------------------------------------------------------------------------- + * Priority Raise/Restore + * - Special functions to forcefully raise and restore a task's priority + * - Used by cache_utils.c when disabling/enabling the cache + * -------------------------------------------------------------------------- */ + +#if ( INCLUDE_vTaskPrioritySet == 1 ) + + typedef struct + { + UBaseType_t uxPriority; + #if ( configUSE_MUTEXES == 1 ) + UBaseType_t uxBasePriority; + #endif + } prvTaskSavedPriority_t; + +/** + * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be + * available. See the configuration section for more information. + * + * Saves the current priority and current base priority of a task, then + * raises the task's current and base priority to uxNewPriority if + * uxNewPriority is of a higher priority. + * + * Once a task's priority has been raised with this function, the priority + * can be restored by calling prvTaskPriorityRestore() + * + * - Note that this function differs from vTaskPrioritySet() as the task's + * current priority will be modified even if the task has already + * inherited a priority. + * - This function is intended for special circumstance where a task must be + * forced immediately to a higher priority. + * + * For configUSE_MUTEXES == 0: A context switch will occur before the + * function returns if the priority being set is higher than the currently + * executing task. + * + * @note This functions is private and should only be called internally + * within various IDF components. Users should never call this function from + * their application. + * + * @note vTaskPrioritySet() should not be called while a task's priority is + * already raised via this function + * + * @param pxSavedPriority returns base and current priorities + * + * @param uxNewPriority The priority to which the task's priority will be + * set. + */ + void prvTaskPriorityRaise( prvTaskSavedPriority_t * pxSavedPriority, + UBaseType_t uxNewPriority ); + +/** + * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be + * available. + * See the configuration section for more information. + * + * Restore a task's priority that was previously raised by + * prvTaskPriorityRaise(). + * + * For configUSE_MUTEXES == 0: A context switch will occur before the function + * returns if the priority + * being set is higher than the currently executing task. + * + * @note This functions is private and should only be called internally within + * various IDF components. Users should never call this function from their + * application. + * + * @param pxSavedPriority previously saved base and current priorities that need + * to be restored + */ + void prvTaskPriorityRestore( prvTaskSavedPriority_t * pxSavedPriority ); + +#endif // ( INCLUDE_vTaskPrioritySet == 1) + +#ifdef __cplusplus + } +#endif diff --git a/components/freertos/esp_additions/include/freertos/idf_additions.h b/components/freertos/esp_additions/include/freertos/idf_additions.h index 6523575c8d..42c46d855a 100644 --- a/components/freertos/esp_additions/include/freertos/idf_additions.h +++ b/components/freertos/esp_additions/include/freertos/idf_additions.h @@ -1,20 +1,34 @@ /* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ +#pragma once + +/* +This file contains exposes the function prototypes of ESP-IDF specific API additions to the FreeRTOS kernel. These API +additions are not part of Vanilla (i.e., upstream) FreeRTOS and include things such as.... +- Various helper functions +- API for ESP-IDF feature additions to FreeRTOS (such as TSLP deletion call backs) +*/ + #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "idf_additions_inc.h" + +#ifdef __cplusplus + extern "C" { +#endif + +/* --------------------------------------------------- SMP Related ----------------------------------------------------- + * - SMP related API additions to FreeRTOS + * + * Todo: Move IDF FreeRTOS SMP related additions to this header as well (see IDF-7201) + * ------------------------------------------------------------------------------------------------------------------ */ #if CONFIG_FREERTOS_SMP || __DOXYGEN__ -/* ------------------------------------------------ Helper Functions --------------------------------------------------- - * - * ------------------------------------------------------------------------------------------------------------------ */ - /** * @brief Create a new task that is pinned to a particular core * @@ -104,6 +118,16 @@ TaskHandle_t xTaskGetIdleTaskHandleForCPU( BaseType_t xCoreID ); */ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ); +#endif // CONFIG_FREERTOS_SMP || __DOXYGEN__ + +/* --------------------------------------------- TLSP Deletion Callbacks ----------------------------------------------- + * - API additions for the TLSP deletion callback feature + * + * Todo: Move IDF FreeRTOS TLSP deletion callback additions to this header as well (see IDF-7201) + * ------------------------------------------------------------------------------------------------------------------ */ + +#if CONFIG_FREERTOS_SMP || __DOXYGEN__ + #if ( CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS ) /** @@ -143,49 +167,6 @@ BaseType_t xTaskGetAffinity( TaskHandle_t xTask ); #endif // CONFIG_FREERTOS_SMP || __DOXYGEN__ -#if ( INCLUDE_vTaskPrioritySet == 1 ) - -/** - * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Saves the current priority and current base priority of a task, then raises the tasks - * current and base priority to uxNewPriority if uxNewPriority is of a higher priority. - * Once a task's priority has been raised with this function, the priority can be restored - * by calling prvTaskPriorityRestore() - * - Note that this function differs from vTaskPrioritySet() as the task's current priority - * will be modified even if the task has already inherited a priority. - * - This function is intended for special circumstance where a task must be forced immediately - * to a higher priority. - * - * For configUSE_MUTEXES == 0: A context switch will occur before the function returns if the priority - * being set is higher than the currently executing task. - * - * @note This functions is private is only be called internally within various IDF components. - * Users should never call this function from their application. - * - * @note vTaskPrioritySet() should not be called while a task's priority is already raised via this function - * - * @param pxSavedPriority returns base and current priorities - * - * @param uxNewPriority The priority to which the task will be set. - */ -void prvTaskPriorityRaise( prvTaskSavedPriority_t * pxSavedPriority, UBaseType_t uxNewPriority ); - -/** - * INCLUDE_vTaskPrioritySet must be defined as 1 for this function to be available. - * See the configuration section for more information. - * - * Restore a task's priority that was previously raised by prvTaskPriorityRaise(). - * - * For configUSE_MUTEXES == 0: A context switch will occur before the function returns if the priority - * being set is higher than the currently executing task. - * - * @note This functions is private is only be called internally within various IDF components. - * Users should never call this function from their application. - * - * @param pxSavedPriority previously saved base and current priorities that need to be restored - */ -void prvTaskPriorityRestore( prvTaskSavedPriority_t * pxSavedPriority ); - -#endif // ( INCLUDE_vTaskPrioritySet == 1) +#ifdef __cplusplus + } +#endif diff --git a/components/freertos/esp_additions/include/freertos/idf_additions_inc.h b/components/freertos/esp_additions/include/freertos/idf_additions_inc.h deleted file mode 100644 index 25b0b6d9a4..0000000000 --- a/components/freertos/esp_additions/include/freertos/idf_additions_inc.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - - -#ifndef FREERTOS_ADDITITIONS_INC_H_ -#define FREERTOS_ADDITITIONS_INC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include "sdkconfig.h" -#include "freertos/FreeRTOS.h" - -#if ( INCLUDE_vTaskPrioritySet == 1 ) - -typedef struct { - UBaseType_t uxPriority; -#if ( configUSE_MUTEXES == 1 ) - UBaseType_t uxBasePriority; -#endif -} prvTaskSavedPriority_t; - -#endif // ( INCLUDE_vTaskPrioritySet == 1) - -#ifdef __cplusplus -} -#endif - -#endif //FREERTOS_ADDITITIONS_INC_H_ diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index 6fc7e0fcc4..8079bd4630 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -11,7 +11,6 @@ #include #include -#include #include #if CONFIG_IDF_TARGET_ESP32 #include "soc/dport_reg.h" @@ -57,6 +56,7 @@ #include "spi_flash_mmap.h" #include "spi_flash_override.h" #include "esp_private/spi_flash_os.h" +#include "esp_private/freertos_idf_additions_priv.h" #include "esp_log.h" #include "esp_cpu.h"