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/platform/ext/target/cypress/psoc64/spm_hal.c b/platform/ext/target/cypress/psoc64/spm_hal.c
index 39e7dee..62dc8a7 100644
--- a/platform/ext/target/cypress/psoc64/spm_hal.c
+++ b/platform/ext/target/cypress/psoc64/spm_hal.c
@@ -29,6 +29,7 @@
 #include "cy_prot.h"
 #include "pc_config.h"
 #include "driver_dap.h"
+#include "region.h"
 
 /* Get address of memory regions to configure MPU */
 extern const struct memory_region_limits memory_regions;
diff --git a/platform/ext/target/cypress/psoc64/target_cfg.c b/platform/ext/target/cypress/psoc64/target_cfg.c
index c626a68..99c341e 100644
--- a/platform/ext/target/cypress/psoc64/target_cfg.c
+++ b/platform/ext/target/cypress/psoc64/target_cfg.c
@@ -30,13 +30,9 @@
 #include "RTE_Device.h"
 #include "target_cfg.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 #ifdef BL2
diff --git a/platform/ext/target/mps2/an519/boot_hal.c b/platform/ext/target/mps2/an519/boot_hal.c
index 26d7ce9..1b11c7b 100644
--- a/platform/ext/target/mps2/an519/boot_hal.c
+++ b/platform/ext/target/mps2/an519/boot_hal.c
@@ -1,27 +1,32 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
         ".syntax unified                             \n"
         "movs    r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "blt     Clear_done                          \n"
-        "str     r0, [r1, r2]                        \n"
+        "str     r0, [%0, %1]                        \n"
         "b       Loop                                \n"
         "Clear_done:                                 \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/mps2/an519/spm_hal.c b/platform/ext/target/mps2/an519/spm_hal.c
index 833aa41..22f8758 100644
--- a/platform/ext/target/mps2/an519/spm_hal.c
+++ b/platform/ext/target/mps2/an519/spm_hal.c
@@ -16,6 +16,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "secure_utilities.h"
+#include "region.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
diff --git a/platform/ext/target/mps2/an519/target_cfg.c b/platform/ext/target/mps2/an519/target_cfg.c
index 8224741..acb7242 100644
--- a/platform/ext/target/mps2/an519/target_cfg.c
+++ b/platform/ext/target/mps2/an519/target_cfg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 Arm Limited
+ * Copyright (c) 2018-2020 Arm Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,14 +21,10 @@
 #include "region_defs.h"
 #include "tfm_secure_api.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 REGION_DECLARE(Load$$LR$$, LR_VENEER, $$Base);
diff --git a/platform/ext/target/mps2/an521/boot_hal.c b/platform/ext/target/mps2/an521/boot_hal.c
index 5dadc3f..d5a804d 100644
--- a/platform/ext/target/mps2/an521/boot_hal.c
+++ b/platform/ext/target/mps2/an521/boot_hal.c
@@ -1,26 +1,30 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
-        ".syntax unified                             \n"
         "mov     r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "itt     ge                                  \n"
-        "strge   r0, [r1, r2]                        \n"
+        "strge   r0, [%0, %1]                        \n"
         "bge     Loop                                \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/mps2/an521/spm_hal.c b/platform/ext/target/mps2/an521/spm_hal.c
index 8e559b2..6526e31 100644
--- a/platform/ext/target/mps2/an521/spm_hal.c
+++ b/platform/ext/target/mps2/an521/spm_hal.c
@@ -16,6 +16,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "secure_utilities.h"
+#include "region.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
diff --git a/platform/ext/target/mps2/an521/target_cfg.c b/platform/ext/target/mps2/an521/target_cfg.c
index a6f5317..78938c3 100644
--- a/platform/ext/target/mps2/an521/target_cfg.c
+++ b/platform/ext/target/mps2/an521/target_cfg.c
@@ -21,6 +21,7 @@
 #include "region_defs.h"
 #include "tfm_secure_api.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 #ifdef PSA_API_TEST_IPC
 #define PSA_FF_TEST_SECURE_UART2
