diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index 75b2397250..0b9baedb14 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -80,6 +80,7 @@ /components/esp_http_server/ @esp-idf-codeowners/app-utilities /components/esp_https_ota/ @esp-idf-codeowners/app-utilities /components/esp_https_server/ @esp-idf-codeowners/app-utilities +/components/esp_hw_support/ @esp-idf-codeowners/system /components/esp_ipc/ @esp-idf-codeowners/system /components/esp_local_ctrl/ @esp-idf-codeowners/app-utilities /components/esp_netif/ @esp-idf-codeowners/network diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index b4a04c3768..9397c0db52 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -15,10 +15,10 @@ if(NOT IDF_TARGET) "in by the parent build process.") endif() -set(COMPONENTS bootloader esptool_py partition_table soc bootloader_support log spi_flash micro-ecc main efuse) +set(COMPONENTS bootloader esptool_py esp_hw_support hal partition_table soc bootloader_support log spi_flash micro-ecc main efuse) set(BOOTLOADER_BUILD 1) include("${IDF_PATH}/tools/cmake/project.cmake") -set(common_req log esp_rom esp_common xtensa) +set(common_req log esp_rom esp_common esp_hw_support hal xtensa) if(LEGACY_INCLUDE_COMMON_HEADERS) list(APPEND common_req soc hal) endif() diff --git a/components/bootloader/subproject/Makefile b/components/bootloader/subproject/Makefile index 0a72a6fd06..8547e3ecb0 100644 --- a/components/bootloader/subproject/Makefile +++ b/components/bootloader/subproject/Makefile @@ -8,7 +8,7 @@ endif PROJECT_NAME := bootloader -COMPONENTS := esptool_py bootloader_support log spi_flash micro-ecc soc main efuse esp_rom hal +COMPONENTS := esp_hw_support esptool_py bootloader_support log spi_flash micro-ecc soc main efuse esp_rom hal # Clear C and CXX from top level project CFLAGS = diff --git a/components/esp_common/CMakeLists.txt b/components/esp_common/CMakeLists.txt index 2c8891ab6a..991dc10579 100644 --- a/components/esp_common/CMakeLists.txt +++ b/components/esp_common/CMakeLists.txt @@ -25,7 +25,7 @@ else() # Note: esp_ipc, esp_pm added as a public requirement to keep compatibility as to be located here. idf_component_register(SRCS "${srcs}" INCLUDE_DIRS include - REQUIRES ${target} espcoredump esp_timer esp_ipc esp_pm + REQUIRES ${target} espcoredump esp_timer esp_ipc esp_pm esp_hw_support PRIV_REQUIRES soc LDFRAGMENTS "linker.lf") diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt new file mode 100644 index 0000000000..8145907364 --- /dev/null +++ b/components/esp_hw_support/CMakeLists.txt @@ -0,0 +1,4 @@ +idf_component_register(SRCS "compare_set.c" + "cpu_util.c" + INCLUDE_DIRS include + REQUIRES soc) diff --git a/components/esp_hw_support/README.md b/components/esp_hw_support/README.md new file mode 100644 index 0000000000..e75de016c4 --- /dev/null +++ b/components/esp_hw_support/README.md @@ -0,0 +1,7 @@ +## `esp_hw_support` ## + +This component contains hardware-related operations for supporting the system. These operations +are one level above that of `hal` in that these(1) use system services such as memory allocation, logging, scheduling +or (2) may be multi-step operations involving/affecting multiple parts of the SoC. + +Implementations that don't fit other components cleanly, but are not worth creating a new component for (yet) may also be placed here as long as they don't pull dependencies other than the core system components. \ No newline at end of file diff --git a/components/soc/src/compare_set.c b/components/esp_hw_support/compare_set.c similarity index 100% rename from components/soc/src/compare_set.c rename to components/esp_hw_support/compare_set.c diff --git a/components/esp_hw_support/component.mk b/components/esp_hw_support/component.mk new file mode 100644 index 0000000000..3734fe3290 --- /dev/null +++ b/components/esp_hw_support/component.mk @@ -0,0 +1,2 @@ +COMPONENT_SRCDIRS := . +COMPONENT_ADD_INCLUDEDIRS := . include diff --git a/components/soc/src/cpu_util.c b/components/esp_hw_support/cpu_util.c similarity index 100% rename from components/soc/src/cpu_util.c rename to components/esp_hw_support/cpu_util.c diff --git a/components/soc/include/soc/compare_set.h b/components/esp_hw_support/include/soc/compare_set.h similarity index 96% rename from components/soc/include/soc/compare_set.h rename to components/esp_hw_support/include/soc/compare_set.h index 626752ad51..b748fa9ea8 100644 --- a/components/soc/include/soc/compare_set.h +++ b/components/esp_hw_support/include/soc/compare_set.h @@ -21,6 +21,9 @@ #include "soc/soc_memory_layout.h" #include "xtensa/xtruntime.h" +#ifdef __cplusplus +extern "C" { +#endif static inline void __attribute__((always_inline)) compare_and_set_native(volatile uint32_t *addr, uint32_t compare, uint32_t *set) { @@ -53,4 +56,8 @@ static inline void __attribute__((always_inline)) compare_and_set_native(volatil void compare_and_set_extram(volatile uint32_t *addr, uint32_t compare, uint32_t *set); +#ifdef __cplusplus +} +#endif + #endif \ No newline at end of file diff --git a/components/soc/include/soc/cpu.h b/components/esp_hw_support/include/soc/cpu.h similarity index 100% rename from components/soc/include/soc/cpu.h rename to components/esp_hw_support/include/soc/cpu.h diff --git a/components/soc/include/soc/spinlock.h b/components/esp_hw_support/include/soc/spinlock.h similarity index 98% rename from components/soc/include/soc/spinlock.h rename to components/esp_hw_support/include/soc/spinlock.h index aace1bbf25..286858315b 100644 --- a/components/soc/include/soc/spinlock.h +++ b/components/esp_hw_support/include/soc/spinlock.h @@ -21,6 +21,9 @@ #include "soc/compare_set.h" #include "xtensa/xtruntime.h" +#ifdef __cplusplus +extern "C" { +#endif #ifdef CONFIG_SPIRAM_WORKAROUND_NEED_VOLATILE_SPINLOCK #define NEED_VOLATILE_MUX volatile @@ -154,5 +157,9 @@ static inline void __attribute__((always_inline)) spinlock_release(spinlock_t *l #endif } +#ifdef __cplusplus +} +#endif + #endif diff --git a/components/soc/CMakeLists.txt b/components/soc/CMakeLists.txt index e088e3bd63..67ef7bc045 100644 --- a/components/soc/CMakeLists.txt +++ b/components/soc/CMakeLists.txt @@ -1,13 +1,10 @@ idf_build_get_property(target IDF_TARGET) -idf_component_register(SRCS "src/cpu_util.c" - "src/memory_layout_utils.c" - "src/lldesc.c" +idf_component_register(SRCS "src/lldesc.c" "src/soc_include_legacy_warn.c" - "src/compare_set.c" - REQUIRES hal #cpu.h directly includes HAL header + "src/memory_layout_utils.c" INCLUDE_DIRS include - PRIV_REQUIRES ${target} + PRIV_REQUIRES hal # [refactor-todo] soc dependency on hal for rtc sources LDFRAGMENTS linker.lf) add_subdirectory(soc) diff --git a/components/soc/src/memory_layout_utils.c b/components/soc/memory_layout_utils.c similarity index 100% rename from components/soc/src/memory_layout_utils.c rename to components/soc/memory_layout_utils.c diff --git a/docs/Doxyfile b/docs/Doxyfile index 242214b14b..7345aa0c12 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -138,11 +138,11 @@ INPUT = \ $(IDF_PATH)/components/hal/include/hal/adc_types.h \ $(IDF_PATH)/components/hal/include/hal/twai_types.h \ $(IDF_PATH)/components/hal/include/hal/touch_sensor_types.h \ - $(IDF_PATH)/components/soc/soc/esp32/include/soc/adc_channel.h \ - $(IDF_PATH)/components/soc/soc/esp32/include/soc/dac_channel.h \ - $(IDF_PATH)/components/soc/soc/esp32/include/soc/touch_sensor_channel.h \ - $(IDF_PATH)/components/soc/soc/esp32/include/soc/uart_channel.h \ - $(IDF_PATH)/components/soc/soc/esp32/include/soc/rtc_io_channel.h \ + $(IDF_PATH)/components/soc/esp32/include/soc/adc_channel.h \ + $(IDF_PATH)/components/soc/esp32/include/soc/dac_channel.h \ + $(IDF_PATH)/components/soc/esp32/include/soc/touch_sensor_channel.h \ + $(IDF_PATH)/components/soc/esp32/include/soc/uart_channel.h \ + $(IDF_PATH)/components/soc/esp32/include/soc/rtc_io_channel.h \ ## esp_netif - API Reference $(IDF_PATH)/components/esp_netif/include/esp_netif.h \ $(IDF_PATH)/components/esp_netif/include/esp_netif_net_stack.h \ diff --git a/docs/en/api-guides/freertos-smp.rst b/docs/en/api-guides/freertos-smp.rst index 0d41d4061a..304fce38da 100644 --- a/docs/en/api-guides/freertos-smp.rst +++ b/docs/en/api-guides/freertos-smp.rst @@ -327,7 +327,7 @@ The ESP-IDF FreeRTOS critical section functions have been modified as follows… section functions (``port*_CRITICAL`` in Non-ISR and ``port*_CRITICAL_ISR`` in ISR) in order to be in compliance with Vanilla FreeRTOS. -For more details see :component_file:`soc/include/soc/spinlock.h` +For more details see :component_file:`esp_hw_support/include/soc/spinlock.h` and :component_file:`freertos/tasks.c` It should be noted that when modifying vanilla FreeRTOS code to be ESP-IDF diff --git a/tools/cmake/build.cmake b/tools/cmake/build.cmake index 707a2e6a87..7560b0267b 100644 --- a/tools/cmake/build.cmake +++ b/tools/cmake/build.cmake @@ -154,7 +154,8 @@ function(__build_init idf_path) # Set components required by all other components in the build # # - lwip is here so that #include works without any special provisions - set(requires_common cxx newlib freertos heap log lwip soc hal esp_rom esp_common esp_system xtensa) + # - esp_hw_support is here for backward compatibility + set(requires_common cxx newlib freertos esp_hw_support heap log lwip soc hal esp_rom esp_common esp_system xtensa) idf_build_set_property(__COMPONENT_REQUIRES_COMMON "${requires_common}") __build_get_idf_git_revision()