HAL: Apply FIH to tfm_hal_platform_init

This patch applies Fault Inject Harden to the tfm_hal_platform_init
API.
And restore the FIH on init_debug() on AN521.

Change-Id: Ib6a640631d6e0ab592d83802158adf5bc4c93ec5
Signed-off-by: Kevin Peng <kevin.peng@arm.com>
diff --git a/secure_fw/spm/cmsis_func/main.c b/secure_fw/spm/cmsis_func/main.c
index a50767f..0ea1911 100644
--- a/secure_fw/spm/cmsis_func/main.c
+++ b/secure_fw/spm/cmsis_func/main.c
@@ -65,10 +65,17 @@
     }
 #endif /* TFM_FIH_PROFILE_ON */
 
-    hal_status = tfm_hal_platform_init();
-    if (hal_status != TFM_HAL_SUCCESS) {
+#ifdef TFM_FIH_PROFILE_ON
+    FIH_CALL(tfm_hal_platform_init, fih_rc);
+    if (fih_not_eq(fih_rc, fih_int_encode(TFM_HAL_SUCCESS))) {
         FIH_RET(fih_int_encode(TFM_ERROR_GENERIC));
     }
+#else /* TFM_FIH_PROFILE_ON */
+    hal_status = tfm_hal_platform_init();
+    if (hal_status != TFM_HAL_SUCCESS) {
+        return TFM_ERROR_GENERIC;
+    }
+#endif /* TFM_FIH_PROFILE_ON */
 
     plat_err = tfm_plat_otp_init();
     if (plat_err != TFM_PLAT_ERR_SUCCESS) {
diff --git a/secure_fw/spm/cmsis_psa/main.c b/secure_fw/spm/cmsis_psa/main.c
index f2eb4d2..46fef6f 100644
--- a/secure_fw/spm/cmsis_psa/main.c
+++ b/secure_fw/spm/cmsis_psa/main.c
@@ -37,10 +37,11 @@
 
 static fih_int tfm_core_init(void)
 {
-    enum tfm_hal_status_t hal_status = TFM_HAL_ERROR_GENERIC;
     enum tfm_plat_err_t plat_err = TFM_PLAT_ERR_SYSTEM_ERR;
 #ifdef TFM_FIH_PROFILE_ON
     fih_int fih_rc = FIH_FAILURE;
+#else
+    enum tfm_hal_status_t hal_status = TFM_HAL_ERROR_GENERIC;
 #endif
 
     /*
@@ -66,10 +67,17 @@
     }
 #endif
 
-    hal_status = tfm_hal_platform_init();
-    if (hal_status != TFM_HAL_SUCCESS) {
+#ifdef TFM_FIH_PROFILE_ON
+    FIH_CALL(tfm_hal_platform_init, fih_rc);
+    if (fih_not_eq(fih_rc, fih_int_encode(TFM_HAL_SUCCESS))) {
         FIH_RET(fih_int_encode(TFM_ERROR_GENERIC));
     }
+#else /* TFM_FIH_PROFILE_ON */
+    hal_status = tfm_hal_platform_init();
+    if (hal_status != TFM_HAL_SUCCESS) {
+        return TFM_ERROR_GENERIC;
+    }
+#endif /* TFM_FIH_PROFILE_ON */
 
     plat_err = tfm_plat_otp_init();
     if (plat_err != TFM_PLAT_ERR_SUCCESS) {