@@ -28,11 +29,6 @@
 
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 REGION_DECLARE(Load$$LR$$, LR_VENEER, $$Base);
diff --git a/platform/ext/target/mps2/an539/boot_hal.c b/platform/ext/target/mps2/an539/boot_hal.c
index 26d7ce9..1b11c7b 100644
--- a/platform/ext/target/mps2/an539/boot_hal.c
+++ b/platform/ext/target/mps2/an539/boot_hal.c
@@ -1,27 +1,32 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
         ".syntax unified                             \n"
         "movs    r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "blt     Clear_done                          \n"
-        "str     r0, [r1, r2]                        \n"
+        "str     r0, [%0, %1]                        \n"
         "b       Loop                                \n"
         "Clear_done:                                 \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/mps2/an539/spm_hal.c b/platform/ext/target/mps2/an539/spm_hal.c
index 959bd45..ce345c5 100644
--- a/platform/ext/target/mps2/an539/spm_hal.c
+++ b/platform/ext/target/mps2/an539/spm_hal.c
@@ -13,6 +13,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "platform_description.h"
+#include "region.h"
 
 /* Debug configuration flags */
 #define SPNIDEN_SEL_STATUS (0x01u << 7)
diff --git a/platform/ext/target/mps2/an539/target_cfg.c b/platform/ext/target/mps2/an539/target_cfg.c
index 2854d33..b59c90b 100644
--- a/platform/ext/target/mps2/an539/target_cfg.c
+++ b/platform/ext/target/mps2/an539/target_cfg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -24,15 +24,11 @@
 #include "mpu_armv8m_drv.h"
 #include "secure_utilities.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 /* Throw out bus error when an access causes security violation */
 #define CMSDK_SECRESPCFG_BUS_ERR_MASK   (1UL << 0)
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 REGION_DECLARE(Load$$LR$$, LR_VENEER, $$Base);
diff --git a/platform/ext/target/mps3/an524/boot_hal.c b/platform/ext/target/mps3/an524/boot_hal.c
index 5dadc3f..d5a804d 100644
--- a/platform/ext/target/mps3/an524/boot_hal.c
+++ b/platform/ext/target/mps3/an524/boot_hal.c
@@ -1,26 +1,30 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
-        ".syntax unified                             \n"
         "mov     r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "itt     ge                                  \n"
-        "strge   r0, [r1, r2]                        \n"
+        "strge   r0, [%0, %1]                        \n"
         "bge     Loop                                \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/mps3/an524/spm_hal.c b/platform/ext/target/mps3/an524/spm_hal.c
index a25aec9..c39c2ca 100644
--- a/platform/ext/target/mps3/an524/spm_hal.c
+++ b/platform/ext/target/mps3/an524/spm_hal.c
@@ -15,6 +15,7 @@
 #include "region_defs.h"
 #include "platform_description.h"
 #include "Driver_Common.h"
+#include "region.h"
 
 /* Debug configuration flags */
 #define SPNIDEN_SEL_STATUS (0x01u << 7)
diff --git a/platform/ext/target/mps3/an524/target_cfg.c b/platform/ext/target/mps3/an524/target_cfg.c
index 5dfdf1a..1fd93c6 100644
--- a/platform/ext/target/mps3/an524/target_cfg.c
+++ b/platform/ext/target/mps3/an524/target_cfg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2019 Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020 Arm Limited. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -23,11 +23,7 @@
 #include "tfm_secure_api.h"
 #include "mpu_armv8m_drv.h"
 #include "tfm_plat_defs.h"
-
-/* Macros to pick linker symbols */
-#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)
+#include "region.h"
 
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
diff --git a/platform/ext/target/musca_a/boot_hal.c b/platform/ext/target/musca_a/boot_hal.c
index 5dadc3f..d5a804d 100644
--- a/platform/ext/target/musca_a/boot_hal.c
+++ b/platform/ext/target/musca_a/boot_hal.c
@@ -1,26 +1,30 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
-        ".syntax unified                             \n"
         "mov     r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "itt     ge                                  \n"
-        "strge   r0, [r1, r2]                        \n"
+        "strge   r0, [%0, %1]                        \n"
         "bge     Loop                                \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/musca_a/spm_hal.c b/platform/ext/target/musca_a/spm_hal.c
