fix(esp_tee): Include required headers explicitly across the esp_tee component

This commit is contained in:
Laukik Hase
2024-12-04 15:02:41 +05:30
parent bd5945d1cc
commit 909fd60d33
11 changed files with 46 additions and 61 deletions

View File

@@ -10,16 +10,10 @@
extern "C" {
#endif
#ifndef __ASSEMBLER__
#if !defined(__ASSEMBLER__) && !(__DOXYGEN__)
#include <stdint.h>
#include <stdio.h>
#include <stddef.h>
#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
}

View File

@@ -1,37 +0,0 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include <stdarg.h>
#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

View File

@@ -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 <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
#include "esp_rom_sys.h"
/**
* @brief TEE initialization function called by the bootloader at boot time.

View File

@@ -4,6 +4,7 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdarg.h>
#include "esp_tee.h"
/* U-mode interrupt handler */

View File

@@ -3,6 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include "tlsf.h"
#include "tlsf_block_functions.h"
#include "multi_heap.h"

View File

@@ -5,17 +5,20 @@
*/
#include <string.h>
#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)

View File

@@ -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)

View File

@@ -7,6 +7,7 @@
#ifndef __ASSEMBLER__
#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>

View File

@@ -5,7 +5,6 @@
*/
#pragma once
#include <string.h>
#include "esp_tee.h"
#include "tlsf.h"
/* multi_heap is a heap implementation for handling multiple

View File

@@ -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

View File

@@ -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"