[coreboot-gerrit] New patch to review for coreboot: 307493e boot_device: add sub region helper

Aaron Durbin (adurbin@chromium.org) gerrit at coreboot.org
Sat May 16 06:47:40 CEST 2015


Aaron Durbin (adurbin at chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/10224

-gerrit

commit 307493ec00821ded182b4ead4f53c6694ee19a59
Author: Aaron Durbin <adurbin at chromium.org>
Date:   Fri May 15 23:21:13 2015 -0500

    boot_device: add sub region helper
    
    Provide boot_device_ro_subregion() which handles the logic
    of making sub regions of the read-only boot device. Utilize
    the helper in the famp library.
    
    Change-Id: I1ba31e72d6026fea8dd9a9fa9def26414a92664c
    Signed-off-by: Aaron Durbin <adurbin at chromium.org>
---
 src/include/boot_device.h |  7 +++++++
 src/lib/boot_device.c     | 13 +++++++++++++
 src/lib/fmap.c            |  5 +----
 3 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/src/include/boot_device.h b/src/include/boot_device.h
index f8cccc7..92fd190 100644
--- a/src/include/boot_device.h
+++ b/src/include/boot_device.h
@@ -26,6 +26,13 @@
 const struct region_device *boot_device_ro(void);
 
 /*
+ * Create a sub-region of the read-only boot device.
+ * Returns 0 on succes, < 0 on error.
+ */
+int boot_device_ro_subregion(const struct region *sub,
+				struct region_device *subrd);
+
+/*
  * Initialize the boot device. This may be called multiple times within
  * a stage so boot device implementations should account for this behavior.
  **/
diff --git a/src/lib/boot_device.c b/src/lib/boot_device.c
index 7d3f774..e0353fc 100644
--- a/src/lib/boot_device.c
+++ b/src/lib/boot_device.c
@@ -23,3 +23,16 @@ void __attribute__((weak)) boot_device_init(void)
 {
 	/* Provide weak do-nothing init. */
 }
+
+int boot_device_ro_subregion(const struct region *sub,
+				struct region_device *subrd)
+{
+	const struct region_device *boot_dev;
+
+	boot_dev = boot_device_ro();
+
+	if (boot_dev == NULL)
+		return -1;
+
+	return rdev_chain(subrd, boot_dev, region_offset(sub), region_sz(sub));
+}
diff --git a/src/lib/fmap.c b/src/lib/fmap.c
index c0cbca1..e57d3bf 100644
--- a/src/lib/fmap.c
+++ b/src/lib/fmap.c
@@ -67,15 +67,12 @@ static int find_fmap_directory(struct region_device *fmrd)
 
 int fmap_locate_area_as_rdev(const char *name, struct region_device *area)
 {
-	const struct region_device *boot;
 	struct region ar;
 
-	boot = boot_device_ro();
-
 	if (fmap_locate_area(name, &ar))
 		return -1;
 
-	return rdev_chain(area, boot, ar.offset, ar.size);
+	return boot_device_ro_subregion(&ar, area);
 }
 
 int fmap_locate_area(const char *name, struct region *ar)



More information about the coreboot-gerrit mailing list