Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/41832 )
Change subject: uti/cbfstool: Add option --pow2page ......................................................................
uti/cbfstool: Add option --pow2page
For add-stage command, --pow2page is equivalent of passing -P log2ceil(sizeof stage). The sizeof stage can be hard to determine in Makefile to be passed on the commandline.
Change-Id: If4b5329c1df5afe49d27ab10220095d747024ad6 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M util/cbfstool/cbfstool.c 1 file changed, 15 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/32/41832/1
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 4ec8c90..dd87a04 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -65,6 +65,7 @@ bool fill_partial_downward; bool show_immutable; bool stage_xip; + bool force_pow2_pagesize; bool autogen_attr; bool machine_parseable; bool unprocessed; @@ -169,6 +170,14 @@
DEBUG("File size is %zd (0x%zx)\n", data_size, data_size);
+ /* Use a page size that can fit the entire file. */ + if (param.force_pow2_pagesize) { + param.pagesize = 1; + while (param.pagesize < data_size) + param.pagesize <<= 1; + DEBUG("Page size is %d (0x%x)\n", param.pagesize, param.pagesize); + } + /* Include cbfs_file size along with space for with name. */ metadata_size += cbfs_calculate_file_header_size(param.name); /* Adjust metadata_size if additional attributes were added */ @@ -1259,7 +1268,7 @@ true, true}, {"add-payload", "H:r:f:n:c:b:C:I:p:vA:gh?", cbfs_add_payload, true, true}, - {"add-stage", "a:H:r:f:n:t:c:b:P:S:p:yvA:gh?", cbfs_add_stage, + {"add-stage", "a:H:r:f:n:t:c:b:P:Q:S:p:yvA:gh?", cbfs_add_stage, true, true}, {"add-int", "H:r:i:n:b:vgh?", cbfs_add_integer, true, true}, {"add-master-header", "H:r:vh?j:", cbfs_add_master_header, true, true}, @@ -1311,6 +1320,7 @@ {"offset", required_argument, 0, 'o' }, {"padding", required_argument, 0, 'p' }, {"page-size", required_argument, 0, 'P' }, + {"pow2page", no_argument, 0, 'Q' }, {"ucode-region", required_argument, 0, 'q' }, {"size", required_argument, 0, 's' }, {"top-aligned", required_argument, 0, 'T' }, @@ -1405,7 +1415,7 @@ "Add a payload to the ROM\n" " add-stage [-r image,regions] -f FILE -n NAME [-A hash] \\n" " [-c compression] [-b base] [-S section-to-ignore] \\n" - " [-a alignment] [-y|--xip] [-P page-size] [--ibb] " + " [-a alignment] [-y|--xip] [-P page-size] [-Q] [--ibb] " "Add a stage to the ROM\n" " add-flat-binary [-r image,regions] -f FILE -n NAME \\n" " [-A hash] -l load-address -e entry-point \\n" @@ -1664,6 +1674,9 @@ return 1; } break; + case 'Q': + param.force_pow2_pagesize = 1; + break; case 'o': param.cbfsoffset = strtoul(optarg, &suffix, 0); if (!*optarg || (suffix && *suffix)) {