Build: Update to IAR support

Cleaned up #ifdef in secure_fw/services/tfm_spm_db.inc.template
Moved "signals" member to front of spm_partition_runtime_data_t.
The suggestion to move the aggregate types to the front turned
out to be hard to make work for both PSA and non-PSA configs.

Moved REGION_DECLARE macros to new include file,
platform/include/region.h.

Cleaned up type cast in core_test_api.c

Change-Id: I5dce1e7c019d4d7e4c14dc79be5ee2b855ad4f9e
Signed-off-by: Thomas Tornblom <thomas.tornblom@iar.com>
diff --git a/secure_fw/spm/spm_api.c b/secure_fw/spm/spm_api.c
index 044e336..f71db78 100644
--- a/secure_fw/spm/spm_api.c
+++ b/secure_fw/spm/spm_api.c
@@ -20,6 +20,7 @@
 #include "tfm_peripherals_def.h"
 #include "spm_partition_defs.h"
 #include "psa/lifecycle.h"
+#include "region.h"
 
 #define NON_SECURE_INTERNAL_PARTITION_DB_IDX 0
 #define TFM_CORE_INTERNAL_PARTITION_DB_IDX   1
diff --git a/secure_fw/spm/spm_api.h b/secure_fw/spm/spm_api.h
index 33118b1..b28cac7 100644
--- a/secure_fw/spm/spm_api.h
+++ b/secure_fw/spm/spm_api.h
@@ -88,8 +88,8 @@
  */
 struct spm_partition_runtime_data_t {
 #ifdef TFM_PSA_API
-    struct tfm_event_t signal_evnt;     /* Event signal                      */
     uint32_t signals;                   /* Service signals had been triggered*/
+    struct tfm_event_t signal_evnt;     /* Event signal                      */
     struct tfm_list_node_t service_list;/* Service list                      */
     struct tfm_core_thread_t sp_thrd;   /* Thread object                     */
     uint32_t assigned_signals;          /* All assigned signals              */
diff --git a/secure_fw/spm/spm_db.h b/secure_fw/spm/spm_db.h
index 6cd0e4e..2cbbe44 100644
--- a/secure_fw/spm/spm_db.h
+++ b/secure_fw/spm/spm_db.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2017-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -68,10 +68,6 @@
     struct spm_partition_desc_t *partitions;
 };
 
-/* Macros to pick linker symbols and allow to form the partition data base */
-#define REGION(a, b, c) a##b##c
-#define REGION_NAME(a, b, c) REGION(a, b, c)
-#define REGION_DECLARE(a, b, c) extern uint32_t REGION_NAME(a, b, c)
 #ifdef TFM_PSA_API
 #define PART_REGION_ADDR(partition, region) \
     (uint32_t)&REGION_NAME(Image$$, partition, region)
diff --git a/secure_fw/spm/tfm_spm_db.inc b/secure_fw/spm/tfm_spm_db.inc
index 3da5c47..d22d46b 100644
--- a/secure_fw/spm/tfm_spm_db.inc
+++ b/secure_fw/spm/tfm_spm_db.inc
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -1261,10 +1261,10 @@
 /**************************************************************************/
 static struct spm_partition_desc_t partition_list [] =
 {
-    {{}}, /* placeholder for Non-secure internal partition */
+    {{0}}, /* placeholder for Non-secure internal partition */
 #ifndef TFM_PSA_API
-    {{}}, /* placeholder for TF-M Core internal partition */
-#endif /* !ifndefined(TFM_PSA_API) */
+    {{0}},   /* placeholder for TF-M Core internal partition */
+#endif
 
     /* -----------------------------------------------------------------------*/
     /* - Partition DB record for TFM_SP_STORAGE */
@@ -1272,7 +1272,7 @@
 #ifdef TFM_PARTITION_SECURE_STORAGE
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1284,7 +1284,7 @@
 #ifdef TFM_PARTITION_INTERNAL_TRUSTED_STORAGE
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1296,7 +1296,7 @@
 #ifdef TFM_PARTITION_AUDIT_LOG
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1308,7 +1308,7 @@
 #ifdef TFM_PARTITION_CRYPTO
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1320,7 +1320,7 @@
 #ifdef TFM_PARTITION_PLATFORM
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1332,7 +1332,7 @@
 #ifdef TFM_PARTITION_INITIAL_ATTESTATION
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1344,7 +1344,7 @@
 #ifdef TFM_PARTITION_TEST_CORE
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1356,7 +1356,7 @@
 #ifdef TFM_PARTITION_TEST_CORE
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1368,7 +1368,7 @@
 #ifdef TFM_PARTITION_TEST_SECURE_SERVICES
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1380,7 +1380,7 @@
 #ifdef TFM_PARTITION_TEST_CORE_IPC
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1392,7 +1392,7 @@
 #ifdef TFM_PARTITION_TEST_CORE_IPC
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1404,7 +1404,7 @@
 #ifdef TFM_ENABLE_IRQ_TEST
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1416,7 +1416,7 @@
 #ifdef TFM_PARTITION_TEST_SST
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1428,7 +1428,7 @@
 #ifdef TFM_PARTITION_TEST_SECURE_SERVICES
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
@@ -1440,7 +1440,7 @@
 #ifdef TFM_MULTI_CORE_TEST
     {
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     },
diff --git a/secure_fw/spm/tfm_spm_db.inc.template b/secure_fw/spm/tfm_spm_db.inc.template
index 83de242..5a0f453 100644
--- a/secure_fw/spm/tfm_spm_db.inc.template
+++ b/secure_fw/spm/tfm_spm_db.inc.template
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
@@ -321,10 +321,10 @@
 /**************************************************************************/
 static struct spm_partition_desc_t partition_list [] =
 {
-    {{'{{}}'}}, /* placeholder for Non-secure internal partition */
+    {{'{{0}}'}}, /* placeholder for Non-secure internal partition */
 #ifndef TFM_PSA_API
-    {{'{{}}'}}, /* placeholder for TF-M Core internal partition */
-#endif /* !ifndefined(TFM_PSA_API) */
+    {{'{{0}}'}},   /* placeholder for TF-M Core internal partition */
+#endif
 
 {% for manifest in manifests %}
     /* -----------------------------------------------------------------------*/
@@ -335,7 +335,7 @@
     {% endif %}
     {{'{'}}
     /* Runtime data */
-        .runtime_data             = {},
+        .runtime_data             = {0},
         .static_data              = NULL,
         .platform_data_list       = NULL,
     {{'},'}}