Boot: Extend flash layout for multiple images

This patch extends the flash layout of supported platforms, and also
introduces the BOOT_IMAGE_NUMBER macro and the current_image variable
in MCUBoot to support multiple updatable images.

The FLASH_AREA_IMAGE_PRIMARY/SECONDARY object-like macros are replaced
with function-like ones and therefore some functions have been updated,
because the labels of a switch statement and the initialization
values of objects with static storage duration have to be constant
expressions.

Change-Id: Ic4425c9034f877fe2b83d80a3df211232f14a09f
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/bl2/ext/mcuboot/include/target.h b/bl2/ext/mcuboot/include/target.h
index 97930d7..728541c 100644
--- a/bl2/ext/mcuboot/include/target.h
+++ b/bl2/ext/mcuboot/include/target.h
@@ -21,28 +21,46 @@
 #error "FLASH_AREA_IMAGE_SECTOR_SIZE must be defined by the target"
 #endif
 
-#ifndef FLASH_AREA_IMAGE_PRIMARY_OFFSET
-#error "FLASH_AREA_IMAGE_PRIMARY_OFFSET must be defined by the target"
+#ifndef FLASH_AREA_0_OFFSET
+#error "FLASH_AREA_0_OFFSET must be defined by the target"
 #endif
 
-#ifndef FLASH_AREA_IMAGE_PRIMARY_SIZE
-#error "FLASH_AREA_IMAGE_PRIMARY_SIZE must be defined by the target"
+#ifndef FLASH_AREA_0_SIZE
+#error "FLASH_AREA_0_SIZE must be defined by the target"
 #endif
 
-#ifndef FLASH_AREA_IMAGE_SECONDARY_OFFSET
-#error "FLASH_AREA_IMAGE_SECONDARY_OFFSET must be defined by the target"
+#ifndef FLASH_AREA_2_OFFSET
+#error "FLASH_AREA_2_OFFSET must be defined by the target"
 #endif
 
-#ifndef FLASH_AREA_IMAGE_SECONDARY_SIZE
-#error "FLASH_AREA_IMAGE_SECONDARY_SIZE must be defined by the target"
+#ifndef FLASH_AREA_2_SIZE
+#error "FLASH_AREA_2_SIZE must be defined by the target"
 #endif
 
-#ifndef FLASH_AREA_IMAGE_SCRATCH_OFFSET
-#error "FLASH_AREA_IMAGE_SCRATCH_OFFSET must be defined by the target"
+#if (MCUBOOT_IMAGE_NUMBER == 2)
+#ifndef FLASH_AREA_1_OFFSET
+#error "FLASH_AREA_1_OFFSET must be defined by the target"
 #endif
 
-#ifndef FLASH_AREA_IMAGE_SCRATCH_SIZE
-#error "FLASH_AREA_IMAGE_SCRATCH_SIZE must be defined by the target"
+#ifndef FLASH_AREA_1_SIZE
+#error "FLASH_AREA_1_SIZE must be defined by the target"
+#endif
+
+#ifndef FLASH_AREA_3_OFFSET
+#error "FLASH_AREA_3_OFFSET must be defined by the target"
+#endif
+
+#ifndef FLASH_AREA_3_SIZE
+#error "FLASH_AREA_3_SIZE must be defined by the target"
+#endif
+#endif /* (MCUBOOT_IMAGE_NUMBER == 2) */
+
+#ifndef FLASH_AREA_SCRATCH_OFFSET
+#error "FLASH_AREA_SCRATCH_OFFSET must be defined by the target"
+#endif
+
+#ifndef FLASH_AREA_SCRATCH_SIZE
+#error "FLASH_AREA_SCRATCH_SIZE must be defined by the target"
 #endif
 
 #ifndef FLASH_DEV_NAME
@@ -57,4 +75,4 @@
 #error "BOOT_MAX_IMG_SECTORS must be defined by the target"
 #endif
 
-#endif
+#endif /* H_TARGETS_TARGET_ */