bootutil_public: made boot_read_swap_state_by_id() API
Made boot_read_swap_state_by_id() public API
function.
Signed-off-by: Andrzej Puzdrowski <andrzej.puzdrowski@nordicsemi.no>
diff --git a/boot/bootutil/include/bootutil/bootutil_public.h b/boot/bootutil/include/bootutil/bootutil_public.h
index 2e37746..02df854 100644
--- a/boot/bootutil/include/bootutil/bootutil_public.h
+++ b/boot/bootutil/include/bootutil/bootutil_public.h
@@ -88,6 +88,14 @@
#define BOOT_MAGIC_SZ (sizeof boot_img_magic)
+struct boot_swap_state {
+ uint8_t magic; /* One of the BOOT_MAGIC_[...] values. */
+ uint8_t swap_type; /* One of the BOOT_SWAP_TYPE_[...] values. */
+ uint8_t copy_done; /* One of the BOOT_FLAG_[...] values. */
+ uint8_t image_ok; /* One of the BOOT_FLAG_[...] values. */
+ uint8_t image_num; /* Boot status belongs to this image */
+};
+
/**
* @brief Determines the action, if any, that mcuboot will take on a image pair.
*
@@ -153,6 +161,17 @@
*/
int boot_read_image_ok(const struct flash_area *fap, uint8_t *image_ok);
+/**
+ * @brief Read the image swap state
+ *
+ * @param flash_area_id Id of flash parttition from which trailer will be read.
+ * @param state Struture for holding swap state.
+ *
+ * @return 0 on success, nonzero errno code on fail.
+ */
+int
+boot_read_swap_state_by_id(int flash_area_id, struct boot_swap_state *state);
+
#define BOOT_MAGIC_ARR_SZ \
(sizeof boot_img_magic / sizeof boot_img_magic[0])
diff --git a/boot/bootutil/src/bootutil_priv.h b/boot/bootutil/src/bootutil_priv.h
index 2d9eb76..69aa6ca 100644
--- a/boot/bootutil/src/bootutil_priv.h
+++ b/boot/bootutil/src/bootutil_priv.h
@@ -146,14 +146,6 @@
extern const uint32_t boot_img_magic[4];
-struct boot_swap_state {
- uint8_t magic; /* One of the BOOT_MAGIC_[...] values. */
- uint8_t swap_type; /* One of the BOOT_SWAP_TYPE_[...] values. */
- uint8_t copy_done; /* One of the BOOT_FLAG_[...] values. */
- uint8_t image_ok; /* One of the BOOT_FLAG_[...] values. */
- uint8_t image_num; /* Boot status belongs to this image */
-};
-
#ifdef MCUBOOT_IMAGE_NUMBER
#define BOOT_IMAGE_NUMBER MCUBOOT_IMAGE_NUMBER
#else
diff --git a/boot/bootutil/src/bootutil_public.c b/boot/bootutil/src/bootutil_public.c
index 3c9e204..b2c588d 100644
--- a/boot/bootutil/src/bootutil_public.c
+++ b/boot/bootutil/src/bootutil_public.c
@@ -295,9 +295,6 @@
return boot_read_image_ok(fap, &state->image_ok);
}
-/**
- * Reads the image trailer from the scratch area.
- */
int
boot_read_swap_state_by_id(int flash_area_id, struct boot_swap_state *state)
{