ifdtool: use max_regions to reflect ifd header version
Change-Id: I71a12235196d478673d2816a9ee64f1373f3a63d Signed-off-by: Alexander Couzens <lynxis@fe80.eu> Reviewed-on: https://review.coreboot.org/16935 Tested-by: build bot (Jenkins) Reviewed-by: Philipp Deppenwiese <zaolin.daisuki@googlemail.com> Reviewed-by: Duncan Laurie <dlaurie@chromium.org>
This commit is contained in:
parent
a81bef1bd6
commit
fd5c658871
|
@ -187,7 +187,7 @@ static void set_region(frba_t *frba, int region_type, region_t region)
|
||||||
|
|
||||||
static const char *region_name(int region_type)
|
static const char *region_name(int region_type)
|
||||||
{
|
{
|
||||||
if (region_type < 0 || region_type >= MAX_REGIONS) {
|
if (region_type < 0 || region_type >= max_regions) {
|
||||||
fprintf(stderr, "Invalid region type.\n");
|
fprintf(stderr, "Invalid region type.\n");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -197,7 +197,7 @@ static const char *region_name(int region_type)
|
||||||
|
|
||||||
static const char *region_name_short(int region_type)
|
static const char *region_name_short(int region_type)
|
||||||
{
|
{
|
||||||
if (region_type < 0 || region_type >= MAX_REGIONS) {
|
if (region_type < 0 || region_type >= max_regions) {
|
||||||
fprintf(stderr, "Invalid region type.\n");
|
fprintf(stderr, "Invalid region type.\n");
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ static int region_num(const char *name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < MAX_REGIONS; i++) {
|
for (i = 0; i < max_regions; i++) {
|
||||||
if (strcasecmp(name, region_names[i].pretty) == 0)
|
if (strcasecmp(name, region_names[i].pretty) == 0)
|
||||||
return i;
|
return i;
|
||||||
if (strcasecmp(name, region_names[i].terse) == 0)
|
if (strcasecmp(name, region_names[i].terse) == 0)
|
||||||
|
@ -233,7 +233,7 @@ static const char *region_filename(int region_type)
|
||||||
"flashregion_8_ec.bin",
|
"flashregion_8_ec.bin",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (region_type < 0 || region_type >= MAX_REGIONS) {
|
if (region_type < 0 || region_type >= max_regions) {
|
||||||
fprintf(stderr, "Invalid region type %d.\n", region_type);
|
fprintf(stderr, "Invalid region type %d.\n", region_type);
|
||||||
exit (EXIT_FAILURE);
|
exit (EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
@ -295,7 +295,7 @@ static void dump_frba_layout(frba_t * frba, char *layout_fname)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < MAX_REGIONS; i++) {
|
for (i = 0; i < max_regions; i++) {
|
||||||
dump_region_layout(buf, bufsize, i, frba);
|
dump_region_layout(buf, bufsize, i, frba);
|
||||||
if (write(layout_fd, buf, strlen(buf)) < 0) {
|
if (write(layout_fd, buf, strlen(buf)) < 0) {
|
||||||
perror("Could not write to file");
|
perror("Could not write to file");
|
||||||
|
@ -980,7 +980,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
|
||||||
frba_t *frba =
|
frba_t *frba =
|
||||||
(frba_t *) (image + (((fdb->flmap0 >> 16) & 0xff) << 4));
|
(frba_t *) (image + (((fdb->flmap0 >> 16) & 0xff) << 4));
|
||||||
|
|
||||||
for (i = 0; i < MAX_REGIONS; i++) {
|
for (i = 0; i < max_regions; i++) {
|
||||||
current_regions[i] = get_region(frba, i);
|
current_regions[i] = get_region(frba, i);
|
||||||
new_regions[i] = get_region(frba, i);
|
new_regions[i] = get_region(frba, i);
|
||||||
}
|
}
|
||||||
|
@ -1024,7 +1024,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
|
||||||
fclose(romlayout);
|
fclose(romlayout);
|
||||||
|
|
||||||
/* check new layout */
|
/* check new layout */
|
||||||
for (i = 0; i < MAX_REGIONS; i++) {
|
for (i = 0; i < max_regions; i++) {
|
||||||
if (new_regions[i].size == 0)
|
if (new_regions[i].size == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -1035,7 +1035,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
|
||||||
printf(" This may result in an unusable image.\n");
|
printf(" This may result in an unusable image.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (j = i + 1; j < MAX_REGIONS; j++) {
|
for (j = i + 1; j < max_regions; j++) {
|
||||||
if (regions_collide(new_regions[i], new_regions[j])) {
|
if (regions_collide(new_regions[i], new_regions[j])) {
|
||||||
fprintf(stderr, "Regions would overlap.\n");
|
fprintf(stderr, "Regions would overlap.\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -1057,7 +1057,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
|
||||||
/* copy regions to a new image */
|
/* copy regions to a new image */
|
||||||
new_image = malloc(new_extent);
|
new_image = malloc(new_extent);
|
||||||
memset(new_image, 0xff, new_extent);
|
memset(new_image, 0xff, new_extent);
|
||||||
for (i = 0; i < MAX_REGIONS; i++) {
|
for (i = 0; i < max_regions; i++) {
|
||||||
int copy_size = new_regions[i].size;
|
int copy_size = new_regions[i].size;
|
||||||
int offset_current = 0, offset_new = 0;
|
int offset_current = 0, offset_new = 0;
|
||||||
region_t current = current_regions[i];
|
region_t current = current_regions[i];
|
||||||
|
@ -1095,7 +1095,7 @@ void new_layout(char *filename, char *image, int size, char *layout_fname)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
||||||
frba = (frba_t *) (new_image + (((fdb->flmap0 >> 16) & 0xff) << 4));
|
frba = (frba_t *) (new_image + (((fdb->flmap0 >> 16) & 0xff) << 4));
|
||||||
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