index 4f78ca1..36f1e15 100644
--- a/platform/ext/target/musca_a/spm_hal.c
+++ b/platform/ext/target/musca_a/spm_hal.c
@@ -16,6 +16,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "secure_utilities.h"
+#include "region.h"
 
 /* Import MPC driver */
 extern ARM_DRIVER_MPC Driver_CODE_SRAM_MPC;
diff --git a/platform/ext/target/musca_a/target_cfg.c b/platform/ext/target/musca_a/target_cfg.c
index d4eb92c..bf39090 100644
--- a/platform/ext/target/musca_a/target_cfg.c
+++ b/platform/ext/target/musca_a/target_cfg.c
@@ -21,15 +21,11 @@
 #include "region_defs.h"
 #include "tfm_secure_api.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 #define MIN(A, B) (((A) < (B)) ? (A) : (B))
 #define MAX(A, B) (((A) > (B)) ? (A) : (B))
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 REGION_DECLARE(Load$$LR$$, LR_VENEER, $$Base);
diff --git a/platform/ext/target/musca_b1/boot_hal.c b/platform/ext/target/musca_b1/boot_hal.c
index 5dadc3f..d5a804d 100644
--- a/platform/ext/target/musca_b1/boot_hal.c
+++ b/platform/ext/target/musca_b1/boot_hal.c
@@ -1,26 +1,30 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
-        ".syntax unified                             \n"
         "mov     r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "itt     ge                                  \n"
-        "strge   r0, [r1, r2]                        \n"
+        "strge   r0, [%0, %1]                        \n"
         "bge     Loop                                \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/musca_b1/spm_hal.c b/platform/ext/target/musca_b1/spm_hal.c
index 49285a3..d9ae389 100644
--- a/platform/ext/target/musca_b1/spm_hal.c
+++ b/platform/ext/target/musca_b1/spm_hal.c
@@ -16,6 +16,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "secure_utilities.h"
+#include "region.h"
 
 /* Import MPC driver */
 extern ARM_DRIVER_MPC Driver_EFLASH0_MPC;
diff --git a/platform/ext/target/musca_b1/target_cfg.c b/platform/ext/target/musca_b1/target_cfg.c
index 84be107..87ff9b7 100644
--- a/platform/ext/target/musca_b1/target_cfg.c
+++ b/platform/ext/target/musca_b1/target_cfg.c
@@ -22,11 +22,7 @@
 #include "region_defs.h"
 #include "tfm_secure_api.h"
 #include "tfm_plat_defs.h"
-
-/* Macros to pick linker symbols */
-#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)
+#include "region.h"
 
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
diff --git a/platform/ext/target/musca_s1/boot_hal.c b/platform/ext/target/musca_s1/boot_hal.c
index 5dadc3f..d5a804d 100644
--- a/platform/ext/target/musca_s1/boot_hal.c
+++ b/platform/ext/target/musca_s1/boot_hal.c
@@ -1,26 +1,30 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
-        ".syntax unified                             \n"
         "mov     r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "itt     ge                                  \n"
-        "strge   r0, [r1, r2]                        \n"
+        "strge   r0, [%0, %1]                        \n"
         "bge     Loop                                \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/musca_s1/spm_hal.c b/platform/ext/target/musca_s1/spm_hal.c
index 5d038f6..45622c4 100644
--- a/platform/ext/target/musca_s1/spm_hal.c
+++ b/platform/ext/target/musca_s1/spm_hal.c
@@ -16,6 +16,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "secure_utilities.h"
+#include "region.h"
 
 /* Import MPC driver */
 extern ARM_DRIVER_MPC Driver_CODE_SRAM_MPC;
