cbfstool locate: Implement alignment switch --align/-a

cbfstool usage change:
 "-a" for "cbfstool locate" can specify base address alignment.

To support putting a blob in aligned location (ex, microcode needs to be aligned
in 0x10), alignment (-a) is implemented into "locate" command.

Verified by manually testing a file (324 bytes) with alignment=0x10:
 cbfstool coreboot.rom locate -f test -n test -a 0x10
 # output: 0x71fdd0
 cbfstool coreboot.rom add -f test -n test -t raw -b 0x71fdd0
 cbfstool coreboot.rom print -v -v
 # output: test                           0x71fd80   raw          324
 # output:  cbfs_file=0x71fd80, offset=0x50, content_address=0x71fdd0+0x144

Also verified to be compatible with old behavior by building i386/axus/tc320
(with page limitation 0x40000):
 cbfstool coreboot.rom locate -f romstage_null.bin -n romstage -P 0x40000
 # output: 0x44
 cbfstool coreboot.rom locate -f x.bin -n romstage -P 0x40000 -a 0x30
 # output: 0x60

Change-Id: I78b549fe6097ce5cb6162b09f064853827069637
Signed-off-by: Hung-Te Lin <hungte@chromium.org>
Reviewed-on: http://review.coreboot.org/2824
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:24:43 +08:00
parent b3b72f350e
commit e4ea2ca18d
3 changed files with 58 additions and 29 deletions

View File

@@ -356,12 +356,12 @@ static int cbfs_locate(void)
}
address = cbfs_locate_entry(&image, param.name, buffer.size,
param.pagesize);
param.pagesize, param.alignment);
buffer_delete(&buffer);
if (address == -1) {
ERROR("'%s' can't fit in CBFS for page-size %#x.\n",
param.name, param.pagesize);
ERROR("'%s' can't fit in CBFS for page-size %#x, align %#x.\n",
param.name, param.pagesize, param.alignment);
cbfs_image_delete(&image);
return 1;
}
@@ -422,7 +422,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:b:H:a:o:m:vh?", cbfs_create},
{"locate", "f:n:P:Tvh?", cbfs_locate},
{"locate", "f:n:P:a:Tvh?", cbfs_locate},
{"print", "vh?", cbfs_print},
{"extract", "n:f:vh?", cbfs_extract},
};
@@ -470,7 +470,7 @@ 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 [-P page-size] [-T] "
" locate -f FILE -n NAME [-P page-size] [-a align] [-T] "
"Find a place for a file of that size\n"
" print "
"Show the contents of the ROM\n"