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. Signed-off-by: David Brown <david.brown@linaro.org> Signed-off-by: Marti Bolivar <marti.bolivar@linaro.org>
This commit is contained in:
parent
83a3cef34d
commit
60399f69fb
|
@ -188,6 +188,37 @@ int flash_area_to_sectors(int idx, int *cnt, struct flash_area *ret)
|
||||||
return 0;
|
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,
|
int bootutil_img_validate(struct image_header *hdr,
|
||||||
const struct flash_area *fap,
|
const struct flash_area *fap,
|
||||||
|
|
Loading…
Reference in New Issue