[coreboot-gerrit] Patch set updated for coreboot: cbfstool: make top-aligned address work per-region

Patrick Georgi (pgeorgi@google.com) gerrit at coreboot.org
Tue Dec 8 15:41:24 CET 2015


Patrick Georgi (pgeorgi at google.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/12683

-gerrit

commit 340062357df701a6e6cb806bda409e2d56d18ea9
Author: Patrick Georgi <pgeorgi at chromium.org>
Date:   Mon Dec 7 23:14:07 2015 +0100

    cbfstool: make top-aligned address work per-region
    
    The former interpretation sprung from the x86 way of doing things
    (assuming top-alignment to 4GB). Extend the mechanism to work with CBFS
    regions residing elsewhere.
    
    It's compatible with x86 because the default region there resides at the
    old location, so things fall in place. It also makes more complex
    layouts and non-x86 layouts work with negative base addresses.
    
    Change-Id: Ibcde973d85bad5d1195d657559f527695478f46c
    Signed-off-by: Patrick Georgi <pgeorgi at chromium.org>
---
 util/cbfstool/cbfstool.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index fb4c8b5..ba98667 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -101,7 +101,7 @@ static bool region_is_modern_cbfs(const char *region)
 
 /*
  * Converts between offsets from the start of the specified image region and
- * "top-aligned" offsets from the top of the entire flash image. Works in either
+ * "top-aligned" offsets from the top of the image region. Works in either
  * direction: pass in one type of offset and receive the other type.
  * N.B. A top-aligned offset is always a positive number, and should not be
  * confused with a top-aliged *address*, which is its arithmetic inverse. */
@@ -110,6 +110,14 @@ static unsigned convert_to_from_top_aligned(const struct buffer *region,
 {
 	assert(region);
 
+	/* cover the situation where a negative base address is given by the
+	 * user. Callers of this function negate it, so it'll be a positive
+	 * number smaller than the region.
+	 */
+	if ((offset > 0) && (offset < region->size)) {
+		return region->size - offset;
+	}
+
 	size_t image_size = partitioned_file_total_size(param.image_file);
 	return image_size - region->offset - offset;
 }



More information about the coreboot-gerrit mailing list