bootutil: add accessors for sector size and number
Taking the opportunity to move some signed integers over to unsigned
size_t as we go. (Depending on compiler settings, signed / unsigned
comparisons can generate warnings, so it's nice to use the signedness
we mean when possible).
Having boot_img_set_num_sectors() is just an intermediate step; this
gets cleaned up as we go forward.
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 7676693..ddfdebd 100644
--- a/boot/bootutil/src/bootutil_priv.h
+++ b/boot/bootutil/src/bootutil_priv.h
@@ -149,6 +149,31 @@
return state->scratch_sector.fa_device_id;
}
+static inline size_t
+boot_img_num_sectors(struct boot_loader_state *state, size_t slot)
+{
+ return state->imgs[slot].num_sectors;
+}
+
+static inline void
+boot_img_set_num_sectors(struct boot_loader_state *state, size_t slot,
+ size_t num_sectors)
+{
+ state->imgs[slot].num_sectors = num_sectors;
+}
+
+static inline size_t
+boot_img_sector_size(struct boot_loader_state *state,
+ size_t slot, size_t sector)
+{
+ return state->imgs[slot].sectors[sector].fa_size;
+}
+
+static inline size_t boot_scratch_area_size(struct boot_loader_state *state)
+{
+ return state->scratch_sector.fa_size;
+}
+
#ifdef __cplusplus
}
#endif