aboutsummaryrefslogtreecommitdiff
path: root/util/cbfstool/cbfstool.c
diff options
context:
space:
mode:
authorDavid Hendricks <dhendrix@chromium.org>2012-11-16 14:48:22 -0800
committerStefan Reinauer <stefan.reinauer@coreboot.org>2012-11-30 00:42:31 +0100
commit90ca3b6bd7d7849898fe2363a9e6d0e002c95943 (patch)
treebe21c4f63d3f01afa0ec98018d83131c4f150f52 /util/cbfstool/cbfstool.c
parent11a20b614e708582ebd7607d39487938f35f2550 (diff)
Add multi-architecture support to cbfstool
This is an initial re-factoring of CBFS code to enable multiple architectures. To achieve a clean solution, an additional field describing the architecture has to be added to the master header. Hence we also increase the version number in the master header. Change-Id: Icda681673221f8c27efbc46f16c2c5682b16a265 Signed-off-by: Stefan Reinauer <reinauer@google.com> Signed-off-by: Hung-Te Lin <hungte@chromium.org> Signed-off-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: http://review.coreboot.org/1944 Tested-by: build bot (Jenkins)
Diffstat (limited to 'util/cbfstool/cbfstool.c')
-rw-r--r--util/cbfstool/cbfstool.c32
1 files changed, 22 insertions, 10 deletions
diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c
index 66db379d02..a09e75b1f1 100644
--- a/util/cbfstool/cbfstool.c
+++ b/util/cbfstool/cbfstool.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2009 coresystems GmbH
* written by Patrick Georgi <patrick.georgi@coresystems.de>
+ * Copyright (C) 2012 Google, Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -372,6 +373,11 @@ static int cbfs_create(void)
return 1;
}
+ if (arch == CBFS_ARCHITECTURE_UNKNOWN) {
+ fprintf(stderr, "E: You need to specify -m/--machine arch\n");
+ return 1;
+ }
+
return create_cbfs_image(cbfs_name, rom_size, rom_bootblock,
rom_alignment, rom_offset);
}
@@ -450,7 +456,7 @@ static const struct command commands[] = {
{"add-stage", "f:n:t:c:b:h?", cbfs_add_stage},
{"add-flat-binary", "f:n:l:e:c:b:h?", cbfs_add_flat_binary},
{"remove", "n:h?", cbfs_remove},
- {"create", "s:B:a:o:h?", cbfs_create},
+ {"create", "s:B:a:o:m:h?", cbfs_create},
{"locate", "f:n:a:h?", cbfs_locate},
{"print", "h?", cbfs_print},
{"extract", "n:f:h?", cbfs_extract},
@@ -468,6 +474,7 @@ static struct option long_options[] = {
{"alignment", required_argument, 0, 'a' },
{"offset", required_argument, 0, 'o' },
{"file", required_argument, 0, 'f' },
+ {"arch", required_argument, 0, 'm' },
{"verbose", no_argument, 0, 'v' },
{"help", no_argument, 0, 'h' },
{NULL, 0, 0, 0 }
@@ -481,26 +488,28 @@ static void usage(char *name)
" %s FILE COMMAND [PARAMETERS]...\n\n" "OPTIONs:\n"
" -h Display this help message\n\n"
"COMMANDs:\n"
- " add -f FILE -n NAME -t TYPE [-b base-address] "
+ " add -f FILE -n NAME -t TYPE [-b base-address] "
"Add a component\n"
- " add-payload -f FILE -n NAME [-c compression] [-b base] "
+ " add-payload -f FILE -n NAME [-c compression] [-b base] "
"Add a payload to the ROM\n"
- " add-stage -f FILE -n NAME [-c compression] [-b base] "
+ " add-stage -f FILE -n NAME [-c compression] [-b base] "
"Add a stage to the ROM\n"
" add-flat-binary -f FILE -n NAME -l load-address \\\n"
- " -e entry-point [-c compression] [-b base] "
+ " -e entry-point [-c compression] [-b base] "
"Add a 32bit flat mode binary\n"
- " remove -n NAME "
+ " remove -n NAME "
"Remove a component\n"
- " create -s size -B bootblock [-a align] [-o offset] "
+ " create -s size -B bootblock -m ARCH [-a align] [-o offset] "
"Create a ROM file\n"
- " locate -f FILE -n NAME -a align "
+ " locate -f FILE -n NAME -a align "
"Find a place for a file of that size\n"
- " print "
+ " print "
"Show the contents of the ROM\n"
- " extract -n NAME -f FILE "
+ " extract -n NAME -f FILE "
"Extracts a raw payload from ROM\n"
"\n"
+ "ARCHes:\n"
+ " armv7, x86\n"
"TYPEs:\n", name, name
);
print_supported_filetypes();
@@ -610,6 +619,9 @@ int main(int argc, char **argv)
case 'v':
verbose++;
break;
+ case 'm':
+ arch = string_to_arch(optarg);
+ break;
case 'h':
case '?':
usage(argv[0]);