Patchwork Enable suffixes for cbfstool create size argument

login
register
about
Submitter Patrick Georgi
Date 2009-12-21 13:21:30
Message ID <4B2F765A.90109@coresystems.de>
Download mbox | patch
Permalink /patch/678/
State Accepted
Commit r4987
Headers show

Comments

Patrick Georgi - 2009-12-21 13:21:30
Hi,

attached patch allows to specify the size of a newly created cbfs image
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>
Peter Stuge - 2009-12-21 13:31:15
Patrick Georgi wrote:
> attached patch allows to specify the size of a newly created cbfs image
> 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>

Patch

Index: src/arch/i386/Makefile.inc
===================================================================
--- src/arch/i386/Makefile.inc	(revision 4985)
+++ src/arch/i386/Makefile.inc	(working copy)
@@ -14,7 +14,7 @@ 
 
 $(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: util/cbfstool/cbfstool.c
===================================================================
--- util/cbfstool/cbfstool.c	(revision 4985)
+++ util/cbfstool/cbfstool.c	(working copy)
@@ -192,7 +192,14 @@ 
 		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;