summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfstool.c
diff options
context:
space:
mode:
authorDaisuke Nojiri <dnojiri@chromium.org>2017-10-30 17:38:04 -0700
committerAaron Durbin <adurbin@chromium.org>2017-12-08 16:05:52 +0000
commitff906fb95bab0c4c24c2589fd0de3b1d1d0b2e24 (patch)
tree42206c9e0af2aedf7251838b2c2bef08295d8ea9 /util/cbfstool/cbfstool.c
parent9adcbfe486cb37ecbf38167ac13a502326f5863c (diff)
downloadcoreboot-ff906fb95bab0c4c24c2589fd0de3b1d1d0b2e24.tar.xz
cbfstool: Add '-p' option for padding
This patch adds '-p' to the 'add' command. It allows the add command to specify the size of the padding added with the file being added. This is useful to reserve an extra space in case the file is too big to be relocated. BUG=b:68660966 BRANCH=none TEST=emerge-fizz coreboot && cbfstool image.bin add -n ecrw -f EC_RW.bin -p 0x10 ... Verify image.bin has extra space in the file header. Change-Id: I64bc54fd10a453b4da467bc69d9590e61b0f7ead Signed-off-by: Daisuke Nojiri <dnojiri@chromium.org> Reviewed-on: https://review.coreboot.org/22239 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r--util/cbfstool/cbfstool.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 3263a91c05..77dbf72e97 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -71,6 +71,7 @@ static struct param {
uint32_t cbfsoffset;
uint32_t cbfsoffset_assigned;
uint32_t arch;
+ uint32_t padding;
bool u64val_assigned;
bool fill_partial_upward;
bool fill_partial_downward;
@@ -421,6 +422,18 @@ static int cbfs_add_component(const char *filename,
}
}
+ if (param.padding) {
+ const uint32_t hs = sizeof(struct cbfs_file_attribute);
+ uint32_t size = MAX(hs, param.padding);
+ INFO("Padding %d bytes\n", size);
+ struct cbfs_file_attribute *attr =
+ (struct cbfs_file_attribute *)cbfs_add_file_attr(
+ header, CBFS_FILE_ATTR_TAG_PADDING,
+ size);
+ if (attr == NULL)
+ return -1;
+ }
+
if (IS_TOP_ALIGNED_ADDRESS(offset))
offset = convert_to_from_top_aligned(param.image_region,
-offset);
@@ -1139,12 +1152,12 @@ static int cbfs_truncate(void)
}
static const struct command commands[] = {
- {"add", "H:r:f:n:t:c:b:a:yvA:gh?", cbfs_add, true, true},
- {"add-flat-binary", "H:r:f:n:l:e:c:b:vA:gh?", cbfs_add_flat_binary,
+ {"add", "H:r:f:n:t:c:b:a:p:yvA:gh?", cbfs_add, true, true},
+ {"add-flat-binary", "H:r:f:n:l:e:c:b:p:vA:gh?", cbfs_add_flat_binary,
true, true},
- {"add-payload", "H:r:f:n:t:c:b:C:I:vA:gh?", cbfs_add_payload,
+ {"add-payload", "H:r:f:n:t:c:b:C:I:p:vA:gh?", cbfs_add_payload,
true, true},
- {"add-stage", "a:H:r:f:n:t:c:b:P:S:yvA:gh?", cbfs_add_stage,
+ {"add-stage", "a:H:r:f:n:t:c:b:P: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?", cbfs_add_master_header, true, true},
@@ -1187,6 +1200,7 @@ static struct option long_options[] = {
{"machine", required_argument, 0, 'm' },
{"name", required_argument, 0, 'n' },
{"offset", required_argument, 0, 'o' },
+ {"padding", required_argument, 0, 'p' },
{"page-size", required_argument, 0, 'P' },
{"size", required_argument, 0, 's' },
{"top-aligned", required_argument, 0, 'T' },
@@ -1267,7 +1281,7 @@ static void usage(char *name)
"COMMANDs:\n"
" add [-r image,regions] -f FILE -n NAME -t TYPE [-A hash] \\\n"
" [-c compression] [-b base-address | -a alignment] \\\n"
- " [-y|--xip if TYPE is FSP] "
+ " [-p padding size] [-y|--xip if TYPE is FSP] "
"Add a component\n"
" add-payload [-r image,regions] -f FILE -n NAME [-A hash] \\\n"
" [-c compression] [-b base-address] \\\n"
@@ -1505,6 +1519,14 @@ int main(int argc, char **argv)
return 1;
}
break;
+ case 'p':
+ param.padding = strtoul(optarg, &suffix, 0);
+ if (!*optarg || (suffix && *suffix)) {
+ ERROR("Invalid pad size '%s'.\n",
+ optarg);
+ return 1;
+ }
+ break;
case 'P':
param.pagesize = strtoul(optarg, &suffix, 0);
if (!*optarg || (suffix && *suffix)) {