sim: Implement flash_area_get_sectors for sim
Implement the new flash sector query API for the simulator.  This is
generated from the data for the deprecated API.  Once the old API is
removed, the flash simulator can be changed to just return the new data
directly.
@@ -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,
