diff options
author | Sol Boucher <solb@chromium.org> | 2015-05-06 14:44:40 -0700 |
---|---|---|
committer | Stefan Reinauer <stefan.reinauer@coreboot.org> | 2015-05-26 02:30:21 +0200 |
commit | 32532ac92dd83d08e5d10de2d3a41fe3c9092e2c (patch) | |
tree | 140f1fad91503353b1292951789a2909c3124ee4 /util/cbfstool/cbfstool.c | |
parent | 83070504125a8023a24cb87c3f3184d3ad9b1d20 (diff) | |
download | coreboot-32532ac92dd83d08e5d10de2d3a41fe3c9092e2c.tar.xz |
cbfstool: Make update-fit action work on new-style images
Because new images place the bootblock in a separate region from the
primary CBFS, performing an update-fit operation requires reading an
additional section and choosing a different destination for the write
based on the image type. Since other actions are not affected by these
requirements, the logic for the optional read and all writing is
implemented in the cbfs_update_fit() function itself, rather than
relying on the main() function for writing as the other actions do.
Change-Id: I2024c59715120ecc3b9b158e007ebce75acff023
Signed-off-by: Sol Boucher <solb@chromium.org>
Reviewed-on: http://review.coreboot.org/10137
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r-- | util/cbfstool/cbfstool.c | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index bd84b01e5b..06d0cef1d4 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -33,6 +33,8 @@ #include "fit.h" #include "partitioned_file.h" +#define SECTION_WITH_FIT_TABLE "BOOTBLOCK" + struct command { const char *name; const char *optstring; @@ -677,12 +679,29 @@ static int cbfs_update_fit(void) return 1; } + // Decide which region to read/write the FIT table from/to. + struct buffer bootblock; + if (partitioned_file_is_partitioned(param.image_file)) { + if (!partitioned_file_read_region(&bootblock, param.image_file, + SECTION_WITH_FIT_TABLE)) + return 1; + } else { + // In legacy images, the bootblock is part of the CBFS. + buffer_clone(&bootblock, param.image_region); + } + struct cbfs_image image; if (cbfs_image_from_buffer(&image, param.image_region, param.headeroffset)) return 1; - return fit_update_table(&image, param.fit_empty_entries, param.name); + if (fit_update_table(&bootblock, &image, param.name, + param.fit_empty_entries, convert_to_from_top_aligned)) + return 1; + + // The region to be written depends on the type of image, so we write it + // here rather than having main() write the CBFS region back as usual. + return !partitioned_file_write_region(param.image_file, &bootblock); } static int cbfs_copy(void) @@ -731,7 +750,7 @@ static const struct command commands[] = { {"print", "H:r:vh?", cbfs_print, true, false}, {"read", "r:f:vh?", cbfs_read, true, false}, {"remove", "H:r:n:vh?", cbfs_remove, true, true}, - {"update-fit", "H:r:n:x:vh?", cbfs_update_fit, true, true}, + {"update-fit", "H:r:n:x:vh?", cbfs_update_fit, true, false}, {"write", "r:f:udvh?", cbfs_write, true, true}, }; |