Просмотр исходного кода

freertos: Refactor FreeRTOSConfig_arch.h

This commit removes or adds some misplaced configs from the
FreeRTOSConfig_arch.h headers of each architecture.
Darian Leung 2 лет назад
Родитель
Сommit
63f318b85b

+ 44 - 5
components/freertos/esp_additions/arch/linux/include/freertos/FreeRTOSConfig_arch.h

@@ -1,12 +1,51 @@
 /*
- * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#ifndef FREERTOS_CONFIG_LINUX_H
-#define FREERTOS_CONFIG_LINUX_H
+#pragma once
 
-// This file is included in the common FreeRTOSConfig.h.
+// Linux POSIX simulator specific configuration. This file is included in the common FreeRTOSConfig.h.
 
-#endif // FREERTOS_CONFIG_LINUX_H
+#include "sdkconfig.h"
+
+/* ------------------------------------------------- FreeRTOS Config ---------------------------------------------------
+ * - All Vanilla FreeRTOS configuration goes into this section
+ * - Match upstream POSIX simulator example FreeRTOSConfig.h where possible. See following link for more details.
+ *   https://github.com/FreeRTOS/FreeRTOS/blob/main/FreeRTOS/Demo/Posix_GCC/FreeRTOSConfig.h
+ * ------------------------------------------------------------------------------------------------------------------ */
+
+// ------------------ Scheduler Related --------------------
+
+#define configMAX_PRIORITIES                                ( 7 )
+#define configUSE_PORT_OPTIMISED_TASK_SELECTION             0
+/* The stack allocated by FreeRTOS will be passed to a pthread.
+   pthread has a minimal stack size which currently is 16KB.
+   The rest is for additional structures of the POSIX/Linux port.
+   This is a magic number since PTHREAD_STACK_MIN seems to not be a constant. */
+#define configMINIMAL_STACK_SIZE                            ( ( unsigned short ) (0x4000 + 40) / sizeof(portSTACK_TYPE) )
+/* Currently not used in Linux POSIX simulator */
+#define configMAX_API_CALL_INTERRUPT_PRIORITY               0
+
+// ----------------------- System --------------------------
+
+#define configUSE_NEWLIB_REENTRANT                          0
+#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H           0
+
+// ----------------------- Memory  -------------------------
+
+#define configTOTAL_HEAP_SIZE                               ( ( size_t ) ( 65 * 1024 ) )
+
+// ------------------- Run-time Stats ----------------------
+
+#define configUSE_TRACE_FACILITY                            1
+
+// -------------------- API Includes -----------------------
+
+#define INCLUDE_xTaskGetCurrentTaskHandle                   0 /* not defined in POSIX simulator */
+#define INCLUDE_vTaskDelayUntil                             1
+
+/* ------------------------------------------------ ESP-IDF Additions --------------------------------------------------
+ *
+ * ------------------------------------------------------------------------------------------------------------------ */

+ 30 - 7
components/freertos/esp_additions/arch/riscv/include/freertos/FreeRTOSConfig_arch.h

@@ -1,13 +1,12 @@
 /*
- * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#ifndef FREERTOS_CONFIG_RISCV_H
-#define FREERTOS_CONFIG_RISCV_H
+#pragma once
 
-//RISC-V Archiecture specific configuration. This file is included in the common FreeRTOSConfig.h.
+// RISC-V Architecture specific configuration. This file is included in the common FreeRTOSConfig.h.
 
 #include "sdkconfig.h"
 
@@ -17,13 +16,39 @@
 
 // ------------------ Scheduler Related --------------------
 
+#define configMAX_PRIORITIES                                ( 25 )
 #ifdef CONFIG_FREERTOS_OPTIMIZED_SCHEDULER
 #define configUSE_PORT_OPTIMISED_TASK_SELECTION             1
 #else
 #define configUSE_PORT_OPTIMISED_TASK_SELECTION             0
-#endif
+#endif /* CONFIG_FREERTOS_OPTIMIZED_SCHEDULER */
+#define configMINIMAL_STACK_SIZE                            ( CONFIG_FREERTOS_IDLE_TASK_STACKSIZE + configSTACK_OVERHEAD_TOTAL )
 #define configMAX_API_CALL_INTERRUPT_PRIORITY               0
 
+// ----------------------- System --------------------------
+
+#define configUSE_NEWLIB_REENTRANT                          1
+#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H           1
+
+// ----------------------- Memory  -------------------------
+
+/* This isn't used as FreeRTOS will only allocate from internal memory (see
+ * heap_idf.c). We simply define this macro to span all non-statically-allocated
+ * shared RAM. */
+#define configTOTAL_HEAP_SIZE                               (&_heap_end - &_heap_start)
+
+// ------------------- Run-time Stats ----------------------
+
+#if CONFIG_FREERTOS_USE_TRACE_FACILITY
+    /* Used by uxTaskGetSystemState(), and other trace facility functions */
+    #define configUSE_TRACE_FACILITY                        1
+#endif /* CONFIG_FREERTOS_USE_TRACE_FACILITY */
+
+// -------------------- API Includes -----------------------
+
+#define INCLUDE_xTaskDelayUntil                             1
+#define INCLUDE_xTaskGetCurrentTaskHandle                   1
+
 /* ------------------------------------------------ ESP-IDF Additions --------------------------------------------------
  *
  * ------------------------------------------------------------------------------------------------------------------ */
