ifdtool: Introduce region_name_fmap

Instead of directly accessing the region_name array use a helper
function. This allows to move the region name array to a separate
file.

Change-Id: Ifc810da1628cebd2728d0185502c462ff9428597
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/68694
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Lean Sheng Tan <sheng.tan@9elements.com>
This commit is contained in:
Patrick Rudolph 2022-10-22 11:19:02 +02:00 committed by Lean Sheng Tan
parent 1920900baa
commit ef5ebdb5bb
1 changed files with 12 additions and 2 deletions

View File

@ -361,6 +361,16 @@ static const char *region_name(unsigned int region_type)
return region_names[region_type].pretty;
}
static const char *region_name_fmap(unsigned int region_type)
{
if (region_type >= max_regions) {
fprintf(stderr, "Invalid region type.\n");
exit(EXIT_FAILURE);
}
return region_names[region_type].fmapname;
}
static const char *region_name_short(unsigned int region_type)
{
if (region_type >= max_regions) {
@ -1073,7 +1083,7 @@ static void validate_layout(char *image, int size)
fmap = (struct fmap *)(image + fmap_loc);
for (i = 0; i < max_regions; i++) {
if (region_names[i].fmapname == NULL)
if (region_name_fmap(i) == NULL)
continue;
region_t region = get_region(frba, i);
@ -1082,7 +1092,7 @@ static void validate_layout(char *image, int size)
continue;
const struct fmap_area *area =
fmap_find_area(fmap, region_names[i].fmapname);
fmap_find_area(fmap, region_name_fmap(i));
if (!area)
continue;