summaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfstool.c
diff options
context:
space:
mode:
authorPatrick Georgi <pgeorgi@google.com>2015-11-20 19:22:50 +0100
committerAaron Durbin <adurbin@chromium.org>2016-01-06 01:12:12 +0100
commit214e4af102ff7901998dacbd08a1c98d1693d8d2 (patch)
tree93455258608b65f38ff806ed11d754454dda1fcd /util/cbfstool/cbfstool.c
parentcbb6c75061c5435f115629b1546e21157de3d194 (diff)
cbfstool: Use buffer over offset/size pair for cbfs_copy_instance
This allows adding support for FMAP based cbfstool copy more easily. BUG=chromium:445938 Change-Id: I72e7bc4da7d27853e324400f76f86136e3d8726e Signed-off-by: Patrick Georgi <pgeorgi@google.com> Reviewed-on: https://review.coreboot.org/12787 Tested-by: build bot (Jenkins)
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r--util/cbfstool/cbfstool.c33
1 files changed, 20 insertions, 13 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 252929628f..c9a9564e94 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -917,27 +917,34 @@ static int cbfs_update_fit(void)
static int cbfs_copy(void)
{
- if (!param.copyoffset_assigned) {
- ERROR("You need to specify -D/--copy-offset.\n");
- return 1;
- }
-
- if (!param.size) {
- ERROR("You need to specify -s/--size.\n");
- return 1;
- }
+ /* always a valid source region */
+ struct cbfs_image src_image;
- struct cbfs_image image;
- if (cbfs_image_from_buffer(&image, param.image_region,
+ if (cbfs_image_from_buffer(&src_image, param.image_region,
param.headeroffset))
return 1;
- if (!cbfs_is_legacy_cbfs(&image)) {
+ struct buffer dst_buffer;
+
+ if (cbfs_is_legacy_cbfs(&src_image)) {
+ if (!param.copyoffset_assigned) {
+ ERROR("You need to specify -D/--copy-offset.\n");
+ return 1;
+ }
+
+ if (!param.size) {
+ ERROR("You need to specify -s/--size.\n");
+ return 1;
+ }
+
+ buffer_splice(&dst_buffer, param.image_region,
+ param.copyoffset, param.size);
+ } else {
ERROR("This operation is only valid on legacy images having CBFS master headers\n");
return 1;
}
- return cbfs_copy_instance(&image, param.copyoffset, param.size);
+ return cbfs_copy_instance(&src_image, &dst_buffer);
}
static const struct command commands[] = {