Replace flash partitioning terminology

This change replaces the slot 0/1 terminology with primary/secondary
slot and replaces FLASH_AREA_IMAGE_0/1 with
FLASH_AREA_IMAGE_PRIMARY/SECONDARY. This naming convention may be more
understandable, fits better to MCUs with multiple images and it is an
architecture agnostic alternative as well.

Change-Id: I655a585f6ae023852c671ee6635399efe25209c9
Signed-off-by: David Vincze <david.vincze@arm.com>
Signed-off-by: David Brown <david.brown@linaro.org>
diff --git a/boot/bootutil/src/bootutil_priv.h b/boot/bootutil/src/bootutil_priv.h
index bc9c61f..b6bb792 100644
--- a/boot/bootutil/src/bootutil_priv.h
+++ b/boot/bootutil/src/bootutil_priv.h
@@ -129,18 +129,26 @@
 #endif
 
 /** Number of image slots in flash; currently limited to two. */
-#define BOOT_NUM_SLOTS             2
+#define BOOT_NUM_SLOTS                  2
 
 /** Maximum number of image sectors supported by the bootloader. */
-#define BOOT_STATUS_STATE_COUNT    3
-#define BOOT_STATUS_MAX_ENTRIES    BOOT_MAX_IMG_SECTORS
+#define BOOT_STATUS_STATE_COUNT         3
+#define BOOT_STATUS_MAX_ENTRIES         BOOT_MAX_IMG_SECTORS
 
-#define BOOT_STATUS_SOURCE_NONE    0
-#define BOOT_STATUS_SOURCE_SCRATCH 1
-#define BOOT_STATUS_SOURCE_SLOT0   2
+#define BOOT_PRIMARY_SLOT               0
+#define BOOT_SECONDARY_SLOT             1
 
-#define BOOT_FLAG_IMAGE_OK         0
-#define BOOT_FLAG_COPY_DONE        1
+#define BOOT_STATUS_SOURCE_NONE         0
+#define BOOT_STATUS_SOURCE_SCRATCH      1
+#define BOOT_STATUS_SOURCE_PRIMARY_SLOT 2
+
+#define BOOT_FLAG_IMAGE_OK              0
+#define BOOT_FLAG_COPY_DONE             1
+
+#if defined(MCUBOOT_MYNEWT)
+    #define FLASH_AREA_IMAGE_PRIMARY    FLASH_AREA_IMAGE_0
+    #define FLASH_AREA_IMAGE_SECONDARY  FLASH_AREA_IMAGE_1
+#endif
 
 extern const uint32_t BOOT_MAGIC_SZ;
 
@@ -265,16 +273,19 @@
     int rc;
 
     switch (flash_area) {
-    case FLASH_AREA_IMAGE_0:
-        rc = flash_area_to_sectors(flash_area, &num_sectors, state->imgs[0].sectors);
-        state->imgs[0].num_sectors = (size_t)num_sectors;
+    case FLASH_AREA_IMAGE_PRIMARY:
+        rc = flash_area_to_sectors(flash_area, &num_sectors,
+                                   state->imgs[BOOT_PRIMARY_SLOT].sectors);
+        state->imgs[BOOT_PRIMARY_SLOT].num_sectors = (size_t)num_sectors;
         break;
-    case FLASH_AREA_IMAGE_1:
-        rc = flash_area_to_sectors(flash_area, &num_sectors, state->imgs[1].sectors);
-        state->imgs[1].num_sectors = (size_t)num_sectors;
+    case FLASH_AREA_IMAGE_SECONDARY:
+        rc = flash_area_to_sectors(flash_area, &num_sectors,
+                                   state->imgs[BOOT_SECONDARY_SLOT].sectors);
+        state->imgs[BOOT_SECONDARY_SLOT].num_sectors = (size_t)num_sectors;
         break;
     case FLASH_AREA_IMAGE_SCRATCH:
-        rc = flash_area_to_sectors(flash_area, &num_sectors, state->scratch.sectors);
+        rc = flash_area_to_sectors(flash_area, &num_sectors,
+                                   state->scratch.sectors);
         state->scratch.num_sectors = (size_t)num_sectors;
         break;
     default:
@@ -310,15 +321,15 @@
     int rc;
 
     switch (flash_area) {
-    case FLASH_AREA_IMAGE_0:
+    case FLASH_AREA_IMAGE_PRIMARY:
         num_sectors = BOOT_MAX_IMG_SECTORS;
-        out_sectors = state->imgs[0].sectors;
-        out_num_sectors = &state->imgs[0].num_sectors;
+        out_sectors = state->imgs[BOOT_PRIMARY_SLOT].sectors;
+        out_num_sectors = &state->imgs[BOOT_PRIMARY_SLOT].num_sectors;
         break;
-    case FLASH_AREA_IMAGE_1:
+    case FLASH_AREA_IMAGE_SECONDARY:
         num_sectors = BOOT_MAX_IMG_SECTORS;
-        out_sectors = state->imgs[1].sectors;
-        out_num_sectors = &state->imgs[1].num_sectors;
+        out_sectors = state->imgs[BOOT_SECONDARY_SLOT].sectors;
+        out_num_sectors = &state->imgs[BOOT_SECONDARY_SLOT].num_sectors;
         break;
     case FLASH_AREA_IMAGE_SCRATCH:
         num_sectors = BOOT_MAX_IMG_SECTORS;