mirror of
https://github.com/fail0verflow/switch-coreboot.git
synced 2025-05-04 01:39:18 -04:00
util/cbfstool: Enable filling fmap regions with a given value
So far, cbfstool write, when used with the -u/-d options (to "fill upwards/downwards") left the parts of the region alone for which there was no new data to write. When adding -i [0..255], these parts are overwritten with the given value. BUG=chromium:595715 BRANCH=none TEST=cbfstool write -u -i 0 ... does the right thing (fill the unused space with zeroes) Change-Id: I3752f731f8e6592b1a390ab565aa56e6b7de6765 Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://chromium-review.googlesource.com/417319 Commit-Ready: Patrick Georgi <pgeorgi@chromium.org> Tested-by: Patrick Georgi <pgeorgi@chromium.org> Reviewed-by: Stefan Reinauer <reinauer@chromium.org>
This commit is contained in:
parent
01ff9e24f6
commit
baf378c5f2
1 changed files with 15 additions and 4 deletions
|
@ -90,6 +90,7 @@ static struct param {
|
|||
.hash = VB2_HASH_INVALID,
|
||||
.headeroffset = ~0,
|
||||
.region_name = SECTION_NAME_PRIMARY_CBFS,
|
||||
.u64val = -1,
|
||||
};
|
||||
|
||||
static bool region_is_flashmap(const char *region)
|
||||
|
@ -980,8 +981,18 @@ static int cbfs_write(void)
|
|||
buffer_delete(&new_content);
|
||||
return 1;
|
||||
}
|
||||
WARN("Written area will abut %s of target region: any unused space will keep its current contents\n",
|
||||
param.fill_partial_upward ? "bottom" : "top");
|
||||
if (param.u64val == (uint64_t)-1) {
|
||||
WARN("Written area will abut %s of target region: any unused space will keep its current contents\n",
|
||||
param.fill_partial_upward ? "bottom" : "top");
|
||||
} else if (param.u64val > 0xff) {
|
||||
ERROR("given fill value (%x) is larger than a byte\n", (unsigned)(param.u64val & 0xff));
|
||||
buffer_delete(&new_content);
|
||||
return 1;
|
||||
} else {
|
||||
memset(buffer_get(param.image_region),
|
||||
param.u64val & 0xff,
|
||||
buffer_size(param.image_region));
|
||||
}
|
||||
if (param.fill_partial_downward)
|
||||
offset = param.image_region->size - new_content.size;
|
||||
}
|
||||
|
@ -1089,7 +1100,7 @@ static const struct command commands[] = {
|
|||
{"read", "r:f:vh?", cbfs_read, true, false},
|
||||
{"remove", "H:r:n:vh?", cbfs_remove, true, true},
|
||||
{"update-fit", "H:r:n:x:vh?", cbfs_update_fit, true, true},
|
||||
{"write", "r:f:Fudvh?", cbfs_write, true, true},
|
||||
{"write", "r:f:i:Fudvh?", cbfs_write, true, true},
|
||||
};
|
||||
|
||||
static struct option long_options[] = {
|
||||
|
@ -1235,7 +1246,7 @@ static void usage(char *name)
|
|||
"Show the contents of the ROM\n"
|
||||
" extract [-r image,regions] [-m ARCH] -n NAME -f FILE "
|
||||
"Extracts a raw payload from ROM\n"
|
||||
" write [-F] -r image,regions -f file [-u | -d] "
|
||||
" write [-F] -r image,regions -f file [-u | -d] [-i int] "
|
||||
"Write file into same-size [or larger] raw region\n"
|
||||
" read [-r fmap-region] -f file "
|
||||
"Extract raw region contents into binary file\n"
|
||||
|
|
Loading…
Add table
Reference in a new issue