sim/mcuboot-sys: provide sim-own porting files

The sim platform was sharing a few header
files with the zephyr-rtos port. This patch provides
sim own headers.

Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/sim/mcuboot-sys/build.rs b/sim/mcuboot-sys/build.rs
index 7a527fe..acc2af2 100644
--- a/sim/mcuboot-sys/build.rs
+++ b/sim/mcuboot-sys/build.rs
@@ -375,7 +375,6 @@
     conf.file("csupport/run.c");
     conf.conf.include("../../boot/bootutil/include");
     conf.conf.include("csupport");
-    conf.conf.include("../../boot/zephyr/include");
     conf.conf.debug(true);
     conf.conf.flag("-Wall");
     conf.conf.flag("-Werror");
diff --git a/sim/mcuboot-sys/csupport/flash_map_backend/flash_map_backend.h b/sim/mcuboot-sys/csupport/flash_map_backend/flash_map_backend.h
new file mode 100644
index 0000000..6783544
--- /dev/null
+++ b/sim/mcuboot-sys/csupport/flash_map_backend/flash_map_backend.h
@@ -0,0 +1,38 @@
+#ifndef __FLASH_MAP_BACKEND_H__
+#define __FLASH_MAP_BACKEND_H__
+
+#include <storage/flash_map.h>
+
+static inline uint32_t flash_area_get_off(const struct flash_area *fa)
+{
+	return (uint32_t)fa->fa_off;
+}
+
+static inline uint32_t flash_area_get_size(const struct flash_area *fa)
+{
+	return (uint32_t)fa->fa_size;
+}
+
+static inline uint32_t flash_sector_get_off(const struct flash_sector *fs)
+{
+	return fs->fs_off;
+}
+
+static inline uint32_t flash_sector_get_size(const struct flash_sector *fs)
+{
+	return fs->fs_size;
+}
+
+#define FLASH_DEVICE_ID 0
+
+static inline uint8_t flash_area_get_device_id(const struct flash_area *fa)
+{
+    return fa->fa_device_id;
+}
+
+static inline uint8_t flash_area_get_id(const struct flash_area *fa)
+{
+	return fa->fa_id;
+}
+
+#endif /* __FLASH_MAP_BACKEND_H__*/
diff --git a/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_config.h b/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_config.h
new file mode 100644
index 0000000..97a0ac5
--- /dev/null
+++ b/sim/mcuboot-sys/csupport/mcuboot_config/mcuboot_config.h
@@ -0,0 +1,28 @@
+/*
+ * Copyright (c) 2022 Nordic Semiconductor ASA
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef __MCUBOOT_CONFIG_H__
+#define __MCUBOOT_CONFIG_H__
+
+/*
+ * This file is included by the simulator, but we don't want to
+ * define almost anything here.
+ *
+ * Instead of using mcuboot_config.h, the simulator adds MCUBOOT_xxx
+ * configuration flags to the compiler command lines based on the
+ * values of environment variables. However, the file still must
+ * exist, or bootutil won't build.
+ */
+
+#define MCUBOOT_WATCHDOG_FEED()         \
+    do {                                \
+    } while (0)
+
+#define MCUBOOT_CPU_IDLE() \
+    do {                                \
+    } while (0)
+
+#endif /* __MCUBOOT_CONFIG_H__ */
diff --git a/sim/mcuboot-sys/csupport/os/os_heap.h b/sim/mcuboot-sys/csupport/os/os_heap.h
new file mode 100644
index 0000000..dfe162a
--- /dev/null
+++ b/sim/mcuboot-sys/csupport/os/os_heap.h
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2022 Nordic Semiconductor ASA
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef H_OS_HEAP_
+#define H_OS_HEAP_
+
+#endif
diff --git a/sim/mcuboot-sys/csupport/os/os_malloc.h b/sim/mcuboot-sys/csupport/os/os_malloc.h
new file mode 100644
index 0000000..4139d4a
--- /dev/null
+++ b/sim/mcuboot-sys/csupport/os/os_malloc.h
@@ -0,0 +1,10 @@
+/*
+ * Copyright (c) 2022 Nordic Semiconductor ASA
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef H_OS_MALLOC_
+#define H_OS_MALLOC_
+
+#endif
diff --git a/sim/mcuboot-sys/csupport/run.c b/sim/mcuboot-sys/csupport/run.c
index cb2016b..82d3e11 100644
--- a/sim/mcuboot-sys/csupport/run.c
+++ b/sim/mcuboot-sys/csupport/run.c
@@ -443,11 +443,6 @@
     abort();
 }
 
-uint8_t flash_area_get_device_id(const struct flash_area *fa)
-{
-    return fa->fa_device_id;
-}
-
 int flash_area_id_from_image_slot(int slot) {
     /* For single image cases, just use the first image. */
     return flash_area_id_from_multi_image_slot(0, slot);
diff --git a/sim/mcuboot-sys/csupport/sysflash/sysflash.h b/sim/mcuboot-sys/csupport/sysflash/sysflash.h
new file mode 100644
index 0000000..7f723a4
--- /dev/null
+++ b/sim/mcuboot-sys/csupport/sysflash/sysflash.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2022 Nordic Semiconductor ASA
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#ifndef __SYSFLASH_H__
+#define __SYSFLASH_H__
+
+#include <devicetree.h>
+#include <mcuboot_config/mcuboot_config.h>
+
+#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_ID(image_0) : \
+                                         FLASH_AREA_ID(image_0))
+#define FLASH_AREA_IMAGE_SECONDARY(x)  (((x) == 0) ?                \
+                                         FLASH_AREA_ID(image_1) : \
+                                         FLASH_AREA_ID(image_1))
+#elif (MCUBOOT_IMAGE_NUMBER == 2)
+/* MCUBoot currently supports only up to 2 updateable 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_ID(image_0) : \
+                                        ((x) == 1) ?                \
+                                         FLASH_AREA_ID(image_2) : \
+                                         255)
+#define FLASH_AREA_IMAGE_SECONDARY(x)  (((x) == 0) ?                \
+                                         FLASH_AREA_ID(image_1) : \
+                                        ((x) == 1) ?                \
+                                         FLASH_AREA_ID(image_3) : \
+                                         255)
+#else
+#error "Image slot and flash area mapping is not defined"
+#endif
+
+#define FLASH_AREA_IMAGE_SCRATCH    FLASH_AREA_ID(image_scratch)
+
+#endif /* __SYSFLASH_H__ */