Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

parserom.pl 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #!/usr/bin/env perl
  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. use strict;
  8. use warnings;
  9. die "Syntax: $0 driver_source.c" unless @ARGV == 1;
  10. my $source = shift;
  11. open DRV, "<$source" or die "Could not open $source: $!\n";
  12. ( my $family, my $driver_name ) = ( $source =~ /^(.*?([^\/]+))\..$/ )
  13. or die "Could not parse source file name \"$source\"\n";
  14. my $printed_family;
  15. sub rom {
  16. ( my $type, my $image, my $desc, my $vendor, my $device, my $dup ) = @_;
  17. my $ids = $vendor ? "$vendor,$device" : "-";
  18. unless ( $printed_family ) {
  19. print "\n";
  20. print "# NIC\t\n";
  21. print "# NIC\tfamily\t$family\n";
  22. print "DRIVERS += $driver_name\n";
  23. $printed_family = 1;
  24. }
  25. print "\n";
  26. return if ( $vendor && ( ( $vendor eq "ffff" ) || ( $device eq "ffff" ) ) );
  27. print "# NIC\t$image\t$ids\t$desc\n";
  28. print "DRIVER_$image = $driver_name\n";
  29. print "ROM_TYPE_$image = $type\n";
  30. print "ROM_DESCRIPTION_$image = \"$desc\"\n";
  31. print "PCI_VENDOR_$image = 0x$vendor\n" if $vendor;
  32. print "PCI_DEVICE_$image = 0x$device\n" if $device;
  33. print "ROMS += $image\n" unless $dup;
  34. print "ROMS_$driver_name += $image\n" unless $dup;
  35. }
  36. while ( <DRV> ) {
  37. next unless /(PCI|ISA)_ROM\s*\(/;
  38. if ( /^\s*PCI_ROM\s*\(
  39. \s*0x([0-9A-Fa-f]{4})\s*, # PCI vendor
  40. \s*0x([0-9A-Fa-f]{4})\s*, # PCI device
  41. \s*\"([^\"]*)\"\s*, # Image
  42. \s*\"([^\"]*)\"\s*, # Description
  43. \s*.*\s* # Driver data
  44. \)/x ) {
  45. ( my $vendor, my $device, my $image, my $desc ) = ( lc $1, lc $2, $3, $4 );
  46. rom ( "pci", lc "${vendor}${device}", $desc, $vendor, $device );
  47. rom ( "pci", $image, $desc, $vendor, $device, 1 );
  48. } elsif ( /^\s*ISA_ROM\s*\(
  49. \s*\"([^\"]*)\"\s*, # Image
  50. \s*\"([^\"]*)\"\s* # Description
  51. \)/x ) {
  52. ( my $image, my $desc ) = ( $1, $2 );
  53. rom ( "isa", $image, $desc );
  54. } else {
  55. warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n";
  56. }
  57. }
  58. close DRV;