FIH: Split FIH library into headers and impl

In order to work with BL1 code-sharing. Create generic hal target to
avoid having to link to platform_s.

Change-Id: Id138b2a5e37790ffc482b2b3afdd9dbab2d7ba04
Signed-off-by: Raef Coles <raef.coles@arm.com>
diff --git a/lib/fih/CMakeLists.txt b/lib/fih/CMakeLists.txt
index e9e1a9c..a03aff5 100644
--- a/lib/fih/CMakeLists.txt
+++ b/lib/fih/CMakeLists.txt
@@ -7,25 +7,32 @@
 
 cmake_minimum_required(VERSION 3.15)
 
-add_library(tfm_fih STATIC)
+add_library(tfm_fih_headers INTERFACE)
+add_library(tfm_fih_implementation STATIC)
 
-target_sources(tfm_fih
+target_sources(tfm_fih_implementation
     PRIVATE
         src/fih.c
 )
 
-target_include_directories(tfm_fih
-    PUBLIC
+target_include_directories(tfm_fih_headers
+    INTERFACE
         $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
 )
 
-target_link_libraries(tfm_fih
-    PRIVATE
-        platform_s
+target_link_libraries(tfm_fih_implementation
+    PUBLIC
+        tfm_fih_headers
+        platform_common_interface
 )
 
-target_compile_definitions(tfm_fih
-    PUBLIC
+target_compile_definitions(tfm_fih_headers
+    INTERFACE
         TFM_FIH_PROFILE_${TFM_FIH_PROFILE}
         $<$<NOT:$<STREQUAL:${TFM_FIH_PROFILE},OFF>>:TFM_FIH_PROFILE_ON>
 )
+
+target_compile_options(tfm_fih_headers
+    INTERFACE
+        $<$<C_COMPILER_ID:GNU>:-Wno-unused-value>
+)
diff --git a/lib/fih/inc/fih.h b/lib/fih/inc/fih.h
index b0d0390..4414ef2 100644
--- a/lib/fih/inc/fih.h
+++ b/lib/fih/inc/fih.h
@@ -497,11 +497,13 @@
 
 #define fih_int_encode(x)     (x)
 
+#define fih_int_encode_zero_equality(x) ((x) == 0 ? 0 : 1)
+
 #define fih_eq(x, y)          ((x) == (y))
 
 #define fih_not_eq(x, y)      ((x) != (y))
 
-#define fih_delay_init()
+#define fih_delay_init()      (0)
 #define fih_delay()
 
 #define FIH_CALL(f, ret, ...) \
@@ -514,6 +516,10 @@
         return ret; \
     } while (0)
 
+#define FIH_PANIC do { \
+        while(1) {}; \
+    } while (0)
+
 #define FIH_CFI_STEP_INIT(x)
 #define FIH_CFI_STEP_DECREMENT()
 #define FIH_CFI_STEP_ERR_RESET()
diff --git a/platform/CMakeLists.txt b/platform/CMakeLists.txt
index 32911f5..1412be1 100755
--- a/platform/CMakeLists.txt
+++ b/platform/CMakeLists.txt
@@ -69,7 +69,7 @@
     PUBLIC
         platform_common_interface
         platform_region_defs
-        tfm_fih
+        tfm_fih_headers
     PRIVATE
         psa_interface
         tfm_secure_api
diff --git a/secure_fw/spm/CMakeLists.txt b/secure_fw/spm/CMakeLists.txt
index b674db6..9803599 100755
--- a/secure_fw/spm/CMakeLists.txt
+++ b/secure_fw/spm/CMakeLists.txt
@@ -87,7 +87,7 @@
         tfm_boot_status
         tfm_secure_api
         tfm_partitions
-        tfm_fih
+        tfm_fih_headers
         tfm_sprt
 )