diff --git a/platform/ext/target/musca_s1/target_cfg.c b/platform/ext/target/musca_s1/target_cfg.c
index ec53df2..b2c9d9a 100644
--- a/platform/ext/target/musca_s1/target_cfg.c
+++ b/platform/ext/target/musca_s1/target_cfg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 Arm Limited. All rights reserved.
+ * Copyright (c) 2018-2020 Arm Limited. All rights reserved.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -22,15 +22,11 @@
 #include "region_defs.h"
 #include "tfm_secure_api.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 #define MIN(A, B) (((A) < (B)) ? (A) : (B))
 #define MAX(A, B) (((A) > (B)) ? (A) : (B))
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 REGION_DECLARE(Load$$LR$$, LR_VENEER, $$Base);
diff --git a/platform/ext/target/sse-200_aws/boot_hal.c b/platform/ext/target/sse-200_aws/boot_hal.c
index 5dadc3f..bea5786 100644
--- a/platform/ext/target/sse-200_aws/boot_hal.c
+++ b/platform/ext/target/sse-200_aws/boot_hal.c
@@ -1,26 +1,31 @@
 /*
- * Copyright (c) 2019, Arm Limited. All rights reserved.
+ * Copyright (c) 2019-2020, Arm Limited. All rights reserved.
  *
  * SPDX-License-Identifier: BSD-3-Clause
  *
  */
 
 #include "cmsis.h"
+#include "region.h"
+
+
+REGION_DECLARE(Image$$, ER_DATA, $$Base)[];
+REGION_DECLARE(Image$$, ARM_LIB_HEAP, $$ZI$$Limit)[];
 
 __attribute__((naked)) void boot_clear_bl2_ram_area(void)
 {
     __ASM volatile(
-        ".syntax unified                             \n"
         "mov     r0, #0                              \n"
-        "ldr     r1, =Image$$ER_DATA$$Base           \n"
-        "ldr     r2, =Image$$ARM_LIB_HEAP$$ZI$$Limit \n"
-        "subs    r2, r2, r1                          \n"
+        "subs    %1, %1, %0                          \n"
         "Loop:                                       \n"
-        "subs    r2, #4                              \n"
+        "subs    %1, #4                              \n"
         "itt     ge                                  \n"
-        "strge   r0, [r1, r2]                        \n"
+        "strge   r0, [%0, %1]                        \n"
         "bge     Loop                                \n"
         "bx      lr                                  \n"
-         : : : "r0" , "r1" , "r2" , "memory"
+        :
+        : "r" (REGION_NAME(Image$$, ER_DATA, $$Base)),
+          "r" (REGION_NAME(Image$$, ARM_LIB_HEAP, $$ZI$$Limit))
+        : "r0", "memory"
     );
 }
diff --git a/platform/ext/target/sse-200_aws/spm_hal.c b/platform/ext/target/sse-200_aws/spm_hal.c
index be04637..34b2c1c 100644
--- a/platform/ext/target/sse-200_aws/spm_hal.c
+++ b/platform/ext/target/sse-200_aws/spm_hal.c
@@ -16,6 +16,7 @@
 #include "mpu_armv8m_drv.h"
 #include "region_defs.h"
 #include "secure_utilities.h"
+#include "region.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
diff --git a/platform/ext/target/sse-200_aws/target_cfg.c b/platform/ext/target/sse-200_aws/target_cfg.c
index 1d37188..5673a2d 100644
--- a/platform/ext/target/sse-200_aws/target_cfg.c
+++ b/platform/ext/target/sse-200_aws/target_cfg.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2017-2019 Arm Limited
+ * Copyright (c) 2017-2020 Arm Limited
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -21,14 +21,10 @@
 #include "region_defs.h"
 #include "tfm_secure_api.h"
 #include "tfm_plat_defs.h"
+#include "region.h"
 
 #define ARRAY_SIZE(arr) (sizeof(arr)/sizeof(arr[0]))
 
-/* Macros to pick linker symbols */
-#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)
-
 /* The section names come from the scatter file */
 REGION_DECLARE(Load$$LR$$, LR_NS_PARTITION, $$Base);
 REGION_DECLARE(Load$$LR$$, LR_VENEER, $$Base);
diff --git a/platform/include/region.h b/platform/include/region.h
new file mode 100644
index 0000000..c6ca921
--- /dev/null
+++ b/platform/include/region.h
@@ -0,0 +1,17 @@
+/*
+ * Copyright (c) 2020, Arm Limited. All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ *
+ */
+
+#ifndef __REGION_H__
+#define __REGION_H__
+
+/* Macros to pick linker symbols */
+#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)
+#define REGION_DECLARE_T(a, b, c, t) extern t REGION_NAME(a, b, c)
+
+#endif  /* __REGION_H__ */