SPM: Add build config for IPC-only FF-M APIs
Use macro "CONFIG_TFM_SPM_BACKEND_IPC" to control FF-M APIs
and SPM APIs that are only used by IPC backend:
- psa_get()
- psa_reply()
- spm_get_handle_by_signal()
Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
Change-Id: I86a7679a325e72ee9eaa7c323cb6965a27975ae3
diff --git a/secure_fw/spm/cmsis_psa/spm_ipc.c b/secure_fw/spm/cmsis_psa/spm_ipc.c
index c6a26bf..7a3fc55 100755
--- a/secure_fw/spm/cmsis_psa/spm_ipc.c
+++ b/secure_fw/spm/cmsis_psa/spm_ipc.c
@@ -10,6 +10,7 @@
#include <stdbool.h>
#include "aapcs_local.h"
#include "bitops.h"
+#include "config_impl.h"
#include "critical_section.h"
#include "current.h"
#include "fih.h"
@@ -199,6 +200,8 @@
/* Partition management functions */
+/* This API is only used in IPC backend. */
+#if CONFIG_TFM_SPM_BACKEND_IPC == 1
struct conn_handle_t *spm_get_handle_by_signal(struct partition_t *p_ptn,
psa_signal_t signal)
{
@@ -230,6 +233,7 @@
return p_msg_iter;
}
+#endif
struct service_t *tfm_spm_get_service_by_sid(uint32_t sid)
{
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 1c41851..64dd210 100644
--- a/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
+++ b/secure_fw/spm/cmsis_psa/tfm_core_svcalls_ipc.c
@@ -49,9 +49,6 @@
break;
case TFM_SVC_PSA_WAIT:
return tfm_spm_partition_psa_wait((psa_signal_t)ctx[0], ctx[1]);
- case TFM_SVC_PSA_GET:
- return tfm_spm_partition_psa_get((psa_signal_t)ctx[0],
- (psa_msg_t *)ctx[1]);
case TFM_SVC_PSA_READ:
return tfm_spm_partition_psa_read((psa_handle_t)ctx[0], ctx[1],
(void *)ctx[2], (size_t)ctx[3]);
@@ -62,9 +59,6 @@
tfm_spm_partition_psa_write((psa_handle_t)ctx[0], ctx[1],
(void *)ctx[2], (size_t)ctx[3]);
break;
- case TFM_SVC_PSA_REPLY:
- tfm_spm_partition_psa_reply((psa_handle_t)ctx[0], (psa_status_t)ctx[1]);
- break;
case TFM_SVC_PSA_NOTIFY:
tfm_spm_partition_psa_notify((int32_t)ctx[0]);
break;
@@ -91,6 +85,15 @@
tfm_spm_partition_psa_set_rhandle((psa_handle_t)ctx[0], (void *)ctx[1]);
break;
#endif /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API */
+/* These APIs are only used in IPC backend. */
+#if CONFIG_TFM_SPM_BACKEND_IPC == 1
+ case TFM_SVC_PSA_GET:
+ return tfm_spm_partition_psa_get((psa_signal_t)ctx[0],
+ (psa_msg_t *)ctx[1]);
+ case TFM_SVC_PSA_REPLY:
+ tfm_spm_partition_psa_reply((psa_handle_t)ctx[0], (psa_status_t)ctx[1]);
+ break;
+#endif /* CONFIG_TFM_SPM_BACKEND_IPC == 1 */
#if TFM_SP_LOG_RAW_ENABLED
case TFM_SVC_OUTPUT_UNPRIV_STRING:
return tfm_hal_output_spm_log((const char *)ctx[0], ctx[1]);
diff --git a/secure_fw/spm/ffm/psa_api.c b/secure_fw/spm/ffm/psa_api.c
index 08ead03..e115a83 100644
--- a/secure_fw/spm/ffm/psa_api.c
+++ b/secure_fw/spm/ffm/psa_api.c
@@ -7,6 +7,7 @@
#include <stdint.h>
#include "bitops.h"
+#include "config_impl.h"
#include "critical_section.h"
#include "psa/lifecycle.h"
#include "psa/service.h"
@@ -470,6 +471,8 @@
return partition->signals_asserted & signal_mask;
}
+/* This API is only used in IPC backend. */
+#if CONFIG_TFM_SPM_BACKEND_IPC == 1
psa_status_t tfm_spm_partition_psa_get(psa_signal_t signal, psa_msg_t *msg)
{
struct conn_handle_t *tmp_msg = NULL;
@@ -528,6 +531,7 @@
return PSA_SUCCESS;
}
+#endif
size_t tfm_spm_partition_psa_read(psa_handle_t msg_handle, uint32_t invec_idx,
void *buffer, size_t num_bytes)
diff --git a/secure_fw/spm/include/ffm/psa_api.h b/secure_fw/spm/include/ffm/psa_api.h
index 97ab352..ddd7769 100644
--- a/secure_fw/spm/include/ffm/psa_api.h
+++ b/secure_fw/spm/include/ffm/psa_api.h
@@ -140,6 +140,8 @@
psa_signal_t tfm_spm_partition_psa_wait(psa_signal_t signal_mask,
uint32_t timeout);
+/* This API is only used in IPC backend. */
+#if CONFIG_TFM_SPM_BACKEND_IPC == 1
/**
* \brief Function body of \ref psa_get.
*
@@ -160,6 +162,7 @@
* reference.
*/
psa_status_t tfm_spm_partition_psa_get(psa_signal_t signal, psa_msg_t *msg);
+#endif
/**
* \brief Function body of \ref psa_read.