T398: Source cleanup for tool chain integration

This is a code cleanup to improve portability.

Specific issues addressed:
- Added type casts to (void *) here and there
- Changed non-standard \e escapes to \033
- Added cmake function to handle preinclude
- Changed a few Image$$ references to make use of the REGION_DECLARE
  macro
- Reordered code slightly to avoid the need for a "void *rangeptr"
  variable
- Changed compile time check typedef "err_msg" to avoid declaring
  zero sized array, which is not standards compliant. It will now
  either be -1 (error) or 1 (ok), not -1 and 0
- Reordered the *nfsptr_t typedef to make the cmse_nonsecure_call
  standards compliant
- Added null tests to both secure and non_secure suites to avoid
  defining zero length array. Also use this to find end of list
- Only define __stdout for ARMCLANG builds and conditionalize ns printf
  output for ARMCLANG/GCC/IAR
- Cleaned up some enum type mismatches
- Changed non standard EINVAL error return to -1. The value was only
  checked against 0 anyway
- Added type cast for conversion from float to int

Have tested with IAR, which starts and runs the idle thread. Changes
related to this is not included in this commit.

       Author: Thomas Tornblom <thomas.tornblom@iar.com>
       Signed-off-by: Thomas Tornblom <thomas.tornblom@iar.com>

       Note: Sign off authority needs to adhere to the [DCO](./dco.txt)
       rules.

Change-Id: I3e5229c0777623b128474af0311020ccacc1b797
diff --git a/secure_fw/ns_callable/tfm_audit_veneers.c b/secure_fw/ns_callable/tfm_audit_veneers.c
index a48ec87..7256482 100644
--- a/secure_fw/ns_callable/tfm_audit_veneers.c
+++ b/secure_fw/ns_callable/tfm_audit_veneers.c
@@ -17,7 +17,7 @@
                                     struct audit_core_retrieve_output *output_s)
 {
     TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID,
-                         audit_core_retrieve_record_wrapper,
+                         (void *) audit_core_retrieve_record_wrapper,
                          input_s, output_s, 0, 0);
 }
 
@@ -25,7 +25,7 @@
 enum psa_audit_err tfm_audit_veneer_add_record(
                                           const struct psa_audit_record *record)
 {
-    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, audit_core_add_record,
+    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, (void *) audit_core_add_record,
                          record, 0, 0, 0);
 }
 
@@ -33,7 +33,7 @@
 enum psa_audit_err tfm_audit_veneer_get_info(uint32_t *num_records,
                                              uint32_t *size)
 {
-    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, audit_core_get_info,
+    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, (void *) audit_core_get_info,
                          num_records, size, 0, 0);
 }
 
@@ -41,7 +41,7 @@
 enum psa_audit_err tfm_audit_veneer_get_record_info(const uint32_t record_index,
                                                     uint32_t *size)
 {
-    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, audit_core_get_record_info,
+    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, (void *) audit_core_get_record_info,
                          record_index, size, 0, 0);
 }
 
@@ -50,6 +50,6 @@
                                                   const uint8_t *token,
                                                   const uint32_t token_size)
 {
-    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, audit_core_delete_record,
+    TFM_CORE_SFN_REQUEST(TFM_SP_AUDIT_LOG_ID, (void *) audit_core_delete_record,
                          record_index, token, token_size, 0);
 }
diff --git a/secure_fw/ns_callable/tfm_veneers.c b/secure_fw/ns_callable/tfm_veneers.c
index 3effa95..2ba8a2c 100644
--- a/secure_fw/ns_callable/tfm_veneers.c
+++ b/secure_fw/ns_callable/tfm_veneers.c
@@ -118,7 +118,7 @@
                                          size_t out_len) \
     { \
         TFM_CORE_IOVEC_SFN_REQUEST(partition_name##_ID, \
-                                   sfn_name, \
+                                   (void *) sfn_name, \
                                    in_vec, in_len, out_vec, out_len); \
     }
 
diff --git a/secure_fw/ns_callable/tfm_veneers.c.template b/secure_fw/ns_callable/tfm_veneers.c.template
index 828a8c4..b58b2f3 100644
--- a/secure_fw/ns_callable/tfm_veneers.c.template
+++ b/secure_fw/ns_callable/tfm_veneers.c.template
@@ -32,7 +32,7 @@
                                          size_t out_len) \
     { \
         TFM_CORE_IOVEC_SFN_REQUEST(partition_name##_ID, \
-                                   sfn_name, \
+                                   (void *) sfn_name, \
                                    in_vec, in_len, out_vec, out_len); \
     }