796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers#!/usr/bin/perl
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieversuse strict;
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sieversuse warnings;
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieverssub usb_vendor {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $vendor;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(IN, "<", "usb.ids");
1d09582ab9d8bc619de3a01f01d614eab44d31c0Kay Sievers open(OUT, ">", "20-usb-vendor-model.hwdb");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "# This file is part of systemd.\n" .
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "#\n" .
378cf88f72a9cda84baf703ed24f54c8c539fdcfKay Sievers "# Data imported from: http://www.linux-usb.org/usb.ids\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers while (my $line = <IN>) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $line =~ s/\s+$//;
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $vendor = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "usb:v" . $vendor . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
1d09582ab9d8bc619de3a01f01d614eab44d31c0Kay Sievers my $model = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
1d09582ab9d8bc619de3a01f01d614eab44d31c0Kay Sievers print(OUT "usb:v" . $vendor . "p" . $model . "*\n");
1d09582ab9d8bc619de3a01f01d614eab44d31c0Kay Sievers print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(IN);
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(OUT);
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers}
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sieverssub usb_classes {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $class;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $subclass;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $protocol;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(IN, "<", "usb.ids");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(OUT, ">", "20-usb-classes.hwdb");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "# This file is part of systemd.\n" .
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "#\n" .
378cf88f72a9cda84baf703ed24f54c8c539fdcfKay Sievers "# Data imported from: http://www.linux-usb.org/usb.ids\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers while (my $line = <IN>) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $line =~ s/\s+$//;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $class = uc $1;
09d8f5d757515122d7b726218e249621e564157cKay Sievers if ($class =~ m/^00$/) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
09d8f5d757515122d7b726218e249621e564157cKay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "usb:v*p*d*dc" . $class . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_USB_CLASS_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (not defined $class) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers } elsif ($line =~ m/^$/) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers last;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $subclass = uc $1;
09d8f5d757515122d7b726218e249621e564157cKay Sievers if ($subclass =~ m/^00$/) {
09d8f5d757515122d7b726218e249621e564157cKay Sievers next;
09d8f5d757515122d7b726218e249621e564157cKay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if ($text =~ m/^(\?|None|Unused)$/) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_USB_SUBCLASS_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $protocol = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if ($text =~ m/^(\?|None|Unused)$/) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "dp" . $protocol . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_USB_PROTOCOL_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(IN);
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(OUT);
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sievers}
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sievers
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieverssub pci_vendor {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $vendor;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $device;
d060b62fcb4746d3758c567e9379c6728a035b66Kay Sievers my $device_text;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(IN, "<", "pci.ids");
1d09582ab9d8bc619de3a01f01d614eab44d31c0Kay Sievers open(OUT, ">", "20-pci-vendor-model.hwdb");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "# This file is part of systemd.\n" .
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "#\n" .
378cf88f72a9cda84baf703ed24f54c8c539fdcfKay Sievers "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers while (my $line = <IN>) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $line =~ s/\s+$//;
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $vendor = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "pci:v0000" . $vendor . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $device = uc $1;
d060b62fcb4746d3758c567e9379c6728a035b66Kay Sievers $device_text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
d060b62fcb4746d3758c567e9379c6728a035b66Kay Sievers print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $sub_vendor = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $sub_device = uc $2;
d060b62fcb4746d3758c567e9379c6728a035b66Kay Sievers my $sub_text = $3;
d060b62fcb4746d3758c567e9379c6728a035b66Kay Sievers $sub_text =~ s/^\Q$device_text\E\s*//;
bd64a88fb0478da2e93c363849b73aed8be36ae7Kay Sievers $sub_text =~ s/(.+)/\ ($1)/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
d060b62fcb4746d3758c567e9379c6728a035b66Kay Sievers print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . $sub_text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(IN);
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(OUT);
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers}
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sievers
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieverssub pci_classes {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $class;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $subclass;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $interface;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(IN, "<", "pci.ids");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(OUT, ">", "20-pci-classes.hwdb");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "# This file is part of systemd.\n" .
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "#\n" .
378cf88f72a9cda84baf703ed24f54c8c539fdcfKay Sievers "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers while (my $line = <IN>) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $line =~ s/\s+$//;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $class = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "pci:v*d*sv*sd*bc" . $class . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_PCI_CLASS_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (not defined $class) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers } elsif ($line =~ m/^$/) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers last;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $subclass = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_PCI_SUBCLASS_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers next;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
c35ddc5b69ef1911de39933329eda0b569cae4b9Kay Sievers $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $interface = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "i" . $interface . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_PCI_INTERFACE_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(IN);
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(OUT);
796b06c21b62d13c9021e2fbd9c58a5c6edb2764Kay Sievers}
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sievers
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmannsub sdio_vendor {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $vendor;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $device;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann open(IN, "<", "sdio.ids");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann open(OUT, ">", "20-sdio-vendor-model.hwdb");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "# This file is part of systemd.\n" .
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann "#\n" .
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann "# Data imported from: hwdb/sdio.ids\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann while (my $line = <IN>) {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $line =~ s/\s+$//;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann if (defined $1) {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $vendor = uc $1;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $text = $2;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "sdio:c*v" . $vendor . "*\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann next;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann }
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann if (defined $1) {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $device = uc $1;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $text = $2;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "sdio:c*v" . $vendor . "d" . $device . "*\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann next;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann }
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann }
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann close(IN);
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann close(OUT);
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann}
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmannsub sdio_classes {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $class;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $subclass;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $interface;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann open(IN, "<", "sdio.ids");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann open(OUT, ">", "20-sdio-classes.hwdb");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "# This file is part of systemd.\n" .
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann "#\n" .
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann "# Data imported from: hwdb/sdio.ids\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann while (my $line = <IN>) {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $line =~ s/\s+$//;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann if (defined $1) {
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann $class = uc $1;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann my $text = $2;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT "sdio:c" . $class . "v*d*\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann print(OUT " ID_SDIO_CLASS_FROM_DATABASE=" . $text . "\n");
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann next;
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann }
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann }
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann close(IN);
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann close(OUT);
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann}
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers# MAC Address Block Large/Medium/Small
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers# Large MA-L 24/24 bit (OUI)
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers# Medium MA-M 28/20 bit (OUI prefix owned by IEEE)
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers# Small MA-S 36/12 bit (OUI prefix owned by IEEE)
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieverssub oui {
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers my $prefix;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers my %ieee_prefixes = ();
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers open(OUT, ">", "20-OUI.hwdb");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "# This file is part of systemd.\n" .
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers "#\n" .
378cf88f72a9cda84baf703ed24f54c8c539fdcfKay Sievers "# Data imported from:\n" .
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-L&format=txt\n" .
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-M&format=txt\n" .
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-S&format=txt\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers open(IN, "<", "ma-small.txt");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers while (my $line = <IN>) {
f2f1861383c5cf4c07a7c6098d7c0b7134f06d51Kay Sievers $line =~ s/^ +//;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers $line =~ s/\s+$//;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen if (defined $1) {
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $prefix = $1 . $2 . $3;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $ieee_prefixes{ $prefix } = 1;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen next;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen }
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen $line =~ m/^([0-9A-F]{3})000-\g1FFF\s*\(base 16\)\s*(.+)$/;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers if (defined $1) {
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $vendor = uc $1;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers my $text = $2;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT "\n");
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers print(OUT "OUI:" . $prefix . $vendor . "*\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers }
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(IN);
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers open(IN, "<", "ma-medium.txt");
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers while (my $line = <IN>) {
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $line =~ s/^ +//;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $line =~ s/\s+$//;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers if (defined $1) {
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $prefix = $1 . $2 . $3;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $ieee_prefixes{ $prefix } = 1;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers next;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers }
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers $line =~ m/^([0-9A-F])00000-\g1FFFFF\s*\(base 16\)\s*(.+)$/;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers if (defined $1) {
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers my $vendor = uc $1;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers my $text = $2;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers print(OUT "\n");
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers print(OUT "OUI:" . $prefix . $vendor . "*\n");
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers }
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers }
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers open(IN, "<", "ma-large.txt");
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen while (my $line = <IN>) {
f2f1861383c5cf4c07a7c6098d7c0b7134f06d51Kay Sievers $line =~ s/^ +//;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen $line =~ s/\s+$//;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.+)$/;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen if (defined $1) {
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen my $vendor = uc $1;
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen my $text = $2;
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers if ($text =~ m/^IEEE REGISTRATION AUTHORITY/) {
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers next;
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers }
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers # skip the IEEE owned prefixes
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers if (! exists $ieee_prefixes{ $vendor }) {
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen print(OUT "\n");
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen print(OUT "OUI:" . $vendor . "*\n");
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen }
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen }
5fe25affc01fb003a3a66937458a25640a6075ceTom Gundersen }
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(IN);
fd5a461316d34d3070d599f4be74bd8ae4b3d00fKay Sievers
f9cd22249dbdcebe2ab54eea56c0b32e2a1c2ce5Mantas Mikulėnas close(OUT);
448004c340d41f1b7eb3c06cbd694b8862e6524dKay Sievers}
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sievers
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieversusb_vendor();
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sieversusb_classes();
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieverspci_vendor();
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieverspci_classes();
8db6dcfd3c3d19d35767f04884a99368f6c64b36Kay Sievers
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmannsdio_vendor();
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmannsdio_classes();
56243d0936f85b2580f4c1028e1af98b96d77b72Marcel Holtmann
cf7ebcea78223b95b2676b97e1d2aad16caa3c86Kay Sieversoui();