Author: myles
Date: 2009-05-13 22:08:28 +0200 (Wed, 13 May 2009)
New Revision: 4282

Modified:
   trunk/coreboot-v2/util/cbfstool/add.c
   trunk/coreboot-v2/util/newconfig/config.g
Log:
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 <[email protected]>
Acked-by: Myles Watson <[email protected]>


Modified: trunk/coreboot-v2/util/cbfstool/add.c
===================================================================
--- trunk/coreboot-v2/util/cbfstool/add.c       2009-05-13 16:27:25 UTC (rev 
4281)
+++ trunk/coreboot-v2/util/cbfstool/add.c       2009-05-13 20:08:28 UTC (rev 
4282)
@@ -219,6 +219,22 @@
            ("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 @@
                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);

Modified: trunk/coreboot-v2/util/newconfig/config.g
===================================================================
--- trunk/coreboot-v2/util/newconfig/config.g   2009-05-13 16:27:25 UTC (rev 
4281)
+++ trunk/coreboot-v2/util/newconfig/config.g   2009-05-13 20:08:28 UTC (rev 
4282)
@@ -2298,7 +2298,7 @@
                file.write("\t./cbfstool %s create %s %s %s.bootblock\n"
                           %(i.name, romsize, bootblocksize, i.name))
                for j in pciroms:
-                       file.write("\t./cbfstool %s add %s pci%04x,%04x.rom 
48\n" % (i.name, j.name, j.pci_vid, j.pci_did))
+                       file.write("\t./cbfstool %s add %s pci%04x,%04x.rom 
optionrom\n" % (i.name, j.name, j.pci_vid, j.pci_did))
                for j in i.roms:
                        #failover is a hack that will go away soon. 
                        if (j != "failover") and (rommapping[j] != "/dev/null"):


-- 
coreboot mailing list: [email protected]
http://www.coreboot.org/mailman/listinfo/coreboot

Reply via email to