2012-10-23 00:23:08 +08:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
2012-11-09 21:29:10 +08:00
|
|
|
sub usb_vendor {
|
2012-11-09 21:53:55 +08:00
|
|
|
my $vendor;
|
|
|
|
|
|
|
|
open(IN, "<", "usb.ids");
|
2013-03-23 23:27:28 +08:00
|
|
|
open(OUT, ">", "20-usb-vendor-model.hwdb");
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
2012-12-15 01:23:36 +08:00
|
|
|
"# Data imported from: http://www.linux-usb.org/usb.ids\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/\s+$//;
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^([0-9a-f]{4})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$vendor = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "usb:v" . $vendor . "*\n");
|
|
|
|
print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
2013-03-23 23:27:28 +08:00
|
|
|
my $model = uc $1;
|
2012-11-09 21:53:55 +08:00
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
2013-03-23 23:27:28 +08:00
|
|
|
print(OUT "usb:v" . $vendor . "p" . $model . "*\n");
|
|
|
|
print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-07 05:34:25 +08:00
|
|
|
close(IN);
|
|
|
|
close(OUT);
|
2012-11-09 21:53:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub usb_classes {
|
|
|
|
my $class;
|
|
|
|
my $subclass;
|
|
|
|
my $protocol;
|
|
|
|
|
|
|
|
open(IN, "<", "usb.ids");
|
|
|
|
open(OUT, ">", "20-usb-classes.hwdb");
|
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
2012-12-15 01:23:36 +08:00
|
|
|
"# Data imported from: http://www.linux-usb.org/usb.ids\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/\s+$//;
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$class = uc $1;
|
2012-11-09 22:23:41 +08:00
|
|
|
if ($class =~ m/^00$/) {
|
2012-11-09 21:53:55 +08:00
|
|
|
next;
|
|
|
|
}
|
2012-11-09 22:23:41 +08:00
|
|
|
my $text = $2;
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "usb:v*p*d*dc" . $class . "*\n");
|
|
|
|
print(OUT " ID_USB_CLASS_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not defined $class) {
|
|
|
|
next;
|
|
|
|
} elsif ($line =~ m/^$/) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$subclass = uc $1;
|
2012-11-09 22:23:41 +08:00
|
|
|
if ($subclass =~ m/^00$/) {
|
|
|
|
next;
|
|
|
|
}
|
2012-11-09 21:53:55 +08:00
|
|
|
my $text = $2;
|
|
|
|
if ($text =~ m/^(\?|None|Unused)$/) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "*\n");
|
|
|
|
print(OUT " ID_USB_SUBCLASS_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$protocol = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
if ($text =~ m/^(\?|None|Unused)$/) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "dp" . $protocol . "*\n");
|
|
|
|
print(OUT " ID_USB_PROTOCOL_FROM_DATABASE=" . $text . "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-07 05:34:25 +08:00
|
|
|
close(IN);
|
|
|
|
close(OUT);
|
2012-11-09 21:29:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
sub pci_vendor {
|
2012-11-09 21:53:55 +08:00
|
|
|
my $vendor;
|
|
|
|
my $device;
|
2014-04-14 22:54:35 +08:00
|
|
|
my $device_text;
|
2012-11-09 21:53:55 +08:00
|
|
|
|
|
|
|
open(IN, "<", "pci.ids");
|
2013-03-23 23:27:28 +08:00
|
|
|
open(OUT, ">", "20-pci-vendor-model.hwdb");
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
2012-12-15 01:23:36 +08:00
|
|
|
"# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/\s+$//;
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^([0-9a-f]{4})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
|
|
|
|
if (defined $1) {
|
|
|
|
$vendor = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "pci:v0000" . $vendor . "*\n");
|
|
|
|
print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$device = uc $1;
|
2014-04-14 22:54:35 +08:00
|
|
|
$device_text = $2;
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
|
2014-04-14 22:54:35 +08:00
|
|
|
print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . "\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
|
|
|
|
if (defined $1) {
|
|
|
|
my $sub_vendor = uc $1;
|
|
|
|
my $sub_device = uc $2;
|
2014-04-14 22:54:35 +08:00
|
|
|
my $sub_text = $3;
|
|
|
|
$sub_text =~ s/^\Q$device_text\E\s*//;
|
2014-08-01 05:06:04 +08:00
|
|
|
$sub_text =~ s/(.+)/\ ($1)/;
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
|
2014-04-14 22:54:35 +08:00
|
|
|
print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . $sub_text . "\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-07 05:34:25 +08:00
|
|
|
close(IN);
|
|
|
|
close(OUT);
|
2012-10-23 00:23:08 +08:00
|
|
|
}
|
2012-11-09 21:29:10 +08:00
|
|
|
|
|
|
|
sub pci_classes {
|
2012-11-09 21:53:55 +08:00
|
|
|
my $class;
|
|
|
|
my $subclass;
|
|
|
|
my $interface;
|
|
|
|
|
|
|
|
open(IN, "<", "pci.ids");
|
|
|
|
open(OUT, ">", "20-pci-classes.hwdb");
|
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
2012-12-15 01:23:36 +08:00
|
|
|
"# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/\s+$//;
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$class = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "pci:v*d*sv*sd*bc" . $class . "*\n");
|
|
|
|
print(OUT " ID_PCI_CLASS_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not defined $class) {
|
|
|
|
next;
|
|
|
|
} elsif ($line =~ m/^$/) {
|
|
|
|
last;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$subclass = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "*\n");
|
|
|
|
print(OUT " ID_PCI_SUBCLASS_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
2012-11-20 09:07:02 +08:00
|
|
|
$line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
$interface = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "i" . $interface . "*\n");
|
|
|
|
print(OUT " ID_PCI_INTERFACE_FROM_DATABASE=" . $text . "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-07 05:34:25 +08:00
|
|
|
close(IN);
|
|
|
|
close(OUT);
|
2012-10-23 00:23:08 +08:00
|
|
|
}
|
2012-11-09 21:29:10 +08:00
|
|
|
|
2013-12-23 03:30:57 +08:00
|
|
|
sub sdio_vendor {
|
|
|
|
my $vendor;
|
|
|
|
my $device;
|
|
|
|
|
|
|
|
open(IN, "<", "sdio.ids");
|
|
|
|
open(OUT, ">", "20-sdio-vendor-model.hwdb");
|
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
|
|
|
"# Data imported from: hwdb/sdio.ids\n");
|
|
|
|
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/\s+$//;
|
|
|
|
$line =~ m/^([0-9a-f]{4})\s*(.+)$/;
|
|
|
|
|
|
|
|
if (defined $1) {
|
|
|
|
$vendor = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "sdio:c*v" . $vendor . "*\n");
|
|
|
|
print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
|
|
|
|
if (defined $1) {
|
|
|
|
$device = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "sdio:c*v" . $vendor . "d" . $device . "*\n");
|
|
|
|
print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close(IN);
|
|
|
|
close(OUT);
|
|
|
|
}
|
|
|
|
|
|
|
|
sub sdio_classes {
|
|
|
|
my $class;
|
|
|
|
my $subclass;
|
|
|
|
my $interface;
|
|
|
|
|
|
|
|
open(IN, "<", "sdio.ids");
|
|
|
|
open(OUT, ">", "20-sdio-classes.hwdb");
|
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
|
|
|
"# Data imported from: hwdb/sdio.ids\n");
|
|
|
|
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/\s+$//;
|
|
|
|
|
|
|
|
$line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
|
|
|
|
if (defined $1) {
|
|
|
|
$class = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "sdio:c" . $class . "v*d*\n");
|
|
|
|
print(OUT " ID_SDIO_CLASS_FROM_DATABASE=" . $text . "\n");
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close(IN);
|
|
|
|
close(OUT);
|
|
|
|
}
|
|
|
|
|
2015-08-27 00:37:16 +08:00
|
|
|
# MAC Address Block Large/Medium/Small
|
|
|
|
# Large MA-L 24/24 bit (OUI)
|
|
|
|
# Medium MA-M 28/20 bit (OUI prefix owned by IEEE)
|
|
|
|
# Small MA-S 36/12 bit (OUI prefix owned by IEEE)
|
2012-11-09 21:29:10 +08:00
|
|
|
sub oui {
|
2015-08-27 00:37:16 +08:00
|
|
|
my $prefix;
|
|
|
|
my %ieee_prefixes = ();
|
2012-12-04 03:15:22 +08:00
|
|
|
|
2012-11-09 21:53:55 +08:00
|
|
|
open(OUT, ">", "20-OUI.hwdb");
|
|
|
|
print(OUT "# This file is part of systemd.\n" .
|
|
|
|
"#\n" .
|
2012-12-15 01:23:36 +08:00
|
|
|
"# Data imported from:\n" .
|
2015-08-27 00:37:16 +08:00
|
|
|
"# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-L&format=txt\n" .
|
|
|
|
"# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-M&format=txt\n" .
|
|
|
|
"# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-S&format=txt\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
|
2015-08-27 00:37:16 +08:00
|
|
|
open(IN, "<", "ma-small.txt");
|
2012-11-09 21:53:55 +08:00
|
|
|
while (my $line = <IN>) {
|
2013-02-05 01:55:10 +08:00
|
|
|
$line =~ s/^ +//;
|
2012-11-09 21:53:55 +08:00
|
|
|
$line =~ s/\s+$//;
|
2012-12-04 03:15:22 +08:00
|
|
|
$line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
|
|
|
|
if (defined $1) {
|
2015-08-27 00:37:16 +08:00
|
|
|
$prefix = $1 . $2 . $3;
|
|
|
|
$ieee_prefixes{ $prefix } = 1;
|
2012-12-04 03:15:22 +08:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line =~ m/^([0-9A-F]{3})000-\g1FFF\s*\(base 16\)\s*(.+)$/;
|
2012-11-09 21:53:55 +08:00
|
|
|
if (defined $1) {
|
|
|
|
my $vendor = uc $1;
|
|
|
|
my $text = $2;
|
2012-12-04 03:15:22 +08:00
|
|
|
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT "\n");
|
2015-08-27 00:37:16 +08:00
|
|
|
print(OUT "OUI:" . $prefix . $vendor . "*\n");
|
2012-11-09 21:53:55 +08:00
|
|
|
print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
|
|
|
|
}
|
|
|
|
}
|
2012-12-07 05:34:25 +08:00
|
|
|
close(IN);
|
2012-12-04 03:15:22 +08:00
|
|
|
|
2015-08-27 00:37:16 +08:00
|
|
|
open(IN, "<", "ma-medium.txt");
|
|
|
|
while (my $line = <IN>) {
|
|
|
|
$line =~ s/^ +//;
|
|
|
|
$line =~ s/\s+$//;
|
|
|
|
$line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
|
|
|
|
if (defined $1) {
|
|
|
|
$prefix = $1 . $2 . $3;
|
|
|
|
$ieee_prefixes{ $prefix } = 1;
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
$line =~ m/^([0-9A-F])00000-\g1FFFFF\s*\(base 16\)\s*(.+)$/;
|
|
|
|
if (defined $1) {
|
|
|
|
my $vendor = uc $1;
|
|
|
|
my $text = $2;
|
|
|
|
|
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "OUI:" . $prefix . $vendor . "*\n");
|
|
|
|
print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
open(IN, "<", "ma-large.txt");
|
2012-12-04 03:15:22 +08:00
|
|
|
while (my $line = <IN>) {
|
2013-02-05 01:55:10 +08:00
|
|
|
$line =~ s/^ +//;
|
2012-12-04 03:15:22 +08:00
|
|
|
$line =~ s/\s+$//;
|
|
|
|
$line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.+)$/;
|
|
|
|
if (defined $1) {
|
|
|
|
my $vendor = uc $1;
|
|
|
|
my $text = $2;
|
2012-11-09 21:53:55 +08:00
|
|
|
|
2015-08-27 00:37:16 +08:00
|
|
|
if ($text =~ m/^IEEE REGISTRATION AUTHORITY/) {
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
# skip the IEEE owned prefixes
|
|
|
|
if (! exists $ieee_prefixes{ $vendor }) {
|
2012-12-04 03:15:22 +08:00
|
|
|
print(OUT "\n");
|
|
|
|
print(OUT "OUI:" . $vendor . "*\n");
|
|
|
|
print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-12-07 05:34:25 +08:00
|
|
|
close(IN);
|
2015-08-27 00:37:16 +08:00
|
|
|
|
2012-12-07 05:34:25 +08:00
|
|
|
close(OUT);
|
2012-11-07 21:05:21 +08:00
|
|
|
}
|
2012-11-09 21:29:10 +08:00
|
|
|
|
|
|
|
usb_vendor();
|
2012-11-09 21:53:55 +08:00
|
|
|
usb_classes();
|
|
|
|
|
2012-11-09 21:29:10 +08:00
|
|
|
pci_vendor();
|
|
|
|
pci_classes();
|
2012-11-09 21:53:55 +08:00
|
|
|
|
2013-12-23 03:30:57 +08:00
|
|
|
sdio_vendor();
|
|
|
|
sdio_classes();
|
|
|
|
|
2012-11-09 21:29:10 +08:00
|
|
|
oui();
|