summaryrefslogtreecommitdiffstats
path: root/convert
diff options
context:
space:
mode:
Diffstat (limited to 'convert')
-rw-r--r--convert/README.pcitable4
-rwxr-xr-xconvert/merge2pcitable.pl62
2 files changed, 64 insertions, 2 deletions
diff --git a/convert/README.pcitable b/convert/README.pcitable
index a4aa727c..27770d7d 100644
--- a/convert/README.pcitable
+++ b/convert/README.pcitable
@@ -10,7 +10,9 @@
rm -f vendors.txt ; wget http://www.yourvote.com/pci/vendors.txt
./merge2pcitable.pl pciids vendors.txt pcitable > pcitable.new
-# http://www.begent.co.uk/pcids.htm
+# Another one
+rm -f pcids.html ; wget http://www.begent.co.uk/pcids.htm
+./merge2pcitable.pl begent_pcids_htm pcids.htm pcitable > pcitable.new
# with redhat's pcitable in /tmp/rh_pcitable (from kudzu or anaconda)
diff --git a/convert/merge2pcitable.pl b/convert/merge2pcitable.pl
index dd8127bb..ef96b111 100755
--- a/convert/merge2pcitable.pl
+++ b/convert/merge2pcitable.pl
@@ -35,6 +35,7 @@ sub dummy_module {
sub to_string {
my ($id, $driver) = @_;
+ @$driver == 2 or die "error: to_string $id\n";
my ($module, $text) = map { qq("$_") } @$driver;
my ($id1, $id2, $subid1, $subid2) = map { "0x$_" } ($id =~ /(....)/g);
join "\t", $id1, $id2, "$subid1 $subid2" ne "0xffff 0xffff" ? ($subid1, $subid2) : (), $module, $text;
@@ -193,6 +194,56 @@ sub read_hwd {
\%drivers;
}
+sub read_begent_pcids_htm {
+ my ($f) = @_;
+ my %drivers;
+ local *F;
+ open F, $f or die "can't open $f\n";
+
+ # drop until TBODY
+ while (<F>) { last if m|<TBODY>| }
+
+ my $get_one = sub { map { scalar <F> } 1 .. 6 };
+ my $from_h = sub {
+ local $_ = lc $_[0];
+ /([0-9a-g]{4})h/ or die "$.: bad number $_\n";
+ $1;
+ };
+
+ # drop first line
+ $get_one->();
+
+ my ($cur_vendor, $cur_vendor_descr, $cur_id);
+
+ while (1) {
+ my ($tr, $vendor, $device, $sub, $text, $tr2) = map { m|<td>(.*)</td>| ? $1 : $_ } $get_one->();
+ last if $tr =~ m|</TBODY>|;
+ $tr =~ m|<tr>| or die "$f:$.: bad <tr> line $tr\n";
+ $tr2 =~ m|</tr>| or die "$f:$.: bad </tr> line $tr2\n";
+
+ if ($vendor) {
+ $device eq '-' && $sub eq '-' or die "$f:$.: bad vendor line\n";
+ $cur_vendor = $vendor;
+ ($cur_vendor_descr) = $text =~ m|<b>(.*)</b>| or die "$f:$.: vendor descr not bold\n";
+ } else {
+ $cur_id = $device || $cur_id;
+ my $sub_t =
+ $sub ? do {
+ $sub =~ /^rev / and next; # ignoring "rev " thingy
+ if ($sub =~ /^(.....)$/) {
+ 'ffff' . $from_h->($sub);
+ } else {
+ my ($s1, $s2) = $sub =~ /^(....)(.....)$/ or die "$f:$.: bad subid $sub\n";
+ $from_h->($s2) . $from_h->($s1 . 'h');
+ }
+ } : 'ffffffff';
+
+ $drivers{$from_h->($cur_vendor) . $from_h->($cur_id) . $sub_t} = [ 'unknown', "$cur_vendor_descr|$text" ];
+ }
+ }
+ \%drivers;
+}
+
# write in RedHat's pcitable old format (mdk one)
sub write_pcitable {
my ($drivers) = @_;
@@ -219,6 +270,15 @@ sub merge {
}
}
} else {
+ if (!/ffffffff$/ && $new->{$_}[0] eq "unknown") {
+ # keep sub-entry with major-entry module
+ # will be dropped if every subids have the same module
+ # ie. if no subids already present have a different module than the main one
+ /(........)/;
+ $new->{$_}[0] = $drivers->{$1 . 'ffffffff'}[0] || "unknown"
+ if exists $drivers->{$1 . 'ffffffff'};
+ }
+
$drivers->{$_} = $new->{$_}
# don't keep sub-entries with unknown drivers
if $all || /ffffffff$/ || $new->{$_}[0] ne "unknown";
@@ -243,7 +303,7 @@ sub cleanup_subids {
foreach my $subid (@{$m{$id}}) {
my $e = $drivers->{"$id$subid"};
$modules{$e->[0]} = 1;
- $text = $e->[1] if length($e->[1]) > length($text);
+ $text = $e->[1] if length($e->[1]) > length($text) || $subid eq 'ffffffff'; # favour previous text
}
if (keys(%modules) == 1) {
my ($module, undef) = %modules;