boot: Modify common code access for flash_area objects
The commit changes direct access to flash_area, and flash_structure,
objects via filed names to access via getter functions
Purpose of this change is to make common code agnostic to internal
implementation of flash_area, and flash_sector, objects.
Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
diff --git a/boot/bootutil/src/bootutil_misc.c b/boot/bootutil/src/bootutil_misc.c
index 9ee317f..e8cef25 100644
--- a/boot/bootutil/src/bootutil_misc.c
+++ b/boot/bootutil/src/bootutil_misc.c
@@ -123,12 +123,12 @@
boot_status_entries(int image_index, const struct flash_area *fap)
{
#if MCUBOOT_SWAP_USING_SCRATCH
- if (fap->fa_id == FLASH_AREA_IMAGE_SCRATCH) {
+ if (flash_area_get_id(fap) == FLASH_AREA_IMAGE_SCRATCH) {
return BOOT_STATUS_STATE_COUNT;
} else
#endif
- if (fap->fa_id == FLASH_AREA_IMAGE_PRIMARY(image_index) ||
- fap->fa_id == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
+ if (flash_area_get_id(fap) == FLASH_AREA_IMAGE_PRIMARY(image_index) ||
+ flash_area_get_id(fap) == FLASH_AREA_IMAGE_SECONDARY(image_index)) {
return BOOT_STATUS_STATE_COUNT * BOOT_STATUS_MAX_ENTRIES;
}
return -1;
@@ -144,14 +144,14 @@
off_from_end = boot_trailer_sz(elem_sz);
- assert(off_from_end <= fap->fa_size);
- return fap->fa_size - off_from_end;
+ assert(off_from_end <= flash_area_get_size(fap));
+ return flash_area_get_size(fap) - off_from_end;
}
static inline uint32_t
boot_magic_off(const struct flash_area *fap)
{
- return fap->fa_size - BOOT_MAGIC_SZ;
+ return flash_area_get_size(fap) - BOOT_MAGIC_SZ;
}
static inline uint32_t
@@ -301,8 +301,8 @@
off = boot_copy_done_off(fap);
BOOT_LOG_DBG("writing copy_done; fa_id=%d off=0x%lx (0x%lx)",
- fap->fa_id, (unsigned long)off,
- (unsigned long)(fap->fa_off + off));
+ flash_area_get_id(fap), (unsigned long)off,
+ (unsigned long)(flash_area_get_off(fap) + off));
return boot_write_trailer_flag(fap, off, BOOT_FLAG_SET);
}
@@ -313,8 +313,8 @@
off = boot_swap_size_off(fap);
BOOT_LOG_DBG("writing swap_size; fa_id=%d off=0x%lx (0x%lx)",
- fap->fa_id, (unsigned long)off,
- (unsigned long)fap->fa_off + off);
+ flash_area_get_id(fap), (unsigned long)off,
+ (unsigned long)flash_area_get_off(fap) + off);
return boot_write_trailer(fap, off, (const uint8_t *) &swap_size, 4);
}
@@ -328,8 +328,8 @@
off = boot_enc_key_off(fap, slot);
BOOT_LOG_DBG("writing enc_key; fa_id=%d off=0x%lx (0x%lx)",
- fap->fa_id, (unsigned long)off,
- (unsigned long)fap->fa_off + off);
+ flash_area_get_id(fap), (unsigned long)off,
+ (unsigned long)flash_area_get_off(fap) + off);
#if MCUBOOT_SWAP_SAVE_ENCTLV
rc = flash_area_write(fap, off, bs->enctlv[slot], BOOT_ENC_TLV_ALIGN_SIZE);
#else