12 #include "tfm_hal_platform.h"
15 #include "tfm_spm_hal.h"
23 #if defined(__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
24 __asm(
" .global __ARM_use_no_argv\n");
28 #error TFM_LVL is not defined!
30 #error Only TFM_LVL 1 is supported for library model!
35 static int32_t tfm_core_init(
void)
38 enum tfm_hal_status_t hal_status = TFM_HAL_ERROR_GENERIC;
39 enum tfm_plat_err_t plat_err = TFM_PLAT_ERR_SYSTEM_ERR;
40 enum irq_target_state_t irq_target_state = TFM_IRQ_TARGET_STATE_SECURE;
43 plat_err = tfm_spm_hal_enable_fault_handlers();
44 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
49 plat_err = tfm_spm_hal_system_reset_cfg();
50 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
55 plat_err = tfm_spm_hal_init_debug();
56 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
64 plat_err = tfm_spm_hal_init_isolation_hw();
65 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
70 hal_status = tfm_hal_platform_init();
71 if (hal_status != TFM_HAL_SUCCESS) {
78 SPMLOG_INFMSG(
"\033[1;34m[Sec Thread] Secure image initializing!\033[0m\r\n");
89 plat_err = tfm_spm_hal_nvic_interrupt_target_state_cfg();
90 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
95 plat_err = tfm_spm_hal_set_secure_irq_priority(
98 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
101 irq_target_state = tfm_spm_hal_set_irq_target_state(
103 TFM_IRQ_TARGET_STATE_SECURE);
104 if (irq_target_state != TFM_IRQ_TARGET_STATE_SECURE) {
110 plat_err = tfm_spm_hal_nvic_interrupt_enable();
111 if (plat_err != TFM_PLAT_ERR_SUCCESS) {
138 #ifdef CONFIG_TFM_ENABLE_MEMORY_PROTECT
139 if (tfm_spm_hal_setup_isolation_hw() != TFM_PLAT_ERR_SUCCESS) {
147 uint32_t psp_stack_bottom =
148 (uint32_t)REGION_NAME(Image$$, ARM_LIB_STACK, $$ZI$$Base);
171 #ifdef TFM_CORE_DEBUG
173 SPMLOG_DBGMSG(
"\033[1;34mJumping to non-secure code...\033[0m\r\n");
#define SPM_PARTITION_STATE_CLOSED
enum spm_err_t tfm_spm_db_init(void)
Initialize partition database.
void jump_to_ns_code(void)
Jump to non-secure code.
__STATIC_INLINE void tfm_arch_set_psplim(uint32_t psplim)
Set PSP limit value.
const struct tfm_core_irq_signal_data_t tfm_core_irq_signals[]
#define SPMLOG_DBGMSG(msg)
void tfm_core_validate_boot_data(void)
Validate the content of shared memory area, which stores the shared data between bootloader and runti...
void configure_ns_code(void)
REGION_DECLARE(Image $$, ARM_LIB_STACK_MSP,$$ZI $$Base)
void tfm_spm_partition_set_state(uint32_t partition_idx, uint32_t state)
Set the current state of a partition.
void tfm_arch_set_secure_exception_priorities(void)
__STATIC_INLINE void tfm_arch_init_secure_msp(uint32_t msplim)
Secure the MSP.
void tfm_core_panic(void)
#define SPMLOG_DBGMSGVAL(msg, val)
const size_t tfm_core_irq_signals_count
#define SPMLOG_INFMSG(msg)
void tfm_arch_configure_coprocessors(void)
Configure coprocessors.
void tfm_spm_seal_psp_stacks(void)
Function to seal the PSP stacks for Function mode.
enum spm_err_t tfm_spm_partition_init(void)
Execute partition init function.
#define TFM_SP_NON_SECURE_ID
#define SPM_PARTITION_STATE_RUNNING