diff options
author | Aaron Durbin <adurbin@chromium.org> | 2016-01-26 17:08:56 -0600 |
---|---|---|
committer | Aaron Durbin <adurbin@chromium.org> | 2016-01-28 19:25:57 +0100 |
commit | 71c60ca4821f9ebd51066b2fb4166fd974755666 (patch) | |
tree | 4d8fc9fd81e3cb22d99089be980385fe0e82656a /util/cbfstool/cbfstool.c | |
parent | 5dc628a2ef4f1b883dfbcf414230d9c459a87548 (diff) | |
download | coreboot-71c60ca4821f9ebd51066b2fb4166fd974755666.tar.xz |
util/cbfstool: add 'compact' command
While assembling CBFS images within the RW slots on Chrome OS
machines the current approach is to 'cbfstool copy' from the
RO CBFS to each RW CBFS. Additional fixups are required such
as removing unneeded files from the RW CBFS (e.g. verstage)
as well as removing and adding back files with the proper
arguments (FSP relocation as well as romstage XIP relocation).
This ends up leaving holes in the RW CBFS. To speed up RW
CBFS slot hashing it's beneficial to pack all non-empty files
together at the beginning of the CBFS. Therefore, provide
the 'compact' command which bubbles all the empty entries to
the end of the CBFS.
Change-Id: I8311172d71a2ccfccab384f8286cf9f21a17dec9
Signed-off-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-on: https://review.coreboot.org/13479
Tested-by: build bot (Jenkins)
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r-- | util/cbfstool/cbfstool.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 13a9956045..5be2d6549c 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -1054,6 +1054,16 @@ static int cbfs_copy(void) return cbfs_copy_instance(&src_image, param.image_region); } +static int cbfs_compact(void) +{ + struct cbfs_image image; + if (cbfs_image_from_buffer(&image, param.image_region, + param.headeroffset)) + return 1; + WARN("Compacting a CBFS doesn't honor alignment or fixed addresses!\n"); + return cbfs_compact_instance(&image); +} + static const struct command commands[] = { {"add", "H:r:f:n:t:c:b:a:vA:gh?", cbfs_add, true, true}, {"add-flat-binary", "H:r:f:n:l:e:c:b:vA:gh?", cbfs_add_flat_binary, @@ -1064,6 +1074,7 @@ static const struct command commands[] = { 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}, + {"compact", "r:h?", cbfs_compact, true, true}, {"copy", "r:R:h?", cbfs_copy, true, true}, {"create", "M:r:s:B:b:H:o:m:vh?", cbfs_create, true, true}, {"hashcbfs", "r:R:A:vh?", cbfs_hash, true, true}, @@ -1198,6 +1209,8 @@ static void usage(char *name) "Add a legacy CBFS master header\n" " remove [-r image,regions] -n NAME " "Remove a component\n" + " compact -r image,regions " + "Defragment CBFS image.\n" " copy -r image,regions -R source-region " "Create a copy (duplicate) cbfs instance in fmap\n" " create -m ARCH -s size [-b bootblock offset] \\\n" |