ids-update.pl revision fd5a461316d34d3070d599f4be74bd8ae4b3d00f
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb#!/usr/bin/perl
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbuse strict;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbuse warnings;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbsub usb_vendor {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $vendor;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(IN, "<", "usb.ids");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(OUT, ">", "20-usb-vendor-model.hwdb");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "# This file is part of systemd.\n" .
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "#\n" .
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "# Data imported from: http://www.linux-usb.org/usb.ids\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb while (my $line = <IN>) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ s/\s+$//;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $vendor = uc $1;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $text = $2;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "usb:v" . $vendor . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $model = uc $1;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $text = $2;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "usb:v" . $vendor . "p" . $model . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb close(IN);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb close(OUT);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb}
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbsub usb_classes {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $class;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $subclass;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $protocol;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(IN, "<", "usb.ids");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(OUT, ">", "20-usb-classes.hwdb");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "# This file is part of systemd.\n" .
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "#\n" .
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "# Data imported from: http://www.linux-usb.org/usb.ids\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb while (my $line = <IN>) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ s/\s+$//;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $class = uc $1;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ($class =~ m/^00$/) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $text = $2;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "usb:v*p*d*dc" . $class . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_USB_CLASS_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (not defined $class) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb } elsif ($line =~ m/^$/) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb last;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $subclass = uc $1;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ($subclass =~ m/^00$/) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $text = $2;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ($text =~ m/^(\?|None|Unused)$/) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_USB_SUBCLASS_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $protocol = uc $1;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $text = $2;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ($text =~ m/^(\?|None|Unused)$/) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "usb:v*p*d*dc" . $class . "dsc" . $subclass . "dp" . $protocol . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_USB_PROTOCOL_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b45c1c292ff1fa635004ae81fa691f8cb3cdda85rbb close(IN);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb close(OUT);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb}
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbsub pci_vendor {
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe my $vendor;
a2a0abd88b19e042a3eb2a9fa1702c25ad51303dwrowe my $device;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $device_text;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(IN, "<", "pci.ids");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(OUT, ">", "20-pci-vendor-model.hwdb");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "# This file is part of systemd.\n" .
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "#\n" .
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb while (my $line = <IN>) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ s/\s+$//;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
c3e342e5b0b9fea6617ee16d2da02c3ef2108126dougm
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $vendor = uc $1;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $text = $2;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "pci:v0000" . $vendor . "*\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe next;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (defined $1) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $device = uc $1;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $device_text = $2;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "pci:v0000" . $vendor . "d0000" . $device . "*\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe next;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $line =~ m/^\t\t([0-9a-f]{4})\s*([0-9a-f]{4})\s*(.*)$/;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (defined $1) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $sub_vendor = uc $1;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $sub_device = uc $2;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $sub_text = $3;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $sub_text =~ s/^\Q$device_text\E\s*//;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $sub_text =~ s/(.+)/\ ($1)/;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "pci:v0000" . $vendor . "d0000" . $device . "sv0000" . $sub_vendor . "sd0000" . $sub_device . "*\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT " ID_MODEL_FROM_DATABASE=" . $device_text . $sub_text . "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe close(IN);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe close(OUT);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe}
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowesub pci_classes {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $class;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $subclass;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $interface;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe open(IN, "<", "pci.ids");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe open(OUT, ">", "20-pci-classes.hwdb");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT "# This file is part of systemd.\n" .
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe "#\n" .
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe "# Data imported from: http://pci-ids.ucw.cz/v2.2/pci.ids\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe while (my $line = <IN>) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ s/\s+$//;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (defined $1) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $class = uc $1;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $text = $2;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "\n");
4775dfc34c90fada8c7c4d6a57ed8a3114d55c2dtrawick print(OUT "pci:v*d*sv*sd*bc" . $class . "*\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT " ID_PCI_CLASS_FROM_DATABASE=" . $text . "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe next;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (not defined $class) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe next;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe } elsif ($line =~ m/^$/) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe last;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ m/^\t([0-9a-f]{2})\s*(.+)$/;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (defined $1) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $subclass = uc $1;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $text = $2;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "*\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT " ID_PCI_SUBCLASS_FROM_DATABASE=" . $text . "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe next;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ m/^\t\t([0-9a-f]{2})\s*(.+)$/;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (defined $1) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $interface = uc $1;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $text = $2;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT "\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT "pci:v*d*sv*sd*bc" . $class . "sc" . $subclass . "i" . $interface . "*\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT " ID_PCI_INTERFACE_FROM_DATABASE=" . $text . "\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe close(IN);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe close(OUT);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe}
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowesub sdio_vendor {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $vendor;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $device;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe open(IN, "<", "sdio.ids");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe open(OUT, ">", "20-sdio-vendor-model.hwdb");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "# This file is part of systemd.\n" .
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe "#\n" .
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe "# Data imported from: hwdb/sdio.ids\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe while (my $line = <IN>) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ s/\s+$//;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ m/^([0-9a-f]{4})\s*(.+)$/;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (defined $1) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $vendor = uc $1;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $text = $2;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "sdio:c*v" . $vendor . "*\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT " ID_VENDOR_FROM_DATABASE=" . $text . "\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe next;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $line =~ m/^\t([0-9a-f]{4})\s*(.+)$/;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe if (defined $1) {
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe $device = uc $1;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe my $text = $2;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT "\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT "sdio:c*v" . $vendor . "d" . $device . "*\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe print(OUT " ID_MODEL_FROM_DATABASE=" . $text . "\n");
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe next;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe }
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe close(IN);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe close(OUT);
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe}
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowesub sdio_classes {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $class;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $subclass;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $interface;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe open(IN, "<", "sdio.ids");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe open(OUT, ">", "20-sdio-classes.hwdb");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "# This file is part of systemd.\n" .
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe "#\n" .
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe "# Data imported from: hwdb/sdio.ids\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe while (my $line = <IN>) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $line =~ s/\s+$//;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $line =~ m/^C\ ([0-9a-f]{2})\s*(.+)$/;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe if (defined $1) {
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe $class = uc $1;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe my $text = $2;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT "sdio:c" . $class . "v*d*\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe print(OUT " ID_SDIO_CLASS_FROM_DATABASE=" . $text . "\n");
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe next;
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe }
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe close(IN);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe close(OUT);
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe}
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe# MAC Address Block Large/Medium/Small
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe# Large MA-L 24/24 bit (OUI)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe# Medium MA-M 28/20 bit (OUI prefix owned by IEEE)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe# Small MA-S 36/12 bit (OUI prefix owned by IEEE)
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowesub oui {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe my $prefix;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe my %ieee_prefixes = ();
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe open(OUT, ">", "20-OUI.hwdb");
0540a0b469147b52e858587270dba31c2aaa9e09wrowe print(OUT "# This file is part of systemd.\n" .
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe "#\n" .
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe "# Data imported from:\n" .
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-L&format=txt\n" .
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-M&format=txt\n" .
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe "# https://services13.ieee.org/RST/standards-ra-web/rest/assignments/download/?registry=MA-S&format=txt\n");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe open(IN, "<", "ma-small.txt");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe while (my $line = <IN>) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ s/^ +//;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ s/\s+$//;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (defined $1) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $prefix = $1 . $2 . $3;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $ieee_prefixes{ $prefix } = 1;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe next;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe }
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ m/^([0-9A-F]{3})000-\g1FFF\s*\(base 16\)\s*(.+)$/;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (defined $1) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe my $vendor = uc $1;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe my $text = $2;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe print(OUT "\n");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe print(OUT "OUI:" . $prefix . $vendor . "*\n");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe }
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe }
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe close(IN);
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe open(IN, "<", "ma-medium.txt");
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe while (my $line = <IN>) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ s/^ +//;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ s/\s+$//;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ m/^([0-9A-F]{2})-([0-9A-F]{2})-([0-9A-F]{2})\s*\(hex\)\s*.+$/;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (defined $1) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $prefix = $1 . $2 . $3;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $ieee_prefixes{ $prefix } = 1;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe next;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe }
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe $line =~ m/^([0-9A-F])00000-\g1FFFFF\s*\(base 16\)\s*(.+)$/;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe if (defined $1) {
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe my $vendor = uc $1;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe my $text = $2;
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "OUI:" . $prefix . $vendor . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb open(IN, "<", "ma-large.txt");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb while (my $line = <IN>) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ s/^ +//;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ s/\s+$//;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb $line =~ m/^([0-9A-F]{6})\s*\(base 16\)\s*(.+)$/;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (defined $1) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $vendor = uc $1;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb my $text = $2;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if ($text =~ m/^IEEE REGISTRATION AUTHORITY/) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb next;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb # skip the IEEE owned prefixes
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb if (! exists $ieee_prefixes{ $vendor }) {
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT "OUI:" . $vendor . "*\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb print(OUT " ID_OUI_FROM_DATABASE=" . $text . "\n");
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb }
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb close(IN);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb close(OUT);
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb}
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbusb_vendor();
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbusb_classes();
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb
b38846b15c8891c6dec44dcc4f96ca40721bf663rbbpci_vendor();
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowepci_classes();
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowesdio_vendor();
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowesdio_classes();
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwroweoui();
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe