diff --git a/modules/trusted-firmware-m/CMakeLists.txt b/modules/trusted-firmware-m/CMakeLists.txt index b5b5880c3a87ee..da37e12e9f894e 100644 --- a/modules/trusted-firmware-m/CMakeLists.txt +++ b/modules/trusted-firmware-m/CMakeLists.txt @@ -181,7 +181,7 @@ function(trusted_firmware_build) ) add_library(tfm_api - ${ZEPHYR_TRUSTED_FIRMWARE_M_MODULE_DIR}/tf-m-tests/app/os_wrapper_cmsis_rtos_v2.c + ${ZEPHYR_BASE}/modules/trusted-firmware-m/src/zephyr_tfm_log.c ) target_include_directories(tfm_api @@ -256,6 +256,8 @@ if (CONFIG_BUILD_WITH_TFM) ) zephyr_link_libraries(tfm_api) + zephyr_sources( + ${ZEPHYR_BASE}/modules/trusted-firmware-m/src/zephyr_tfm_ns_interface.c) # Set default image versions if not defined elsewhere if (NOT DEFINED TFM_IMAGE_VERSION_S) diff --git a/modules/trusted-firmware-m/src/zephyr_tfm_log.c b/modules/trusted-firmware-m/src/zephyr_tfm_log.c new file mode 100644 index 00000000000000..f5a74196f0740c --- /dev/null +++ b/modules/trusted-firmware-m/src/zephyr_tfm_log.c @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2021 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include + +int tfm_log_printf(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + vprintk(fmt, ap); + va_end(ap); + + return 0; +} diff --git a/samples/tfm_integration/psa_level_1/src/tfm_ipc.c b/modules/trusted-firmware-m/src/zephyr_tfm_ns_interface.c similarity index 79% rename from samples/tfm_integration/psa_level_1/src/tfm_ipc.c rename to modules/trusted-firmware-m/src/zephyr_tfm_ns_interface.c index 1aad8ee3efd82c..1e81461137143d 100644 --- a/samples/tfm_integration/psa_level_1/src/tfm_ipc.c +++ b/modules/trusted-firmware-m/src/zephyr_tfm_ns_interface.c @@ -1,19 +1,19 @@ /* * Copyright (c) 2019,2020 Linaro Limited + * Copyright (c) 2021 Nordic Semiconductor ASA * * SPDX-License-Identifier: Apache-2.0 */ #include +#include -#include "tfm_api.h" -#include "tfm_ns_interface.h" K_MUTEX_DEFINE(tfm_mutex); int32_t tfm_ns_interface_dispatch(veneer_fn fn, - uint32_t arg0, uint32_t arg1, - uint32_t arg2, uint32_t arg3) + uint32_t arg0, uint32_t arg1, + uint32_t arg2, uint32_t arg3) { int32_t result; diff --git a/samples/tfm_integration/psa_level_1/CMakeLists.txt b/samples/tfm_integration/psa_level_1/CMakeLists.txt index afcbe6c6d5865e..f958ce6593c1e8 100644 --- a/samples/tfm_integration/psa_level_1/CMakeLists.txt +++ b/samples/tfm_integration/psa_level_1/CMakeLists.txt @@ -14,7 +14,6 @@ target_sources(app PRIVATE src/main.c) target_sources(app PRIVATE src/psa_attestation.c) target_sources(app PRIVATE src/psa_crypto.c) target_sources(app PRIVATE src/shell.c) -target_sources(app PRIVATE src/tfm_ipc.c) target_sources(app PRIVATE src/util_app_cfg.c) target_sources(app PRIVATE src/util_app_log.c) target_sources(app PRIVATE src/util_sformat.c) diff --git a/samples/tfm_integration/tfm_ipc/src/main.c b/samples/tfm_integration/tfm_ipc/src/main.c index e2551f00db41d4..18e8b17675c738 100644 --- a/samples/tfm_integration/tfm_ipc/src/main.c +++ b/samples/tfm_integration/tfm_ipc/src/main.c @@ -13,33 +13,6 @@ #include "psa_manifest/sid.h" #endif -K_MUTEX_DEFINE(tfm_mutex); - -int32_t tfm_ns_interface_dispatch(veneer_fn fn, - uint32_t arg0, uint32_t arg1, - uint32_t arg2, uint32_t arg3) -{ - int32_t result; - - /* TFM request protected by NS lock */ - if (k_mutex_lock(&tfm_mutex, K_FOREVER) != 0) { - return (int32_t)TFM_ERROR_GENERIC; - } - - result = fn(arg0, arg1, arg2, arg3); - - k_mutex_unlock(&tfm_mutex); - - return result; -} - -enum tfm_status_e tfm_ns_interface_init(void) -{ - /* The static K_MUTEX_DEFINE handles mutex init, so just return. */ - - return TFM_SUCCESS; -} - /** * \brief Retrieve the version of the PSA Framework API. *