Skip to content

Commit 1acec48

Browse files
committed
boot: generalize boot_write_image_ok() function to get flag as parameter
This commit generalizes boot_write_image_ok() function to take flag as an input parameter. Function is also rename to boot_write_image_flag() so the name matches the usage better. This is useful to future implementation of different algorithms that might need other flags than BOOT_FLAG_SET to be written to image trailer. Signed-off-by: Michal Lenc <michallenc@seznam.cz>
1 parent d2e69bf commit 1acec48

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

boot/bootutil/src/bootutil_priv.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ int boot_read_swap_state_by_id(int flash_area_id,
277277
int boot_write_magic(const struct flash_area *fap);
278278
int boot_write_status(const struct boot_loader_state *state, struct boot_status *bs);
279279
int boot_write_copy_done(const struct flash_area *fap);
280-
int boot_write_image_ok(const struct flash_area *fap);
280+
int boot_write_image_flag(const struct flash_area *fap, int flag);
281281
int boot_write_swap_info(const struct flash_area *fap, uint8_t swap_type,
282282
uint8_t image_num);
283283
int boot_write_swap_size(const struct flash_area *fap, uint32_t swap_size);

boot/bootutil/src/bootutil_public.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -354,15 +354,15 @@ boot_write_trailer_flag(const struct flash_area *fap, uint32_t off,
354354
}
355355

356356
int
357-
boot_write_image_ok(const struct flash_area *fap)
357+
boot_write_image_flag(const struct flash_area *fap, int flag)
358358
{
359359
uint32_t off;
360360

361361
off = boot_image_ok_off(fap);
362362
BOOT_LOG_DBG("writing image_ok; fa_id=%d off=0x%lx (0x%lx)",
363363
flash_area_get_id(fap), (unsigned long)off,
364364
(unsigned long)(flash_area_get_off(fap) + off));
365-
return boot_write_trailer_flag(fap, off, BOOT_FLAG_SET);
365+
return boot_write_trailer_flag(fap, off, flag);
366366
}
367367

368368
int
@@ -515,7 +515,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
515515
* confirm a padded image which has been programmed using
516516
* a programming interface.
517517
*/
518-
rc = boot_write_image_ok(fa);
518+
rc = boot_write_image_flag(fa, BOOT_FLAG_SET);
519519
}
520520

521521
break;
@@ -525,7 +525,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
525525
rc = boot_write_magic(fa);
526526

527527
if (rc == 0 && confirm) {
528-
rc = boot_write_image_ok(fa);
528+
rc = boot_write_image_flag(fa, BOOT_FLAG_SET);
529529
}
530530

531531
if (rc == 0) {
@@ -605,7 +605,7 @@ boot_set_next(const struct flash_area *fa, bool active, bool confirm)
605605
}
606606

607607
if (slot_state.image_ok == BOOT_FLAG_UNSET) {
608-
rc = boot_write_image_ok(fa);
608+
rc = boot_write_image_flag(fa, BOOT_FLAG_SET);
609609
if (rc != 0) {
610610
break;
611611
}

boot/bootutil/src/swap_misc.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ swap_status_init(const struct boot_loader_state *state,
106106
}
107107

108108
if (swap_state.image_ok == BOOT_FLAG_SET) {
109-
rc = boot_write_image_ok(fap);
109+
rc = boot_write_image_flag(fap, BOOT_FLAG_SET);
110110
assert(rc == 0);
111111
}
112112

@@ -222,7 +222,7 @@ swap_set_image_ok(uint8_t image_index)
222222
}
223223

224224
if (state.image_ok == BOOT_FLAG_UNSET) {
225-
rc = boot_write_image_ok(fap);
225+
rc = boot_write_image_flag(fap, BOOT_FLAG_SET);
226226
}
227227

228228
out:

boot/bootutil/src/swap_move.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ fixup_revert(const struct boot_loader_state *state, struct boot_status *bs,
483483
rc = swap_erase_trailer_sectors(state, fap_sec);
484484
assert(rc == 0);
485485

486-
rc = boot_write_image_ok(fap_sec);
486+
rc = boot_write_image_flag(fap_sec, BOOT_FLAG_SET);
487487
assert(rc == 0);
488488

489489
rc = boot_write_swap_size(fap_sec, bs->swap_size);

boot/bootutil/src/swap_scratch.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ boot_swap_sectors(int idx, uint32_t sz, struct boot_loader_state *state,
635635
assert(rc == 0);
636636

637637
if (swap_state.image_ok == BOOT_FLAG_SET) {
638-
rc = boot_write_image_ok(fap_primary_slot);
638+
rc = boot_write_image_flag(fap_primary_slot, BOOT_FLAG_SET);
639639
assert(rc == 0);
640640
}
641641

boot/zephyr/firmware_loader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ boot_image_validate_once(const struct flash_area *fa_p,
8787
if (rc != 0)
8888
FIH_RET(FIH_FAILURE);
8989
}
90-
rc = boot_write_image_ok(fa_p);
90+
rc = boot_write_image_flag(fa_p, BOOT_FLAG_SET);
9191
if (rc != 0)
9292
FIH_RET(FIH_FAILURE);
9393
}

boot/zephyr/single_loader.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ boot_image_validate_once(const struct flash_area *fa_p,
8383
if (rc != 0)
8484
FIH_RET(FIH_FAILURE);
8585
}
86-
rc = boot_write_image_ok(fa_p);
86+
rc = boot_write_image_flag(fa_p, BOOT_FLAG_SET);
8787
if (rc != 0)
8888
FIH_RET(FIH_FAILURE);
8989
}

0 commit comments

Comments
 (0)