Arthur Heymans has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/49225 )
Change subject: util/cbfstool/ifittool: Add an option to just print the FIT table ......................................................................
util/cbfstool/ifittool: Add an option to just print the FIT table
Add a coreboot-agnostic option '-P|--print-fit' to just print a FIT table.
TESTED: can print the FIT table of both a coreboot and an UEFI image.
Change-Id: I341c8e7ad6efaeacceaa403534310fa4cf345b5f Signed-off-by: Arthur Heymans arthur@aheymans.xyz --- M util/cbfstool/ifittool.c 1 file changed, 27 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/25/49225/1
diff --git a/util/cbfstool/ifittool.c b/util/cbfstool/ifittool.c index 7e99d4f..b6d4d8e 100644 --- a/util/cbfstool/ifittool.c +++ b/util/cbfstool/ifittool.c @@ -15,7 +15,7 @@ /* Global variables */ partitioned_file_t *image_file;
-static const char *optstring = "H:j:f:r:d:t:n:s:cAaDvh?"; +static const char *optstring = "H:j:f:r:d:t:n:s:cAaDvhP?"; static struct option long_options[] = { {"file", required_argument, 0, 'f' }, {"region", required_argument, 0, 'r' }, @@ -28,6 +28,7 @@ {"max-table-size", required_argument, 0, 's' }, {"topswap-size", required_argument, 0, 'j' }, {"dump", no_argument, 0, 'D' }, + {"print-fit", no_argument, 0, 'P' }, {"verbose", no_argument, 0, 'v' }, {"help", no_argument, 0, 'h' }, {"header-offset", required_argument, 0, 'H' }, @@ -50,6 +51,7 @@ "\t\t-H|--header-offset : Do not search for header, use this offset\n" "\t\t-v|--verbose : Be verbose\n" "\t\t-D|--dump : Dump FIT table (at end of operation)\n" + "\t\t-P|--print-fit : Print the FIT table of any image (only needs the file argument)\n" "\t\t-c|--clear-table : Remove all existing entries (do not update)\n" "\t\t-j|--topswap-size : Use second FIT table if non zero\n" "\tREQUIRED ARGUMENTS:\n" @@ -128,7 +130,8 @@ ADD_CBFS_OP, ADD_REGI_OP, ADD_ADDR_OP, - DEL_OP + DEL_OP, + PRINT_OP };
int main(int argc, char *argv[]) @@ -206,6 +209,14 @@ case 'D': dump = true; break; + case 'P': + if (op != NO_OP) { + ERROR("specified multiple actions at once\n"); + usage(argv[0]); + return 1; + } + op = PRINT_OP; + break; case 'f': input_file = optarg; break; @@ -273,6 +284,20 @@ return 1; } } + if (op == PRINT_OP) { + struct buffer input_buffer; + buffer_from_file(&input_buffer, input_file); + + struct fit_table *fit = + fit_get_table(&input_buffer, convert_to_from_top_aligned, topswap_size); + + if (fit_dump(fit)) { + buffer_delete(&input_buffer); + return 1; + } + buffer_delete(&input_buffer); + return 0; + }
if (!region_name) { ERROR("Region not given\n");