SPM: Set features with config header file

Signed-off-by: Xinyu Zhang <xinyu.zhang@arm.com>
Change-Id: Ie9dd99456a3ad8cb3d7601d484c0f396b201c448
diff --git a/secure_fw/spm/CMakeLists.txt b/secure_fw/spm/CMakeLists.txt
index 5361d97..bdc6cf9 100755
--- a/secure_fw/spm/CMakeLists.txt
+++ b/secure_fw/spm/CMakeLists.txt
@@ -78,6 +78,7 @@
     PRIVATE
         platform_s
         tfm_boot_status
+        tfm_config
         tfm_partitions
         tfm_fih_headers
         tfm_sprt
@@ -91,10 +92,8 @@
         $<$<AND:$<BOOL:${BL2}>,$<BOOL:${CONFIG_TFM_BOOT_STORE_MEASUREMENTS}>>:BOOT_DATA_AVAILABLE>
         $<$<BOOL:${CONFIG_TFM_HALT_ON_CORE_PANIC}>:CONFIG_TFM_HALT_ON_CORE_PANIC>
         $<$<BOOL:${TFM_NS_MANAGE_NSID}>:TFM_NS_MANAGE_NSID>
-        CONFIG_TFM_CONN_HANDLE_MAX_NUM=${CONFIG_TFM_CONN_HANDLE_MAX_NUM}
         $<$<STREQUAL:${CONFIG_TFM_FLOAT_ABI},hard>:CONFIG_TFM_FLOAT_ABI=2>
         $<$<STREQUAL:${CONFIG_TFM_FLOAT_ABI},soft>:CONFIG_TFM_FLOAT_ABI=0>
-        $<$<BOOL:${CONFIG_TFM_DOORBELL_API}>:CONFIG_TFM_DOORBELL_API=1>
         $<$<BOOL:${CONFIG_TFM_STACK_WATERMARKS}>:CONFIG_TFM_STACK_WATERMARKS>
 )
 
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_cross.c b/secure_fw/spm/cmsis_psa/psa_interface_cross.c
index 5e851ec..5697f90 100644
--- a/secure_fw/spm/cmsis_psa/psa_interface_cross.c
+++ b/secure_fw/spm/cmsis_psa/psa_interface_cross.c
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 #include "compiler_ext_defs.h"
+#include "config_spm.h"
 #include "ffm/psa_api.h"
 #include "spm_ipc.h"
 #include "svc_num.h"
diff --git a/secure_fw/spm/cmsis_psa/psa_interface_svc.c b/secure_fw/spm/cmsis_psa/psa_interface_svc.c
index 3674e24..28e27bd 100644
--- a/secure_fw/spm/cmsis_psa/psa_interface_svc.c
+++ b/secure_fw/spm/cmsis_psa/psa_interface_svc.c
@@ -7,6 +7,7 @@
 
 #include <stdint.h>
 #include "compiler_ext_defs.h"
+#include "config_spm.h"
 #include "svc_num.h"
 #include "tfm_psa_call_pack.h"
 #include "utilities.h"
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index d5263dc..2354e2b 100755
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -13,6 +13,7 @@
 #include <stdint.h>
 #include "bitops.h"
 #include "config_impl.h"
+#include "config_spm.h"
 #include "critical_section.h"
 #include "current.h"
 #include "fih.h"
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.h b/secure_fw/spm/cmsis_psa/spm_ipc.h
index 9a710a2..767914b 100644
--- a/secure_fw/spm/cmsis_psa/spm_ipc.h
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.h
@@ -13,6 +13,7 @@
 
 #include <stdint.h>
 #include "config_impl.h"
+#include "config_spm.h"
 #include "current.h"
 #include "tfm_arch.h"
 #include "lists.h"
diff --git a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
index 73a9fff..8e4b309 100644
--- a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
+++ b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
@@ -6,6 +6,7 @@
  */
 
 #include <string.h>
+#include "config_spm.h"
 #include "region.h"
 #include "spm_ipc.h"
 #include "svc_num.h"
diff --git a/secure_fw/spm/ffm/backend_ipc.c b/secure_fw/spm/ffm/backend_ipc.c
index c9b4563..a284166 100644
--- a/secure_fw/spm/ffm/backend_ipc.c
+++ b/secure_fw/spm/ffm/backend_ipc.c
@@ -12,6 +12,7 @@
 #include "aapcs_local.h"
 #include "critical_section.h"
 #include "compiler_ext_defs.h"
+#include "config_spm.h"
 #include "runtime_defs.h"
 #include "ffm/stack_watermark.h"
 #include "spm_ipc.h"
diff --git a/secure_fw/spm/ffm/psa_api.c b/secure_fw/spm/ffm/psa_api.c
index 6b60e53..59b82a8 100644
--- a/secure_fw/spm/ffm/psa_api.c
+++ b/secure_fw/spm/ffm/psa_api.c
@@ -11,6 +11,7 @@
 #include <stdint.h>
 #include "bitops.h"
 #include "config_impl.h"
+#include "config_spm.h"
 #include "critical_section.h"
 #include "psa/lifecycle.h"
 #include "psa/service.h"
diff --git a/secure_fw/spm/ffm/utilities.c b/secure_fw/spm/ffm/utilities.c
index cdc5d7c..c9a0c67 100644
--- a/secure_fw/spm/ffm/utilities.c
+++ b/secure_fw/spm/ffm/utilities.c
@@ -5,6 +5,7 @@
  *
  */
 #include <inttypes.h>
+#include "config_spm.h"
 #include "fih.h"
 #include "utilities.h"
 #include "tfm_hal_platform.h"
diff --git a/secure_fw/spm/include/config_spm.h b/secure_fw/spm/include/config_spm.h
new file mode 100644
index 0000000..728301f
--- /dev/null
+++ b/secure_fw/spm/include/config_spm.h
@@ -0,0 +1,33 @@
+/*
+ * Copyright (c) 2022, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __CONFIG_PARTITION_SPM_H__
+#define __CONFIG_PARTITION_SPM_H__
+
+#include "config_impl.h"
+#include "config_tfm.h"
+
+/* The maximal number of secure services that are connected or requested at the same time */
+#ifndef CONFIG_TFM_CONN_HANDLE_MAX_NUM
+#pragma message ("CONFIG_TFM_CONN_HANDLE_MAX_NUM is defaulted to 8. Please check and set it explicitly.")
+#define CONFIG_TFM_CONN_HANDLE_MAX_NUM 8
+#endif
+
+/* Enable the doorbell APIs */
+#ifndef CONFIG_TFM_DOORBELL_API
+#pragma message ("CONFIG_TFM_DOORBELL_API is defaulted to 1. Please check and set it explicitly.")
+#define CONFIG_TFM_DOORBELL_API        1
+#endif
+
+/* Disable doorbell for SFN backend */
+#if CONFIG_TFM_SPM_BACKEND_SFN == 1
+#pragma message ("CONFIG_TFM_DOORBELL_API is redefined to 0.")
+#undef  CONFIG_TFM_DOORBELL_API
+#define CONFIG_TFM_DOORBELL_API        0
+#endif
+
+#endif /* __CONFIG_PARTITION_SPM_H__ */
diff --git a/secure_fw/spm/include/ffm/psa_api.h b/secure_fw/spm/include/ffm/psa_api.h
index 9f8354b..868c178 100644
--- a/secure_fw/spm/include/ffm/psa_api.h
+++ b/secure_fw/spm/include/ffm/psa_api.h
@@ -10,6 +10,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
+#include "config_spm.h"
 #include "psa/client.h"
 #include "psa/service.h"