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/interface/CMakeLists.txt b/interface/CMakeLists.txt
index 65e01ec..b62a1a9 100644
--- a/interface/CMakeLists.txt
+++ b/interface/CMakeLists.txt
@@ -52,9 +52,6 @@
$<$<BOOL:${TFM_MULTI_CORE_TOPOLOGY}>:TFM_MULTI_CORE_TOPOLOGY>
$<$<BOOL:${FORWARD_PROT_MSG}>:FORWARD_PROT_MSG=${FORWARD_PROT_MSG}>
$<$<BOOL:${CONFIG_TFM_PARTITION_META}>:CONFIG_TFM_PARTITION_META>
- $<$<BOOL:${CONFIG_TFM_PSA_API_SUPERVISOR_CALL}>:CONFIG_TFM_PSA_API_SUPERVISOR_CALL>
- $<$<BOOL:${CONFIG_TFM_PSA_API_CROSS_CALL}>:CONFIG_TFM_PSA_API_CROSS_CALL>
- $<$<BOOL:${CONFIG_TFM_PSA_API_SFN_CALL}>:CONFIG_TFM_PSA_API_SFN_CALL>
)
###################### PSA api (S lib) #########################################
diff --git a/interface/include/config_impl.h.template b/interface/include/config_impl.h.template
index 0696b91..85b2cba 100644
--- a/interface/include/config_impl.h.template
+++ b/interface/include/config_impl.h.template
@@ -9,9 +9,18 @@
#ifndef __CONFIG_IMPL_H__
#define __CONFIG_IMPL_H__
-{% if partition_statistics['ipc_partition_num'] > 0
- and partition_statistics['sfn_partition_num'] == 0 %}
-/* IPC model */
+/* Backends */
+#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_IPC")}} {{config_impl['CONFIG_TFM_SPM_BACKEND_IPC']}}
+#define {{"%-56s"|format("CONFIG_TFM_SPM_BACKEND_SFN")}} {{config_impl['CONFIG_TFM_SPM_BACKEND_SFN']}}
+
+/* API calls */
+#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SFN_CALL")}} {{config_impl['CONFIG_TFM_PSA_API_SFN_CALL']}}
+#define {{"%-56s"|format("CONFIG_TFM_PSA_API_CROSS_CALL")}} {{config_impl['CONFIG_TFM_PSA_API_CROSS_CALL']}}
+#define {{"%-56s"|format("CONFIG_TFM_PSA_API_SUPERVISOR_CALL")}} {{config_impl['CONFIG_TFM_PSA_API_SUPERVISOR_CALL']}}
+
+#define {{"%-56s"|format("CONFIG_TFM_CONNECTION_BASED_SERVICE_API")}} {{config_impl['CONFIG_TFM_CONNECTION_BASED_SERVICE_API']}}
+
+#if CONFIG_TFM_SPM_BACKEND_IPC == 1
/* Trustzone NS agent working stack size. */
#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} 1024
@@ -19,10 +28,7 @@
#define {{"%-56s"|format("CONFIG_TFM_SPM_THREAD_STACK_SIZE")}} \
{{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}}
-{% elif partition_statistics['sfn_partition_num'] > 0
- and partition_statistics['ipc_partition_num'] == 0 %}
-/* SFN model */
-
+#elif CONFIG_TFM_SPM_BACKEND_SFN == 1
{% set total_stk = namespace(size=0) %}
{% for partition in partitions %}
{% if "0x" in partition.manifest.stack_size or "0X" in partition.manifest.stack_size %}
@@ -48,20 +54,10 @@
#define {{"%-56s"|format("CONFIG_TFM_NS_AGENT_TZ_STACK_SIZE")}} \
((({{"0x%x"|format(total_stk.size)}} >> CONFIG_TFM_NS_AGENT_TZ_STK_SIZE_SHIFT_FACTOR) + 0x7) & (~0x7))
-{% elif partition_statistics['sfn_partition_num'] > 0
- and partition_statistics['ipc_partition_num'] > 0 %}
-#error "IPC and SFN co-work not supported yet."
-{% else %}
-#error "Invalid partition number input, check configurations."
-{% endif %}
+#endif /* CONFIG_TFM_SPM_BACKEND_IPC == 1 */
#if (CONFIG_TFM_FP > 0) && (CONFIG_TFM_SPM_BACKEND_SFN == 1)
#error "FP is not supported for SFN model."
#endif
-{% if partition_statistics['connection_based_srv_num'] > 0 %}
-/* Connection-based services exist, include the connection-specific API set. */
-#define {{"%-56s"|format("CONFIG_TFM_CONNECTION_BASED_SERVICE_API")}} 1
-{% endif %}
-
#endif /* __CONFIG_IMPL_H__ */
diff --git a/interface/include/psa_interface_redirect.h b/interface/include/psa_interface_redirect.h
index 3c16cdf..ee46d15 100644
--- a/interface/include/psa_interface_redirect.h
+++ b/interface/include/psa_interface_redirect.h
@@ -9,7 +9,7 @@
#include "psa/framework_feature.h"
-#if defined(CONFIG_TFM_PSA_API_SUPERVISOR_CALL)
+#if CONFIG_TFM_PSA_API_SUPERVISOR_CALL == 1
#define psa_framework_version psa_framework_version_svc
#define psa_version psa_version_svc
@@ -35,7 +35,7 @@
#define psa_set_rhandle psa_set_rhandle_svc
#endif /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API */
-#elif defined(CONFIG_TFM_PSA_API_CROSS_CALL)
+#elif CONFIG_TFM_PSA_API_CROSS_CALL == 1
#define psa_framework_version psa_framework_version_cross
#define psa_version psa_version_cross
@@ -68,7 +68,7 @@
#define psa_unmap_outvec psa_unmap_outvec_cross
#endif /* PSA_FRAMEWORK_HAS_MM_IOVEC */
-#elif defined(CONFIG_TFM_PSA_API_SFN_CALL)
+#elif CONFIG_TFM_PSA_API_SFN_CALL == 1
#define psa_framework_version psa_framework_version_sfn
#define psa_version psa_version_sfn
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
diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt
index 5dfcaee..7bb5a00 100644
--- a/tools/CMakeLists.txt
+++ b/tools/CMakeLists.txt
@@ -133,6 +133,7 @@
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tfm_parse_manifest_list.py
-m ${COMBINED_LIST}
-f ${GENERATED_FILE_LISTS}
+ -l ${TFM_ISOLATION_LEVEL}
-o ${CMAKE_BINARY_DIR}/generated
${PARSE_MANIFEST_QUIET_FLAG}
DEPENDS ${TEMPLATE_FILES} ${MANIFEST_FILES}
@@ -146,6 +147,7 @@
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/tfm_parse_manifest_list.py
-m ${COMBINED_LIST}
-f ${GENERATED_FILE_LISTS}
+ -l ${TFM_ISOLATION_LEVEL}
-o ${CMAKE_BINARY_DIR}/generated
${PARSE_MANIFEST_QUIET_FLAG}
RESULT_VARIABLE RET
diff --git a/tools/config_impl.cmake.template b/tools/config_impl.cmake.template
index 4c9dbcc..5aeb360 100644
--- a/tools/config_impl.cmake.template
+++ b/tools/config_impl.cmake.template
@@ -9,29 +9,12 @@
########{{utilities.donotedit_warning}}########
if(TFM_PSA_API)
-{% if partition_statistics['ipc_partition_num'] > 0
- and partition_statistics['sfn_partition_num'] == 0 %}
- set(CONFIG_TFM_SPM_BACKEND_IPC ON PARENT_SCOPE)
+ set(CONFIG_TFM_SPM_BACKEND_SFN {{config_impl['CONFIG_TFM_SPM_BACKEND_SFN']}} PARENT_SCOPE)
+ set(CONFIG_TFM_SPM_BACKEND_IPC {{config_impl['CONFIG_TFM_SPM_BACKEND_IPC']}} PARENT_SCOPE)
- if(TFM_ISOLATION_LEVEL GREATER 1)
- set(CONFIG_TFM_PSA_API_SUPERVISOR_CALL ON PARENT_SCOPE)
- else()
- set(CONFIG_TFM_PSA_API_CROSS_CALL ON PARENT_SCOPE)
- endif()
-{% elif partition_statistics['sfn_partition_num'] > 0
- and partition_statistics['ipc_partition_num'] == 0 %}
- set(CONFIG_TFM_SPM_BACKEND_SFN ON PARENT_SCOPE)
- set(CONFIG_TFM_PSA_API_SFN_CALL ON PARENT_SCOPE)
-
- if(TFM_ISOLATION_LEVEL GREATER 1)
- message(FATAL_ERROR "High isolation level SFN model is not supported.")
- endif()
-{% elif partition_statistics['sfn_partition_num'] > 0
- and partition_statistics['ipc_partition_num'] > 0 %}
- message(FATAL_ERROR "IPC and SFN co-work not supported yet.")
-{% else %}
- message(FATAL_ERROR "Invalid partition number input, check configurations.")
-{% endif %}
+ set(CONFIG_TFM_PSA_API_SFN_CALL {{config_impl['CONFIG_TFM_PSA_API_SFN_CALL']}} PARENT_SCOPE)
+ set(CONFIG_TFM_PSA_API_CROSS_CALL {{config_impl['CONFIG_TFM_PSA_API_CROSS_CALL']}} PARENT_SCOPE)
+ set(CONFIG_TFM_PSA_API_SUPERVISOR_CALL {{config_impl['CONFIG_TFM_PSA_API_SUPERVISOR_CALL']}} PARENT_SCOPE)
if((CONFIG_TFM_FP GREATER 0) AND CONFIG_TFM_SPM_BACKEND_SFN)
message(FATAL_ERROR "FP is not supported for SFN model.")
diff --git a/tools/tfm_parse_manifest_list.py b/tools/tfm_parse_manifest_list.py
index b6a687e..32b06dd 100644
--- a/tools/tfm_parse_manifest_list.py
+++ b/tools/tfm_parse_manifest_list.py
@@ -117,7 +117,7 @@
return partition_manifest
-def process_partition_manifests(manifest_lists):
+def process_partition_manifests(manifest_lists, isolation_level):
"""
Parse the input manifest lists, generate the data base for genereated files
and generate manifest header files.
@@ -147,6 +147,14 @@
'ipc_partition_num': 0,
'sfn_partition_num': 0
}
+ config_impl = {
+ 'CONFIG_TFM_SPM_BACKEND_SFN' : '0',
+ 'CONFIG_TFM_SPM_BACKEND_IPC' : '0',
+ 'CONFIG_TFM_PSA_API_SFN_CALL' : '0',
+ 'CONFIG_TFM_PSA_API_CROSS_CALL' : '0',
+ 'CONFIG_TFM_PSA_API_SUPERVISOR_CALL' : '0',
+ 'CONFIG_TFM_CONNECTION_BASED_SERVICE_API' : '0'
+ }
# Get all the manifests information as a dictionary
for i, item in enumerate(manifest_lists):
@@ -256,8 +264,34 @@
all_manifests[idx]['pid'] = pid
pid_list.append(pid)
+ # Set up configurations
+ if partition_statistics['ipc_partition_num'] == 0 and \
+ partition_statistics['sfn_partition_num'] > 0:
+ if isolation_level > 1:
+ print('High isolation level SFN model is not supported.')
+ exit(1)
+ config_impl['CONFIG_TFM_SPM_BACKEND_SFN'] = '1'
+ config_impl['CONFIG_TFM_PSA_API_SFN_CALL'] = '1'
+ elif partition_statistics['ipc_partition_num'] > 0 and \
+ partition_statistics['sfn_partition_num'] == 0:
+ config_impl['CONFIG_TFM_SPM_BACKEND_IPC'] = '1'
+ if isolation_level > 1:
+ config_impl['CONFIG_TFM_PSA_API_SUPERVISOR_CALL'] = '1'
+ else:
+ config_impl['CONFIG_TFM_PSA_API_CROSS_CALL'] = '1'
+ elif partition_statistics['ipc_partition_num'] > 0 and \
+ partition_statistics['sfn_partition_num'] > 0:
+ print('IPC and SFN co-work not supported yet.')
+ exit(1)
+ else:
+ print('Invalid partition number input, check configurations.')
+ exit(1)
+
+ if partition_statistics['connection_based_srv_num'] > 0:
+ config_impl['CONFIG_TFM_CONNECTION_BASED_SERVICE_API'] = 1
+
context['partitions'] = partition_list
- context['partition_statistics'] = partition_statistics
+ context['config_impl'] = config_impl
context['stateless_services'] = process_stateless_services(partition_list)
return context
@@ -485,6 +519,14 @@
, required=True
, metavar='file-list'
, help='These files descripe the file list to generate')
+
+ parser.add_argument('-l', '--isolation-level'
+ , dest='isolation_level'
+ , required=True
+ , choices=['1', '2', '3']
+ , metavar='isolation-level'
+ , help='The isolation level')
+
parser.add_argument('-q', '--quiet'
, dest='quiet'
, required=False
@@ -537,7 +579,7 @@
"""
os.chdir(os.path.join(sys.path[0], '..'))
- context = process_partition_manifests(manifest_lists)
+ context = process_partition_manifests(manifest_lists, int(args.isolation_level))
utilities = {}
utilities['donotedit_warning'] = donotedit_warning