Make the vendor name optional in the -m flashrom parameter when there's only

one board name that matches. The full syntax still works, and is required
when two vendors have boards with the same names.

Signed-off-by: Peter Stuge <peter@stuge.se>
Acked-by: Stefan Reinauer <stepan@coresystems.de>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3082 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
This commit is contained in:
Peter Stuge 2008-01-27 16:21:21 +00:00
parent 3bbf2ff789
commit e2bbcb10d1
4 changed files with 51 additions and 35 deletions

View File

@ -23,7 +23,7 @@ Usage
----- -----
$ flashrom [-rwvEVfh] [-c chipname] [-s exclude_start] [-e exclude_end] $ flashrom [-rwvEVfh] [-c chipname] [-s exclude_start] [-e exclude_end]
[-m vendor:part] [-l file.layout] [-i imagename] [file] [-m [vendor:]part] [-l file.layout] [-i imagename] [file]
-r | --read: read flash and save into file -r | --read: read flash and save into file
-w | --write: write file into flash (default when -w | --write: write file into flash (default when
file is specified) file is specified)
@ -33,7 +33,7 @@ Usage
-c | --chip <chipname>: probe only for specified flash chip -c | --chip <chipname>: probe only for specified flash chip
-s | --estart <addr>: exclude start position -s | --estart <addr>: exclude start position
-e | --eend <addr>: exclude end postion -e | --eend <addr>: exclude end postion
-m | --mainboard <vendor:part>: override mainboard settings -m | --mainboard <[vendor:]part>: override mainboard settings
-f | --force: force write without checking image -f | --force: force write without checking image
-l | --layout <file.layout>: read rom layout from file -l | --layout <file.layout>: read rom layout from file
-i | --image <name>: only flash image name from flash layout -i | --image <name>: only flash image name from flash layout

View File

@ -413,9 +413,10 @@ struct board_pciid_enable board_pciid_enables[] = {
static struct board_pciid_enable *board_match_coreboot_name(const char *vendor, const char *part) static struct board_pciid_enable *board_match_coreboot_name(const char *vendor, const char *part)
{ {
struct board_pciid_enable *board = board_pciid_enables; struct board_pciid_enable *board = board_pciid_enables;
struct board_pciid_enable *partmatch = NULL;
for (; board->name; board++) { for (; board->name; board++) {
if (!board->lb_vendor || strcmp(board->lb_vendor, vendor)) if (vendor && (!board->lb_vendor || strcmp(board->lb_vendor, vendor)))
continue; continue;
if (!board->lb_part || strcmp(board->lb_part, part)) if (!board->lb_part || strcmp(board->lb_part, part))
@ -427,8 +428,23 @@ static struct board_pciid_enable *board_match_coreboot_name(const char *vendor,
if (board->second_vendor && if (board->second_vendor &&
!pci_dev_find(board->second_vendor, board->second_device)) !pci_dev_find(board->second_vendor, board->second_device))
continue; continue;
if (vendor)
return board; return board;
if (partmatch) {
/* a second entry has a matching part name */
printf("AMBIGUOUS BOARD NAME: %s\n", part);
printf("At least vendors '%s' and '%s' match.\n",
partmatch->lb_vendor, board->lb_vendor);
printf("Please use the full -m vendor:part syntax.\n");
return NULL;
} }
partmatch = board;
}
if (partmatch)
return partmatch;
printf("NOT FOUND %s:%s\n", vendor, part); printf("NOT FOUND %s:%s\n", vendor, part);
@ -477,7 +493,7 @@ int board_flash_enable(const char *vendor, const char *part)
struct board_pciid_enable *board = NULL; struct board_pciid_enable *board = NULL;
int ret = 0; int ret = 0;
if (vendor && part) if (part)
board = board_match_coreboot_name(vendor, part); board = board_match_coreboot_name(vendor, part);
if (!board) if (!board)

View File

@ -40,11 +40,11 @@ Exclude start position (obsolete).
.B "\-e, \-\-eend" <addr> .B "\-e, \-\-eend" <addr>
Exclude end postion (obsolete). Exclude end postion (obsolete).
.TP .TP
.B "\-m, \-\-mainboard" <vendor:part> .B "\-m, \-\-mainboard" <[vendor:]part>
Override mainboard settings. This option is needed for some mainboards, Override mainboard settings. This option is needed for some mainboards,
see the see the
.B flashrom .B flashrom
README for a list. README for a list. The vendor is not required when the board name is unique.
.TP .TP
.B "\-f, \-\-force" .B "\-f, \-\-force"
Force write without checking whether the ROM image file is really meant Force write without checking whether the ROM image file is really meant

View File

@ -196,7 +196,7 @@ int verify_flash(struct flashchip *flash, uint8_t *buf)
void usage(const char *name) void usage(const char *name)
{ {
printf("usage: %s [-rwvEVfhR] [-c chipname] [-s exclude_start]\n", name); printf("usage: %s [-rwvEVfhR] [-c chipname] [-s exclude_start]\n", name);
printf(" [-e exclude_end] [-m vendor:part] [-l file.layout] [-i imagename] [file]\n"); printf(" [-e exclude_end] [-m [vendor:]part] [-l file.layout] [-i imagename] [file]\n");
printf printf
(" -r | --read: read flash and save into file\n" (" -r | --read: read flash and save into file\n"
" -w | --write: write file into flash\n" " -w | --write: write file into flash\n"
@ -206,7 +206,7 @@ void usage(const char *name)
" -c | --chip <chipname>: probe only for specified flash chip\n" " -c | --chip <chipname>: probe only for specified flash chip\n"
" -s | --estart <addr>: exclude start position\n" " -s | --estart <addr>: exclude start position\n"
" -e | --eend <addr>: exclude end postion\n" " -e | --eend <addr>: exclude end postion\n"
" -m | --mainboard <vendor:part>: override mainboard settings\n" " -m | --mainboard <[vendor:]part>: override mainboard settings\n"
" -f | --force: force write without checking image\n" " -f | --force: force write without checking image\n"
" -l | --layout <file.layout>: read rom layout from file\n" " -l | --layout <file.layout>: read rom layout from file\n"
" -i | --image <name>: only flash image name from flash layout\n" " -i | --image <name>: only flash image name from flash layout\n"
@ -301,8 +301,8 @@ int main(int argc, char *argv[])
lb_vendor = tempstr; lb_vendor = tempstr;
lb_part = tempstr2; lb_part = tempstr2;
} else { } else {
printf("warning: ignored wrong format of" lb_vendor = NULL;
" mainboard: %s\n", tempstr); lb_part = tempstr;
} }
break; break;
case 'f': case 'f':