diff options
author | Michael Brown | 2005-04-08 17:01:17 +0200 |
---|---|---|
committer | Michael Brown | 2005-04-08 17:01:17 +0200 |
commit | 0ff80b477dcff0726ebdbed95e8a93971e59e82b (patch) | |
tree | 860b7150212a07c24a9529ea072f3fb12700974c /src/util/parserom.pl | |
parent | Merged this file into HEAD (diff) | |
download | ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.tar.gz ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.tar.xz ipxe-0ff80b477dcff0726ebdbed95e8a93971e59e82b.zip |
Merged mcb30-realmode-redesign back to HEAD
Diffstat (limited to 'src/util/parserom.pl')
-rw-r--r-- | src/util/parserom.pl | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/util/parserom.pl b/src/util/parserom.pl new file mode 100644 index 00000000..56bb9445 --- /dev/null +++ b/src/util/parserom.pl @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w +# +# Parse PCI_ROM and ISA_ROM entries from a source file on stdin and +# output the relevant Makefile variable definitions to stdout +# +# Based upon portions of Ken Yap's genrules.pl + +use strict; +use warnings; + +die "Syntax: $0 driver_source.c" unless @ARGV == 1; +my $source = shift; +open DRV, "<$source" or die "Could not open $source: $!\n"; + +( my $family, my $driver_name ) = ( $source =~ /^(.*?([^\/]+))\..$/ ) + or die "Could not parse source file name \"$source\"\n"; + +my $printed_family; + +sub rom { + ( my $type, my $image, my $desc, my $vendor, my $device ) = @_; + my $ids = $vendor ? "$vendor,$device" : "-"; + unless ( $printed_family ) { + print "\n"; + print "# NIC\t\n"; + print "# NIC\tfamily\t$family\n"; + print "DRIVERS += $driver_name\n"; + $printed_family = 1; + } + print "\n"; + print "# NIC\t$image\t$ids\t$desc\n"; + print "DRIVER_$image = $driver_name\n"; + print "ROM_TYPE_$image = $type\n"; + print "ROM_DESCRIPTION_$image = \"$desc\"\n"; + print "PCI_VENDOR_$image = $vendor\n" if $vendor; + print "PCI_DEVICE_$image = $device\n" if $device; + print "ROMS += $image\n"; + print "ROMS_$driver_name += $image\n"; +} + +while ( <DRV> ) { + next unless /(PCI|ISA)_ROM\s*\(/; + + if ( /^\s*PCI_ROM\s*\( + \s*(0x[0-9A-Fa-f]{4})\s*, # PCI vendor + \s*(0x[0-9A-Fa-f]{4})\s*, # PCI device + \s*\"([^\"]*)\"\s*, # Image + \s*\"([^\"]*)\"\s* # Description + \)/x ) { + ( my $vendor, my $device, my $image, my $desc ) = ( lc $1, lc $2, $3, $4 ); + rom ( "pci", $image, $desc, $vendor, $device ); + } elsif ( /^\s*ISA_ROM\s*\( + \s*\"([^\"]*)\"\s*, # Image + \s*\"([^\"]*)\"\s* # Description + \)/x ) { + ( my $image, my $desc ) = ( $1, $2 ); + rom ( "isa", $image, $desc ); + } else { + warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n"; + } +} + +close DRV; |