root/morphix/trunk/hwdata-morphix/makeids

Revision 2, 3.5 kB (checked in by nextime, 2 years ago)

Initial import, branching from morphix svn

  • Property svn:executable set to
Line 
1 #!/usr/bin/perl
2
3 #egrep  "0x[0-9a-f]{4}[ \t]*.?0x[0-9a-f]{4}[ \t]*.?0" pcitable
4
5 require("translations");
6
7 print "Make ABSOLUTELY SURE no entries are lost. Look at pcitable.old, and merge the differences.\n";
8
9 $drivers = {};
10
11 open(F, "pcitable");
12 while (<F>) {
13     chop;
14     if (/^# List of known device classes/) { break; }
15     if (/^#/) { next; }
16     s/  *$//;
17     if (!length($_)) { next };
18     if (  /(0x[0-9a-f]{4})[ \t]+(0x[0-9a-f]{4})[ \t]+(0x[0-9a-f]{4})[ \t]+(0x[0-9a-f]{4})[ \t]+(".*")$/i) {
19       $vendor = $1;
20       $device = $2;
21       $subvendor = $3;
22       $subdevice = $4;
23       $driver = $5;
24       $class =~ s/  *$//;
25       $device =~ s/  *$//;
26       $id = $vendor . "|" . $device . "|" . $subvendor . "|" . $subdevice;
27       $drivers{$id} = $driver;
28     } elsif ( /(0x[0-9a-f]{4})[ \t]+(0x[0-9a-f]{4})[ \t]+(".*")$/i) {
29       $vendor = $1;
30       $device = $2;
31       $driver = $3;
32       $class =~ s/  *$//;
33       $device =~ s/  *$//;
34       $id = $vendor . "|" . $device;
35       $drivers{$id} = $driver;
36     }
37 }
38 close(F);
39 rename("pcitable","pcitable.old");
40 open(F, "<pci.ids");
41
42 open(DRIVERS, ">pcitable");
43
44 print DRIVERS "# This file is automatically generated from isys/pci. Edit\n";
45 print DRIVERS "# it by hand to change a driver mapping. Other changes will\n";
46 print DRIVERS "# be lost at the next merge - you have been warned.\n";
47 print DRIVERS "# Edit by hand to change a driver mapping. Changes to descriptions\n";
48 print DRIVERS "# will be lost at the next merge - you have been warned.\n";
49 print DRIVERS "# If you run makeids, please make sure no entries are lost.";
50 print DRIVERS "\n";
51 print DRIVERS "# The format is (\"%d\\t%d\\t%s\\t\"%s\"\\n\", vendid, devid, moduleName, cardDescription)\n";
52 print DRIVERS "# or (\"%d\\t%d\\t%d\\t%d\\t%s\\t\"%s\"\\n\", vendid, devid, subvendid, subdevid, moduleName, cardDescription)";
53 print DRIVERS "\n\n";
54
55 $class = "";
56
57 $vendors = {};
58 while (<F>) {
59     chop;
60     s/   */ /g;
61     s/^  *//g;
62     s/  *$//g;
63     if (/^# List of known device classes/) { last; }
64     if (/^#.*/) { next };
65     if (!length($_)) { next };
66
67     if (!/^\t/) {
68         s/([0-9A-Fa-f]+) +//;
69         $classid = $1;
70         if ($classtr{$_}) {
71            $class = $classtr{$_};
72         } else {
73            $class = $_;
74         }
75         $vendors{$classid} = $class;
76     }
77 }
78 close(F);
79
80 open(F, "<pci.ids");
81 while (<F>) {
82     chop;
83     s/   */ /g;
84     s/^  *//g;
85     s/  *$//g;
86     if (/^# List of known device classes/) { last; }
87     if (/^#.*/) { next };
88     if (!length($_)) { next };
89
90     if (/^\t/ && ! /^\t\t/) {
91         if ($class eq "") {
92             die "unexpected device\n";
93         }
94         s/\t([0-9A-Fa-f]+) +//;
95         $devid = $1;
96
97         $name = $class . "|" . $_;
98         $device = "0x" . $classid . "|0x" . $devid;
99         if ($drivers{$device}) {
100             printf(DRIVERS "0x%s\t0x%s\t%s\t\"%s\"\n",
101                    $classid, $devid,
102                    $drivers{$device},$name);
103         } else {
104 #           printf(DRIVERS "0x%s\t0x%s\t%s\t\"%s\"\n",
105 #                 $classid, $devid,
106 #                 "\"unknown\"",$name);
107         }
108     } elsif ( /^\t\t/ ) {
109         if ($class eq "") {
110             die "unexpected subdevice\n";
111         }
112         if ($devid eq "") {
113             die "unexpected subdevice\n";
114         }
115         s/\t\t([0-9A-Fa-f]+) ([0-9A-Fa-f]+) +//;
116         $subvend = $1;
117         $subdev = $2;
118        
119         $name = $vendors{$subvend} . "|" . $_;
120         $device = "0x" . $classid . "|0x" . $devid . "|0x" . $subvend . "|0x" . $subdev;
121         if ($drivers{$device}) {
122             printf(DRIVERS "0x%s\t0x%s\t0x%s\t0x%s\t%s\t\"%s\"\n",
123                    $classid, $devid, $subvend, $subdev,
124                    $drivers{$device},$name);
125         }
126     } else  {
127         s/([0-9A-Fa-f]+) +//;
128         $classid = $1;
129         if ($classtr{$_}) {
130            $class = $classtr{$_};
131         } else {
132            $class = $_;
133         }
134     }
135 }
136
137 close(F);
138
Note: See TracBrowser for help on using the browser.