summaryrefslogtreecommitdiffstats
path: root/libflashrom.c
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2019-06-15 15:55:11 +0200
committerNico Huber <nico.h@gmx.de>2021-06-26 15:54:22 +0000
commitf394fcec0da2fd4a9d1bd7a7911065344e67ce34 (patch)
treecdce7e8fe9c980df3602711cc7de9881f2deaf3e /libflashrom.c
parent7ebd578100e6526ef46c98cb9978d692160d8179 (diff)
downloadflashrom-f394fcec0da2fd4a9d1bd7a7911065344e67ce34.tar.gz
flashrom-f394fcec0da2fd4a9d1bd7a7911065344e67ce34.tar.bz2
flashrom-f394fcec0da2fd4a9d1bd7a7911065344e67ce34.zip
layout: Introduce flashrom_layout_add_region()
Adds a region to an existing layout, as long as there is space. Change-Id: I50d473d0d5d1fb38bd6f9ae3d7127e9ea66a94e1 Signed-off-by: Nico Huber <nico.h@gmx.de> Reviewed-on: https://review.coreboot.org/c/flashrom/+/33517 Reviewed-by: Angel Pons <th3fanbus@gmail.com> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Peter Marheine <pmarheine@chromium.org> Reviewed-by: Edward O'Callaghan <quasisec@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'libflashrom.c')
-rw-r--r--libflashrom.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/libflashrom.c b/libflashrom.c
index 2a39a80dd..c5c4c8957 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -501,6 +501,8 @@ static int flashrom_layout_parse_fmap(struct flashrom_layout **layout,
struct flashctx *const flashctx, const struct fmap *const fmap)
{
int i;
+ char name[FMAP_STRLEN + 1];
+ const struct fmap_area *area;
struct flashrom_layout *l = get_global_layout();
if (!fmap || !l)
@@ -511,21 +513,10 @@ static int flashrom_layout_parse_fmap(struct flashrom_layout **layout,
return 1;
}
- for (i = 0; i < fmap->nareas; i++) {
- l->entries[l->num_entries].start = fmap->areas[i].offset;
- l->entries[l->num_entries].end = fmap->areas[i].offset + fmap->areas[i].size - 1;
- l->entries[l->num_entries].included = false;
- l->entries[l->num_entries].name =
- strndup((const char *)fmap->areas[i].name, FMAP_STRLEN);
- if (!l->entries[l->num_entries].name) {
- msg_gerr("Error adding layout entry: %s\n", strerror(errno));
+ for (i = 0, area = fmap->areas; i < fmap->nareas; i++, area++) {
+ snprintf(name, sizeof(name), "%s", area->name);
+ if (flashrom_layout_add_region(l, area->offset, area->offset + area->size - 1, name))
return 1;
- }
- msg_gdbg("fmap %08x - %08x named %s\n",
- l->entries[l->num_entries].start,
- l->entries[l->num_entries].end,
- l->entries[l->num_entries].name);
- l->num_entries++;
}
*layout = l;