Build: Change NS build to be one of mailbox or TZ
Refactors the NS build so that it is either built for mailbox or for
TrustZone, but not both. TF-M allows platforms to have both TZ and
mailbox agents, but the NS build must be done for the local and remote
cores separately. Having both the mailbox and TZ APIs built into the
same binary results in link errors due to multiple definition of the
PSA functions.
The TFM_NS_MAILBOX_API flag is set ON by default if TF-M was built with
the mailbox agent and not the TZ agent, OFF by default otherwise. The
default only needs to be overridden to do a mailbox build on platforms
with both agents.
Change-Id: Ic296dd7cb4141ff5ec5f008962c9fe9459ecff5f
Signed-off-by: Jamie Fox <jamie.fox@arm.com>
diff --git a/app_broker/CMakeLists.txt b/app_broker/CMakeLists.txt
index b5bd5ec..eaf4b3f 100644
--- a/app_broker/CMakeLists.txt
+++ b/app_broker/CMakeLists.txt
@@ -24,6 +24,16 @@
# Therefore, NS library can be shared and re-used in other downstream projects, without specially
# handling the differences of dependencies and paths in NS builds.
+# Choose whether to use the TF-M mailbox API or TrustZone API to communicate
+# with the SPE based on the TF-M config. If the TF-M config provides both, then
+# default to the TrustZone APIs. This default needs to be overridden to do a
+# mailbox build on platforms with both agents.
+if (TFM_PARTITION_NS_AGENT_MAILBOX AND NOT CONFIG_TFM_USE_TRUSTZONE)
+ set(TFM_NS_MAILBOX_API ON CACHE BOOL "Build NS code for a remote processing element using mailbox APIs")
+else()
+ set(TFM_NS_MAILBOX_API OFF CACHE BOOL "Build NS code for a remote processing element using mailbox APIs")
+endif()
+
# Interface files exported from TF-M secure build
set(SPE_INSTALL_INTERFACE_SRC ${CONFIG_SPE_PATH}/interface/src)
set(SPE_INSTALL_INTERFACE_INC ${CONFIG_SPE_PATH}/interface/include)
@@ -76,7 +86,7 @@
target_sources(RTX_OS
INTERFACE
# Provide TZ context management stub to RTOS if protected by Trustzone
- $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${APP_LIB_DIR}/nsid_manager/tz_shim_layer.c>
+ $<$<NOT:$<BOOL:${TFM_NS_MAILBOX_API}>>:${APP_LIB_DIR}/nsid_manager/tz_shim_layer.c>
# Provide CMSIS-RTX config implementation
os_config_cmsis_rtx.c
)
@@ -87,7 +97,7 @@
)
# Multi-core library
-if(TFM_PARTITION_NS_AGENT_MAILBOX)
+if(TFM_NS_MAILBOX_API)
add_library(ns_multi_core STATIC)
target_sources(ns_multi_core
@@ -135,13 +145,13 @@
target_include_directories(platform_ns
PUBLIC
- $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:${SPE_INSTALL_INTERFACE_INC}/multi_core>
+ $<$<BOOL:${TFM_NS_MAILBOX_API}>:${SPE_INSTALL_INTERFACE_INC}/multi_core>
${SPE_INSTALL_INTERFACE_INC}
)
target_compile_definitions(platform_ns
PUBLIC
- $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:TFM_MULTI_CORE_NS_OS>
+ $<$<BOOL:${TFM_NS_MAILBOX_API}>:TFM_MULTI_CORE_NS_OS>
)
################# Update NS interface with NS settings ################
@@ -149,7 +159,7 @@
target_sources(tfm_api_ns
PRIVATE
# NS specific implementation of NS interface dispatcher
- $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:${SPE_INSTALL_INTERFACE_SRC}/os_wrapper/tfm_ns_interface_rtos.c>
+ $<$<NOT:$<BOOL:${TFM_NS_MAILBOX_API}>>:${SPE_INSTALL_INTERFACE_SRC}/os_wrapper/tfm_ns_interface_rtos.c>
)
target_compile_definitions(tfm_api_ns
@@ -159,7 +169,9 @@
target_link_libraries(tfm_api_ns
PRIVATE
- $<$<BOOL:${CONFIG_TFM_USE_TRUSTZONE}>:os_wrapper>
+ $<$<BOOL:${TFM_NS_MAILBOX_API}>:tfm_api_ns_mailbox>
+ $<$<NOT:$<BOOL:${TFM_NS_MAILBOX_API}>>:tfm_api_ns_tz>
+ $<$<NOT:$<BOOL:${TFM_NS_MAILBOX_API}>>:os_wrapper>
)
######################## NS application broker ########################
@@ -184,10 +196,11 @@
RTX_OS
tfm_api_ns
tfm_ns_log
- $<$<BOOL:${TFM_PARTITION_NS_AGENT_MAILBOX}>:ns_multi_core>
+ $<$<BOOL:${TFM_NS_MAILBOX_API}>:ns_multi_core>
)
target_compile_definitions(tfm_test_broker
PUBLIC
$<$<BOOL:${TFM_NS_REG_TEST}>:TFM_NS_REG_TEST>
+ $<$<BOOL:${TFM_NS_MAILBOX_API}>:TFM_NS_MAILBOX_API>
)