FIH: Change fih_delay() to return int

This will facilitate its use in macros to enhance fault protection.

Signed-off-by: Chris Brand <chris.brand@cypress.com>
Change-Id: I880b5f64a3329debaa8bae2e4eeddbeb2703a103
diff --git a/lib/fih/inc/fih.h b/lib/fih/inc/fih.h
index fd8f20a..0e90cfe 100644
--- a/lib/fih/inc/fih.h
+++ b/lib/fih/inc/fih.h
@@ -170,7 +170,7 @@
 
 /* Delaying logic, with randomness from a CSPRNG */
 __attribute__((always_inline)) inline
-void fih_delay(void)
+int fih_delay(void)
 {
     uint32_t i = 0;
     volatile uint32_t delay = FIH_NEGATIVE_VALUE;
@@ -191,11 +191,13 @@
     if (counter != delay) {
         FIH_PANIC;
     }
+
+    return 1;
 }
 #else /* FIH_ENABLE_DELAY */
 #define fih_delay_init()
 
-#define fih_delay()
+#define fih_delay()     1
 #endif /* FIH_ENABLE_DELAY */
 
 #ifdef FIH_ENABLE_DOUBLE_VARS
@@ -239,13 +241,13 @@
         rc1 = FIH_TRUE;
     }
 
-    fih_delay();
+    (void)fih_delay();
 
     if (x.msk == y.msk) {
         rc2 = FIH_TRUE;
     }
 
-    fih_delay();
+    (void)fih_delay();
 
     if (rc1 != rc2) {
         FIH_PANIC;
@@ -267,13 +269,13 @@
         rc1 = FIH_TRUE;
     }
 
-    fih_delay();
+    (void)fih_delay();
 
     if (x.msk != y.msk) {
         rc2 = FIH_TRUE;
     }
 
-    fih_delay();
+    (void)fih_delay();
 
     if (rc1 != rc2) {
         FIH_PANIC;
@@ -300,7 +302,7 @@
         rc = FIH_TRUE;
     }
 
-    fih_delay();
+    (void)fih_delay();
 
     if (x != y) {
         rc = FIH_FALSE;
@@ -318,7 +320,7 @@
         rc = FIH_TRUE;
     }
 
-    fih_delay();
+    (void)fih_delay();
 
     if (x == y) {
         rc = FIH_FALSE;
@@ -470,7 +472,7 @@
         FIH_LABEL("FIH_CALL_START_" # f); \
         FIH_CFI_PRECALL_BLOCK; \
         ret = FIH_FAILURE; \
-        fih_delay(); \
+        (void)fih_delay(); \
         ret = f(__VA_ARGS__); \
         FIH_CFI_POSTCALL_BLOCK; \
         (void)fih_int_validate(ret); \
@@ -516,7 +518,7 @@
 #define fih_not_eq(x, y)      ((x) != (y))
 
 #define fih_delay_init()      (0)
-#define fih_delay()
+#define fih_delay()           1
 
 #define FIH_CALL(f, ret, ...) \
     do { \
diff --git a/secure_fw/partitions/idle_partition/idle_partition.c b/secure_fw/partitions/idle_partition/idle_partition.c
index 38ae349..8f45f94 100644
--- a/secure_fw/partitions/idle_partition/idle_partition.c
+++ b/secure_fw/partitions/idle_partition/idle_partition.c
@@ -1,5 +1,8 @@
 /*
  * Copyright (c) 2021-2024, Arm Limited. All rights reserved.
+ * Copyright (c) 2024 Cypress Semiconductor Corporation (an Infineon
+ * company) or an affiliate of Cypress Semiconductor Corporation. All rights
+ * reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -24,7 +27,7 @@
     }
 
 #ifdef TFM_FIH_PROFILE_ON
-    fih_delay();
+    (void)fih_delay();
 
     while (1) {
         /*
diff --git a/secure_fw/spm/core/arch/tfm_arch_v8m_base.c b/secure_fw/spm/core/arch/tfm_arch_v8m_base.c
index 5cc587f..c66d8ac 100644
--- a/secure_fw/spm/core/arch/tfm_arch_v8m_base.c
+++ b/secure_fw/spm/core/arch/tfm_arch_v8m_base.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2018-2024, Arm Limited. All rights reserved.
- * Copyright (c) 2022-2023 Cypress Semiconductor Corporation (an Infineon
+ * Copyright (c) 2022-2024 Cypress Semiconductor Corporation (an Infineon
  * company) or an affiliate of Cypress Semiconductor Corporation. All rights
  * reserved.
  *
@@ -277,7 +277,7 @@
     if ((scb->AIRCR & SCB_AIRCR_PRIS_Msk) !=  SCB_AIRCR_PRIS_Msk) {
         FIH_RET(FIH_FAILURE);
     }
-    fih_delay();
+    (void)fih_delay();
     if ((scb->AIRCR & SCB_AIRCR_PRIS_Msk) !=  SCB_AIRCR_PRIS_Msk) {
         FIH_RET(FIH_FAILURE);
     }
diff --git a/secure_fw/spm/core/arch/tfm_arch_v8m_main.c b/secure_fw/spm/core/arch/tfm_arch_v8m_main.c
index ce41e37..5bde22d 100644
--- a/secure_fw/spm/core/arch/tfm_arch_v8m_main.c
+++ b/secure_fw/spm/core/arch/tfm_arch_v8m_main.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2018-2024, Arm Limited. All rights reserved.
- * Copyright (c) 2022-2023 Cypress Semiconductor Corporation (an Infineon
+ * Copyright (c) 2022-2024 Cypress Semiconductor Corporation (an Infineon
  * company) or an affiliate of Cypress Semiconductor Corporation. All rights
  * reserved.
  *
@@ -245,7 +245,7 @@
     if ((scb->AIRCR & SCB_AIRCR_PRIS_Msk) != SCB_AIRCR_PRIS_Msk) {
         FIH_RET(FIH_FAILURE);
     }
-    fih_delay();
+    (void)fih_delay();
     if ((scb->AIRCR & SCB_AIRCR_PRIS_Msk) != SCB_AIRCR_PRIS_Msk) {
         FIH_RET(FIH_FAILURE);
     }
diff --git a/secure_fw/spm/core/utilities.c b/secure_fw/spm/core/utilities.c
index c9a0c67..c8f0f67 100644
--- a/secure_fw/spm/core/utilities.c
+++ b/secure_fw/spm/core/utilities.c
@@ -1,5 +1,8 @@
 /*
  * Copyright (c) 2018-2021, Arm Limited. All rights reserved.
+ * Copyright (c) 2024 Cypress Semiconductor Corporation (an Infineon
+ * company) or an affiliate of Cypress Semiconductor Corporation. All rights
+ * reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -12,7 +15,7 @@
 
 void tfm_core_panic(void)
 {
-    fih_delay();
+    (void)fih_delay();
 
 #ifdef CONFIG_TFM_HALT_ON_CORE_PANIC
 
@@ -23,7 +26,7 @@
     tfm_hal_system_halt();
 
 #ifdef TFM_FIH_PROFILE_ON
-    fih_delay();
+    (void)fih_delay();
 
     tfm_hal_system_halt();
 #endif
@@ -40,7 +43,7 @@
     tfm_hal_system_reset();
 
 #ifdef TFM_FIH_PROFILE_ON
-    fih_delay();
+    (void)fih_delay();
 
     tfm_hal_system_reset();
 #endif