Allow user to specify the size of a newly created cbfs image
authorPatrick Georgi <patrick.georgi@coresystems.de>
Mon, 21 Dec 2009 13:50:37 +0000 (13:50 +0000)
committerPatrick Georgi <patrick.georgi@coresystems.de>
Mon, 21 Dec 2009 13:50:37 +0000 (13:50 +0000)
to be stated in kilobytes or megabytes. Usage is
cbfstool coreboot.rom create 1048576 coreboot.bootblock
cbfstool coreboot.rom create 1024k coreboot.bootblock
cbfstool coreboot.rom create 1m coreboot.bootblock
to get an 1048576 bytes = 1024kb = 1mb image.

Kconfig also uses this instead of calculating bytes from kilobytes itself.

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Peter Stuge <peter@stuge.se>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4987 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

src/arch/i386/Makefile.inc
util/cbfstool/cbfstool.c

index 2459af102b0251b40930ccc87a287bd9fa13fb51..e2f464d2853642e0a689cba20cb7670073b6f67f 100644 (file)
@@ -14,7 +14,7 @@ ifdef POST_EVALUATION
 
 $(obj)/coreboot.rom: $(obj)/coreboot.bootblock $(obj)/coreboot_ram $(CBFSTOOL)
        rm -f $@
-       $(CBFSTOOL) $@ create $(shell expr 1024 \* $(CONFIG_COREBOOT_ROMSIZE_KB)) $(obj)/coreboot.bootblock
+       $(CBFSTOOL) $@ create $(CONFIG_COREBOOT_ROMSIZE_KB)K $(obj)/coreboot.bootblock
        if [ -f fallback/coreboot_apc ]; \
        then \
                $(CBFSTOOL) $@ add-stage fallback/coreboot_apc fallback/coreboot_apc $(CBFS_COMPRESS_FLAG); \
index 26e443364f324337cf27c398af5069cb9da6708f..3c6db6f231ef3393157a1373da504db79db04c81 100644 (file)
@@ -192,7 +192,14 @@ static int cbfs_create(int argc, char **argv)
                return 1;
        }
 
-       uint32_t size = strtoul(argv[3], NULL, 0);
+       char* suffix;
+       uint32_t size = strtoul(argv[3], &suffix, 0);
+       if (tolower(suffix[0])=='k') {
+               size *= 1024;
+       }
+       if (tolower(suffix[0])=='m') {
+               size *= 1024 * 1024;
+       }
        char *bootblock = argv[4];
        uint32_t align = 0;