diff --git a/components/freertos/CMakeLists.txt b/components/freertos/CMakeLists.txt index aea0dfbcca..87219c162f 100644 --- a/components/freertos/CMakeLists.txt +++ b/components/freertos/CMakeLists.txt @@ -82,17 +82,14 @@ endif() if(CONFIG_IDF_TARGET_ARCH_XTENSA) list(APPEND srcs - "${kernel_dir}/portable/${arch}/xtensa_context.S" "${kernel_dir}/portable/${arch}/xtensa_init.c" - "${kernel_dir}/portable/${arch}/xtensa_overlay_os_hook.c" - "${kernel_dir}/portable/${arch}/xtensa_vectors.S") + "${kernel_dir}/portable/${arch}/xtensa_overlay_os_hook.c") + + list(APPEND include_dirs + "${kernel_dir}/portable/xtensa/include/freertos") # For #include "xtensa_...h" endif() -if(CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY) - list(APPEND srcs "${kernel_dir}/portable/xtensa/xtensa_loadstore_handler.S") -endif() - idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${include_dirs} PRIV_INCLUDE_DIRS ${private_include_dirs} diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_api.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_api.h deleted file mode 100644 index bd2bfeb208..0000000000 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_api.h +++ /dev/null @@ -1,2 +0,0 @@ -/* This header file has been moved, please include in future */ -#include diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_context.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_context.h deleted file mode 100644 index 45c4272869..0000000000 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_context.h +++ /dev/null @@ -1,2 +0,0 @@ -/* This header file has been moved, please include in future */ -#include diff --git a/components/freertos/esp_additions/arch/xtensa/include/freertos/FreeRTOSConfig_arch.h b/components/freertos/esp_additions/arch/xtensa/include/freertos/FreeRTOSConfig_arch.h index a7ed6d5e4a..0803ac1535 100644 --- a/components/freertos/esp_additions/arch/xtensa/include/freertos/FreeRTOSConfig_arch.h +++ b/components/freertos/esp_additions/arch/xtensa/include/freertos/FreeRTOSConfig_arch.h @@ -11,7 +11,7 @@ #include "sdkconfig.h" /* Required for configuration-dependent settings. */ -#include "freertos/xtensa_config.h" +#include "xtensa_config.h" /* -------------------------------------------- Xtensa Additional Config ---------------------------------------------- * - Provide Xtensa definitions usually given by -D option when building with xt-make (see readme_xtensa.txt) diff --git a/components/xtensa/CMakeLists.txt b/components/xtensa/CMakeLists.txt index 3d8522a9ae..b918475e8b 100644 --- a/components/xtensa/CMakeLists.txt +++ b/components/xtensa/CMakeLists.txt @@ -1,3 +1,20 @@ +# Xtensa Component Architecture +# +# The ESP-IDF Xtesna component contains two major features: +# - The Xtensa HAL +# - The Xtensa RTOS porting layer +# +# The Xtensa HAL provides various macros/functions regarding the Xtensa processor's configuration and extensions (see +# "sys_sw_rm.pdf 3.1"). The Xtensa HAL... +# - is packaged as a library ("libxt_hal.a") in the ESP-IDF Xtensa component +# - expects `#include ` as the include path to the Xtensa HAL's headers +# +# The Xtensa RTOS Porting Layer is a set of helper functions and interrupt vectors that act as a basis of an RTOS port. +# The porting layer sources files are OS agnostic, thus are common across multiple Xtensa RTOS ports (e.g., FreeRTOS, +# ThreadX). The Xtensa RTOS Porting Layer... +# - interfaces with an RTOS port via the "xtensa_rtos.h" header provided by the RTOS port +# - expected `#include <...h>` as the incldue path to the porting layer's headers + idf_build_get_property(target IDF_TARGET) idf_build_get_property(arch IDF_TARGET_ARCH) @@ -5,14 +22,37 @@ if(NOT "${arch}" STREQUAL "xtensa") return() endif() -set(srcs "eri.c" "xt_trax.c") +set(include_dirs + "${target}/include" # - Add include path for target specific Xtensa HAL headers (`#include `) + "include" # - Add include path for... + # - common Xtensa HAL headers (`#include `) + # - Xtensa RTOS porting layer headers (`#include <...h>`) + "deprecated_include") # - For deprecated include paths (see IDF-7230) +set(srcs + "eri.c" + "xt_trax.c") + +# Minor optimization. The following sources are excluded from the bootloader as they are not required by the bootloader. +# +# - ROM provides a copy of basic exception vectors (e.g., _UserExceptionVector and _WindowOverflow8) +# - The bootloader doesn't register any interrupts, thus... +# - the "xtensa_api.h" isn't used +# - the "xtensa_context.h" functions aren't used as there are no interrupts to trigger a context switch if(NOT BOOTLOADER_BUILD) - list(APPEND srcs "xtensa_intr.c" "xtensa_intr_asm.S") + list(APPEND srcs + "xtensa_context.S" + "xtensa_intr_asm.S" + "xtensa_intr.c" + "xtensa_vectors.S") + + if(CONFIG_ESP32_IRAM_AS_8BIT_ACCESSIBLE_MEMORY) + list(APPEND srcs "xtensa_loadstore_handler.S") + endif() endif() idf_component_register(SRCS ${srcs} - INCLUDE_DIRS include ${target}/include + INCLUDE_DIRS ${include_dirs} LDFRAGMENTS linker.lf) target_link_libraries(${COMPONENT_LIB} PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/${target}/libxt_hal.a") diff --git a/components/xtensa/deprecated_include/freertos/xtensa_api.h b/components/xtensa/deprecated_include/freertos/xtensa_api.h new file mode 100644 index 0000000000..1e506180ee --- /dev/null +++ b/components/xtensa/deprecated_include/freertos/xtensa_api.h @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* This header file has been moved, thus `#include ` is deprecated. Please use `#include ` instead */ +/* Todo: IDF-7230 */ +#include diff --git a/components/xtensa/deprecated_include/freertos/xtensa_context.h b/components/xtensa/deprecated_include/freertos/xtensa_context.h new file mode 100644 index 0000000000..83c7a762b2 --- /dev/null +++ b/components/xtensa/deprecated_include/freertos/xtensa_context.h @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* This header file has been moved, thus `#include ` is deprecated. Please use `#include ` instead */ +/* Todo: IDF-7230 */ +#include diff --git a/components/xtensa/deprecated_include/freertos/xtensa_timer.h b/components/xtensa/deprecated_include/freertos/xtensa_timer.h new file mode 100644 index 0000000000..40f7223f44 --- /dev/null +++ b/components/xtensa/deprecated_include/freertos/xtensa_timer.h @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* This header file has been moved, thus `#include ` is deprecated. Please use `#include ` instead */ +/* Todo: IDF-7230 */ +#include diff --git a/components/xtensa/deprecated_include/xtensa/xtensa_api.h b/components/xtensa/deprecated_include/xtensa/xtensa_api.h new file mode 100644 index 0000000000..dbcbfd91c8 --- /dev/null +++ b/components/xtensa/deprecated_include/xtensa/xtensa_api.h @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* This header file has been moved, thus `#include ` is deprecated. Please use `#include ` instead */ +/* Todo: IDF-7230 */ +#include diff --git a/components/xtensa/deprecated_include/xtensa/xtensa_context.h b/components/xtensa/deprecated_include/xtensa/xtensa_context.h new file mode 100644 index 0000000000..e49c7e5df8 --- /dev/null +++ b/components/xtensa/deprecated_include/xtensa/xtensa_context.h @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* This header file has been moved, thus `#include ` is deprecated. Please use `#include ` instead */ +/* Todo: IDF-7230 */ +#include diff --git a/components/xtensa/deprecated_include/xtensa/xtensa_timer.h b/components/xtensa/deprecated_include/xtensa/xtensa_timer.h new file mode 100644 index 0000000000..7df0c8d502 --- /dev/null +++ b/components/xtensa/deprecated_include/xtensa/xtensa_timer.h @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +/* This header file has been moved, thus `#include ` is deprecated. Please use `#include ` instead */ +/* Todo: IDF-7230 */ +#include diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/xt_asm_utils.h b/components/xtensa/include/xt_asm_utils.h similarity index 100% rename from components/freertos/FreeRTOS-Kernel/portable/xtensa/xt_asm_utils.h rename to components/xtensa/include/xt_asm_utils.h diff --git a/components/xtensa/include/xtensa/xtensa_api.h b/components/xtensa/include/xtensa_api.h similarity index 96% rename from components/xtensa/include/xtensa/xtensa_api.h rename to components/xtensa/include/xtensa_api.h index deef36f7c6..5911750191 100644 --- a/components/xtensa/include/xtensa/xtensa_api.h +++ b/components/xtensa/include/xtensa_api.h @@ -1,3 +1,10 @@ +/* + * SPDX-FileCopyrightText: 2015-2019 Cadence Design Systems, Inc. + * + * SPDX-License-Identifier: MIT + * + * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD + */ /******************************************************************************* Copyright (c) 2006-2015 Cadence Design Systems Inc. diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_config.h b/components/xtensa/include/xtensa_config.h similarity index 100% rename from components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_config.h rename to components/xtensa/include/xtensa_config.h diff --git a/components/xtensa/include/xtensa/xtensa_context.h b/components/xtensa/include/xtensa_context.h similarity index 98% rename from components/xtensa/include/xtensa/xtensa_context.h rename to components/xtensa/include/xtensa_context.h index ee87d2741f..49188bb7ff 100644 --- a/components/xtensa/include/xtensa/xtensa_context.h +++ b/components/xtensa/include/xtensa_context.h @@ -1,4 +1,10 @@ - +/* + * SPDX-FileCopyrightText: 2015-2019 Cadence Design Systems, Inc. + * + * SPDX-License-Identifier: MIT + * + * SPDX-FileContributor: 2016-2022 Espressif Systems (Shanghai) CO LTD + */ /* * Copyright (c) 2015-2019 Cadence Design Systems, Inc. * diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_timer.h b/components/xtensa/include/xtensa_timer.h similarity index 99% rename from components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_timer.h rename to components/xtensa/include/xtensa_timer.h index 53555ed8cd..afffcdf25f 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/xtensa_timer.h +++ b/components/xtensa/include/xtensa_timer.h @@ -56,7 +56,6 @@ #include "xtensa_rtos.h" /* in case this wasn't included directly */ -#include "freertos/FreeRTOSConfig.h" /* Select timer to use for periodic tick, and determine its interrupt number diff --git a/components/xtensa/linker.lf b/components/xtensa/linker.lf index 5227ce02df..084c2537eb 100644 --- a/components/xtensa/linker.lf +++ b/components/xtensa/linker.lf @@ -1,8 +1,9 @@ [mapping:xtensa] archive: libxtensa.a entries: - eri (noflash_text) - xtensa_intr_asm (noflash_text) + * (noflash_text) # Default all functions to IRAM + xt_trax (default) + xtensa_intr (default) [mapping:xt_hal] archive: libxt_hal.a diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_context.S b/components/xtensa/xtensa_context.S similarity index 100% rename from components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_context.S rename to components/xtensa/xtensa_context.S diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_loadstore_handler.S b/components/xtensa/xtensa_loadstore_handler.S similarity index 100% rename from components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_loadstore_handler.S rename to components/xtensa/xtensa_loadstore_handler.S diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S b/components/xtensa/xtensa_vectors.S similarity index 100% rename from components/freertos/FreeRTOS-Kernel/portable/xtensa/xtensa_vectors.S rename to components/xtensa/xtensa_vectors.S