Platform: Move BL2 trailer base values to platform

This change moves the definition of BOOT_STATUS_MAX_ENTRIES and
BOOT_MAX_IMG_SECTORS from BL2 to the platform specific file
flash_layout.h.

Change-Id: I0e028c3e514a9661850fc9f41b6104089903e207
Signed-off-by: Mate Toth-Pal <mate.toth-pal@arm.com>
diff --git a/bl2/ext/mcuboot/bootutil/src/bootutil_priv.h b/bl2/ext/mcuboot/bootutil/src/bootutil_priv.h
index 9c3d258..a8969e3 100644
--- a/bl2/ext/mcuboot/bootutil/src/bootutil_priv.h
+++ b/bl2/ext/mcuboot/bootutil/src/bootutil_priv.h
@@ -22,6 +22,7 @@
 
 #include "flash_map/flash_map.h"
 #include "bootutil/image.h"
+#include "flash_layout.h"
 
 #ifdef __cplusplus
 extern "C" {
@@ -84,7 +85,6 @@
 };
 
 #define BOOT_STATUS_STATE_COUNT 3
-#define BOOT_STATUS_MAX_ENTRIES 256
 
 #define BOOT_STATUS_SOURCE_NONE    0
 #define BOOT_STATUS_SOURCE_SCRATCH 1
@@ -101,9 +101,6 @@
 /** Number of image slots in flash; currently limited to two. */
 #define BOOT_NUM_SLOTS              2
 
-/** Maximum number of image sectors supported by the bootloader. */
-#define BOOT_MAX_IMG_SECTORS        256
-
 /**
  * Compatibility shim for flash sector type.
  *
diff --git a/bl2/ext/mcuboot/include/target.h b/bl2/ext/mcuboot/include/target.h
index 47d5a84..28e6cac 100644
--- a/bl2/ext/mcuboot/include/target.h
+++ b/bl2/ext/mcuboot/include/target.h
@@ -49,4 +49,12 @@
 #error "BL2 supports CMSIS flash interface and device name must be specified"
 #endif
 
+#ifndef BOOT_STATUS_MAX_ENTRIES
+#error "BOOT_STATUS_MAX_ENTRIES must be defined by the target"
+#endif
+
+#ifndef BOOT_MAX_IMG_SECTORS
+#error "BOOT_MAX_IMG_SECTORS must be defined by the target"
+#endif
+
 #endif
diff --git a/platform/ext/target/mps2/an519/partition/flash_layout.h b/platform/ext/target/mps2/an519/partition/flash_layout.h
index a0881d1..e792f7b 100644
--- a/platform/ext/target/mps2/an519/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an519/partition/flash_layout.h
@@ -72,6 +72,14 @@
 #define FLASH_AREA_IMAGE_SCRATCH_OFFSET (0x280000)
 #define FLASH_AREA_IMAGE_SCRATCH_SIZE   (2 * FLASH_PARTITION_SIZE)
 
+/* Maximum number of status entries supported by the bootloader. */
+#define BOOT_STATUS_MAX_ENTRIES         ((2 * FLASH_PARTITION_SIZE) / \
+                                         FLASH_AREA_IMAGE_SCRATCH_SIZE)
+
+/** Maximum number of image sectors supported by the bootloader. */
+#define BOOT_MAX_IMG_SECTORS            ((2 * FLASH_PARTITION_SIZE) / \
+                                         FLASH_AREA_IMAGE_SECTOR_SIZE)
+
 #define FLASH_SST_AREA_OFFSET           (0x380000)
 #define FLASH_SST_AREA_SIZE             (0x5000)   /* 20 KB */
 
diff --git a/platform/ext/target/mps2/an521/partition/flash_layout.h b/platform/ext/target/mps2/an521/partition/flash_layout.h
index 21b57a1..cf0d1ab 100644
--- a/platform/ext/target/mps2/an521/partition/flash_layout.h
+++ b/platform/ext/target/mps2/an521/partition/flash_layout.h
@@ -72,6 +72,14 @@
 #define FLASH_AREA_IMAGE_SCRATCH_OFFSET (0x280000)
 #define FLASH_AREA_IMAGE_SCRATCH_SIZE   (2 * FLASH_PARTITION_SIZE)
 
+/* Maximum number of status entries supported by the bootloader. */
+#define BOOT_STATUS_MAX_ENTRIES         ((2 * FLASH_PARTITION_SIZE) / \
+                                         FLASH_AREA_IMAGE_SCRATCH_SIZE)
+
+/** Maximum number of image sectors supported by the bootloader. */
+#define BOOT_MAX_IMG_SECTORS            ((2 * FLASH_PARTITION_SIZE) / \
+                                         FLASH_AREA_IMAGE_SECTOR_SIZE)
+
 #define FLASH_SST_AREA_OFFSET           (0x380000)
 #define FLASH_SST_AREA_SIZE             (0x5000)   /* 20 KB */
 
diff --git a/platform/ext/target/musca_a/partition/flash_layout.h b/platform/ext/target/musca_a/partition/flash_layout.h
index 3267a8c..2b1d099 100755
--- a/platform/ext/target/musca_a/partition/flash_layout.h
+++ b/platform/ext/target/musca_a/partition/flash_layout.h
@@ -80,6 +80,13 @@
                                          FLASH_AREA_IMAGE_1_SIZE)
 #define FLASH_AREA_IMAGE_SCRATCH_SIZE   (FLASH_AREA_IMAGE_SIZE)
 
+/* Maximum number of status entries supported by the bootloader. */
+#define BOOT_STATUS_MAX_ENTRIES         (FLASH_AREA_IMAGE_SIZE / \
+                                         FLASH_AREA_IMAGE_SCRATCH_SIZE)
+
+/** Maximum number of image sectors supported by the bootloader. */
+#define BOOT_MAX_IMG_SECTORS            (FLASH_AREA_IMAGE_SIZE / \
+                                         FLASH_AREA_IMAGE_SECTOR_SIZE)
 /*
  * Note: Though the SST_FLASH_AREA_ADDR is pointing to offset in flash, but
  * the actual contents of SST is stored in Code SRAM. See Driver_Flash.c for