Tools: Generate SPM configurations in script
The manifest tool has two places (config_impl.h and config_impl.cmake)
to check SFN/IPC Partitions numbers.
This doubles the maintainance effort.
This patch moves those checks forward to the manifest script.
This patch also adds back all the SPM configurations to config_impl.h
so that all sources need them only have to include the head file but
no need to add compiler definitions.
This patch removes the backend.c and builds the backend_ipc/sfn.c
according to the configurations.
Change-Id: I8da72bccc547df6ee4b2503869daf490b04bcf8b
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/secure_fw/partitions/ns_agent_tz/tfm_psa_api_veneers.c b/secure_fw/partitions/ns_agent_tz/tfm_psa_api_veneers.c
index 69273d0..172da19 100644
--- a/secure_fw/partitions/ns_agent_tz/tfm_psa_api_veneers.c
+++ b/secure_fw/partitions/ns_agent_tz/tfm_psa_api_veneers.c
@@ -15,7 +15,7 @@
#include "tfm_psa_call_pack.h"
#include "tfm_secure_api.h"
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
#include "spm_ipc.h"
#include "ffm/psa_api.h"
#endif
@@ -38,7 +38,7 @@
#if defined(__ICCARM__)
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
#pragma required = tfm_spm_client_psa_framework_version
#pragma required = tfm_spm_client_psa_version
@@ -50,7 +50,7 @@
#pragma required = tfm_spm_client_psa_close
#endif /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API */
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1 */
#endif
@@ -70,7 +70,7 @@
#endif
" mrs r3, control \n"
" push {r2, r3} \n"
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
" push {r0-r4, lr} \n"
" ldr r0, =tfm_spm_client_psa_framework_version \n"
" mov r1, sp \n"
@@ -79,7 +79,7 @@
" pop {r0-r3} \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
-#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+#elif CONFIG_TFM_PSA_API_SFN_CALL == 1
" push {r4, lr} \n"
" bl psa_framework_version_sfn \n"
" pop {r2, r3} \n"
@@ -114,7 +114,7 @@
#endif
" mrs r3, control \n"
" push {r2, r3} \n"
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
" push {r0-r4, lr} \n"
" ldr r0, =tfm_spm_client_psa_version \n"
" mov r1, sp \n"
@@ -123,7 +123,7 @@
" pop {r0-r3} \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
-#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+#elif CONFIG_TFM_PSA_API_SFN_CALL == 1
" push {r4, lr} \n"
" bl psa_version_sfn \n"
" pop {r2, r3} \n"
@@ -165,7 +165,7 @@
" mrs r3, control \n"
" push {r2, r3} \n"
" mov r3, r12 \n"
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
" push {r0-r4, lr} \n"
" ldr r0, =tfm_spm_client_psa_call \n"
" mov r1, sp \n"
@@ -174,7 +174,7 @@
" pop {r0-r3} \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
-#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+#elif CONFIG_TFM_PSA_API_SFN_CALL == 1
" push {r4, lr} \n"
" bl psa_call_pack_sfn \n"
" pop {r2, r3} \n"
@@ -213,7 +213,7 @@
" mrs r3, control \n"
" push {r2, r3} \n"
" mov r3, r12 \n"
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
" push {r0-r4, lr} \n"
" ldr r0, =tfm_spm_client_psa_connect \n"
" mov r1, sp \n"
@@ -222,7 +222,7 @@
" pop {r0-r3} \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
-#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+#elif CONFIG_TFM_PSA_API_SFN_CALL == 1
" push {r4, lr} \n"
" bl psa_connect_sfn \n"
" pop {r2, r3} \n"
@@ -257,7 +257,7 @@
#endif
" mrs r3, control \n"
" push {r2, r3} \n"
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
" push {r0-r4, lr} \n"
" ldr r0, =tfm_spm_client_psa_close \n"
" mov r1, sp \n"
@@ -266,7 +266,7 @@
" pop {r0-r3} \n"
" pop {r2, r3} \n"
" mov lr, r3 \n"
-#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+#elif CONFIG_TFM_PSA_API_SFN_CALL == 1
" push {r4, lr} \n"
" bl psa_close_sfn \n"
" pop {r2, r3} \n"
diff --git a/secure_fw/spm/CMakeLists.txt b/secure_fw/spm/CMakeLists.txt
index fc8df28..06787ee 100755
--- a/secure_fw/spm/CMakeLists.txt
+++ b/secure_fw/spm/CMakeLists.txt
@@ -51,7 +51,8 @@
$<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:cmsis_psa/spm_cross_call.c>
$<$<BOOL:${TFM_PSA_API}>:cmsis_psa/static_load.c>
$<$<BOOL:${TFM_PSA_API}>:ffm/psa_api.c>
- $<$<BOOL:${TFM_PSA_API}>:ffm/backend.c>
+ $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:ffm/backend_ipc.c>
+ $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_SFN}>:ffm/backend_sfn.c>
$<$<BOOL:${TFM_PSA_API}>:ffm/interrupt.c>
$<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_core_svcalls_ipc.c>
$<$<BOOL:${TFM_PSA_API}>:cmsis_psa/tfm_pools.c>
@@ -92,10 +93,7 @@
$<$<AND:$<BOOL:${BL2}>,$<BOOL:${MCUBOOT_MEASURED_BOOT}>>:BOOT_DATA_AVAILABLE>
$<$<BOOL:${TFM_EXCEPTION_INFO_DUMP}>:TFM_EXCEPTION_INFO_DUMP>
$<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
- $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_IPC}>:CONFIG_TFM_SPM_BACKEND_IPC>
- $<$<BOOL:${CONFIG_TFM_SPM_BACKEND_SFN}>:CONFIG_TFM_SPM_BACKEND_SFN>
$<$<BOOL:${TFM_PSA_API}>:CONFIG_TFM_CONN_HANDLE_MAX_NUM=${CONFIG_TFM_CONN_HANDLE_MAX_NUM}>
-
# CONFIG_TFM_FP
$<$<STREQUAL:${CONFIG_TFM_FP},hard>:CONFIG_TFM_FP=2>
$<$<STREQUAL:${CONFIG_TFM_FP},soft>:CONFIG_TFM_FP=0>
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
index 4f9e647..0493f61 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v6m_v7m.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -30,15 +30,15 @@
#pragma required = scheduler_lock
#pragma required = tfm_core_svc_handler
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
#pragma required = cross_call_execute_c
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1*/
#endif
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
__naked uint32_t arch_non_preempt_call(uintptr_t fn_addr, uintptr_t frame_addr,
uint32_t stk_base, uint32_t stk_limit)
@@ -75,7 +75,7 @@
);
}
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1*/
__attribute__((naked)) void PendSV_Handler(void)
{
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
index 52ba185..d95af8f 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_base.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2022, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*
@@ -31,15 +31,15 @@
#pragma required = scheduler_lock
#pragma required = tfm_core_svc_handler
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
#pragma required = cross_call_execute_c
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1 */
#endif
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
__naked uint32_t arch_non_preempt_call(uintptr_t fn_addr, uintptr_t frame_addr,
uint32_t stk_base, uint32_t stk_limit)
@@ -81,7 +81,7 @@
);
}
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1 */
__attribute__((naked)) void PendSV_Handler(void)
{
diff --git a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
index cfc4e7e..aff6a78 100644
--- a/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
+++ b/secure_fw/spm/cmsis_psa/arch/tfm_arch_v8m_main.c
@@ -36,15 +36,15 @@
#pragma required = scheduler_lock
#pragma required = tfm_core_svc_handler
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
#pragma required = cross_call_execute_c
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1*/
#endif
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
__naked uint32_t arch_non_preempt_call(uintptr_t fn_addr, uintptr_t frame_addr,
uint32_t stk_base, uint32_t stk_limit)
@@ -84,7 +84,7 @@
);
}
-#endif /* CONFIG_TFM_PSA_API_CROSS_CALL */
+#endif /* CONFIG_TFM_PSA_API_CROSS_CALL == 1*/
__attribute__((naked)) void PendSV_Handler(void)
{
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 4f513b3..bf4b498 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -392,7 +392,7 @@
*/
void spm_assert_signal(void *p_pt, psa_signal_t signal);
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
/*
* SPM dispatcher to handle the API call under non-privileged model.
diff --git a/secure_fw/spm/ffm/backend.c b/secure_fw/spm/ffm/backend.c
deleted file mode 100644
index 9df5de7..0000000
--- a/secure_fw/spm/ffm/backend.c
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- * Copyright (c) 2021, Arm Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-3-Clause
- *
- */
-#include "config_impl.h"
-
-#if CONFIG_TFM_SPM_BACKEND_SFN == 1
-#include "backend_sfn.c"
-#elif CONFIG_TFM_SPM_BACKEND_IPC == 1
-#include "backend_ipc.c"
-#else
-#error "Invalid configuration."
-#endif
diff --git a/secure_fw/spm/ffm/backend_ipc.c b/secure_fw/spm/ffm/backend_ipc.c
index 443c5da..543282a 100644
--- a/secure_fw/spm/ffm/backend_ipc.c
+++ b/secure_fw/spm/ffm/backend_ipc.c
@@ -23,7 +23,7 @@
/* Declare the global component list */
struct partition_head_t partition_listhead;
-#ifdef CONFIG_TFM_PSA_API_CROSS_CALL
+#if CONFIG_TFM_PSA_API_CROSS_CALL == 1
#ifdef TFM_MULTI_CORE_TOPOLOGY
/* TODO: To be checked when RPC design updates. */
@@ -115,7 +115,7 @@
THRD_INIT(&p_pt->thrd, &p_pt->ctx_ctrl,
TO_THREAD_PRIORITY(PARTITION_PRIORITY(p_pldi->flags)));
-#if defined(CONFIG_TFM_PSA_API_CROSS_CALL) && !defined(TFM_MULTI_CORE_TOPOLOGY)
+#if (CONFIG_TFM_PSA_API_CROSS_CALL == 1) && !defined(TFM_MULTI_CORE_TOPOLOGY)
if (p_pldi->pid == TFM_SP_NON_SECURE_ID) {
SPM_THREAD_CONTEXT = &p_pt->ctx_ctrl;
}
@@ -132,7 +132,7 @@
uint32_t control;
struct partition_t *p_cur_pt;
-#ifdef CONFIG_TFM_PSA_API_THREAD_CALL
+#if CONFIG_TFM_PSA_API_THREAD_CALL == 1
TFM_CORE_ASSERT(SPM_THREAD_CONTEXT);
#endif