@@ -31,5 +56,3 @@
 #ifndef configISR_STACK_SIZE
 #define configISR_STACK_SIZE                                (CONFIG_FREERTOS_ISR_STACKSIZE)
 #endif
-
-#endif // FREERTOS_CONFIG_RISCV_H

+ 31 - 8
components/freertos/esp_additions/arch/xtensa/include/freertos/FreeRTOSConfig_arch.h

@@ -1,18 +1,17 @@
 /*
- * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
+ * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD
  *
  * SPDX-License-Identifier: Apache-2.0
  */
 
-#ifndef FREERTOS_CONFIG_XTENSA_H
-#define FREERTOS_CONFIG_XTENSA_H
+#pragma once
 
-//Xtensa Archiecture specific configuration. This file is included in the common FreeRTOSConfig.h.
+// Xtensa Architecture specific configuration. This file is included in the common FreeRTOSConfig.h.
 
 #include "sdkconfig.h"
 
 /* Required for configuration-dependent settings. */
-#include "xtensa_config.h"
+#include "freertos/xtensa_config.h"
 
 /* -------------------------------------------- Xtensa Additional Config  ----------------------------------------------
  * - Provide Xtensa definitions usually given by -D option when building with xt-make (see readme_xtensa.txt)
@@ -44,13 +43,39 @@
 
 // ------------------ Scheduler Related --------------------
 
+#define configMAX_PRIORITIES                                ( 25 )
 #ifdef CONFIG_FREERTOS_OPTIMIZED_SCHEDULER
 #define configUSE_PORT_OPTIMISED_TASK_SELECTION             1
 #else
 #define configUSE_PORT_OPTIMISED_TASK_SELECTION             0
-#endif
+#endif /* CONFIG_FREERTOS_OPTIMIZED_SCHEDULER */
+#define configMINIMAL_STACK_SIZE                            ( CONFIG_FREERTOS_IDLE_TASK_STACKSIZE + configSTACK_OVERHEAD_TOTAL )
 #define configMAX_API_CALL_INTERRUPT_PRIORITY               XCHAL_EXCM_LEVEL
 
+// ----------------------- System --------------------------
+
+#define configUSE_NEWLIB_REENTRANT                          1
+#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H           1
+
+// ----------------------- Memory  -------------------------
+
+/* This isn't used as FreeRTOS will only allocate from internal memory (see
+ * heap_idf.c). We simply define this macro to span all non-statically-allocated
+ * shared RAM. */
+#define configTOTAL_HEAP_SIZE                               (&_heap_end - &_heap_start)
+
+// ------------------- Run-time Stats ----------------------
+
+#if CONFIG_FREERTOS_USE_TRACE_FACILITY
+    /* Used by uxTaskGetSystemState(), and other trace facility functions */
+    #define configUSE_TRACE_FACILITY                        1
+#endif /* CONFIG_FREERTOS_USE_TRACE_FACILITY */
+
+// -------------------- API Includes -----------------------
+
+#define INCLUDE_xTaskDelayUntil                             1
+#define INCLUDE_xTaskGetCurrentTaskHandle                   1
+
 /* ------------------------------------------------ ESP-IDF Additions --------------------------------------------------
  *
  * ------------------------------------------------------------------------------------------------------------------ */
@@ -64,5 +89,3 @@
 #ifndef configISR_STACK_SIZE
 #define configISR_STACK_SIZE                                ((CONFIG_FREERTOS_ISR_STACKSIZE + configSTACK_ALIGNMENT - 1) & (~(configSTACK_ALIGNMENT - 1)))
 #endif
-
-#endif // FREERTOS_CONFIG_XTENSA_H

+ 4 - 47
components/freertos/esp_additions/include/freertos/FreeRTOSConfig.h

@@ -24,15 +24,6 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
 
 #else // CONFIG_FREERTOS_SMP
 
-// The arch-specific FreeRTOSConfig_arch.h in port/<arch>/include.
-#include "freertos/FreeRTOSConfig_arch.h"
-
-#if !(defined(FREERTOS_CONFIG_XTENSA_H) \
-        || defined(FREERTOS_CONFIG_RISCV_H) \
-        || defined(FREERTOS_CONFIG_LINUX_H))
-#error "Needs architecture-speific FreeRTOSConfig.h!"
-#endif
-
 /* ----------------------------------------------------- Helpers -------------------------------------------------------
  * - Macros that the FreeRTOS configuration macros depend on
  * ------------------------------------------------------------------------------------------------------------------ */
@@ -73,6 +64,10 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
                                     STACK_OVERHEAD_WATCHPOINT     \
                                                             )
 
