cbfstool locate: Rename -a align switch to -P for page size

cbfstool usage change:
   The "-a" parameter for "cbfstool locate" is switched to "-P/--page-size".

The "locate" command was used to find a place to store ELF stage image in one
memory page. Its argument "-a (alignment)" was actually specifying the page size
instead of doing memory address alignment. This can be confusing when people are
trying to put a blob in aligned location (ex, microcode needs to be aligned in
0x10), and see this:
  cbfstool coreboot.rom locate -f test.bin -n test -a 0x40000
  # output: 0x44, which does not look like aligned to 0x40000.

To prevent confusion, it's now switched to "-P/--page-size".

Verified by building i386/axus/tc320 (with page limitation 0x40000):
 cbfstool coreboot.rom locate -f romstage_null.bin -n romstage -P 0x40000
 # output: 0x44

Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Change-Id: I0893adde51ebf46da1c34913f9c35507ed8ff731
Reviewed-on: http://review.coreboot.org/2730
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
Tested-by: build bot (Jenkins)
This commit is contained in:
Hung-Te Lin 2013-03-19 12:17:12 +08:00
parent e29e2ff8e8
commit e91983767c
3 changed files with 12 additions and 7 deletions

View File

@ -282,7 +282,7 @@ $(objgenerated)/romstage_xip.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/bas
$(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin $(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin
@printf " generating base_xip.txt\n" @printf " generating base_xip.txt\n"
rm -f $@ rm -f $@
$(CBFSTOOL) $(obj)/coreboot.pre1 locate -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -a $(CONFIG_XIP_ROM_SIZE) > $@.tmp \ $(CBFSTOOL) $(obj)/coreboot.pre1 locate -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -P $(CONFIG_XIP_ROM_SIZE) > $@.tmp \
|| { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
mv $@.tmp $@ mv $@.tmp $@

View File

@ -393,7 +393,7 @@ $(objgenerated)/romstage_xip.ld: $(objgenerated)/romstage_null.ld $(objcbfs)/bas
$(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin $(objcbfs)/base_xip.txt: $(obj)/coreboot.pre1 $(objcbfs)/romstage_null.bin
rm -f $@ rm -f $@
$(CBFSTOOL) $(obj)/coreboot.pre1 locate -T -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -a $(CONFIG_XIP_ROM_SIZE) > $@.tmp \ $(CBFSTOOL) $(obj)/coreboot.pre1 locate -T -f $(objcbfs)/romstage_null.bin -n $(CONFIG_CBFS_PREFIX)/romstage -P $(CONFIG_XIP_ROM_SIZE) > $@.tmp \
|| { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; } || { echo "The romstage is larger than XIP size. Please expand the CONFIG_XIP_ROM_SIZE" ; exit 1; }
mv $@.tmp $@ mv $@.tmp $@

View File

@ -50,6 +50,7 @@ static struct param {
uint32_t entrypoint; uint32_t entrypoint;
uint32_t size; uint32_t size;
uint32_t alignment; uint32_t alignment;
uint32_t pagesize;
uint32_t offset; uint32_t offset;
uint32_t top_aligned; uint32_t top_aligned;
comp_algo algo; comp_algo algo;
@ -355,12 +356,12 @@ static int cbfs_locate(void)
} }
address = cbfs_locate_entry(&image, param.name, buffer.size, address = cbfs_locate_entry(&image, param.name, buffer.size,
param.alignment); param.pagesize);
buffer_delete(&buffer); buffer_delete(&buffer);
if (address == -1) { if (address == -1) {
ERROR("'%s' can't fit in CBFS for align 0x%x.\n", ERROR("'%s' can't fit in CBFS for page-size %#x.\n",
param.name, param.alignment); param.name, param.pagesize);
cbfs_image_delete(&image); cbfs_image_delete(&image);
return 1; return 1;
} }
@ -421,7 +422,7 @@ static const struct command commands[] = {
{"add-flat-binary", "f:n:l:e:c:b:vh?", cbfs_add_flat_binary}, {"add-flat-binary", "f:n:l:e:c:b:vh?", cbfs_add_flat_binary},
{"remove", "n:vh?", cbfs_remove}, {"remove", "n:vh?", cbfs_remove},
{"create", "s:B:b:H:a:o:m:vh?", cbfs_create}, {"create", "s:B:b:H:a:o:m:vh?", cbfs_create},
{"locate", "f:n:a:Tvh?", cbfs_locate}, {"locate", "f:n:P:Tvh?", cbfs_locate},
{"print", "vh?", cbfs_print}, {"print", "vh?", cbfs_print},
{"extract", "n:f:vh?", cbfs_extract}, {"extract", "n:f:vh?", cbfs_extract},
}; };
@ -437,6 +438,7 @@ static struct option long_options[] = {
{"size", required_argument, 0, 's' }, {"size", required_argument, 0, 's' },
{"bootblock", required_argument, 0, 'B' }, {"bootblock", required_argument, 0, 'B' },
{"alignment", required_argument, 0, 'a' }, {"alignment", required_argument, 0, 'a' },
{"page-size", required_argument, 0, 'P' },
{"offset", required_argument, 0, 'o' }, {"offset", required_argument, 0, 'o' },
{"file", required_argument, 0, 'f' }, {"file", required_argument, 0, 'f' },
{"arch", required_argument, 0, 'm' }, {"arch", required_argument, 0, 'm' },
@ -468,7 +470,7 @@ static void usage(char *name)
"Remove a component\n" "Remove a component\n"
" create -s size -B bootblock -m ARCH [-a align] [-o offset] " " create -s size -B bootblock -m ARCH [-a align] [-o offset] "
"Create a ROM file\n" "Create a ROM file\n"
" locate -f FILE -n NAME [-a align] [-T] " " locate -f FILE -n NAME [-P page-size] [-T] "
"Find a place for a file of that size\n" "Find a place for a file of that size\n"
" print " " print "
"Show the contents of the ROM\n" "Show the contents of the ROM\n"
@ -572,6 +574,9 @@ int main(int argc, char **argv)
case 'a': case 'a':
param.alignment = strtoul(optarg, NULL, 0); param.alignment = strtoul(optarg, NULL, 0);
break; break;
case 'P':
param.pagesize = strtoul(optarg, NULL, 0);
break;
case 'o': case 'o':
param.offset = strtoul(optarg, NULL, 0); param.offset = strtoul(optarg, NULL, 0);
break; break;