diff --git a/components/esp_tee/include/esp_tee.h b/components/esp_tee/include/esp_tee.h index 3b4833c937..3afd53b8bc 100644 --- a/components/esp_tee/include/esp_tee.h +++ b/components/esp_tee/include/esp_tee.h @@ -10,16 +10,10 @@ extern "C" { #endif -#ifndef __ASSEMBLER__ +#if !defined(__ASSEMBLER__) && !(__DOXYGEN__) #include -#include #include -#include "soc/soc.h" -#include "sdkconfig.h" -#include "esp_cpu.h" -#include "esp_attr.h" - -#include "riscv/rv_utils.h" +#include "esp_assert.h" #define ESP_TEE_APP_CFG_MAGIC 0x3348AAED @@ -63,27 +57,46 @@ typedef struct { extern esp_tee_config_t esp_tee_app_config; -#endif // ifndef __ASSEMBLER__ +#endif // !defined(__ASSEMBLER__) && !(__DOXYGEN__) #if !ESP_TEE_BUILD -#include "private/esp_tee_app.h" +/** + * @brief Interface function that allows untrusted applications to invoke secure services through TEE + * + * @param argc Number of arguments being passed to the secure service + * + * @return Value returned by the secure service function + */ +uint32_t esp_tee_service_call(int argc, ...); + +/** + * @brief Interface function that allows untrusted applications to invoke secure services through TEE, + * with the scheduler and the non-IRAM interrupts disabled + * + * @param argc Number of arguments being passed to the secure service + * + * @return Value returned by the secure service function + */ +uint32_t esp_tee_service_call_with_noniram_intr_disabled(int argc, ...); #else #include "private/esp_tee_binary.h" #endif +#if !(__DOXYGEN__) /* Offsets of some values in esp_tee_config_t that are used by assembly code */ #define ESP_TEE_CFG_OFFS_S_ENTRY_ADDR 0x14 #define ESP_TEE_CFG_OFFS_S_INTR_HANDLER 0x18 #define ESP_TEE_CFG_OFFS_NS_ENTRY_ADDR 0x1C #define ESP_TEE_CFG_OFFS_NS_INTR_HANDLER 0x20 -#ifndef __ASSEMBLER__ +#if !defined(__ASSEMBLER__) /* Check the offsets are correct using the C compiler */ ESP_STATIC_ASSERT(offsetof(esp_tee_config_t, s_entry_addr) == ESP_TEE_CFG_OFFS_S_ENTRY_ADDR, "offset macro is wrong"); ESP_STATIC_ASSERT(offsetof(esp_tee_config_t, s_int_handler) == ESP_TEE_CFG_OFFS_S_INTR_HANDLER, "offset macro is wrong"); ESP_STATIC_ASSERT(offsetof(esp_tee_config_t, ns_entry_addr) == ESP_TEE_CFG_OFFS_NS_ENTRY_ADDR, "offset macro is wrong"); ESP_STATIC_ASSERT(offsetof(esp_tee_config_t, ns_int_handler) == ESP_TEE_CFG_OFFS_NS_INTR_HANDLER, "offset macro is wrong"); -#endif // ifndef __ASSEMBLER__ +#endif // !defined(__ASSEMBLER__) +#endif // !(__DOXYGEN__) #ifdef __cplusplus } diff --git a/components/esp_tee/include/private/esp_tee_app.h b/components/esp_tee/include/private/esp_tee_app.h deleted file mode 100644 index 7aa652bd63..0000000000 --- a/components/esp_tee/include/private/esp_tee_app.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Interface function that allows untrusted applications to invoke secure services through TEE - * - * @param argc Number of arguments being passed to the secure service - * - * @return Value returned by the secure service function - */ -uint32_t esp_tee_service_call(int argc, ...); - -/** - * @brief Interface function that allows untrusted applications to invoke secure services through TEE, - * with the scheduler and the non-IRAM interrupts disabled - * - * @param argc Number of arguments being passed to the secure service - * - * @return Value returned by the secure service function - */ -uint32_t esp_tee_service_call_with_noniram_intr_disabled(int argc, ...); - -#ifdef __cplusplus -} -#endif diff --git a/components/esp_tee/include/private/esp_tee_binary.h b/components/esp_tee/include/private/esp_tee_binary.h index f0975f451b..0599531a8a 100644 --- a/components/esp_tee/include/private/esp_tee_binary.h +++ b/components/esp_tee/include/private/esp_tee_binary.h @@ -44,10 +44,8 @@ extern "C" { #define SOC_S_MMU_MMAP_RESV_START_VADDR (SOC_MMU_END_VADDR - SOC_S_MMU_MMAP_RESV_PAGE_NUM * SOC_MMU_PAGE_SIZE) #ifndef __ASSEMBLER__ -#include #include #include -#include "esp_rom_sys.h" /** * @brief TEE initialization function called by the bootloader at boot time. diff --git a/components/esp_tee/src/esp_tee_config.c b/components/esp_tee/src/esp_tee_config.c index c506a0c6ee..fce4c7ddf8 100644 --- a/components/esp_tee/src/esp_tee_config.c +++ b/components/esp_tee/src/esp_tee_config.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include "esp_tee.h" /* U-mode interrupt handler */ diff --git a/components/esp_tee/subproject/main/common/multi_heap.c b/components/esp_tee/subproject/main/common/multi_heap.c index 5da57c4f4d..6d92034cca 100644 --- a/components/esp_tee/subproject/main/common/multi_heap.c +++ b/components/esp_tee/subproject/main/common/multi_heap.c @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include #include "tlsf.h" #include "tlsf_block_functions.h" #include "multi_heap.h" diff --git a/components/esp_tee/subproject/main/common/panic/esp_tee_panic.c b/components/esp_tee/subproject/main/common/panic/esp_tee_panic.c index 8558a5e0e7..444c357391 100644 --- a/components/esp_tee/subproject/main/common/panic/esp_tee_panic.c +++ b/components/esp_tee/subproject/main/common/panic/esp_tee_panic.c @@ -5,17 +5,20 @@ */ #include +#include "esp_cpu.h" #include "esp_attr.h" #include "esp_macros.h" #include "esp_rom_sys.h" #include "esp_rom_uart.h" -#include "hal/apm_hal.h" +#include "riscv/rv_utils.h" #include "riscv/rvruntime-frames.h" +#include "hal/apm_hal.h" + #include "esp_tee.h" -#include "panic_helper.h" #include "esp_tee_apm_intr.h" +#include "panic_helper.h" #define RV_FUNC_STK_SZ (32) diff --git a/components/esp_tee/subproject/main/common/panic/panic_helper_riscv.c b/components/esp_tee/subproject/main/common/panic/panic_helper_riscv.c index de2eae60fd..db55e7c687 100644 --- a/components/esp_tee/subproject/main/common/panic/panic_helper_riscv.c +++ b/components/esp_tee/subproject/main/common/panic/panic_helper_riscv.c @@ -3,13 +3,17 @@ * * SPDX-License-Identifier: Apache-2.0 */ -#include "esp_tee.h" +#include "soc/soc.h" #include "esp_attr.h" +#include "esp_rom_sys.h" #include "esp_private/panic_reason.h" + #include "riscv/csr.h" #include "riscv/encoding.h" #include "riscv/rvruntime-frames.h" +#include "esp_tee.h" + #define tee_panic_print(format, ...) esp_rom_printf(DRAM_STR(format), ##__VA_ARGS__) void panic_print_backtrace(const void *f, int depth) diff --git a/components/esp_tee/subproject/main/include/esp_tee_intr.h b/components/esp_tee/subproject/main/include/esp_tee_intr.h index 9a7371dd75..6622968ecc 100644 --- a/components/esp_tee/subproject/main/include/esp_tee_intr.h +++ b/components/esp_tee/subproject/main/include/esp_tee_intr.h @@ -7,6 +7,7 @@ #ifndef __ASSEMBLER__ +#include #include #include diff --git a/components/esp_tee/subproject/main/include/multi_heap.h b/components/esp_tee/subproject/main/include/multi_heap.h index b61a0b0bf3..c46c401a71 100644 --- a/components/esp_tee/subproject/main/include/multi_heap.h +++ b/components/esp_tee/subproject/main/include/multi_heap.h @@ -5,7 +5,6 @@ */ #pragma once #include -#include "esp_tee.h" #include "tlsf.h" /* multi_heap is a heap implementation for handling multiple diff --git a/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_interrupt.c b/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_interrupt.c index c5877e009a..021a25901d 100644 --- a/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_interrupt.c +++ b/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_interrupt.c @@ -4,18 +4,19 @@ * SPDX-License-Identifier: Apache-2.0 */ -#include "soc/timer_group_reg.h" -#include "esp_tee.h" +#include "esp_cpu.h" #include "esp_log.h" -#include "esp_tee_test.h" - #include "riscv/csr.h" -#include "soc/interrupt_matrix_reg.h" -#include "esp_tee_intr.h" #include "hal/timer_ll.h" #include "hal/clk_gate_ll.h" + #include "soc/timer_group_reg.h" +#include "soc/interrupt_matrix_reg.h" + +#include "esp_tee.h" +#include "esp_tee_intr.h" +#include "esp_tee_test.h" #define TIMER_DIVIDER 80 // Hardware timer clock divider #define TIMER_RESOLUTION_HZ 1000000 // 1MHz resolution diff --git a/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_sec_srv.c b/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_sec_srv.c index 7d84a4e7a7..8cf63bf4e1 100644 --- a/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_sec_srv.c +++ b/components/esp_tee/test_apps/tee_test_fw/components/test_sec_srv/src/test_sec_srv.c @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include "esp_cpu.h" #include "esp_log.h" #include "esp_tee.h" #include "esp_tee_test.h"