util/ifdtool: Support modification of single Flash Descriptor
Add the capability to update the Flash Descriptor directly instead of raising a Segmentation Fault. In this way it will be possible to add a Kconfig options to modify the ifd descriptor at build-time. Change-Id: Id3db09291af2bd2e759c283e316afd5da1fb4ca7 Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io> Reviewed-on: https://review.coreboot.org/c/coreboot/+/38711 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
f2eb687d19
commit
6f9a77851b
|
@ -1336,12 +1336,19 @@ static void new_layout(const char *filename, char *image, int size,
|
||||||
new_extent = new_regions[i].limit;
|
new_extent = new_regions[i].limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check if the image is actually a Flash Descriptor region */
|
||||||
|
if (size == new_regions[0].size) {
|
||||||
|
printf("The image is a single Flash Descriptor:\n");
|
||||||
|
printf(" Only the descriptor will be modified\n");
|
||||||
|
new_extent = size;
|
||||||
|
} else {
|
||||||
new_extent = next_pow2(new_extent - 1);
|
new_extent = next_pow2(new_extent - 1);
|
||||||
if (new_extent != size) {
|
if (new_extent != size) {
|
||||||
printf("The image has changed in size.\n");
|
printf("The image has changed in size.\n");
|
||||||
printf("The old image is %d bytes.\n", size);
|
printf("The old image is %d bytes.\n", size);
|
||||||
printf("The new image is %d bytes.\n", new_extent);
|
printf("The new image is %d bytes.\n", new_extent);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* copy regions to a new image */
|
/* copy regions to a new image */
|
||||||
new_image = malloc(new_extent);
|
new_image = malloc(new_extent);
|
||||||
|
@ -1367,6 +1374,12 @@ static void new_layout(const char *filename, char *image, int size,
|
||||||
offset_current = current->size - new->size;
|
offset_current = current->size - new->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (size < current->base + offset_current + copy_size) {
|
||||||
|
printf("Skip descriptor %d (%s) (region missing in the old image)\n", i,
|
||||||
|
region_name(i));
|
||||||
|
continue;
|
||||||
|
};
|
||||||
|
|
||||||
printf("Copy Descriptor %d (%s) (%d bytes)\n", i,
|
printf("Copy Descriptor %d (%s) (%d bytes)\n", i,
|
||||||
region_name(i), copy_size);
|
region_name(i), copy_size);
|
||||||
printf(" from %08x+%08x:%08x (%10d)\n", current->base,
|
printf(" from %08x+%08x:%08x (%10d)\n", current->base,
|
||||||
|
@ -1384,6 +1397,7 @@ static void new_layout(const char *filename, char *image, int size,
|
||||||
if (!frba)
|
if (!frba)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
|
printf("Modify Flash Descriptor regions\n");
|
||||||
for (i = 1; i < max_regions; i++)
|
for (i = 1; i < max_regions; i++)
|
||||||
set_region(frba, i, &new_regions[i]);
|
set_region(frba, i, &new_regions[i]);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue