SPM: Add build config for FF-M interrupt APIs

Add configs of optionally building FF-M interrupt APIs. Build:
- psa_irq_enable() and psa_irq_disable() for either FLIH or
  SLIH enabled.
- psa_reset_signal() for FLIH enabled.
- psa_eoi() for SLIH enabled.

Signed-off-by: Mingyang Sun <mingyang.sun@arm.com>
Change-Id: I0822f96c1e827181edf34a409b357b7e81485dc4
diff --git a/secure_fw/spm/ffm/psa_api.c b/secure_fw/spm/ffm/psa_api.c
index e115a83..c8ede67 100644
--- a/secure_fw/spm/ffm/psa_api.c
+++ b/secure_fw/spm/ffm/psa_api.c
@@ -877,38 +877,6 @@
     CRITICAL_SECTION_LEAVE(cs_assert);
 }
 
-void tfm_spm_partition_psa_eoi(psa_signal_t irq_signal)
-{
-    struct critical_section_t cs_assert = CRITICAL_SECTION_STATIC_INIT;
-    struct irq_load_info_t *irq_info = NULL;
-    struct partition_t *partition = NULL;
-
-    partition = GET_CURRENT_COMPONENT();
-
-    irq_info = get_irq_info_for_signal(partition->p_ldinf, irq_signal);
-    /* It is a fatal error if passed signal is not an interrupt signal. */
-    if (!irq_info) {
-        tfm_core_panic();
-    }
-
-    if (irq_info->flih_func) {
-        /* This API is for SLIH IRQs only */
-        tfm_core_panic();
-    }
-
-    /* It is a fatal error if passed signal is not currently asserted */
-    if ((partition->signals_asserted & irq_signal) == 0) {
-        tfm_core_panic();
-    }
-
-    CRITICAL_SECTION_ENTER(cs_assert);
-    partition->signals_asserted &= ~irq_signal;
-    CRITICAL_SECTION_LEAVE(cs_assert);
-
-    tfm_hal_irq_clear_pending(irq_info->source);
-    tfm_hal_irq_enable(irq_info->source);
-}
-
 void tfm_spm_partition_psa_panic(void)
 {
     /*
@@ -918,6 +886,31 @@
     tfm_hal_system_reset();
 }
 
+/* psa_set_rhandle is only needed by connection-based services */
+#if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1
+
+void tfm_spm_partition_psa_set_rhandle(psa_handle_t msg_handle, void *rhandle)
+{
+    struct conn_handle_t *hdl;
+
+    /* It is a fatal error if message handle is invalid */
+    hdl = spm_get_handle_by_user_handle(msg_handle);
+    if (!hdl) {
+        tfm_core_panic();
+    }
+
+    /* It is a PROGRAMMER ERROR if a stateless service sets rhandle. */
+    if (SERVICE_IS_STATELESS(hdl->service->p_ldinf->flags)) {
+        tfm_core_panic();
+    }
+
+    hdl->msg.rhandle = rhandle;
+    hdl->rhandle = rhandle;
+}
+
+#endif /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API */
+
+#if CONFIG_TFM_FLIH_API == 1 || CONFIG_TFM_SLIH_API == 1
 void tfm_spm_partition_psa_irq_enable(psa_signal_t irq_signal)
 {
     struct partition_t *partition;
@@ -950,6 +943,8 @@
     return 1;
 }
 
+/* This API is only used for FLIH. */
+#if CONFIG_TFM_FLIH_API == 1
 void tfm_spm_partition_psa_reset_signal(psa_signal_t irq_signal)
 {
     struct critical_section_t cs_assert = CRITICAL_SECTION_STATIC_INIT;
@@ -977,30 +972,43 @@
     partition->signals_asserted &= ~irq_signal;
     CRITICAL_SECTION_LEAVE(cs_assert);
 }
+#endif
 
-/* psa_set_rhandle is only needed by connection-based services */
-#if CONFIG_TFM_CONNECTION_BASED_SERVICE_API == 1
-
-void tfm_spm_partition_psa_set_rhandle(psa_handle_t msg_handle, void *rhandle)
+/* This API is only used for SLIH. */
+#if CONFIG_TFM_SLIH_API == 1
+void tfm_spm_partition_psa_eoi(psa_signal_t irq_signal)
 {
-    struct conn_handle_t *hdl;
+    struct critical_section_t cs_assert = CRITICAL_SECTION_STATIC_INIT;
+    struct irq_load_info_t *irq_info = NULL;
+    struct partition_t *partition = NULL;
 
-    /* It is a fatal error if message handle is invalid */
-    hdl = spm_get_handle_by_user_handle(msg_handle);
-    if (!hdl) {
+    partition = GET_CURRENT_COMPONENT();
+
+    irq_info = get_irq_info_for_signal(partition->p_ldinf, irq_signal);
+    /* It is a fatal error if passed signal is not an interrupt signal. */
+    if (!irq_info) {
         tfm_core_panic();
     }
 
-    /* It is a PROGRAMMER ERROR if a stateless service sets rhandle. */
-    if (SERVICE_IS_STATELESS(hdl->service->p_ldinf->flags)) {
+    if (irq_info->flih_func) {
+        /* This API is for SLIH IRQs only */
         tfm_core_panic();
     }
 
-    hdl->msg.rhandle = rhandle;
-    hdl->rhandle = rhandle;
+    /* It is a fatal error if passed signal is not currently asserted */
+    if ((partition->signals_asserted & irq_signal) == 0) {
+        tfm_core_panic();
+    }
+
+    CRITICAL_SECTION_ENTER(cs_assert);
+    partition->signals_asserted &= ~irq_signal;
+    CRITICAL_SECTION_LEAVE(cs_assert);
+
+    tfm_hal_irq_clear_pending(irq_info->source);
+    tfm_hal_irq_enable(irq_info->source);
 }
-
-#endif /* CONFIG_TFM_CONNECTION_BASED_SERVICE_API */
+#endif
+#endif /* CONFIG_TFM_FLIH_API == 1 || CONFIG_TFM_SLIH_API == 1 */
 
 #if PSA_FRAMEWORK_HAS_MM_IOVEC