bootutil: move loader state definition to private header
This begins some preparatory work to using flash_area_get_sectors() in
loader.c. Subsequent commits will add and use additional accessors for
the contents of this struct.
Making the struct contents opaque will allow it to contain struct
flash_area or struct flash_sector values in its sectors field. This
will allow use of either flash_area_get_sectors() or the
now-deprecated flash_area_to_sectors().
Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
diff --git a/boot/bootutil/src/bootutil_priv.h b/boot/bootutil/src/bootutil_priv.h
index e8c8a8f..fa50644 100644
--- a/boot/bootutil/src/bootutil_priv.h
+++ b/boot/bootutil/src/bootutil_priv.h
@@ -20,6 +20,7 @@
#ifndef H_BOOTUTIL_PRIV_
#define H_BOOTUTIL_PRIV_
+#include "flash_map/flash_map.h"
#include "bootutil/image.h"
#ifdef __cplusplus
@@ -94,6 +95,22 @@
extern const uint32_t BOOT_MAGIC_SZ;
+/** Number of image slots in flash; currently limited to two. */
+#define BOOT_NUM_SLOTS 2
+
+/** Private state maintained during boot. */
+struct boot_loader_state {
+ struct {
+ struct image_header hdr;
+ struct flash_area *sectors;
+ int num_sectors;
+ } imgs[BOOT_NUM_SLOTS];
+
+ struct flash_area scratch_sector;
+
+ uint8_t write_sz;
+};
+
int bootutil_verify_sig(uint8_t *hash, uint32_t hlen, uint8_t *sig, int slen,
uint8_t key_id);