Hung-Te Lin (hungte@chromium.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/2198
-gerrit
commit d43d5d5868a5d9de8c3f2fa03a04bb3e03c3e627 Author: Hung-Te Lin hungte@chromium.org Date: Mon Jan 28 15:27:48 2013 +0800
cbfstool: Change "locate" to "locate-stage".
The "locate" has implicit logic of constructing stage-style files (ex, adding extra sizeof(struct cbfs_stage) bytes to header size requirement). In other words, if we try to add a component with header larger than stage, it may fail to fit in the space.
To prevent confusion, the command should be renamed to reflect the fact it's designed for stage files.
Moreover, output format is changed to include "0x", in case if we want to allow outputting decimal on demand in future.
Change-Id: I168ed20d2cb682c22e0f03d42d0d071ec68b5ba7 Signed-off-by: Hung-Te Lin hungte@chromium.org --- src/arch/armv7/Makefile.inc | 11 ++++++----- src/arch/x86/Makefile.inc | 11 ++++++----- util/cbfstool/cbfstool.c | 14 +++++++------- util/cbfstool/common.c | 4 ++-- util/cbfstool/common.h | 4 ++-- 5 files changed, 23 insertions(+), 21 deletions(-)
diff --git a/src/arch/armv7/Makefile.inc b/src/arch/armv7/Makefile.inc index 872365c..905fbf8 100644 --- a/src/arch/armv7/Makefile.inc +++ b/src/arch/armv7/Makefile.inc @@ -314,11 +314,12 @@ $(objgenerated)/romstage_xip.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/bas $(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin @printf " generating base_xip.txt\n" rm -f $@ - $(CBFSTOOL) $(obj)/coreboot.pre1 locate -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -a $(CONFIG_XIP_ROM_SIZE) > $@.tmp \ - || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } - sed -e 's/^/0x/g' $@.tmp > $@.tmp2 - rm $@.tmp - mv $@.tmp2 $@ + $(CBFSTOOL) $(obj)/coreboot.pre1 locate-stage \ + -f $(objcbfs)/romstage_null.bin \ + -n $(CONFIG_CBFS_PREFIX)/romstage \ + -a $(CONFIG_XIP_ROM_SIZE) > $@.tmp || \ + { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } + mv $@.tmp $@
$(objgenerated)/crt0.romstage.S: $$(crt0s) @printf " GEN $(subst $(obj)/,,$(@))\n" diff --git a/src/arch/x86/Makefile.inc b/src/arch/x86/Makefile.inc index ea86f8f..f79016e 100644 --- a/src/arch/x86/Makefile.inc +++ b/src/arch/x86/Makefile.inc @@ -375,11 +375,12 @@ $(objgenerated)/romstage_xip.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/bas
$(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin rm -f $@ - $(CBFSTOOL) $(obj)/coreboot.pre1 locate -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -a $(CONFIG_XIP_ROM_SIZE) > $@.tmp \ - || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } - sed -e 's/^/0x/g' $@.tmp > $@.tmp2 - rm $@.tmp - mv $@.tmp2 $@ + $(CBFSTOOL) $(obj)/coreboot.pre1 locate-stage \ + -f $(objcbfs)/romstage_null.bin \ + -n $(CONFIG_CBFS_PREFIX)/romstage \ + -a $(CONFIG_XIP_ROM_SIZE) > $@.tmp || \ + { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } + mv $@.tmp $@
$(objgenerated)/crt0.romstage.S: $$(crt0s) @printf " GEN $(subst $(obj)/,,$(@))\n" diff --git a/util/cbfstool/cbfstool.c b/util/cbfstool/cbfstool.c index 378440f..48812d9 100644 --- a/util/cbfstool/cbfstool.c +++ b/util/cbfstool/cbfstool.c @@ -360,7 +360,7 @@ static int cbfs_create(void) param.alignment, param.offset); }
-static int cbfs_locate(void) +static int cbfs_locate_stage(void) { uint32_t filesize, location;
@@ -376,10 +376,10 @@ static int cbfs_locate(void)
filesize = getfilesize(param.filename);
- location = cbfs_find_location(param.cbfs_name, filesize, - param.name, param.alignment); + location = cbfs_find_stage_location(param.cbfs_name, filesize, + param.name, param.alignment);
- printf("%x\n", location); + printf("0x%x\n", location); return location == 0 ? 1 : 0; }
@@ -435,7 +435,7 @@ static const struct command commands[] = { {"add-flat-binary", "f:n:l:e:c:b:vh?", cbfs_add_flat_binary}, {"remove", "n:vh?", cbfs_remove}, {"create", "s:B:a:o:m:vh?", cbfs_create}, - {"locate", "f:n:a:vh?", cbfs_locate}, + {"locate-stage", "f:n:a:vh?", cbfs_locate_stage}, {"print", "vh?", cbfs_print}, {"extract", "n:f:vh?", cbfs_extract}, }; @@ -479,8 +479,8 @@ static void usage(char *name) "Remove a component\n" " create -s size -B bootblock -m ARCH [-a align] [-o offset] " "Create a ROM file\n" - " locate -f FILE -n NAME -a align " - "Find a place for a file of that size\n" + " locate-stage -f FILE -n NAME [-a align] " + "Find a space for stage to fit in one aligned page\n" " print " "Show the contents of the ROM\n" " extract -n NAME -f FILE " diff --git a/util/cbfstool/common.c b/util/cbfstool/common.c index 8b4b4b4..3e48534 100644 --- a/util/cbfstool/common.c +++ b/util/cbfstool/common.c @@ -711,8 +711,8 @@ static int in_segment(int addr, int size, int gran) return ((addr & ~(gran - 1)) == ((addr + size) & ~(gran - 1))); }
-uint32_t cbfs_find_location(const char *romfile, uint32_t filesize, - const char *filename, uint32_t alignment) +uint32_t cbfs_find_stage_location(const char *romfile, uint32_t filesize, + const char *filename, uint32_t alignment) { void *rom; size_t filename_size, headersize, totalsize; diff --git a/util/cbfstool/common.h b/util/cbfstool/common.h index 7b92179..45b88af 100644 --- a/util/cbfstool/common.h +++ b/util/cbfstool/common.h @@ -84,8 +84,8 @@ void print_cbfs_directory(const char *filename); int extract_file_from_cbfs(const char *filename, const char *payloadname, const char *outpath); int remove_file_from_cbfs(const char *filename);
-uint32_t cbfs_find_location(const char *romfile, uint32_t filesize, - const char *filename, uint32_t align); +uint32_t cbfs_find_stage_location(const char *romfile, uint32_t filesize, + const char *filename, uint32_t align);
void print_supported_filetypes(void);