summaryrefslogtreecommitdiff
path: root/util/cbfstool
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
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')
-rw-r--r--util/cbfstool/cbfs.h3
-rw-r--r--util/cbfstool/cbfstool.c32
2 files changed, 29 insertions, 6 deletions
diff --git a/util/cbfstool/cbfs.h b/util/cbfstool/cbfs.h
index f7b5f917e7..2964304772 100644
--- a/util/cbfstool/cbfs.h
+++ b/util/cbfstool/cbfs.h
@@ -104,8 +104,9 @@ struct cbfs_file_attribute {
#define CBFS_FILE_ATTR_TAG_UNUSED2 0xffffffff
#define CBFS_FILE_ATTR_TAG_COMPRESSION 0x42435a4c
#define CBFS_FILE_ATTR_TAG_HASH 0x68736148
-#define CBFS_FILE_ATTR_TAG_POSITION 0x42435350 /* PSCB */
+#define CBFS_FILE_ATTR_TAG_POSITION 0x42435350 /* PSCB */
#define CBFS_FILE_ATTR_TAG_ALIGNMENT 0x42434c41 /* ALCB */
+#define CBFS_FILE_ATTR_TAG_PADDING 0x47444150 /* PDNG */
struct cbfs_file_attr_compression {
uint32_t tag;
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)) {