+/* The arch-specific FreeRTOSConfig_arch.h in esp_additions/arch_include/<arch>.
+ * Placed here due to configSTACK_OVERHEAD_TOTAL. Todo: IDF-5712. */
+#include "freertos/FreeRTOSConfig_arch.h"
+
 /* ------------------------------------------------- FreeRTOS Config ---------------------------------------------------
  * - All Vanilla FreeRTOS configuration goes into this section
  * - Keep this section in-sync with the corresponding version of single-core upstream version of FreeRTOS
@@ -102,17 +97,6 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
 #endif //configUSE_TICKLESS_IDLE
 #define configCPU_CLOCK_HZ                              (CONFIG_ESP_DEFAULT_CPU_FREQ_MHZ * 1000000)
 #define configTICK_RATE_HZ                              CONFIG_FREERTOS_HZ
-#ifdef CONFIG_IDF_TARGET_LINUX
-#define configMAX_PRIORITIES                            ( 7 ) // Default in upstream simulator
-/* The stack allocated by FreeRTOS will be passed to a pthread.
-   pthread has a minimal stack size which currently is 16KB.
-   The rest is for additional structures of the POSIX/Linux port.
-   This is a magic number since PTHREAD_STACK_MIN seems to not be a constant. */
-#define configMINIMAL_STACK_SIZE                        ( ( unsigned short ) (0x4000 + 40) / sizeof(portSTACK_TYPE) )
-#else
-#define configMAX_PRIORITIES                            ( 25 )  //This has impact on speed of search for highest priority
-#define configMINIMAL_STACK_SIZE                        ( CONFIG_FREERTOS_IDLE_TASK_STACKSIZE + configSTACK_OVERHEAD_TOTAL )
-#endif
 #define configUSE_TIME_SLICING                          1
 #define configUSE_16_BIT_TICKS                          0
 #define configIDLE_SHOULD_YIELD                         0
@@ -133,12 +117,6 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
 #define configMAX_TASK_NAME_LEN                         CONFIG_FREERTOS_MAX_TASK_NAME_LEN
 #define configNUM_THREAD_LOCAL_STORAGE_POINTERS         CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS
 #define configSTACK_DEPTH_TYPE                          uint32_t
-#ifndef CONFIG_IDF_TARGET_LINUX
-#define configUSE_NEWLIB_REENTRANT                      1
-#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H       1
-#else
-#define configINCLUDE_FREERTOS_TASK_C_ADDITIONS_H       0 // Default in upstream simulator
-#endif
 #if CONFIG_FREERTOS_ENABLE_BACKWARD_COMPATIBILITY
 #define configENABLE_BACKWARD_COMPATIBILITY             1
 #else
@@ -150,13 +128,6 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
 
 #define configSUPPORT_STATIC_ALLOCATION                 1
 #define configSUPPORT_DYNAMIC_ALLOCATION                1
-#ifdef CONFIG_IDF_TARGET_LINUX
-#define configTOTAL_HEAP_SIZE                           ( ( size_t ) ( 65 * 1024 ) ) // Default in upstream simulator
-#else
-//We define the heap to span all of the non-statically-allocated shared RAM. ToDo: Make sure there
-//is some space left for the app and main cpu when running outside of a thread.
-#define configTOTAL_HEAP_SIZE                           (&_heap_end - &_heap_start)//( ( size_t ) (64 * 1024) )
-#endif
 #define configAPPLICATION_ALLOCATED_HEAP                1
 #define configSTACK_ALLOCATION_FROM_SEPARATE_HEAP       0
 
@@ -178,13 +149,6 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
 #ifdef CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS
 #define configGENERATE_RUN_TIME_STATS                   1   /* Used by vTaskGetRunTimeStats() */
 #endif
-#ifdef CONFIG_IDF_TARGET_LINUX
-#define configUSE_TRACE_FACILITY                        1
-#else
-#ifdef CONFIG_FREERTOS_USE_TRACE_FACILITY
-#define configUSE_TRACE_FACILITY                        1   /* Used by uxTaskGetSystemState(), and other trace facility functions */
-#endif
-#endif
 #ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
 #define configUSE_STATS_FORMATTING_FUNCTIONS            1   /* Used by vTaskList() */
 #endif
@@ -224,13 +188,6 @@ This file gets pulled into assembly sources. Therefore, some includes need to be
 #define INCLUDE_xTaskResumeFromISR                      1
 #define INCLUDE_xTimerPendFunctionCall                  1
 #define INCLUDE_xTaskGetSchedulerState                  1
-#ifdef CONFIG_IDF_TARGET_LINUX
-#define INCLUDE_xTaskGetCurrentTaskHandle               0 // not defined in POSIX simulator
-#define INCLUDE_vTaskDelayUntil                         1
-#else
-#define INCLUDE_xTaskDelayUntil                         1
-#define INCLUDE_xTaskGetCurrentTaskHandle               1
-#endif
 //Unlisted
 #define INCLUDE_pxTaskGetStackStart                     1