Annotation of qemu/roms/ipxe/src/util/parserom.pl, revision 1.1

1.1     ! root        1: #!/usr/bin/perl -w
        !             2: #
        !             3: # Parse PCI_ROM and ISA_ROM entries from a source file on stdin and
        !             4: # output the relevant Makefile variable definitions to stdout
        !             5: #
        !             6: # Based upon portions of Ken Yap's genrules.pl
        !             7: 
        !             8: use strict;
        !             9: use warnings;
        !            10: 
        !            11: die "Syntax: $0 driver_source.c" unless @ARGV == 1;
        !            12: my $source = shift;
        !            13: open DRV, "<$source" or die "Could not open $source: $!\n";
        !            14: 
        !            15: ( my $family, my $driver_name ) = ( $source =~ /^(.*?([^\/]+))\..$/ )
        !            16:     or die "Could not parse source file name \"$source\"\n";
        !            17: 
        !            18: my $printed_family;
        !            19: 
        !            20: sub rom {
        !            21:   ( my $type, my $image, my $desc, my $vendor, my $device, my $dup ) = @_;
        !            22:   my $ids = $vendor ? "$vendor,$device" : "-";
        !            23:   unless ( $printed_family ) {
        !            24:     print "\n";
        !            25:     print "# NIC\t\n";
        !            26:     print "# NIC\tfamily\t$family\n";
        !            27:     print "DRIVERS += $driver_name\n";
        !            28:     $printed_family = 1;
        !            29:   }
        !            30:   print "\n";
        !            31:   print "# NIC\t$image\t$ids\t$desc\n";
        !            32:   print "DRIVER_$image = $driver_name\n";
        !            33:   print "ROM_TYPE_$image = $type\n";
        !            34:   print "ROM_DESCRIPTION_$image = \"$desc\"\n";
        !            35:   print "PCI_VENDOR_$image = 0x$vendor\n" if $vendor;
        !            36:   print "PCI_DEVICE_$image = 0x$device\n" if $device;
        !            37:   print "ROMS += $image\n" unless $dup;
        !            38:   print "ROMS_$driver_name += $image\n" unless $dup;
        !            39: }
        !            40: 
        !            41: while ( <DRV> ) {
        !            42:   next unless /(PCI|ISA)_ROM\s*\(/;
        !            43: 
        !            44:   if ( /^\s*PCI_ROM\s*\(
        !            45:          \s*0x([0-9A-Fa-f]{4})\s*, # PCI vendor
        !            46:          \s*0x([0-9A-Fa-f]{4})\s*, # PCI device
        !            47:          \s*\"([^\"]*)\"\s*,      # Image
        !            48:          \s*\"([^\"]*)\"\s*,      # Description
        !            49:          \s*.*\s*                 # Driver data
        !            50:        \)/x ) {
        !            51:     ( my $vendor, my $device, my $image, my $desc ) = ( lc $1, lc $2, $3, $4 );
        !            52:     next if ( $vendor eq "ffff" ) || ( $device eq "ffff" );
        !            53:     rom ( "pci", lc "${vendor}${device}", $desc, $vendor, $device );
        !            54:     rom ( "pci", $image, $desc, $vendor, $device, 1 );
        !            55:   } elsif ( /^\s*ISA_ROM\s*\(
        !            56:              \s*\"([^\"]*)\"\s*,  # Image
        !            57:              \s*\"([^\"]*)\"\s*   # Description
        !            58:            \)/x ) {
        !            59:     ( my $image, my $desc ) = ( $1, $2 );
        !            60:     rom ( "isa", $image, $desc );
        !            61:   } else {
        !            62:     warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n";
        !            63:   }
        !            64: }
        !            65: 
        !            66: close DRV;

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.