diff --git a/components/app_trace/gcov/gcov_rtio.c b/components/app_trace/gcov/gcov_rtio.c index 70c30cf8e69..614c3c8ebc6 100644 --- a/components/app_trace/gcov/gcov_rtio.c +++ b/components/app_trace/gcov/gcov_rtio.c @@ -11,7 +11,6 @@ #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" -#include "soc/cpu.h" #include "soc/timer_periph.h" #include "esp_app_trace.h" #include "esp_freertos_hooks.h" diff --git a/components/app_trace/test/test_trace.c b/components/app_trace/test/test_trace.c index a6c132c9c24..e62880b72b4 100644 --- a/components/app_trace/test/test_trace.c +++ b/components/app_trace/test/test_trace.c @@ -11,7 +11,6 @@ #include "unity.h" #include "driver/timer.h" #include "esp_rom_sys.h" -#include "soc/cpu.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/task.h" diff --git a/components/bootloader_support/src/bootloader_init.c b/components/bootloader_support/src/bootloader_init.c index 41538bce85a..ba6068b65b6 100644 --- a/components/bootloader_support/src/bootloader_init.c +++ b/components/bootloader_support/src/bootloader_init.c @@ -15,7 +15,7 @@ #include "bootloader_clock.h" #include "bootloader_common.h" #include "esp_flash_encrypt.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "hal/wdt_hal.h" diff --git a/components/bootloader_support/src/bootloader_mem.c b/components/bootloader_support/src/bootloader_mem.c index 2466a6913fd..50534fd5905 100644 --- a/components/bootloader_support/src/bootloader_mem.c +++ b/components/bootloader_support/src/bootloader_mem.c @@ -11,7 +11,7 @@ #include "hal/mpu_types.h" #include "soc/soc_caps.h" #include "bootloader_mem.h" -#include "soc/cpu.h" +#include "esp_cpu.h" void bootloader_init_mem(void) { diff --git a/components/bootloader_support/src/bootloader_utility.c b/components/bootloader_support/src/bootloader_utility.c index b3bfa0fb972..e6e44179b9f 100644 --- a/components/bootloader_support/src/bootloader_utility.c +++ b/components/bootloader_support/src/bootloader_utility.c @@ -70,7 +70,7 @@ #endif #include "soc/soc.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/gpio_periph.h" #include "soc/efuse_periph.h" diff --git a/components/bootloader_support/src/esp32/bootloader_esp32.c b/components/bootloader_support/src/esp32/bootloader_esp32.c index 358e398fe51..c2632074efc 100644 --- a/components/bootloader_support/src/esp32/bootloader_esp32.c +++ b/components/bootloader_support/src/esp32/bootloader_esp32.c @@ -18,7 +18,7 @@ #include "bootloader_console.h" #include "bootloader_flash_priv.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/dport_reg.h" #include "soc/efuse_reg.h" #include "soc/gpio_periph.h" diff --git a/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c b/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c index 608654e091a..3e926a6e2d0 100644 --- a/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c +++ b/components/bootloader_support/src/esp32c3/bootloader_esp32c3.c @@ -17,7 +17,7 @@ #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" #include "soc/assist_debug_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/spi_periph.h" #include "soc/extmem_reg.h" diff --git a/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c b/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c index 7ff27dd6938..eb317c370f1 100644 --- a/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c +++ b/components/bootloader_support/src/esp32h2/bootloader_esp32h2.c @@ -17,7 +17,7 @@ #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" #include "soc/assist_debug_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/spi_periph.h" #include "soc/extmem_reg.h" diff --git a/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c b/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c index 177ce835c14..ea28e055bb8 100644 --- a/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c +++ b/components/bootloader_support/src/esp32s2/bootloader_esp32s2.c @@ -30,7 +30,7 @@ #include "esp_image_format.h" #include "flash_qio_mode.h" #include "soc/assist_debug_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/dport_reg.h" #include "soc/extmem_reg.h" #include "soc/rtc.h" diff --git a/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c b/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c index 8346b00d02e..0aff0d5c9d4 100644 --- a/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c +++ b/components/bootloader_support/src/esp32s3/bootloader_esp32s3.c @@ -13,7 +13,7 @@ #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" #include "soc/assist_debug_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/dport_reg.h" #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" diff --git a/components/bootloader_support/src/esp8684/bootloader_esp8684.c b/components/bootloader_support/src/esp8684/bootloader_esp8684.c index 61aa3f39427..1d75e8806cf 100644 --- a/components/bootloader_support/src/esp8684/bootloader_esp8684.c +++ b/components/bootloader_support/src/esp8684/bootloader_esp8684.c @@ -17,7 +17,7 @@ #include "soc/gpio_sig_map.h" #include "soc/io_mux_reg.h" #include "soc/assist_debug_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/spi_periph.h" #include "soc/extmem_reg.h" diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c index ebfd92c9c8c..60bb47f4275 100644 --- a/components/bootloader_support/src/esp_image_format.c +++ b/components/bootloader_support/src/esp_image_format.c @@ -5,7 +5,7 @@ */ #include #include -#include +#include #include #include #include diff --git a/components/esp_gdbstub/riscv/gdbstub_riscv.c b/components/esp_gdbstub/riscv/gdbstub_riscv.c index ad99f5c64f1..474a144bf5e 100644 --- a/components/esp_gdbstub/riscv/gdbstub_riscv.c +++ b/components/esp_gdbstub/riscv/gdbstub_riscv.c @@ -1,21 +1,12 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include "esp_gdbstub.h" #include "esp_gdbstub_common.h" -#include "soc/cpu.h" #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/components/esp_gdbstub/xtensa/gdbstub_xtensa.c b/components/esp_gdbstub/xtensa/gdbstub_xtensa.c index 9640a574de1..64c1436f6f2 100644 --- a/components/esp_gdbstub/xtensa/gdbstub_xtensa.c +++ b/components/esp_gdbstub/xtensa/gdbstub_xtensa.c @@ -1,20 +1,12 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include "esp_gdbstub_common.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/soc_memory_layout.h" #include "xtensa/config/specreg.h" #include "sdkconfig.h" diff --git a/components/esp_hw_support/cpu_util.c b/components/esp_hw_support/cpu_util.c index a101ce6a030..1969df6e621 100644 --- a/components/esp_hw_support/cpu_util.c +++ b/components/esp_hw_support/cpu_util.c @@ -5,7 +5,7 @@ */ #include "esp_attr.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/soc.h" #include "soc/rtc_periph.h" #include "sdkconfig.h" @@ -46,13 +46,13 @@ esp_err_t IRAM_ATTR esp_cpu_set_watchpoint(int no, void *adr, int size, int flag switch (flags) { - case ESP_WATCHPOINT_LOAD: + case ESP_CPU_WATCHPOINT_LOAD: trigger = WATCHPOINT_TRIGGER_ON_RO; break; - case ESP_WATCHPOINT_STORE: + case ESP_CPU_WATCHPOINT_STORE: trigger = WATCHPOINT_TRIGGER_ON_WO; break; - case ESP_WATCHPOINT_ACCESS: + case ESP_CPU_WATCHPOINT_ACCESS: trigger = WATCHPOINT_TRIGGER_ON_RW; break; default: diff --git a/components/esp_hw_support/include/esp_cpu.h b/components/esp_hw_support/include/esp_cpu.h index 2a810aba440..1c0450d9e02 100644 --- a/components/esp_hw_support/include/esp_cpu.h +++ b/components/esp_hw_support/include/esp_cpu.h @@ -17,9 +17,9 @@ extern "C" { #endif -#define ESP_WATCHPOINT_LOAD 0x40000000 -#define ESP_WATCHPOINT_STORE 0x80000000 -#define ESP_WATCHPOINT_ACCESS 0xC0000000 +#define ESP_CPU_WATCHPOINT_LOAD 0x40000000 +#define ESP_CPU_WATCHPOINT_STORE 0x80000000 +#define ESP_CPU_WATCHPOINT_ACCESS 0xC0000000 typedef uint32_t esp_cpu_ccount_t; @@ -68,6 +68,12 @@ static inline void esp_cpu_set_ccount(esp_cpu_ccount_t val) cpu_hal_set_cycle_count(val); } +/** + * @brief Configure CPU to disable access to invalid memory regions + * + */ +void esp_cpu_configure_region_protection(void); + /** * @brief Set a watchpoint to break/panic when a certain memory range is accessed. * @@ -75,7 +81,7 @@ static inline void esp_cpu_set_ccount(esp_cpu_ccount_t val) * @param adr Base address to watch * @param size Size of the region, starting at the base address, to watch. Must * be one of 2^n, with n in [0..6]. - * @param flags One of ESP_WATCHPOINT_* flags + * @param flags One of ESP_CPU_WATCHPOINT_* flags * * @return ESP_ERR_INVALID_ARG on invalid arg, ESP_OK otherwise * diff --git a/components/esp_hw_support/include/soc/compare_set.h b/components/esp_hw_support/include/soc/compare_set.h index b5a35fa701a..a1ab4a5c588 100644 --- a/components/esp_hw_support/include/soc/compare_set.h +++ b/components/esp_hw_support/include/soc/compare_set.h @@ -8,7 +8,7 @@ #include #include -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/soc_memory_types.h" #if __XTENSA__ diff --git a/components/esp_hw_support/include/soc/cpu.h b/components/esp_hw_support/include/soc/cpu.h deleted file mode 100644 index 526171bc1ce..00000000000 --- a/components/esp_hw_support/include/soc/cpu.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#ifndef _SOC_CPU_H -#define _SOC_CPU_H - -#include -#include -#include - -#include "esp_cpu.h" - -#if __XTENSA__ -#include "xt_instr_macros.h" -// [refactor-todo] not actually needed in this header now, -// but kept for compatibility -#include "xtensa/corebits.h" -#include "xtensa/config/core.h" - -#include "xtensa/config/specreg.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/** @brief Read current stack pointer address. - * Superseded by esp_cpu_get_sp in esp_cpu.h. - */ -static inline __attribute__((deprecated)) void *get_sp(void) -{ - return esp_cpu_get_sp(); -} - -static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc) -{ - if (pc & 0x80000000) { - //Top two bits of a0 (return address) specify window increment. Overwrite to map to address space. - pc = (pc & 0x3fffffff) | 0x40000000; - } - //Minus 3 to get PC of previous instruction (i.e. instruction executed before return address) - return pc - 3; -} - -/** - * @brief Configure CPU to disable access to invalid memory regions - * - */ -void esp_cpu_configure_region_protection(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/components/esp_hw_support/include/soc/spinlock.h b/components/esp_hw_support/include/soc/spinlock.h index fbeff5054b4..ff9cbf741e4 100644 --- a/components/esp_hw_support/include/soc/spinlock.h +++ b/components/esp_hw_support/include/soc/spinlock.h @@ -8,7 +8,6 @@ #include #include #include "sdkconfig.h" -#include "soc/cpu.h" #include "hal/cpu_hal.h" #include "soc/compare_set.h" diff --git a/components/esp_hw_support/port/esp32c3/cpu_util_esp32c3.c b/components/esp_hw_support/port/esp32c3/cpu_util_esp32c3.c index 3d797ea8c04..0dfce32eda3 100644 --- a/components/esp_hw_support/port/esp32c3/cpu_util_esp32c3.c +++ b/components/esp_hw_support/port/esp32c3/cpu_util_esp32c3.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include -#include "soc/cpu.h" +#include "esp_cpu.h" void esp_cpu_configure_region_protection(void) { diff --git a/components/esp_hw_support/port/esp32h2/cpu_util_esp32h2.c b/components/esp_hw_support/port/esp32h2/cpu_util_esp32h2.c index 3d797ea8c04..0dfce32eda3 100644 --- a/components/esp_hw_support/port/esp32h2/cpu_util_esp32h2.c +++ b/components/esp_hw_support/port/esp32h2/cpu_util_esp32h2.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include -#include "soc/cpu.h" +#include "esp_cpu.h" void esp_cpu_configure_region_protection(void) { diff --git a/components/esp_hw_support/port/esp32s2/memprot.c b/components/esp_hw_support/port/esp32s2/memprot.c index a3b0958e560..dc97162e102 100644 --- a/components/esp_hw_support/port/esp32s2/memprot.c +++ b/components/esp_hw_support/port/esp32s2/memprot.c @@ -18,7 +18,7 @@ #include "hal/memprot_peri_ll.h" #include "esp32s2/memprot.h" #include "esp_fault.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "esp32s2/rom/ets_sys.h" extern int _iram_text_end; diff --git a/components/esp_hw_support/port/esp8684/cpu_util_esp8684.c b/components/esp_hw_support/port/esp8684/cpu_util_esp8684.c index 096b4c960e3..be12789187a 100644 --- a/components/esp_hw_support/port/esp8684/cpu_util_esp8684.c +++ b/components/esp_hw_support/port/esp8684/cpu_util_esp8684.c @@ -4,7 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include -#include "soc/cpu.h" +#include "esp_cpu.h" void esp_cpu_configure_region_protection(void) { diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 4cd80d54720..1118e423d23 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -25,7 +25,6 @@ #include "driver/uart.h" -#include "soc/cpu.h" #include "soc/rtc.h" #include "soc/soc_caps.h" diff --git a/components/esp_hw_support/test/test_dport.c b/components/esp_hw_support/test/test_dport.c index 5c3c741ea8c..ad2811cc042 100644 --- a/components/esp_hw_support/test/test_dport.c +++ b/components/esp_hw_support/test/test_dport.c @@ -17,7 +17,6 @@ #include "freertos/task.h" #include "freertos/semphr.h" #include "freertos/xtensa_timer.h" -#include "soc/cpu.h" #include "unity.h" #include "test_utils.h" #include "esp_rom_uart.h" diff --git a/components/esp_hw_support/test/test_fp.c b/components/esp_hw_support/test/test_fp.c index 774eb6cddef..47f2a259b87 100644 --- a/components/esp_hw_support/test/test_fp.c +++ b/components/esp_hw_support/test/test_fp.c @@ -9,7 +9,6 @@ #include #include -#include "soc/cpu.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "freertos/semphr.h" diff --git a/components/esp_system/esp_system.c b/components/esp_system/esp_system.c index b6d97cf8dc1..6bcb8415db2 100644 --- a/components/esp_system/esp_system.c +++ b/components/esp_system/esp_system.c @@ -9,7 +9,7 @@ #include "esp_heap_caps.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/rtc_cntl_reg.h" #include "esp_private/panic_internal.h" diff --git a/components/esp_system/panic.c b/components/esp_system/panic.c index efb20cb2c20..f15f1a0be2d 100644 --- a/components/esp_system/panic.c +++ b/components/esp_system/panic.c @@ -13,7 +13,7 @@ #include "esp_private/usb_console.h" #include "esp_ota_ops.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "hal/timer_hal.h" #include "hal/cpu_hal.h" diff --git a/components/esp_system/port/arch/xtensa/debug_helpers.c b/components/esp_system/port/arch/xtensa/debug_helpers.c index 0a819d5d73f..8f173843ae4 100644 --- a/components/esp_system/port/arch/xtensa/debug_helpers.c +++ b/components/esp_system/port/arch/xtensa/debug_helpers.c @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include @@ -20,7 +12,7 @@ #include "esp_err.h" #include "esp_debug_helpers.h" #include "soc/soc_memory_layout.h" -#include "soc/cpu.h" +#include "esp_cpu_utils.h" #include "esp_private/panic_internal.h" #include "xtensa/xtensa_context.h" diff --git a/components/esp_system/port/arch/xtensa/esp_ipc_isr.c b/components/esp_system/port/arch/xtensa/esp_ipc_isr.c index fbd5e589eaa..f2ca76a1192 100644 --- a/components/esp_system/port/arch/xtensa/esp_ipc_isr.c +++ b/components/esp_system/port/arch/xtensa/esp_ipc_isr.c @@ -10,7 +10,6 @@ #include #include "esp_err.h" #include "esp_attr.h" -#include "soc/cpu.h" #include "soc/soc.h" #include "soc/dport_access.h" #ifdef CONFIG_IDF_TARGET_ESP32 diff --git a/components/esp_system/port/brownout.c b/components/esp_system/port/brownout.c index 5d46e743f46..cbb8d085835 100644 --- a/components/esp_system/port/brownout.c +++ b/components/esp_system/port/brownout.c @@ -15,7 +15,7 @@ #include "esp_rom_sys.h" #include "soc/soc.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc_periph.h" #include "hal/cpu_hal.h" diff --git a/components/esp_system/port/cpu_start.c b/components/esp_system/port/cpu_start.c index 2932551d4fc..c58fee6570c 100644 --- a/components/esp_system/port/cpu_start.c +++ b/components/esp_system/port/cpu_start.c @@ -74,7 +74,7 @@ #include "soc/rtc.h" #include "soc/efuse_reg.h" #include "soc/periph_defs.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/spinlock.h" diff --git a/components/esp_system/port/panic_handler.c b/components/esp_system/port/panic_handler.c index dfa3089afdc..8ef243dc780 100644 --- a/components/esp_system/port/panic_handler.c +++ b/components/esp_system/port/panic_handler.c @@ -11,7 +11,7 @@ #include "esp_private/system_internal.h" #include "soc/soc_memory_layout.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/soc_caps.h" #include "soc/rtc.h" diff --git a/components/esp_system/port/soc/esp32/system_internal.c b/components/esp_system/port/soc/esp32/system_internal.c index c2249e0ed6b..d11b88747ea 100644 --- a/components/esp_system/port/soc/esp32/system_internal.c +++ b/components/esp_system/port/soc/esp32/system_internal.c @@ -18,7 +18,7 @@ #include "soc/efuse_periph.h" #include "soc/rtc_periph.h" #include "soc/timer_periph.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "hal/wdt_hal.h" #include "hal/cpu_hal.h" diff --git a/components/esp_system/port/soc/esp32c3/system_internal.c b/components/esp_system/port/soc/esp32c3/system_internal.c index 73c2ad26261..0cd0cf24d29 100644 --- a/components/esp_system/port/soc/esp32c3/system_internal.c +++ b/components/esp_system/port/soc/esp32c3/system_internal.c @@ -17,7 +17,7 @@ #include "soc/gpio_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/timer_group_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "soc/syscon_reg.h" diff --git a/components/esp_system/port/soc/esp32h2/system_internal.c b/components/esp_system/port/soc/esp32h2/system_internal.c index 944864d45c7..fc45991e030 100644 --- a/components/esp_system/port/soc/esp32h2/system_internal.c +++ b/components/esp_system/port/soc/esp32h2/system_internal.c @@ -17,7 +17,7 @@ #include "soc/gpio_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/timer_group_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "soc/syscon_reg.h" diff --git a/components/esp_system/port/soc/esp32s2/system_internal.c b/components/esp_system/port/soc/esp32s2/system_internal.c index 5f8f0ad299b..4251b3f1083 100644 --- a/components/esp_system/port/soc/esp32s2/system_internal.c +++ b/components/esp_system/port/soc/esp32s2/system_internal.c @@ -1,16 +1,8 @@ -// Copyright 2018 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include "sdkconfig.h" @@ -25,7 +17,7 @@ #include "soc/gpio_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/timer_group_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/syscon_reg.h" #include "soc/rtc_periph.h" diff --git a/components/esp_system/port/soc/esp32s3/system_internal.c b/components/esp_system/port/soc/esp32s3/system_internal.c index 551e90e7244..4d9aec16664 100644 --- a/components/esp_system/port/soc/esp32s3/system_internal.c +++ b/components/esp_system/port/soc/esp32s3/system_internal.c @@ -1,17 +1,9 @@ -// Copyright 2018 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2018-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include "sdkconfig.h" @@ -24,7 +16,7 @@ #include "soc/gpio_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/timer_group_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/syscon_reg.h" #include "soc/rtc_periph.h" diff --git a/components/esp_system/port/soc/esp8684/system_internal.c b/components/esp_system/port/soc/esp8684/system_internal.c index ace49463527..7633cd5cde2 100644 --- a/components/esp_system/port/soc/esp8684/system_internal.c +++ b/components/esp_system/port/soc/esp8684/system_internal.c @@ -17,7 +17,7 @@ #include "soc/gpio_reg.h" #include "soc/rtc_cntl_reg.h" #include "soc/timer_group_reg.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include "soc/rtc.h" #include "soc/rtc_periph.h" #include "soc/syscon_reg.h" diff --git a/components/espcoredump/include_core_dump/esp_core_dump_common.h b/components/espcoredump/include_core_dump/esp_core_dump_common.h index e2986abe164..5362a27cc2f 100644 --- a/components/espcoredump/include_core_dump/esp_core_dump_common.h +++ b/components/espcoredump/include_core_dump/esp_core_dump_common.h @@ -1,21 +1,12 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef ESP_CORE_DUMP_COMMON_H_ #define ESP_CORE_DUMP_COMMON_H_ #include "freertos/FreeRTOS.h" -#include "soc/cpu.h" #include "esp_debug_helpers.h" #include "esp_app_format.h" #include "esp_core_dump_types.h" diff --git a/components/espcoredump/include_core_dump/esp_core_dump_port.h b/components/espcoredump/include_core_dump/esp_core_dump_port.h index b99beb32ecd..c643201f8f5 100644 --- a/components/espcoredump/include_core_dump/esp_core_dump_port.h +++ b/components/espcoredump/include_core_dump/esp_core_dump_port.h @@ -1,16 +1,8 @@ -// Copyright 2015-2019 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #ifndef ESP_CORE_DUMP_PORT_H_ #define ESP_CORE_DUMP_PORT_H_ @@ -26,7 +18,6 @@ #include "sdkconfig.h" #include "freertos/FreeRTOS.h" -#include "soc/cpu.h" #include "esp_debug_helpers.h" #include "esp_app_format.h" #include "esp_core_dump_types.h" diff --git a/components/espcoredump/src/core_dump_common.c b/components/espcoredump/src/core_dump_common.c index ca995a62600..1bd56333113 100644 --- a/components/espcoredump/src/core_dump_common.c +++ b/components/espcoredump/src/core_dump_common.c @@ -1,16 +1,8 @@ -// Copyright 2015-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include #include #include "sdkconfig.h" @@ -128,7 +120,7 @@ FORCE_INLINE_ATTR void esp_core_dump_setup_stack(void) if (esp_core_dump_in_isr_context()) { uint8_t* topStack = esp_core_dump_get_isr_stack_top(); esp_cpu_clear_watchpoint(1); - esp_cpu_set_watchpoint(1, topStack+xPortGetCoreID()*configISR_STACK_SIZE, 1, ESP_WATCHPOINT_STORE); + esp_cpu_set_watchpoint(1, topStack+xPortGetCoreID()*configISR_STACK_SIZE, 1, ESP_CPU_WATCHPOINT_STORE); } else { /* for tasks user should enable stack overflow detection in menuconfig TODO: if not enabled in menuconfig enable it ourselves */ diff --git a/components/espcoredump/src/port/xtensa/core_dump_port.c b/components/espcoredump/src/port/xtensa/core_dump_port.c index a96117a99fb..646840c1fdd 100644 --- a/components/espcoredump/src/port/xtensa/core_dump_port.c +++ b/components/espcoredump/src/port/xtensa/core_dump_port.c @@ -19,6 +19,7 @@ #include "esp_core_dump_common.h" #include "esp_core_dump_port.h" #include "esp_debug_helpers.h" +#include "esp_cpu_utils.h" const static DRAM_ATTR char TAG[] __attribute__((unused)) = "esp_core_dump_port"; diff --git a/components/freertos/FreeRTOS-Kernel/portable/port_systick.c b/components/freertos/FreeRTOS-Kernel/portable/port_systick.c index 0c14a155a11..ef10f9131d5 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/port_systick.c +++ b/components/freertos/FreeRTOS-Kernel/portable/port_systick.c @@ -6,7 +6,6 @@ #include #include -#include "soc/cpu.h" #include "FreeRTOS.h" #include "task.h" #include "esp_intr_alloc.h" diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h index b6e88431010..5c903ccfd90 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/include/freertos/portmacro.h @@ -37,7 +37,6 @@ #include #include "soc/spinlock.h" #include "soc/interrupt_core0_reg.h" -#include "soc/cpu.h" #include "esp_attr.h" #include "esp_rom_sys.h" #include "esp_timer.h" /* required for FreeRTOS run time stats */ diff --git a/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c b/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c index 196306d2df9..42a6f891798 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c +++ b/components/freertos/FreeRTOS-Kernel/portable/riscv/port.c @@ -394,7 +394,7 @@ void vPortSetStackWatchpoint(void *pxStackStart) { uint32_t addr = (uint32_t)pxStackStart; addr = (addr + (STACK_WATCH_AREA_SIZE - 1)) & (~(STACK_WATCH_AREA_SIZE - 1)); - esp_cpu_set_watchpoint(STACK_WATCH_POINT_NUMBER, (char *)addr, STACK_WATCH_AREA_SIZE, ESP_WATCHPOINT_STORE); + esp_cpu_set_watchpoint(STACK_WATCH_POINT_NUMBER, (char *)addr, STACK_WATCH_AREA_SIZE, ESP_CPU_WATCHPOINT_STORE); } diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h index 5aad351ca02..68fc125e4b1 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/include/freertos/portmacro.h @@ -54,7 +54,6 @@ #include #include #include -#include "soc/cpu.h" #ifdef CONFIG_LEGACY_INCLUDE_COMMON_HEADERS #include "soc/soc_memory_layout.h" #endif diff --git a/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c b/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c index aa86586f5e1..fee570466fa 100644 --- a/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c +++ b/components/freertos/FreeRTOS-Kernel/portable/xtensa/port.c @@ -67,6 +67,7 @@ #include "FreeRTOS.h" /* This pulls in portmacro.h */ #include "task.h" /* Required for TaskHandle_t, tskNO_AFFINITY, and vTaskStartScheduler */ #include "port_systick.h" +#include "esp_cpu.h" _Static_assert(tskNO_AFFINITY == CONFIG_FREERTOS_NO_AFFINITY, "incorrect tskNO_AFFINITY value"); @@ -417,7 +418,7 @@ void vPortSetStackWatchpoint( void *pxStackStart ) //This way, we make sure we trigger before/when the stack canary is corrupted, not after. int addr = (int)pxStackStart; addr = (addr + 31) & (~31); - esp_cpu_set_watchpoint(STACK_WATCH_POINT_NUMBER, (char *)addr, 32, ESP_WATCHPOINT_STORE); + esp_cpu_set_watchpoint(STACK_WATCH_POINT_NUMBER, (char *)addr, 32, ESP_CPU_WATCHPOINT_STORE); } /* ---------------------------------------------- Misc Implementations ------------------------------------------------- diff --git a/components/freertos/test/test_float_in_isr.c b/components/freertos/test/test_float_in_isr.c index 3c2285dcf3e..f9093942ed0 100644 --- a/components/freertos/test/test_float_in_isr.c +++ b/components/freertos/test/test_float_in_isr.c @@ -7,7 +7,6 @@ #include "freertos/queue.h" #include "esp_intr_alloc.h" #include "unity.h" -#include "soc/cpu.h" #include "test_utils.h" #include "math.h" diff --git a/components/freertos/test/test_freertos_scheduling_time.c b/components/freertos/test/test_freertos_scheduling_time.c index 6da0ad6af14..d939b8e1ce5 100644 --- a/components/freertos/test/test_freertos_scheduling_time.c +++ b/components/freertos/test/test_freertos_scheduling_time.c @@ -6,7 +6,6 @@ #include "freertos/queue.h" #include "esp_intr_alloc.h" #include "unity.h" -#include "soc/cpu.h" #include "test_utils.h" #define NUMBER_OF_ITERATIONS 10 diff --git a/components/freertos/test/test_isr_latency.c b/components/freertos/test/test_isr_latency.c index 28dad5fe4bf..81c6462d0df 100644 --- a/components/freertos/test/test_isr_latency.c +++ b/components/freertos/test/test_isr_latency.c @@ -7,7 +7,6 @@ #include "freertos/queue.h" #include "esp_intr_alloc.h" #include "unity.h" -#include "soc/cpu.h" #include "test_utils.h" #if CONFIG_IDF_TARGET_ARCH_XTENSA #include "xtensa/hal.h" diff --git a/components/freertos/test/test_preemption.c b/components/freertos/test/test_preemption.c index 62c44fd6cca..4d033fc2f2e 100644 --- a/components/freertos/test/test_preemption.c +++ b/components/freertos/test/test_preemption.c @@ -10,7 +10,6 @@ #include "freertos/semphr.h" #include "freertos/queue.h" #include "unity.h" -#include "soc/cpu.h" #include "hal/cpu_hal.h" #include "test_utils.h" #include "sdkconfig.h" diff --git a/components/freertos/test/test_spinlocks.c b/components/freertos/test/test_spinlocks.c index fb131e6b715..495c58fe773 100644 --- a/components/freertos/test/test_spinlocks.c +++ b/components/freertos/test/test_spinlocks.c @@ -10,7 +10,6 @@ #include "freertos/semphr.h" #include "freertos/queue.h" #include "unity.h" -#include "soc/cpu.h" #include "hal/cpu_hal.h" #include "test_utils.h" diff --git a/components/freertos/test/test_suspend_scheduler.c b/components/freertos/test/test_suspend_scheduler.c index 63fecfce306..178bd28f33f 100644 --- a/components/freertos/test/test_suspend_scheduler.c +++ b/components/freertos/test/test_suspend_scheduler.c @@ -6,7 +6,6 @@ #include "freertos/semphr.h" #include "freertos/queue.h" #include "unity.h" -#include "soc/cpu.h" #include "test_utils.h" #include "driver/timer.h" diff --git a/components/freertos/test/test_task_suspend_resume.c b/components/freertos/test/test_task_suspend_resume.c index 2d6f12fa3aa..17d0faee38e 100644 --- a/components/freertos/test/test_task_suspend_resume.c +++ b/components/freertos/test/test_task_suspend_resume.c @@ -8,7 +8,6 @@ #include "freertos/timers.h" #include "freertos/queue.h" #include "unity.h" -#include "soc/cpu.h" #include "test_utils.h" #include "driver/timer.h" diff --git a/components/freertos/test/test_tasks_snapshot.c b/components/freertos/test/test_tasks_snapshot.c index b7b6bab36b9..20ffd8d8553 100644 --- a/components/freertos/test/test_tasks_snapshot.c +++ b/components/freertos/test/test_tasks_snapshot.c @@ -3,7 +3,7 @@ */ #include -#include "soc/cpu.h" +#include "esp_cpu.h" #include "freertos/FreeRTOS.h" #include "freertos/task_snapshot.h" #include "unity.h" diff --git a/components/mbedtls/port/aes/block/esp_aes.c b/components/mbedtls/port/aes/block/esp_aes.c index 003ffcc3985..aa349c31633 100644 --- a/components/mbedtls/port/aes/block/esp_aes.c +++ b/components/mbedtls/port/aes/block/esp_aes.c @@ -36,7 +36,6 @@ #include -#include "soc/cpu.h" #include #include "esp_private/periph_ctrl.h" diff --git a/components/mbedtls/test/test_aes_sha_rsa.c b/components/mbedtls/test/test_aes_sha_rsa.c index e1d26d8b5df..f3ecd368bce 100644 --- a/components/mbedtls/test/test_aes_sha_rsa.c +++ b/components/mbedtls/test/test_aes_sha_rsa.c @@ -15,7 +15,6 @@ #include "freertos/task.h" #include "freertos/semphr.h" #include "freertos/xtensa_timer.h" -#include "soc/cpu.h" #include "unity.h" #include "test_utils.h" #include "esp32/rom/sha.h" diff --git a/components/newlib/locks.c b/components/newlib/locks.c index 16f522d37ea..afde8c6de2b 100644 --- a/components/newlib/locks.c +++ b/components/newlib/locks.c @@ -8,7 +8,6 @@ #include #include #include "esp_attr.h" -#include "soc/cpu.h" #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "freertos/task.h" diff --git a/components/soc/esp32s3/include/soc/cpu.h b/components/soc/esp32s3/include/soc/cpu.h deleted file mode 100644 index ad7f7c11d57..00000000000 --- a/components/soc/esp32s3/include/soc/cpu.h +++ /dev/null @@ -1,131 +0,0 @@ -// Copyright 2010-2020 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#pragma once - -#include -#include -#include -#include "xtensa/corebits.h" - -/* C macros for xtensa special register read/write/exchange */ - -#define RSR(reg, curval) asm volatile ("rsr %0, " #reg : "=r" (curval)); -#define WSR(reg, newval) asm volatile ("wsr %0, " #reg : : "r" (newval)); -#define XSR(reg, swapval) asm volatile ("xsr %0, " #reg : "+r" (swapval)); - -/** @brief Read current stack pointer address - * - */ -static inline void *get_sp(void) -{ - void *sp; - asm volatile ("mov %0, sp;" : "=r" (sp)); - return sp; -} - -/* Functions to set page attributes for Region Protection option in the CPU. - * See Xtensa ISA Reference manual for explanation of arguments (section 4.6.3.2). - */ - -static inline void cpu_write_dtlb(uint32_t vpn, unsigned attr) -{ - asm volatile ("wdtlb %1, %0; dsync\n" :: "r" (vpn), "r" (attr)); -} - - -static inline void cpu_write_itlb(unsigned vpn, unsigned attr) -{ - asm volatile ("witlb %1, %0; isync\n" :: "r" (vpn), "r" (attr)); -} - -/** - * @brief Configure memory region protection - * - * Make page 0 access raise an exception. - * Also protect some other unused pages so we can catch weirdness. - * Useful attribute values: - * 0 — cached, RW - * 2 — bypass cache, RWX (default value after CPU reset) - * 15 — no access, raise exception - */ - -static inline void cpu_configure_region_protection(void) -{ - const uint32_t pages_to_protect[] = {0x00000000, 0x80000000, 0xa0000000, 0xc0000000, 0xe0000000}; - for (int i = 0; i < sizeof(pages_to_protect) / sizeof(pages_to_protect[0]); ++i) { - cpu_write_dtlb(pages_to_protect[i], 0xf); - cpu_write_itlb(pages_to_protect[i], 0xf); - } - cpu_write_dtlb(0x20000000, 0); - cpu_write_itlb(0x20000000, 0); -} - -/** - * @brief Stall CPU using RTC controller - * @param cpu_id ID of the CPU to stall (0 = PRO, 1 = APP) - */ -void esp_cpu_stall(int cpu_id); - -/** - * @brief Un-stall CPU using RTC controller - * @param cpu_id ID of the CPU to un-stall (0 = PRO, 1 = APP) - */ -void esp_cpu_unstall(int cpu_id); - -/** - * @brief Reset CPU using RTC controller - * @param cpu_id ID of the CPU to reset (0 = PRO, 1 = APP) - */ -void esp_cpu_reset(int cpu_id); - - -/** - * @brief Returns true if a JTAG debugger is attached to CPU - * OCD (on chip debug) port. - * - * @note If "Make exception and panic handlers JTAG/OCD aware" - * is disabled, this function always returns false. - */ -bool esp_cpu_in_ocd_debug_mode(void); - -/** - * @brief Convert the PC register value to its true address - * - * The address of the current instruction is not stored as an exact uint32_t - * representation in PC register. This function will convert the value stored in - * the PC register to a uint32_t address. - * - * @param pc_raw The PC as stored in register format. - * - * @return Address in uint32_t format - */ -static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc) -{ - if (pc & 0x80000000) { - //Top two bits of a0 (return address) specify window increment. Overwrite to map to address space. - pc = (pc & 0x3fffffff) | 0x40000000; - } - //Minus 3 to get PC of previous instruction (i.e. instruction executed before return address) - return pc - 3; -} - -typedef uint32_t esp_cpu_ccount_t; - -static inline esp_cpu_ccount_t esp_cpu_get_ccount(void) -{ - uint32_t result; - RSR(CCOUNT, result); - return result; -} diff --git a/components/spi_flash/cache_utils.c b/components/spi_flash/cache_utils.c index f8afdccf9cc..db31f6ac414 100644 --- a/components/spi_flash/cache_utils.c +++ b/components/spi_flash/cache_utils.c @@ -51,6 +51,7 @@ #include "esp_intr_alloc.h" #include "esp_spi_flash.h" #include "esp_log.h" +#include "esp_cpu.h" static __attribute__((unused)) const char *TAG = "cache"; diff --git a/components/unity/unity_port_esp32.c b/components/unity/unity_port_esp32.c index cf34148ec3a..752f8c3ac3e 100644 --- a/components/unity/unity_port_esp32.c +++ b/components/unity/unity_port_esp32.c @@ -6,7 +6,6 @@ #include #include "unity.h" #include "sdkconfig.h" -#include "soc/cpu.h" #include "hal/cpu_hal.h" #include "esp_rom_uart.h" #include "esp_private/esp_clk.h" diff --git a/components/vfs/vfs_semihost.c b/components/vfs/vfs_semihost.c index b8a5c447594..0991a1ee9ee 100644 --- a/components/vfs/vfs_semihost.c +++ b/components/vfs/vfs_semihost.c @@ -7,7 +7,7 @@ #include "esp_vfs.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" -#include "soc/cpu.h" +#include "esp_cpu.h" #include #include #include diff --git a/components/wear_levelling/test_apps/main/test_wl.c b/components/wear_levelling/test_apps/main/test_wl.c index b3e3167961d..e3a5d590a21 100644 --- a/components/wear_levelling/test_apps/main/test_wl.c +++ b/components/wear_levelling/test_apps/main/test_wl.c @@ -11,7 +11,6 @@ #include "freertos/task.h" #include "freertos/semphr.h" #include "esp_private/esp_clk.h" -#include "soc/cpu.h" #include "sdkconfig.h" diff --git a/components/xtensa/include/esp_cpu_utils.h b/components/xtensa/include/esp_cpu_utils.h new file mode 100644 index 00000000000..58b69ab11bf --- /dev/null +++ b/components/xtensa/include/esp_cpu_utils.h @@ -0,0 +1,34 @@ +/* + * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _ESP_CPU_UTILS_H +#define _ESP_CPU_UTILS_H + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Fetch the PC value of the previous instruction + * + * @param pc PC value of the current backtrace frame + * + */ +static inline uint32_t esp_cpu_process_stack_pc(uint32_t pc) +{ + if (pc & 0x80000000) { + //Top two bits of a0 (return address) specify window increment. Overwrite to map to address space. + pc = (pc & 0x3fffffff) | 0x40000000; + } + //Minus 3 to get PC of previous instruction (i.e. instruction executed before return address) + return pc - 3; +} + +#ifdef __cplusplus +} +#endif + +#endif // _ESP_CPU_UTILS_H diff --git a/docs/en/migration-guides/system.rst b/docs/en/migration-guides/system.rst index 8d291d489bf..638273677aa 100644 --- a/docs/en/migration-guides/system.rst +++ b/docs/en/migration-guides/system.rst @@ -38,3 +38,7 @@ Tasks snapshot -------------- The header ``task_snapshot.h`` has been removed from ``freertos/task.h``. ESP-IDF developers should include ``"freertos/task_snapshot.h``` in case they need tasks snapshot API. + +ESP HW Support +-------------- +The header files ``soc/cpu.h`` have been deleted and deprecated CPU util functions have been removed. ESP-IDF developers should include ``esp_cpu.h`` instead for equivalent functions. diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index fe147ec8fb3..2128e4d6a18 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -489,10 +489,8 @@ components/esp_gdbstub/esp_common/gdbstub_common.c components/esp_gdbstub/include/esp_gdbstub.h components/esp_gdbstub/private_include/esp_gdbstub_common.h components/esp_gdbstub/riscv/esp_gdbstub_arch.h -components/esp_gdbstub/riscv/gdbstub_riscv.c components/esp_gdbstub/src/packet.c components/esp_gdbstub/xtensa/esp_gdbstub_arch.h -components/esp_gdbstub/xtensa/gdbstub_xtensa.c components/esp_hid/include/esp_hid_common.h components/esp_hid/include/esp_hidd.h components/esp_hid/include/esp_hidd_gatts.h @@ -776,7 +774,6 @@ components/esp_system/include/esp_private/usb_console.h components/esp_system/include/esp_task.h components/esp_system/include/esp_task_wdt.h components/esp_system/port/arch/riscv/expression_with_stack.c -components/esp_system/port/arch/xtensa/debug_helpers.c components/esp_system/port/arch/xtensa/expression_with_stack.c components/esp_system/port/public_compat/brownout.h components/esp_system/port/public_compat/cache_err_int.h @@ -796,11 +793,9 @@ components/esp_system/port/soc/esp32h2/reset_reason.c components/esp_system/port/soc/esp32s2/cache_err_int.c components/esp_system/port/soc/esp32s2/cache_err_int.h components/esp_system/port/soc/esp32s2/reset_reason.c -components/esp_system/port/soc/esp32s2/system_internal.c components/esp_system/port/soc/esp32s2/usb_console.c components/esp_system/port/soc/esp32s3/cache_err_int.h components/esp_system/port/soc/esp32s3/reset_reason.c -components/esp_system/port/soc/esp32s3/system_internal.c components/esp_system/port/soc/esp32s3/usb_console.c components/esp_system/stack_check.c components/esp_system/test/test_delay.c @@ -851,14 +846,11 @@ components/espcoredump/include_core_dump/core_dump_binary.h components/espcoredump/include_core_dump/core_dump_checksum.h components/espcoredump/include_core_dump/core_dump_elf.h components/espcoredump/include_core_dump/elf.h -components/espcoredump/include_core_dump/esp_core_dump_common.h -components/espcoredump/include_core_dump/esp_core_dump_port.h components/espcoredump/include_core_dump/esp_core_dump_types.h components/espcoredump/include_core_dump/port/riscv/esp_core_dump_port_impl.h components/espcoredump/include_core_dump/port/xtensa/esp_core_dump_port_impl.h components/espcoredump/src/core_dump_binary.c components/espcoredump/src/core_dump_checksum.c -components/espcoredump/src/core_dump_common.c components/espcoredump/src/core_dump_elf.c components/espcoredump/src/core_dump_flash.c components/espcoredump/src/core_dump_uart.c