# Copyright (C) 2003 Georg Baum <gbaum@users.sf.net>
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# Known bugs/limitations:
# - Does not recognize all drivers because some require special cflags.
# Fails also on some drivers that do belong to other architectures
# than the one of the machine this script is running on.
# This is currently not so important because all drivers that have an
# Etherboot counterpart are recognized.
use strict;
use POSIX "uname";
# Where to find the kernel sources
my $kernel_src = "/usr/src/linux";
if($#ARGV >= 0) {
$kernel_src = shift;
}
# Sanity checks
if($#ARGV >= 0) {
exit 1;
}
exit 1;
}
# Flags that are needed to preprocess the drivers.
# Some drivers need optimization
my $cflags="-D__KERNEL__ -I$kernel_src/include -I$kernel_src/net/inet -O2";
# The C preprocessor. It needs to spit out the preprocessed source on stdout.
my $cpp="gcc -E";
# List of drivers. We parse every .c file. It does not harm if it does not contain a driver.
# Kernel version
my $version = `grep UTS_RELEASE $kernel_src/include/linux/version.h`;
$version =~ s/\s*#define\s+UTS_RELEASE\s+"(\S+)".*$/$1/g;
# Architecture
# Print header
my $driver;
# Process the drivers
# Preprocess to expand macros
# Extract the pci_device_id structure
my $found = 0;
my @lines;
# This file contains a driver. Print the name.
$driver =~ s!$kernel_src/drivers/net/!!g;
$found = 1;
next;
}
# End of struct
$found = 0;
} else {
if(/\}\s*,?\s*\n?$/) {
# This line contains a full entry or the last part of it.
$_ = $line . $_;
s/[,\{\};\(\)]//g; # Strip punctuation
s/^\s+//g; # Eat whitespace at beginning of line
tr[A-Z][a-z]; # Convert to lowercase
# Push the vendor and device id to @lines if this line is not empty.
# We ignore everything else that might be there
} else {
# This line does contain a partial entry. Remember it.
}
}
}
}
# Now print out the sorted values
# Some drivers (e.g. e100) do contain subfamilies
$lastline = $_;
}
}