diff options
author | Summer Qin <summer.qin@arm.com> | 2020-08-04 10:23:39 +0800 |
---|---|---|
committer | Ken Liu <ken.liu@arm.com> | 2020-08-05 08:31:20 +0000 |
commit | 90602deca27419dc68e7cea875d2eaaeea8d6818 (patch) | |
tree | 0196d29d5b7ce1420455d17d7cd574dabef3d922 /secure_fw | |
parent | 6b7722d431ffaa363f17b03e1f9888fca3a402df (diff) | |
download | trusted-firmware-m-90602deca27419dc68e7cea875d2eaaeea8d6818.tar.gz |
SPM: Restructure SPM folder
- Change model_ipc to cmsis_psa, and move arch into it.
- Change model_func to cmsis_func, and move arch related operations to
arch.c file.
- Remove tfm_spm_services.c, and move related function into cmsis_psa
and cmsis_func.
- Move tfm_arch.h and tfm_arch_v8m.h into spm/include, so this header
could be shared by cmsis_psa and cmsis_func.
Change-Id: I120395a6f613cb151c144c344a9394efdfb2b67d
Signed-off-by: Summer Qin <summer.qin@arm.com>
Diffstat (limited to 'secure_fw')
-rw-r--r-- | secure_fw/CMakeLists.txt | 6 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/CMakeLists.inc (renamed from secure_fw/spm/model_func/CMakeLists.inc) | 12 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/arch.c (renamed from secure_fw/spm/model_func/arch.c) | 164 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/spm_func.c (renamed from secure_fw/spm/model_func/spm_func.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_core_svcalls_func.c (renamed from secure_fw/spm/model_func/tfm_core_svcalls_func.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_nspm_func.c (renamed from secure_fw/spm/model_func/tfm_nspm_func.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_secure_api.c (renamed from secure_fw/spm/model_func/tfm_secure_api.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc (renamed from secure_fw/spm/model_func/tfm_secure_irq_handlers.inc) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template (renamed from secure_fw/spm/model_func/tfm_secure_irq_handlers.inc.template) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_spm_db_func.inc (renamed from secure_fw/spm/model_func/tfm_spm_db_func.inc) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_spm_db_func.inc.template (renamed from secure_fw/spm/model_func/tfm_spm_db_func.inc.template) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_veneers.c (renamed from secure_fw/spm/model_func/tfm_veneers.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_func/tfm_veneers.c.template (renamed from secure_fw/spm/model_func/tfm_veneers.c.template) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/CMakeLists.inc (renamed from secure_fw/spm/model_ipc/CMakeLists.inc) | 17 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/arch/CMakeLists.inc (renamed from secure_fw/spm/arch/CMakeLists.inc) | 1 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/arch/tfm_arch.c (renamed from secure_fw/spm/arch/tfm_arch.c) | 39 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c (renamed from secure_fw/spm/arch/tfm_arch_v6m_v7m.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h (renamed from secure_fw/spm/arch/tfm_arch_v6m_v7m.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c (renamed from secure_fw/spm/arch/tfm_arch_v8m_base.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c (renamed from secure_fw/spm/arch/tfm_arch_v8m_main.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_internal_defines.h (renamed from secure_fw/spm/model_ipc/include/tfm_internal_defines.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_list.h (renamed from secure_fw/spm/model_ipc/include/tfm_list.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_message_queue.h (renamed from secure_fw/spm/model_ipc/include/tfm_message_queue.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_multi_core.h (renamed from secure_fw/spm/model_ipc/include/tfm_multi_core.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_pools.h (renamed from secure_fw/spm/model_ipc/include/tfm_pools.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_rpc.h (renamed from secure_fw/spm/model_ipc/include/tfm_rpc.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_spe_mailbox.h (renamed from secure_fw/spm/model_ipc/include/tfm_spe_mailbox.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_svcalls.h (renamed from secure_fw/spm/model_ipc/include/tfm_svcalls.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_thread.h (renamed from secure_fw/spm/model_ipc/include/tfm_thread.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/include/tfm_wait.h (renamed from secure_fw/spm/model_ipc/include/tfm_wait.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_ipc.c (renamed from secure_fw/spm/model_ipc/spm_ipc.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_psa_client_call.c (renamed from secure_fw/spm/model_ipc/spm_psa_client_call.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/spm_psa_client_call.h (renamed from secure_fw/spm/model_ipc/spm_psa_client_call.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c (renamed from secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_message_queue.c (renamed from secure_fw/spm/model_ipc/tfm_message_queue.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_multi_core.c (renamed from secure_fw/spm/model_ipc/tfm_multi_core.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_multi_core_mem_check.c (renamed from secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c (renamed from secure_fw/spm/model_ipc/tfm_nspm_ipc.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_pools.c (renamed from secure_fw/spm/model_ipc/tfm_pools.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c (renamed from secure_fw/spm/model_ipc/tfm_psa_api_veneers.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_rpc.c (renamed from secure_fw/spm/model_ipc/tfm_rpc.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc (renamed from secure_fw/spm/model_ipc/tfm_secure_irq_handlers_ipc.inc) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template (renamed from secure_fw/spm/model_ipc/tfm_secure_irq_handlers_ipc.inc.template) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_spe_mailbox.c (renamed from secure_fw/spm/model_ipc/tfm_spe_mailbox.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc (renamed from secure_fw/spm/model_ipc/tfm_spm_db_ipc.inc) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template (renamed from secure_fw/spm/model_ipc/tfm_spm_db_ipc.inc.template) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_thread.c (renamed from secure_fw/spm/model_ipc/tfm_thread.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/cmsis_psa/tfm_wait.c (renamed from secure_fw/spm/model_ipc/tfm_wait.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/common/init/tfm_boot_data.c (renamed from secure_fw/spm/init/tfm_boot_data.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/common/init/tfm_core.c (renamed from secure_fw/spm/init/tfm_core.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/common/runtime/tfm_core_mem_check.c (renamed from secure_fw/spm/runtime/tfm_core_mem_check.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/common/runtime/tfm_core_utils.c (renamed from secure_fw/spm/runtime/tfm_core_utils.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/common/runtime/utilities.c (renamed from secure_fw/spm/runtime/utilities.c) | 0 | ||||
-rw-r--r-- | secure_fw/spm/include/tfm_arch.h (renamed from secure_fw/spm/arch/tfm_arch.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/include/tfm_arch_v8m.h (renamed from secure_fw/spm/arch/tfm_arch_v8m.h) | 0 | ||||
-rw-r--r-- | secure_fw/spm/runtime/tfm_spm_services.c | 108 |
56 files changed, 217 insertions, 130 deletions
diff --git a/secure_fw/CMakeLists.txt b/secure_fw/CMakeLists.txt index 8f7780fec9..7e0eee8fd7 100644 --- a/secure_fw/CMakeLists.txt +++ b/secure_fw/CMakeLists.txt @@ -98,13 +98,11 @@ endif() #Involve all IPC related sources in ipc's CMakeLists.inc, and switch core between IPC and Library. if(TFM_PSA_API) - include(${SECURE_FW_DIR}/spm/model_ipc/CMakeLists.inc) + include(${SECURE_FW_DIR}/spm/cmsis_psa/CMakeLists.inc) else() - include(${SECURE_FW_DIR}/spm/model_func/CMakeLists.inc) + include(${SECURE_FW_DIR}/spm/cmsis_func/CMakeLists.inc) endif() -include(${SECURE_FW_DIR}/spm/arch/CMakeLists.inc) - set(BUILD_CMSIS_CORE On) set(BUILD_RETARGET On) set(BUILD_NATIVE_DRIVERS On) diff --git a/secure_fw/spm/model_func/CMakeLists.inc b/secure_fw/spm/cmsis_func/CMakeLists.inc index 9720fc1758..b9235f0608 100644 --- a/secure_fw/spm/model_func/CMakeLists.inc +++ b/secure_fw/spm/cmsis_func/CMakeLists.inc @@ -30,20 +30,19 @@ endif() #Get the current directory where this file is located. set(SFW_FUNC_SPM_DIR ${CMAKE_CURRENT_LIST_DIR}) set(SFW_SPM_DIR "${SFW_FUNC_SPM_DIR}/..") -set(SFW_SPM_ARCH_DIR "${SFW_SPM_DIR}/arch") -set(SFW_SPM_INIT_DIR "${SFW_SPM_DIR}/init") +set(SFW_SPM_INIT_DIR "${SFW_SPM_DIR}/common/init") +set(SFW_SPM_RUNTIME_DIR "${SFW_SPM_DIR}/common/runtime") set (SFW_FUNC_SPM_SRC "${SFW_SPM_INIT_DIR}/tfm_boot_data.c" "${SFW_SPM_INIT_DIR}/tfm_core.c" "${SFW_FUNC_SPM_DIR}/tfm_core_svcalls_func.c" "${SFW_FUNC_SPM_DIR}/tfm_secure_api.c" - "${SFW_FUNC_SPM_DIR}/../runtime/tfm_spm_services.c" "${SFW_FUNC_SPM_DIR}/spm_func.c" "${SFW_FUNC_SPM_DIR}/tfm_nspm_func.c" - "${SFW_FUNC_SPM_DIR}/../runtime/utilities.c" - "${SFW_FUNC_SPM_DIR}/../runtime/tfm_core_mem_check.c" - "${SFW_FUNC_SPM_DIR}/../runtime/tfm_core_utils.c" + "${SFW_SPM_RUNTIME_DIR}/utilities.c" + "${SFW_SPM_RUNTIME_DIR}/tfm_core_mem_check.c" + "${SFW_SPM_RUNTIME_DIR}/tfm_core_utils.c" "${SFW_FUNC_SPM_DIR}/tfm_veneers.c" "${SFW_FUNC_SPM_DIR}/arch.c" ) @@ -57,5 +56,4 @@ embedded_include_directories(PATH ${SFW_FUNC_SPM_DIR} ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/include ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm/include ABSOLUTE) -embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm/arch ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/bl2/include ABSOLUTE) diff --git a/secure_fw/spm/model_func/arch.c b/secure_fw/spm/cmsis_func/arch.c index e7faa2ca0b..d142e846ea 100644 --- a/secure_fw/spm/model_func/arch.c +++ b/secure_fw/spm/cmsis_func/arch.c @@ -6,6 +6,94 @@ */ #include "tfm_secure_api.h" +#include "tfm_internal.h" +#include "tfm/tfm_spm_services.h" + +nsfptr_t ns_entry; + +void jump_to_ns_code(void) +{ + /* Calls the non-secure Reset_Handler to jump to the non-secure binary */ + ns_entry(); +} + +__attribute__((naked)) +int32_t tfm_core_get_caller_client_id(int32_t *caller_client_id) +{ + __ASM volatile( + "SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_GET_CALLER_CLIENT_ID)); +} + +__attribute__((naked)) +int32_t tfm_spm_request(void) +{ + __ASM volatile( + "SVC %0\n" + "BX lr\n" + : : "I" (TFM_SVC_SPM_REQUEST)); +} + +__attribute__((naked)) +int32_t tfm_spm_request_reset_vote(void) +{ + __ASM volatile( + "MOVS R0, %0\n" + "B tfm_spm_request\n" + : : "I" (TFM_SPM_REQUEST_RESET_VOTE)); +} + +__attribute__((naked)) +void tfm_enable_irq(psa_signal_t irq_signal) +{ + __ASM("SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_ENABLE_IRQ)); +} + +__attribute__((naked)) +void tfm_disable_irq(psa_signal_t irq_signal) +{ + __ASM("SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_DISABLE_IRQ)); +} + +__attribute__((naked)) +static psa_signal_t psa_wait_internal(psa_signal_t signal_mask, + uint32_t timeout) +{ + __ASM("SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_PSA_WAIT)); +} + +psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout) +{ + /* FIXME: By using the 'WFI' instruction this function blocks until an + * interrupt happens. It is necessary to do this here as tfm_core_psa_wait + * runs with the priority of the SVC, so it cannot be interrupted, so + * waiting in it for the required interrupt to happen is not an option. + */ + psa_signal_t actual_signal_mask; + + while (1) { + actual_signal_mask = psa_wait_internal(signal_mask, timeout); + if ((actual_signal_mask & signal_mask) != 0) { + return actual_signal_mask; + } + __WFI(); + } +} + +__attribute__((naked)) +void psa_eoi(psa_signal_t irq_signal) +{ + __ASM("SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_PSA_EOI)); +} #if defined(__ARM_ARCH_8_1M_MAIN__) || defined(__ARM_ARCH_8M_MAIN__) __attribute__((section("SFN"), naked)) @@ -144,3 +232,79 @@ void priv_irq_handler_main(uint32_t partition_id, uint32_t unpriv_handler, ); } #endif + +#if defined(__ARM_ARCH_8_1M_MAIN__) || \ + defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8M_BASE__) +void tfm_arch_prioritize_secure_exception(void) +{ + uint32_t VECTKEY; + SCB_Type *scb = SCB; + uint32_t AIRCR; + + /* Set PRIS flag in AIRCR */ + AIRCR = scb->AIRCR; + VECTKEY = (~AIRCR & SCB_AIRCR_VECTKEYSTAT_Msk); + scb->AIRCR = SCB_AIRCR_PRIS_Msk | + VECTKEY | + (AIRCR & ~SCB_AIRCR_VECTKEY_Msk); +} +#elif defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_7M__) || \ + defined(__ARM_ARCH_7EM__) +void tfm_arch_prioritize_secure_exception(void) +{ +} +#endif + +#if defined(__ARM_ARCH_8_1M_MAIN__) || defined(__ARM_ARCH_8M_MAIN__) +__attribute__((naked)) void SVC_Handler(void) +{ + __ASM volatile( + "MRS r2, MSP \n" + /* Check store SP in thread mode to r0 */ + "TST lr, #4 \n" + "ITE EQ \n" + "MOVEQ r0, r2 \n" + "MRSNE r0, PSP \n" + "MOV r1, lr \n" + "BL tfm_core_svc_handler \n" + "BX r0 \n" + ); +} +#elif defined(__ARM_ARCH_8M_BASE__) +__attribute__((naked)) void SVC_Handler(void) +{ + __ASM volatile( + "MRS r2, MSP \n" + "MOVS r1, #4 \n" + "MOV r3, lr \n" + "MOV r0, r2 \n" + "TST r1, r3 \n" + "BEQ handler \n" + /* If SVC was made from thread mode, overwrite r0 with PSP */ + "MRS r0, PSP \n" + "handler: \n" + "MOV r1, lr \n" + "BL tfm_core_svc_handler \n" + "BX r0 \n" + ); +} +#elif defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_7M__) || \ + defined(__ARM_ARCH_7EM__) +__attribute__((naked)) void SVC_Handler(void) +{ + __ASM volatile( + "MOVS r0, #4 \n" /* Check store SP in thread mode to r0 */ + "MOV r1, lr \n" + "TST r0, r1 \n" + "BEQ handler \n" + "MRS r0, PSP \n" /* Coming from thread mode */ + "B sp_stored \n" + "handler: \n" + "BX lr \n" /* Coming from handler mode */ + "sp_stored: \n" + "MOV r1, lr \n" + "BL tfm_core_svc_handler \n" + "BX r0 \n" + ); +} +#endif diff --git a/secure_fw/spm/model_func/spm_func.c b/secure_fw/spm/cmsis_func/spm_func.c index 9cfd1a82b5..9cfd1a82b5 100644 --- a/secure_fw/spm/model_func/spm_func.c +++ b/secure_fw/spm/cmsis_func/spm_func.c diff --git a/secure_fw/spm/model_func/tfm_core_svcalls_func.c b/secure_fw/spm/cmsis_func/tfm_core_svcalls_func.c index c1b21f684b..c1b21f684b 100644 --- a/secure_fw/spm/model_func/tfm_core_svcalls_func.c +++ b/secure_fw/spm/cmsis_func/tfm_core_svcalls_func.c diff --git a/secure_fw/spm/model_func/tfm_nspm_func.c b/secure_fw/spm/cmsis_func/tfm_nspm_func.c index bc36c152c3..bc36c152c3 100644 --- a/secure_fw/spm/model_func/tfm_nspm_func.c +++ b/secure_fw/spm/cmsis_func/tfm_nspm_func.c diff --git a/secure_fw/spm/model_func/tfm_secure_api.c b/secure_fw/spm/cmsis_func/tfm_secure_api.c index d4fe17913b..d4fe17913b 100644 --- a/secure_fw/spm/model_func/tfm_secure_api.c +++ b/secure_fw/spm/cmsis_func/tfm_secure_api.c diff --git a/secure_fw/spm/model_func/tfm_secure_irq_handlers.inc b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc index 8c35661d3f..8c35661d3f 100644 --- a/secure_fw/spm/model_func/tfm_secure_irq_handlers.inc +++ b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc diff --git a/secure_fw/spm/model_func/tfm_secure_irq_handlers.inc.template b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template index 9db5d64ac1..9db5d64ac1 100644 --- a/secure_fw/spm/model_func/tfm_secure_irq_handlers.inc.template +++ b/secure_fw/spm/cmsis_func/tfm_secure_irq_handlers.inc.template diff --git a/secure_fw/spm/model_func/tfm_spm_db_func.inc b/secure_fw/spm/cmsis_func/tfm_spm_db_func.inc index 54f2ddb4b9..54f2ddb4b9 100644 --- a/secure_fw/spm/model_func/tfm_spm_db_func.inc +++ b/secure_fw/spm/cmsis_func/tfm_spm_db_func.inc diff --git a/secure_fw/spm/model_func/tfm_spm_db_func.inc.template b/secure_fw/spm/cmsis_func/tfm_spm_db_func.inc.template index 8f424b8f7e..8f424b8f7e 100644 --- a/secure_fw/spm/model_func/tfm_spm_db_func.inc.template +++ b/secure_fw/spm/cmsis_func/tfm_spm_db_func.inc.template diff --git a/secure_fw/spm/model_func/tfm_veneers.c b/secure_fw/spm/cmsis_func/tfm_veneers.c index b58fca5cda..b58fca5cda 100644 --- a/secure_fw/spm/model_func/tfm_veneers.c +++ b/secure_fw/spm/cmsis_func/tfm_veneers.c diff --git a/secure_fw/spm/model_func/tfm_veneers.c.template b/secure_fw/spm/cmsis_func/tfm_veneers.c.template index b51816466e..b51816466e 100644 --- a/secure_fw/spm/model_func/tfm_veneers.c.template +++ b/secure_fw/spm/cmsis_func/tfm_veneers.c.template diff --git a/secure_fw/spm/model_ipc/CMakeLists.inc b/secure_fw/spm/cmsis_psa/CMakeLists.inc index a0736b8113..3182fd4c68 100644 --- a/secure_fw/spm/model_ipc/CMakeLists.inc +++ b/secure_fw/spm/cmsis_psa/CMakeLists.inc @@ -30,8 +30,9 @@ endif() #Get the current directory where this file is located. set(SFW_IPC_SPM_DIR ${CMAKE_CURRENT_LIST_DIR}) set(SFW_SPM_DIR "${SFW_IPC_SPM_DIR}/..") -set(SFW_SPM_ARCH_DIR "${SFW_SPM_DIR}/arch") -set(SFW_SPM_INIT_DIR "${SFW_SPM_DIR}/init") +set(SFW_SPM_ARCH_DIR "${SFW_IPC_SPM_DIR}/arch") +set(SFW_SPM_INIT_DIR "${SFW_SPM_DIR}/common/init") +set(SFW_SPM_RUNTIME_DIR "${SFW_SPM_DIR}/common/runtime") set (SFW_IPC_SPM_SRC "${SFW_SPM_INIT_DIR}/tfm_boot_data.c" @@ -40,9 +41,8 @@ set (SFW_IPC_SPM_SRC "${SFW_IPC_SPM_DIR}/spm_psa_client_call.c" "${SFW_IPC_SPM_DIR}/tfm_core_svcalls_ipc.c" "${SFW_IPC_SPM_DIR}/tfm_message_queue.c" - "${SFW_IPC_SPM_DIR}/../runtime/utilities.c" - "${SFW_IPC_SPM_DIR}/../runtime/tfm_core_utils.c" - "${SFW_IPC_SPM_DIR}/../runtime/tfm_spm_services.c" + "${SFW_SPM_RUNTIME_DIR}/utilities.c" + "${SFW_SPM_RUNTIME_DIR}/tfm_core_utils.c" "${SFW_IPC_SPM_DIR}/tfm_pools.c" "${SFW_IPC_SPM_DIR}/tfm_thread.c" "${SFW_IPC_SPM_DIR}/tfm_wait.c" @@ -57,7 +57,7 @@ if (DEFINED TFM_MULTI_CORE_TOPOLOGY AND TFM_MULTI_CORE_TOPOLOGY) else () list(APPEND SFW_IPC_SPM_SRC "${SFW_IPC_SPM_DIR}/tfm_nspm_ipc.c" "${SFW_IPC_SPM_DIR}/tfm_psa_api_veneers.c" - "${SFW_IPC_SPM_DIR}/../runtime/tfm_core_mem_check.c" + "${SFW_SPM_RUNTIME_DIR}/tfm_core_mem_check.c" ) endif () @@ -71,5 +71,8 @@ embedded_include_directories(PATH ${SFW_IPC_SPM_DIR}/include ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/interface/include ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/include ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm/include ABSOLUTE) -embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm/arch ABSOLUTE) +embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/spm/cmsis_psa/arch ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/bl2/include ABSOLUTE) + +#Involve all IPC related sources in psa CMakeLists.inc +include(${SFW_IPC_SPM_DIR}/arch/CMakeLists.inc) diff --git a/secure_fw/spm/arch/CMakeLists.inc b/secure_fw/spm/cmsis_psa/arch/CMakeLists.inc index 01ab370d6a..c0616cdbb8 100644 --- a/secure_fw/spm/arch/CMakeLists.inc +++ b/secure_fw/spm/cmsis_psa/arch/CMakeLists.inc @@ -57,4 +57,3 @@ unset(TFM_ARCH_C_SRC) #Setting include directories embedded_include_directories(PATH ${TFM_ROOT_DIR}/platform/ext/cmsis ABSOLUTE) embedded_include_directories(PATH ${TFM_ROOT_DIR}/secure_fw/include ABSOLUTE) -embedded_include_directories(PATH ${TFM_ARCH_DIR}/include ABSOLUTE) diff --git a/secure_fw/spm/arch/tfm_arch.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch.c index 54df423e7c..99e6cbf2fa 100644 --- a/secure_fw/spm/arch/tfm_arch.c +++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch.c @@ -7,8 +7,43 @@ #include "tfm_arch.h" #include "tfm_core_utils.h" +#include "tfm/tfm_core_svc.h" +#include "tfm/tfm_spm_services.h" + +__attribute__((naked)) +int32_t tfm_spm_request(void) +{ + __ASM volatile( + "SVC %0\n" + "BX lr\n" + : : "I" (TFM_SVC_SPM_REQUEST)); +} + +__attribute__((naked)) +int32_t tfm_spm_request_reset_vote(void) +{ + __ASM volatile( + "MOVS R0, %0\n" + "B tfm_spm_request\n" + : : "I" (TFM_SPM_REQUEST_RESET_VOTE)); +} + +__attribute__((naked)) +void tfm_enable_irq(psa_signal_t irq_signal) +{ + __ASM("SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_ENABLE_IRQ)); +} + +__attribute__((naked)) +void tfm_disable_irq(psa_signal_t irq_signal) +{ + __ASM("SVC %0\n" + "BX LR\n" + : : "I" (TFM_SVC_DISABLE_IRQ)); +} -#ifdef TFM_PSA_API static void tfm_arch_init_state_ctx(struct tfm_state_context_t *p_stat_ctx, void *param, uintptr_t pfn) { @@ -48,5 +83,3 @@ void tfm_arch_init_context(struct tfm_arch_ctx_t *p_actx, tfm_core_util_memset(p_actx, 0, sizeof(*p_actx)); tfm_arch_init_actx(p_actx, (uint32_t)p_stat_ctx, (uint32_t)stk_btm); } - -#endif /* TFM_PSA_API */ diff --git a/secure_fw/spm/arch/tfm_arch_v6m_v7m.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c index 34debc6b36..34debc6b36 100644 --- a/secure_fw/spm/arch/tfm_arch_v6m_v7m.c +++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c diff --git a/secure_fw/spm/arch/tfm_arch_v6m_v7m.h b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h index 380df16af1..380df16af1 100644 --- a/secure_fw/spm/arch/tfm_arch_v6m_v7m.h +++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.h diff --git a/secure_fw/spm/arch/tfm_arch_v8m_base.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c index 7c3c0fe4d8..7c3c0fe4d8 100644 --- a/secure_fw/spm/arch/tfm_arch_v8m_base.c +++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c diff --git a/secure_fw/spm/arch/tfm_arch_v8m_main.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c index d03d05179d..d03d05179d 100644 --- a/secure_fw/spm/arch/tfm_arch_v8m_main.c +++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c diff --git a/secure_fw/spm/model_ipc/include/tfm_internal_defines.h b/secure_fw/spm/cmsis_psa/include/tfm_internal_defines.h index e948e7eb2e..e948e7eb2e 100644 --- a/secure_fw/spm/model_ipc/include/tfm_internal_defines.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_internal_defines.h diff --git a/secure_fw/spm/model_ipc/include/tfm_list.h b/secure_fw/spm/cmsis_psa/include/tfm_list.h index 976450362e..976450362e 100644 --- a/secure_fw/spm/model_ipc/include/tfm_list.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_list.h diff --git a/secure_fw/spm/model_ipc/include/tfm_message_queue.h b/secure_fw/spm/cmsis_psa/include/tfm_message_queue.h index a4e0e1b449..a4e0e1b449 100644 --- a/secure_fw/spm/model_ipc/include/tfm_message_queue.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_message_queue.h diff --git a/secure_fw/spm/model_ipc/include/tfm_multi_core.h b/secure_fw/spm/cmsis_psa/include/tfm_multi_core.h index 2618804095..2618804095 100644 --- a/secure_fw/spm/model_ipc/include/tfm_multi_core.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_multi_core.h diff --git a/secure_fw/spm/model_ipc/include/tfm_pools.h b/secure_fw/spm/cmsis_psa/include/tfm_pools.h index 422484b33c..422484b33c 100644 --- a/secure_fw/spm/model_ipc/include/tfm_pools.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_pools.h diff --git a/secure_fw/spm/model_ipc/include/tfm_rpc.h b/secure_fw/spm/cmsis_psa/include/tfm_rpc.h index cf573f8799..cf573f8799 100644 --- a/secure_fw/spm/model_ipc/include/tfm_rpc.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_rpc.h diff --git a/secure_fw/spm/model_ipc/include/tfm_spe_mailbox.h b/secure_fw/spm/cmsis_psa/include/tfm_spe_mailbox.h index fd07907117..fd07907117 100644 --- a/secure_fw/spm/model_ipc/include/tfm_spe_mailbox.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_spe_mailbox.h diff --git a/secure_fw/spm/model_ipc/include/tfm_svcalls.h b/secure_fw/spm/cmsis_psa/include/tfm_svcalls.h index d553fc8f5d..d553fc8f5d 100644 --- a/secure_fw/spm/model_ipc/include/tfm_svcalls.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_svcalls.h diff --git a/secure_fw/spm/model_ipc/include/tfm_thread.h b/secure_fw/spm/cmsis_psa/include/tfm_thread.h index 925967b292..925967b292 100644 --- a/secure_fw/spm/model_ipc/include/tfm_thread.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_thread.h diff --git a/secure_fw/spm/model_ipc/include/tfm_wait.h b/secure_fw/spm/cmsis_psa/include/tfm_wait.h index 7d2055bd1e..7d2055bd1e 100644 --- a/secure_fw/spm/model_ipc/include/tfm_wait.h +++ b/secure_fw/spm/cmsis_psa/include/tfm_wait.h diff --git a/secure_fw/spm/model_ipc/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c index f15344c57f..f15344c57f 100644 --- a/secure_fw/spm/model_ipc/spm_ipc.c +++ b/secure_fw/spm/cmsis_psa/spm_ipc.c diff --git a/secure_fw/spm/model_ipc/spm_psa_client_call.c b/secure_fw/spm/cmsis_psa/spm_psa_client_call.c index 9fca10c617..9fca10c617 100644 --- a/secure_fw/spm/model_ipc/spm_psa_client_call.c +++ b/secure_fw/spm/cmsis_psa/spm_psa_client_call.c diff --git a/secure_fw/spm/model_ipc/spm_psa_client_call.h b/secure_fw/spm/cmsis_psa/spm_psa_client_call.h index 5146e76fc6..5146e76fc6 100644 --- a/secure_fw/spm/model_ipc/spm_psa_client_call.h +++ b/secure_fw/spm/cmsis_psa/spm_psa_client_call.h diff --git a/secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c index 7f8bbd9796..7f8bbd9796 100644 --- a/secure_fw/spm/model_ipc/tfm_core_svcalls_ipc.c +++ b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c diff --git a/secure_fw/spm/model_ipc/tfm_message_queue.c b/secure_fw/spm/cmsis_psa/tfm_message_queue.c index 1a7790ee83..1a7790ee83 100644 --- a/secure_fw/spm/model_ipc/tfm_message_queue.c +++ b/secure_fw/spm/cmsis_psa/tfm_message_queue.c diff --git a/secure_fw/spm/model_ipc/tfm_multi_core.c b/secure_fw/spm/cmsis_psa/tfm_multi_core.c index f8ef7d6fa4..f8ef7d6fa4 100644 --- a/secure_fw/spm/model_ipc/tfm_multi_core.c +++ b/secure_fw/spm/cmsis_psa/tfm_multi_core.c diff --git a/secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c b/secure_fw/spm/cmsis_psa/tfm_multi_core_mem_check.c index 9cf8bf8be2..9cf8bf8be2 100644 --- a/secure_fw/spm/model_ipc/tfm_multi_core_mem_check.c +++ b/secure_fw/spm/cmsis_psa/tfm_multi_core_mem_check.c diff --git a/secure_fw/spm/model_ipc/tfm_nspm_ipc.c b/secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c index cc6449ec9b..cc6449ec9b 100644 --- a/secure_fw/spm/model_ipc/tfm_nspm_ipc.c +++ b/secure_fw/spm/cmsis_psa/tfm_nspm_ipc.c diff --git a/secure_fw/spm/model_ipc/tfm_pools.c b/secure_fw/spm/cmsis_psa/tfm_pools.c index 2fa3d402c2..2fa3d402c2 100644 --- a/secure_fw/spm/model_ipc/tfm_pools.c +++ b/secure_fw/spm/cmsis_psa/tfm_pools.c diff --git a/secure_fw/spm/model_ipc/tfm_psa_api_veneers.c b/secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c index d2f4b4b0ee..d2f4b4b0ee 100644 --- a/secure_fw/spm/model_ipc/tfm_psa_api_veneers.c +++ b/secure_fw/spm/cmsis_psa/tfm_psa_api_veneers.c diff --git a/secure_fw/spm/model_ipc/tfm_rpc.c b/secure_fw/spm/cmsis_psa/tfm_rpc.c index 351c97108f..351c97108f 100644 --- a/secure_fw/spm/model_ipc/tfm_rpc.c +++ b/secure_fw/spm/cmsis_psa/tfm_rpc.c diff --git a/secure_fw/spm/model_ipc/tfm_secure_irq_handlers_ipc.inc b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc index 65fba46272..65fba46272 100644 --- a/secure_fw/spm/model_ipc/tfm_secure_irq_handlers_ipc.inc +++ b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc diff --git a/secure_fw/spm/model_ipc/tfm_secure_irq_handlers_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template index e5a7d6b252..e5a7d6b252 100644 --- a/secure_fw/spm/model_ipc/tfm_secure_irq_handlers_ipc.inc.template +++ b/secure_fw/spm/cmsis_psa/tfm_secure_irq_handlers_ipc.inc.template diff --git a/secure_fw/spm/model_ipc/tfm_spe_mailbox.c b/secure_fw/spm/cmsis_psa/tfm_spe_mailbox.c index c0affe1fe6..c0affe1fe6 100644 --- a/secure_fw/spm/model_ipc/tfm_spe_mailbox.c +++ b/secure_fw/spm/cmsis_psa/tfm_spe_mailbox.c diff --git a/secure_fw/spm/model_ipc/tfm_spm_db_ipc.inc b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc index 0102970bbf..0102970bbf 100644 --- a/secure_fw/spm/model_ipc/tfm_spm_db_ipc.inc +++ b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc diff --git a/secure_fw/spm/model_ipc/tfm_spm_db_ipc.inc.template b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template index 86390df74e..86390df74e 100644 --- a/secure_fw/spm/model_ipc/tfm_spm_db_ipc.inc.template +++ b/secure_fw/spm/cmsis_psa/tfm_spm_db_ipc.inc.template diff --git a/secure_fw/spm/model_ipc/tfm_thread.c b/secure_fw/spm/cmsis_psa/tfm_thread.c index e3554e37f7..e3554e37f7 100644 --- a/secure_fw/spm/model_ipc/tfm_thread.c +++ b/secure_fw/spm/cmsis_psa/tfm_thread.c diff --git a/secure_fw/spm/model_ipc/tfm_wait.c b/secure_fw/spm/cmsis_psa/tfm_wait.c index c199c8815e..c199c8815e 100644 --- a/secure_fw/spm/model_ipc/tfm_wait.c +++ b/secure_fw/spm/cmsis_psa/tfm_wait.c diff --git a/secure_fw/spm/init/tfm_boot_data.c b/secure_fw/spm/common/init/tfm_boot_data.c index 20739a6181..20739a6181 100644 --- a/secure_fw/spm/init/tfm_boot_data.c +++ b/secure_fw/spm/common/init/tfm_boot_data.c diff --git a/secure_fw/spm/init/tfm_core.c b/secure_fw/spm/common/init/tfm_core.c index 6be9c353f1..6be9c353f1 100644 --- a/secure_fw/spm/init/tfm_core.c +++ b/secure_fw/spm/common/init/tfm_core.c diff --git a/secure_fw/spm/runtime/tfm_core_mem_check.c b/secure_fw/spm/common/runtime/tfm_core_mem_check.c index d0983cba15..d0983cba15 100644 --- a/secure_fw/spm/runtime/tfm_core_mem_check.c +++ b/secure_fw/spm/common/runtime/tfm_core_mem_check.c diff --git a/secure_fw/spm/runtime/tfm_core_utils.c b/secure_fw/spm/common/runtime/tfm_core_utils.c index 341e75c468..341e75c468 100644 --- a/secure_fw/spm/runtime/tfm_core_utils.c +++ b/secure_fw/spm/common/runtime/tfm_core_utils.c diff --git a/secure_fw/spm/runtime/utilities.c b/secure_fw/spm/common/runtime/utilities.c index c601311801..c601311801 100644 --- a/secure_fw/spm/runtime/utilities.c +++ b/secure_fw/spm/common/runtime/utilities.c diff --git a/secure_fw/spm/arch/tfm_arch.h b/secure_fw/spm/include/tfm_arch.h index 96251aecc9..96251aecc9 100644 --- a/secure_fw/spm/arch/tfm_arch.h +++ b/secure_fw/spm/include/tfm_arch.h diff --git a/secure_fw/spm/arch/tfm_arch_v8m.h b/secure_fw/spm/include/tfm_arch_v8m.h index 94a2e4fb54..94a2e4fb54 100644 --- a/secure_fw/spm/arch/tfm_arch_v8m.h +++ b/secure_fw/spm/include/tfm_arch_v8m.h diff --git a/secure_fw/spm/runtime/tfm_spm_services.c b/secure_fw/spm/runtime/tfm_spm_services.c deleted file mode 100644 index 033bbb162b..0000000000 --- a/secure_fw/spm/runtime/tfm_spm_services.c +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2017-2020, Arm Limited. All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - * - */ - -#include <arm_cmse.h> - -#include "tfm/tfm_core_svc.h" -#include "tfm_secure_api.h" -#include "tfm_internal.h" -#include "tfm/tfm_spm_services.h" -#include "spm_api.h" -#include "psa/service.h" - -#ifndef TFM_PSA_API -nsfptr_t ns_entry; - -void jump_to_ns_code(void) -{ - /* Calls the non-secure Reset_Handler to jump to the non-secure binary */ - ns_entry(); -} - -__attribute__((naked)) -int32_t tfm_core_get_caller_client_id(int32_t *caller_client_id) -{ - __ASM volatile( - "SVC %0\n" - "BX LR\n" - : : "I" (TFM_SVC_GET_CALLER_CLIENT_ID)); -} - -#endif - -__attribute__((naked)) -int32_t tfm_spm_request(void) -{ - __ASM volatile( - "SVC %0\n" - "BX lr\n" - : : "I" (TFM_SVC_SPM_REQUEST)); -} - -__attribute__((naked)) -int32_t tfm_spm_request_reset_vote(void) -{ - __ASM volatile( - "MOVS R0, %0\n" - "B tfm_spm_request\n" - : : "I" (TFM_SPM_REQUEST_RESET_VOTE)); -} - -__attribute__((naked)) -void tfm_enable_irq(psa_signal_t irq_signal) -{ - __ASM("SVC %0\n" - "BX LR\n" - : : "I" (TFM_SVC_ENABLE_IRQ)); -} - -__attribute__((naked)) -void tfm_disable_irq(psa_signal_t irq_signal) -{ - __ASM("SVC %0\n" - "BX LR\n" - : : "I" (TFM_SVC_DISABLE_IRQ)); -} - -#ifndef TFM_PSA_API - -__attribute__((naked)) -static psa_signal_t psa_wait_internal(psa_signal_t signal_mask, - uint32_t timeout) -{ - __ASM("SVC %0\n" - "BX LR\n" - : : "I" (TFM_SVC_PSA_WAIT)); -} - -psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout) -{ - /* FIXME: By using the 'WFI' instruction this function blocks until an - * interrupt happens. It is necessary to do this here as tfm_core_psa_wait - * runs with the priority of the SVC, so it cannot be interrupted, so - * waiting in it for the required interrupt to happen is not an option. - */ - psa_signal_t actual_signal_mask; - - while (1) { - actual_signal_mask = psa_wait_internal(signal_mask, timeout); - if ((actual_signal_mask & signal_mask) != 0) { - return actual_signal_mask; - } - __WFI(); - } -} - -__attribute__((naked)) -void psa_eoi(psa_signal_t irq_signal) -{ - __ASM("SVC %0\n" - "BX LR\n" - : : "I" (TFM_SVC_PSA_EOI)); -} - -#endif |