aboutsummaryrefslogtreecommitdiff
path: root/interface
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 /interface
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>
Diffstat (limited to 'interface')
-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
3 files changed, 47 insertions, 33 deletions
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_ */