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);
 
diff --git a/boot/bootutil/src/loader.c b/boot/bootutil/src/loader.c
index d42c40e..d56cade 100644
--- a/boot/bootutil/src/loader.c
+++ b/boot/bootutil/src/loader.c
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include <string.h>
 #include "sysflash/sysflash.h"
-#include "flash_map/flash_map.h"
 #include <hal/hal_flash.h>
 #include <os/os_malloc.h>
 #include "bootutil/bootutil.h"
@@ -44,20 +43,7 @@
 
 #define BOOT_MAX_IMG_SECTORS        120
 
-/** Number of image slots in flash; currently limited to two. */
-#define BOOT_NUM_SLOTS              2
-
-static struct {
-    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;
-} boot_data;
+static struct boot_loader_state boot_data;
 
 struct boot_status_table {
     /**