summaryrefslogtreecommitdiffstats
path: root/mdk-stage1/pci-resource/update-pci-ids.pl
blob: 154ea8b423706e598436f5895c1b464067bf5c75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/perl

use lib "../../perl-install";

use common qw(:common);
require '../../../soft/ldetect-lst/convert/merge2pcitable.pl';

my $drivers = read_pcitable("../../../soft/ldetect-lst/lst/pcitable");


print '
#define PCI_REVISION_ID         0x08    /* Revision ID */

struct pci_module_map {
	unsigned short	vendor;     /* PCI vendor id */
	unsigned short	device;     /* PCI device id */
	const char      *name;      /* PCI human readable name */
	const char      *module;    /* module to load */
};

';

my %t = (scsi => 'scsi', eth => 'net');

foreach (keys %t) {
    print "#ifndef DISABLE_NETWORK\n" if ($_ eq 'eth');
    print "#ifndef DISABLE_MEDIAS\n" if ($_ eq 'scsi');

    print "
struct pci_module_map ${_}_pci_ids[] = {
";
    my %l;
    foreach (glob("../../kernel*/lib/modules/*/$t{$_}/*.o")) {
	m|([^/]*)\.o$|;
	$l{$1} = 1;
    }
    while (my ($k, $v) = each %$drivers) {
	$l{$v->[0]} or next;
	$k =~ /^(....)(....)/;
	printf qq|\t{0x%s  , 0x%s  , ( "%s" ), ( "%s" )} ,\n|,
	   $1, $2, $v->[1], $v->[0];
    }

print "
};
int ${_}_num_ids=sizeof(${_}_pci_ids)/sizeof(struct pci_module_map);
";

    print "#endif\n";

}