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@chromium.org> Reviewed-on: https://review.coreboot.org/12683 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins)
This commit is contained in:
parent
72c83a8e23
commit
9731119b32
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue