diff --git a/sim/csupport/run.c b/sim/csupport/run.c index 5d6f6510..dc44c312 100644 --- a/sim/csupport/run.c +++ b/sim/csupport/run.c @@ -188,6 +188,37 @@ int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret) return 0; } +int flash_area_get_sectors(int fa_id, uint32_t *count, + struct flash_sector *sectors) +{ + int i; + struct area *slot; + + for (i = 0; i < flash_areas->num_slots; i++) { + if (flash_areas->slots[i].id == fa_id) + break; + } + if (i == flash_areas->num_slots) { + printf("Unsupported area\n"); + abort(); + } + + slot = &flash_areas->slots[i]; + + if (slot->num_areas > *count) { + printf("Too many areas in slot\n"); + abort(); + } + + for (i = 0; i < slot->num_areas; i++) { + sectors[i].fs_off = slot->areas[i].fa_off - + slot->whole.fa_off; + sectors[i].fs_size = slot->areas[i].fa_size; + } + *count = slot->num_areas; + + return 0; +} int bootutil_img_validate(struct image_header *hdr, const struct flash_area *fap,