From 2c895aaac366017bea3641b43cc5f71e5cc86609 Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Mon, 24 Apr 2023 19:28:21 +0200 Subject: util/ifdtool/ifdtool.c: Fix default FMAP generation According to SPI programming guide, a region limit of 0 as well as region base of 7FFFh indicates an unused/reserved region. Signed-off-by: Maximilian Brune Change-Id: I790d7f5631ecef3043b2c17c41430dc4fd854f72 Reviewed-on: https://review.coreboot.org/c/coreboot/+/74735 Tested-by: build bot (Jenkins) Reviewed-by: Matt DeVillier --- util/ifdtool/ifdtool.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'util') diff --git a/util/ifdtool/ifdtool.c b/util/ifdtool/ifdtool.c index 625b4cf5ac..ada120b001 100644 --- a/util/ifdtool/ifdtool.c +++ b/util/ifdtool/ifdtool.c @@ -457,8 +457,11 @@ static void dump_flashrom_layout(char *image, int size, const char *layout_fname for (unsigned int i = 0; i < max_regions; i++) { struct region region = get_region(frba, i); - /* is region invalid? */ - if (region.size < 1) + + /* A region limit of 0 is an indicator of an unused region + * A region base of 7FFFh is an indicator of a reserved region + */ + if (region.limit == 0 || region.base == 0x07FFF000) continue; char buf[LAYOUT_LINELEN]; @@ -1027,8 +1030,11 @@ static void create_fmap_template(char *image, int size, const char *layout_fname struct region sorted_regions[MAX_REGIONS] = { 0 }; for (unsigned int i = 0; i < max_regions; i++) { struct region region = get_region(frba, i); - /* is region invalid? */ - if (region.size < 1) + + /* A region limit of 0 is an indicator of an unused region + * A region base of 7FFFh is an indicator of a reserved region + */ + if (region.limit == 0 || region.base == 0x07FFF000) continue; /* Here we decide to use the coreboot generated FMAP BIOS region, instead of -- cgit v1.2.3