summaryrefslogtreecommitdiffstats
path: root/util/cbfstool
diff options
context:
space:
mode:
authorWard Vandewege <ward@gnu.org>2009-05-13 20:08:28 +0000
committerMyles Watson <mylesgw@gmail.com>2009-05-13 20:08:28 +0000
commita064b5239dd8cda663af5d99603ff21492ca52d7 (patch)
treec8d523b4a62afbf4f6845ed575f2ee1ca820d6bd /util/cbfstool
parent5eceb32a79d4298a9f57bbe9fd5e06a83db0ce95 (diff)
downloadcoreboot-staging-a064b5239dd8cda663af5d99603ff21492ca52d7.zip
coreboot-staging-a064b5239dd8cda663af5d99603ff21492ca52d7.tar.gz
Add support for human-friendly component string types for the cbfstool add
command. Make use of it in config.g (Myles) Signed-off-by: Ward Vandewege <ward@gnu.org> Acked-by: Myles Watson <mylesgw@gmail.com> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4282 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'util/cbfstool')
-rw-r--r--util/cbfstool/add.c40
1 files changed, 38 insertions, 2 deletions
diff --git a/util/cbfstool/add.c b/util/cbfstool/add.c
index 83f8d29..a62a158 100644
--- a/util/cbfstool/add.c
+++ b/util/cbfstool/add.c
@@ -219,6 +219,22 @@ void add_payload_usage(void)
("add-payload FILE NAME [OPTIONS]\tAdd a payload to the ROM\n");
}
+int select_component_type(char *s)
+{
+ int i = 0;
+ char *accepted_strings[] = {
+ "stage",
+ "payload",
+ "optionrom",
+ "deleted",
+ "free",
+ };
+ for (i=0; i < 5; i++)
+ if (!strcmp(s, accepted_strings[i]))
+ return i;
+ return -1;
+}
+
int add_handler(struct rom *rom, int argc, char **argv)
{
unsigned int type = CBFS_COMPONENT_NULL;
@@ -233,13 +249,33 @@ int add_handler(struct rom *rom, int argc, char **argv)
return -1;
}
+ int component_type;
+
/* There are two ways to specify the type - a string or a number */
if (isdigit(*(argv[2])))
type = strtoul(argv[2], 0, 0);
else {
- ERROR("String types (%s) aren't implemented yet.\n", argv[2]);
- return -1;
+ switch( component_type = select_component_type(argv[2])) {
+ case 0:
+ type = CBFS_COMPONENT_STAGE;
+ break;
+ case 1:
+ type = CBFS_COMPONENT_PAYLOAD;
+ break;
+ case 2:
+ type = CBFS_COMPONENT_OPTIONROM;
+ break;
+ case 3:
+ type = CBFS_COMPONENT_DELETED;
+ break;
+ case 4:
+ type = CBFS_COMPONENT_NULL;
+ break;
+ default:
+ ERROR("Unrecognized component type %s.\nValid options are: stage, payload, optionrom, deleted, free.\n", argv[2]);
+ return -1;
+ }
}
return add_blob(rom, argv[0], argv[1], type);
OpenPOWER on IntegriCloud