9 open(IN, "<", "usb.ids");
10 open(OUT, ">", "20-usb-vendor-model.hwdb");
11 print(OUT "# This file is part of systemd.\n" .
13 "# Data imported from: http://www.linux-usb.org/usb.ids\n");
15 while (my $line = <IN>) {
17 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
22 print(OUT "usb:v" . $vendor . "*\n");
23 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
27 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
32 print(OUT "usb:v" . $vendor . "p" . $model . "*\n");
33 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
46 open(IN, "<", "usb.ids");
47 open(OUT, ">", "20-usb-classes.hwdb");
48 print(OUT "# This file is part of systemd.\n" .
50 "# Data imported from: http://www.linux-usb.org/usb.ids\n");
52 while (my $line = <IN>) {
55 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
58 if ($class =~ m/^00$/) {
63 print(OUT "usb:v*p*d*dc" . $class . "*\n");
64 print(OUT " ID_USB_CLASS_FROM_DATABASE=" . $text . "\n");
68 if (not defined $class) {
70 } elsif ($line =~ m/^$/) {
74 $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
77 if ($subclass =~ m/^00$/) {
81 if ($text =~ m/^(\?|None|Unused)$/) {
85 print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "*\n");
86 print(OUT " ID_USB_SUBCLASS_FROM_DATABASE=" . $text . "\n");
90 $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
94 if ($text =~ m/^(\?|None|Unused)$/) {
98 print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "dp" . $protocol . "*\n");
99 print(OUT " ID_USB_PROTOCOL_FROM_DATABASE=" . $text . "\n");
112 open(IN, "<", "pci.ids");
113 open(OUT, ">", "20-pci-vendor-model.hwdb");
114 print(OUT "# This file is part of systemd.\n" .
116 "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
118 while (my $line = <IN>) {
120 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
126 print(OUT "pci:v0000" . $vendor . "*\n");
127 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
131 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
136 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
137 print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . "\n");
141 $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
143 my $sub_vendor = uc $1;
144 my $sub_device = uc $2;
146 $sub_text =~ s/^\Q$device_text\E\s*//;
147 $sub_text =~ s/(.+)/\ ($1)/;
149 print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
150 print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . $sub_text . "\n");
163 open(IN, "<", "pci.ids");
164 open(OUT, ">", "20-pci-classes.hwdb");
165 print(OUT "# This file is part of systemd.\n" .
167 "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
169 while (my $line = <IN>) {
172 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
177 print(OUT "pci:v*d*sv*sd*bc" . $class . "*\n");
178 print(OUT " ID_PCI_CLASS_FROM_DATABASE=" . $text . "\n");
182 if (not defined $class) {
184 } elsif ($line =~ m/^$/) {
188 $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
193 print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "*\n");
194 print(OUT " ID_PCI_SUBCLASS_FROM_DATABASE=" . $text . "\n");
198 $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
203 print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "i" . $interface . "*\n");
204 print(OUT " ID_PCI_INTERFACE_FROM_DATABASE=" . $text . "\n");
216 open(IN, "<", "sdio.ids");
217 open(OUT, ">", "20-sdio-vendor-model.hwdb");
218 print(OUT "# This file is part of systemd.\n" .
220 "# Data imported from: hwdb/sdio.ids\n");
222 while (my $line = <IN>) {
224 $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
230 print(OUT "sdio:c*v" . $vendor . "*\n");
231 print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
235 $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
240 print(OUT "sdio:c*v" . $vendor . "d" . $device . "*\n");
241 print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
255 open(IN, "<", "sdio.ids");
256 open(OUT, ">", "20-sdio-classes.hwdb");
257 print(OUT "# This file is part of systemd.\n" .
259 "# Data imported from: hwdb/sdio.ids\n");
261 while (my $line = <IN>) {
264 $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
269 print(OUT "sdio:c" . $class . "v*d*\n");
270 print(OUT " ID_SDIO_CLASS_FROM_DATABASE=" . $text . "\n");
279 # MAC Address Block Large/Medium/Small
280 # Large MA-L 24/24 bit (OUI)
281 # Medium MA-M 28/20 bit (OUI prefix owned by IEEE)
282 # Small MA-S 36/12 bit (OUI prefix owned by IEEE)
285 my %ieee_prefixes = ();
287 open(OUT, ">", "20-OUI.hwdb");
288 print(OUT "# This file is part of systemd.\n" .
290 "# Data imported from:\n" .
291 "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-L&format=txt\n" .
292 "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-M&format=txt\n" .
293 "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-S&format=txt\n");
295 open(IN, "<", "ma-small.txt");
296 while (my $line = <IN>) {
299 $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
301 $prefix = $1 . $2 . $3;
302 $ieee_prefixes{ $prefix } = 1;
306 $line =~ m/^([0-9A-F]{3})000-\g1FFF\s*\(base 16\)\s*(.+)$/;
312 print(OUT "OUI:" . $prefix . $vendor . "*\n");
313 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
318 open(IN, "<", "ma-medium.txt");
319 while (my $line = <IN>) {
322 $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
324 $prefix = $1 . $2 . $3;
325 $ieee_prefixes{ $prefix } = 1;
329 $line =~ m/^([0-9A-F])00000-\g1FFFFF\s*\(base 16\)\s*(.+)$/;
335 print(OUT "OUI:" . $prefix . $vendor . "*\n");
336 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
340 open(IN, "<", "ma-large.txt");
341 while (my $line = <IN>) {
344 $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.+)$/;
349 if ($text =~ m/^IEEE REGISTRATION AUTHORITY/) {
353 # skip the IEEE owned prefixes
354 if (! exists $ieee_prefixes{ $vendor }) {
356 print(OUT "OUI:" . $vendor . "*\n");
357 print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");