This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / util / cbfstool / add.c
index a62a15857b15e42efbf034540be21e5294ada218..95b785298308a782448943be5709e2fcbaa9ab2b 100644 (file)
@@ -76,7 +76,7 @@ static int add_from_fd(struct rom *rom, const char *name, int type, int fd)
                return -1;
        }
 
-       ret = rom_add(rom, name, buffer, size, type);
+       ret = rom_add(rom, name, buffer, 0, size, type);
        free(buffer);
 
        return ret;
@@ -165,7 +165,7 @@ int fork_tool_and_add(struct rom *rom, const char *tool, const char *input,
 }
 
 static int add_blob(struct rom *rom, const char *filename,
-                   const char *name, int type)
+                   const char *name, unsigned long address, int type)
 {
        void *ptr;
        struct stat s;
@@ -195,7 +195,7 @@ static int add_blob(struct rom *rom, const char *filename,
                return -1;
        }
 
-       ret = rom_add(rom, name, ptr, s.st_size, type);
+       ret = rom_add(rom, name, ptr, address, s.st_size, type);
 
        munmap(ptr, s.st_size);
        close(fd);
@@ -205,7 +205,7 @@ static int add_blob(struct rom *rom, const char *filename,
 
 void add_usage(void)
 {
-       printf("add FILE NAME TYPE\tAdd a component\n");
+       printf("add FILE NAME TYPE [base address]\tAdd a component\n");
 }
 
 void add_stage_usage(void)
@@ -238,12 +238,17 @@ int select_component_type(char *s)
 int add_handler(struct rom *rom, int argc, char **argv)
 {
        unsigned int type = CBFS_COMPONENT_NULL;
+       unsigned long address = 0;
 
-       if (argc != 3) {
+       if ((argc < 3) || (argc >  4)) {
                add_usage();
                return -1;
        }
 
+       if (argc > 3) {
+               address = strtoul(argv[3], 0, 0);
+       }
+
        if (!rom_exists(rom)) {
                ERROR("You need to create the ROM before adding files to it\n");
                return -1;
@@ -278,7 +283,7 @@ int add_handler(struct rom *rom, int argc, char **argv)
                }
        }
 
-       return add_blob(rom, argv[0], argv[1], type);
+       return add_blob(rom, argv[0], argv[1], address, type);
 }
 
 char *find_tool(char *tool)