summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@chromium.org>2015-07-09 11:27:44 +0200
committerPatrick Georgi <pgeorgi@google.com>2015-07-14 15:48:43 +0200
commit995269062e631b83079c11bd91112fc0b71c523a (patch)
tree9258c59a902fd364c81205694d9c5f7b57ebe1c0 /src/lib
parentad0dda767b9fc1357450e4de04bdf276c7bb40f1 (diff)
downloadcoreboot-995269062e631b83079c11bd91112fc0b71c523a.tar.xz
fmap: Introduce new function to derive fmap name from offset/size
vboot passes around the offset and size of the region to use in later stages. To assign more meaning to this pair, provide a function that returns the fmap area name if there's a precise match (and an error otherwise). Change-Id: I5724b860271025c8cb8b390ecbd33352ea779660 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-on: http://review.coreboot.org/10865 Tested-by: build bot (Jenkins) Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/fmap.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/fmap.c b/src/lib/fmap.c
index 0f48cdc414..f2087c3f69 100644
--- a/src/lib/fmap.c
+++ b/src/lib/fmap.c
@@ -117,3 +117,46 @@ int fmap_locate_area(const char *name, struct region *ar)
return -1;
}
+
+int fmap_find_region_name(const struct region * const ar,
+ char name[FMAP_STRLEN])
+{
+ struct region_device fmrd;
+ size_t offset;
+
+ if (find_fmap_directory(&fmrd))
+ return -1;
+
+ /* Start reading the areas just after fmap header. */
+ offset = sizeof(struct fmap);
+
+ while (1) {
+ struct fmap_area *area;
+
+ area = rdev_mmap(&fmrd, offset, sizeof(*area));
+
+ if (area == NULL)
+ return -1;
+
+ if ((ar->offset != area->offset) ||
+ (ar->size != area->size)) {
+ rdev_munmap(&fmrd, area);
+ offset += sizeof(struct fmap_area);
+ continue;
+ }
+
+ printk(BIOS_DEBUG, "FMAP: area (%zx, %zx) found, named %s\n",
+ ar->offset, ar->size, area->name);
+
+ memcpy(name, area->name, FMAP_STRLEN);
+
+ rdev_munmap(&fmrd, area);
+
+ return 0;
+ }
+
+ printk(BIOS_DEBUG, "FMAP: area (%zx, %zx) not found\n",
+ ar->offset, ar->size);
+
+ return -1;
+}