Boot: Use the same flash_map module as upstream MCUBoot

Add new sysflash.h and flash_map_extended.h files as they are needed to
build TF-M with the original MCUBoot. Some of the macro definitions and
function declarations from flash_map.h were moved into these
new headers.

Change-Id: I9b5ddeba9528c82c7ccfc59fbba5c661f0ad1084
Signed-off-by: David Vincze <david.vincze@arm.com>
diff --git a/bl2/ext/mcuboot/include/sysflash/sysflash.h b/bl2/ext/mcuboot/include/sysflash/sysflash.h
new file mode 100644
index 0000000..9ade3a3
--- /dev/null
+++ b/bl2/ext/mcuboot/include/sysflash/sysflash.h
@@ -0,0 +1,50 @@
+/* Manual version of auto-generated version. */
+
+/*
+ * Original code taken from mcuboot project at:
+ * https://github.com/JuulLabs-OSS/mcuboot
+ * Git SHA of the original version: ac55554059147fff718015be9f4bd3108123f50a
+ * Modifications are Copyright (c) 2020 Arm Limited.
+ */
+
+#ifndef __SYSFLASH_H__
+#define __SYSFLASH_H__
+
+#include "flash_layout.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if (MCUBOOT_IMAGE_NUMBER == 1)
+/*
+ * NOTE: the definition below returns the same values for true/false on
+ * purpose, to avoid having to mark x as non-used by all callers when
+ * running in single image mode.
+ */
+#define FLASH_AREA_IMAGE_PRIMARY(x)     (((x) == 0) ? FLASH_AREA_0_ID : \
+                                                      FLASH_AREA_0_ID)
+#define FLASH_AREA_IMAGE_SECONDARY(x)   (((x) == 0) ? FLASH_AREA_2_ID : \
+                                                      FLASH_AREA_2_ID)
+#elif (MCUBOOT_IMAGE_NUMBER == 2)
+/* MCUBoot currently supports only up to 2 updatable firmware images.
+ * If the number of the current image is greater than MCUBOOT_IMAGE_NUMBER - 1
+ * then a dummy value will be assigned to the flash area macros.
+ */
+#define FLASH_AREA_IMAGE_PRIMARY(x)     (((x) == 0) ? FLASH_AREA_0_ID : \
+                                         ((x) == 1) ? FLASH_AREA_1_ID : \
+                                                      255 )
+#define FLASH_AREA_IMAGE_SECONDARY(x)   (((x) == 0) ? FLASH_AREA_2_ID : \
+                                         ((x) == 1) ? FLASH_AREA_3_ID : \
+                                                      255 )
+#else
+#error "Image slot and flash area mapping is not defined"
+#endif
+
+#define FLASH_AREA_IMAGE_SCRATCH        FLASH_AREA_SCRATCH_ID
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __SYSFLASH_H__ */
\ No newline at end of file