aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Hu <david.hu@arm.com>2020-11-27 20:59:52 +0800
committerDavid Hu <david.hu@arm.com>2021-01-22 02:21:55 +0000
commit8b526d4544a8d1e3aa98ac2101b1f818cc0dd888 (patch)
treeaafcc530e661ec27e640c8e8b2975f53c6988cf9
parent04969a400441dd2e41212a4e2937d17873bb3765 (diff)
downloadtrusted-firmware-m-8b526d4544a8d1e3aa98ac2101b1f818cc0dd888.tar.gz
Build: Improve the setting of number of mailbox queue slots
Move configuration of number of mailbox queue slots from platform's device_cfg.h into a common header file tfm_mailbox_config.h. tfm_mailbox_config.h is automatically generated during build. The value of NUM_MAILBOX_QUEUE_SLOT is passed from build configuration and then set in tfm_mailbox_config.h. Change-Id: I9a3ac465b71b316accf6cd41cea80745eec8607c Signed-off-by: David Hu <david.hu@arm.com>
-rw-r--r--cmake/install.cmake1
-rw-r--r--config/check_config.cmake3
-rw-r--r--config/config_default.cmake1
-rw-r--r--interface/CMakeLists.txt9
-rw-r--r--interface/include/multi_core/tfm_mailbox.h35
-rw-r--r--interface/include/multi_core/tfm_mailbox_config.h.in36
-rw-r--r--platform/ext/target/cypress/psoc64/Device/Config/device_cfg.h6
-rw-r--r--platform/ext/target/cypress/psoc64/config.cmake3
8 files changed, 54 insertions, 40 deletions
diff --git a/cmake/install.cmake b/cmake/install.cmake
index 981bfba1ee..106369ec85 100644
--- a/cmake/install.cmake
+++ b/cmake/install.cmake
@@ -56,6 +56,7 @@ if (TFM_MULTI_CORE_TOPOLOGY)
install(FILES ${INTERFACE_INC_DIR}/multi_core/tfm_multi_core_api.h
${INTERFACE_INC_DIR}/multi_core/tfm_ns_mailbox.h
${INTERFACE_INC_DIR}/multi_core/tfm_mailbox.h
+ ${INTERFACE_INC_DIR}/multi_core/tfm_mailbox_config.h
DESTINATION ${INSTALL_INTERFACE_INC_DIR})
else()
install(FILES ${CMAKE_BINARY_DIR}/generated/interface/include/tfm_veneers.h
diff --git a/config/check_config.cmake b/config/check_config.cmake
index 6fb8cdd6cb..395f4a51f6 100644
--- a/config/check_config.cmake
+++ b/config/check_config.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -29,6 +29,7 @@ tfm_invalid_config(TFM_ISOLATION_LEVEL GREATER 1 AND NOT TFM_PSA_API)
tfm_invalid_config(TFM_MULTI_CORE_TOPOLOGY AND NOT TFM_PSA_API)
tfm_invalid_config(TFM_MULTI_CORE_MULTI_CLIENT_CALL AND NOT TFM_MULTI_CORE_TOPOLOGY)
+tfm_invalid_config(NUM_MAILBOX_QUEUE_SLOT GREATER 1 AND NOT TFM_MULTI_CORE_MULTI_CLIENT_CALL)
tfm_invalid_config(TEST_S AND TEST_PSA_API)
tfm_invalid_config(TEST_NS AND TEST_PSA_API)
diff --git a/config/config_default.cmake b/config/config_default.cmake
index ef002db933..4438def80e 100644
--- a/config/config_default.cmake
+++ b/config/config_default.cmake
@@ -71,6 +71,7 @@ set(MCUBOOT_NS_IMAGE_MIN_VER 0.0.0+0 CACHE STRING "Minimum ver
set(TFM_MULTI_CORE_TOPOLOGY OFF CACHE BOOL "Whether to build for a dual-cpu architecture")
set(TFM_MULTI_CORE_MULTI_CLIENT_CALL OFF CACHE BOOL "Whether to enable multiple PSA client calls feature")
+set(NUM_MAILBOX_QUEUE_SLOT 1 CACHE BOOL "Number of mailbox queue slots")
set(DEBUG_AUTHENTICATION CHIP_DEFAULT CACHE STRING "Debug authentication setting. [CHIP_DEFAULT, NONE, NS_ONLY, FULL")
set(SECURE_UART1 OFF CACHE BOOL "Enable secure UART1")
diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt
index 0351754767..188e651c95 100644
--- a/interface/CMakeLists.txt
+++ b/interface/CMakeLists.txt
@@ -61,3 +61,12 @@ target_sources(tfm_secure_api
$<$<BOOL:${TFM_PSA_API}>:${CMAKE_CURRENT_SOURCE_DIR}/src/psa/psa_lifecycle.c>
${CMAKE_CURRENT_SOURCE_DIR}/src/log/tfm_log_raw.c
)
+
+###################### Export configurations to NS #############################
+
+if (TFM_MULTI_CORE_TOPOLOGY OR FORWARD_PROT_MSG)
+ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core/tfm_mailbox_config.h.in
+ ${CMAKE_CURRENT_SOURCE_DIR}/include/multi_core/tfm_mailbox_config.h
+ NEWLINE_STYLE UNIX
+ )
+endif()
diff --git a/interface/include/multi_core/tfm_mailbox.h b/interface/include/multi_core/tfm_mailbox.h
index 45eb97ef21..5824543bc5 100644
--- a/interface/include/multi_core/tfm_mailbox.h
+++ b/interface/include/multi_core/tfm_mailbox.h
@@ -18,45 +18,14 @@
#include <stdbool.h>
#include <stdint.h>
#include <stddef.h>
-#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
-#include "device_cfg.h"
-#endif
+
#include "psa/client.h"
+#include "tfm_mailbox_config.h"
#ifdef __cplusplus
extern "C" {
#endif
-/*
- * If multiple outstanding NS PSA Client calls is enabled, multi-core platform
- * should define the number of mailbox queue slots NUM_MAILBOX_QUEUE_SLOT in
- * platform device_cfg.h.
- * Otherwise, NUM_MAILBOX_QUEUE_SLOT is defined as 1.
- */
-#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
-#ifndef NUM_MAILBOX_QUEUE_SLOT
-#error "Error: Platform doesn't define NUM_MAILBOX_QUEUE_SLOT for mailbox queue"
-#endif
-
-#if (NUM_MAILBOX_QUEUE_SLOT < 2)
-#error "Error: Invalid NUM_MAILBOX_QUEUE_SLOT. The value should be more than 1"
-#endif
-
-/*
- * The number of slots should be no more than the number of bits in
- * mailbox_queue_status_t.
- * Here the value is hardcoded. A better way is to define a sizeof() to
- * calculate the bits in mailbox_queue_status_t and dump it with pragma message.
- */
-#if (NUM_MAILBOX_QUEUE_SLOT > 32)
-#error "Error: Invalid NUM_MAILBOX_QUEUE_SLOT. The value should be no more than 32"
-#endif
-#else /* TFM_MULTI_CORE_MULTI_CLIENT_CALL */
-/* Force the number of mailbox queue slots as 1. */
-#undef NUM_MAILBOX_QUEUE_SLOT
-#define NUM_MAILBOX_QUEUE_SLOT (1)
-#endif /* TFM_MULTI_CORE_MULTI_CLIENT_CALL */
-
/* PSA client call type value */
#define MAILBOX_PSA_FRAMEWORK_VERSION (0x1)
#define MAILBOX_PSA_VERSION (0x2)
diff --git a/interface/include/multi_core/tfm_mailbox_config.h.in b/interface/include/multi_core/tfm_mailbox_config.h.in
new file mode 100644
index 0000000000..bd85ef6914
--- /dev/null
+++ b/interface/include/multi_core/tfm_mailbox_config.h.in
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2020-2021, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef _TFM_MAILBOX_CONFIG_
+#define _TFM_MAILBOX_CONFIG_
+
+/*
+ * \note Don't modify this file. Change the build configuration value
+ * and re-build TF-M SPE side to update the value.
+ */
+
+/* Get number of mailbox queue slots from build configuration */
+#cmakedefine NUM_MAILBOX_QUEUE_SLOT @NUM_MAILBOX_QUEUE_SLOT@
+
+#ifndef NUM_MAILBOX_QUEUE_SLOT
+#define NUM_MAILBOX_QUEUE_SLOT 1
+#endif
+
+#if (NUM_MAILBOX_QUEUE_SLOT < 1)
+#error "Error: Invalid NUM_MAILBOX_QUEUE_SLOT. The value should be >= 1"
+#endif
+
+/*
+ * The number of slots should be no more than the number of bits in
+ * mailbox_queue_status_t.
+ * Here the value is hardcoded. A better way is to define a sizeof() to
+ * calculate the bits in mailbox_queue_status_t and dump it with pragma message.
+ */
+#if (NUM_MAILBOX_QUEUE_SLOT > 32)
+#error "Error: Invalid NUM_MAILBOX_QUEUE_SLOT. The value should be <= 32"
+#endif
+
+#endif /* _TFM_MAILBOX_CONFIG_ */
diff --git a/platform/ext/target/cypress/psoc64/Device/Config/device_cfg.h b/platform/ext/target/cypress/psoc64/Device/Config/device_cfg.h
index 021b124744..eeebdc0d62 100644
--- a/platform/ext/target/cypress/psoc64/Device/Config/device_cfg.h
+++ b/platform/ext/target/cypress/psoc64/Device/Config/device_cfg.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2017-2018 Arm Limited
+ * Copyright (c) 2017-2021 Arm Limited
* Copyright (c) 2020, Cypress Semiconductor Corporation. All rights reserved.
*
* Licensed under the Apache License Version 2.0 (the "License");
@@ -34,8 +34,4 @@
#define DEFAULT_UART_BAUDRATE 115200
-#ifdef TFM_MULTI_CORE_MULTI_CLIENT_CALL
-#define NUM_MAILBOX_QUEUE_SLOT 4
-#endif
-
#endif /* __ARM_LTD_DEVICE_CFG_H__ */
diff --git a/platform/ext/target/cypress/psoc64/config.cmake b/platform/ext/target/cypress/psoc64/config.cmake
index d4411a8316..24bc3c09e4 100644
--- a/platform/ext/target/cypress/psoc64/config.cmake
+++ b/platform/ext/target/cypress/psoc64/config.cmake
@@ -1,5 +1,5 @@
#-------------------------------------------------------------------------------
-# Copyright (c) 2020, Arm Limited. All rights reserved.
+# Copyright (c) 2020-2021, Arm Limited. All rights reserved.
#
# SPDX-License-Identifier: BSD-3-Clause
#
@@ -15,6 +15,7 @@ set(TFM_NS_CLIENT_IDENTIFICATION OFF CACHE BOOL "Enable NS c
set(TFM_MULTI_CORE_TOPOLOGY ON CACHE BOOL "Whether to build for a dual-cpu architecture")
set(TFM_MULTI_CORE_MULTI_CLIENT_CALL ON CACHE BOOL "Whether to enable multiple PSA client calls feature")
+set(NUM_MAILBOX_QUEUE_SLOT 4 CACHE BOOL "Number of mailbox queue slots")
set(PLATFORM_DUMMY_ATTEST_HAL FALSE CACHE BOOL "Use dummy attest hal implementation. Should not be used in production.")
set(PLATFORM_DUMMY_NV_COUNTERS FALSE CACHE BOOL "Use dummy nv counter implementation. Should not be used in production.")