--- src/tools/tools/pciid/mk_pci_vendors.pl 2006/06/15 13:37:35 1.1 +++ src/tools/tools/pciid/mk_pci_vendors.pl 2008/03/08 20:17:38 1.2 @@ -26,20 +26,24 @@ # $FreeBSD: src/tools/tools/pciid/mk_pci_vendors.pl,v 1.5 2004/06/28 11:46:48 mux Exp $ # $DragonFly$ # -# usage: mk_pci_vendors [-lq] [-p pcidevs.txt] [-v vendors.txt] +# usage: mk_pci_vendors [-lq] [-p pcidevs.txt] [-v vendors.txt] [-x pci.ids] # -# Generate src/share/misc/pci_vendors from the Hart and Boemler lists, +# Generate src/share/misc/pci_vendors from the Hart, Boemler and Mares lists, # currently available at: # # Boemler: http://www.pcidatabase.com/reports.php?type=tab-delimeted # Hart: http://members.datafast.net.au/dft0802/downloads/pcidevs.txt +# Mares: http://pciids.sourceforge.net/pci.ids # -# -l Where an entry is found in both input lists, use the entry with -# the longest description. The default is for the Boemler file to -# override the Hart file. +# -l Where an entry is found in the Boemler and the Hart lists, use the +# entry with the longest description. The -l option doesn't affect +# the Mares list whose entries are only used if they are new. The +# default is for the Boemler file to override the Hart file to +# override the Mares file. # -q Do not print diagnostics. # -p Specify the pathname of the Hart file. (Default ./pcidevs.txt) # -v Specify the pathname of the Boemler file. (Default ./vendors.txt) +# -x Specify the pathname of the Mares file. (Default ./pci.ids) # use strict; use Getopt::Std; @@ -47,6 +51,7 @@ use Getopt::Std; my $PROGNAME = 'mk_pci_vendors'; my $VENDORS_FILE = 'vendors.txt'; my $PCIDEVS_FILE = 'pcidevs.txt'; +my $PCIIDS_FILE = 'pci.ids'; my $cur_vendor; my %opts; @@ -64,9 +69,10 @@ my $W_PCIDEVS = 2; sub clean_descr($); sub vendors_parse($\$\$); sub pcidevs_parse($\$\$); +sub pciids_parse($\$\$); -if (not getopts('lp:qv:', \%opts) or @ARGV > 0) { - print STDERR "usage: $PROGNAME [-lq] [-p pcidevs.txt] [-v vendors.txt]\n"; +if (not getopts('lp:qv:x:', \%opts) or @ARGV > 0) { + print STDERR "usage: $PROGNAME [-lq] [-p pcidevs.txt] [-v vendors.txt] [-x pci.ids]\n"; exit 1; } @@ -76,6 +82,9 @@ if (not defined($opts{p})) { if (not defined($opts{v})) { $opts{v} = $VENDORS_FILE; } +if (not defined($opts{x})) { + $opts{x} = $PCIIDS_FILE; +} foreach (('l', 'q')) { if (not exists($opts{$_})) { $opts{$_} = 0; @@ -154,6 +163,24 @@ while ($line = ) { } close(PCIDEVS); +open(PCIIDS, "< $opts{x}") or + die "$PROGNAME: $opts{x}: $!\n"; +while ($line = ) { + chomp($line); + $rv = pciids_parse($line, $id, $descr); + if ($rv == $IS_VENDOR) { + if (not exists($vendors{$id})) { + $vendors{$id} = [$descr, {}]; + } + $cur_vendor = $id; + } elsif ($rv == $IS_DEVICE) { + if (not exists(${$vendors{$cur_vendor}->[$V_DEVSL]}{$id})) { + ${$vendors{$cur_vendor}->[$V_DEVSL]}{$id} = $descr; + } + } +} +close(PCIIDS); + $optlused = $opts{l} ? "with" : "without"; print <