選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

parserom.pl 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. 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 ) = @_;
  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. print "# NIC\t$image\t$ids\t$desc\n";
  27. print "DRIVER_$image = $driver_name\n";
  28. print "ROM_TYPE_$image = $type\n";
  29. print "ROM_DESCRIPTION_$image = \"$desc\"\n";
  30. print "PCI_VENDOR_$image = $vendor\n" if $vendor;
  31. print "PCI_DEVICE_$image = $device\n" if $device;
  32. print "ROMS += $image\n";
  33. print "ROMS_$driver_name += $image\n";
  34. }
  35. while ( <DRV> ) {
  36. next unless /(PCI|ISA)_ROM\s*\(/;
  37. if ( /^\s*PCI_ROM\s*\(
  38. \s*(0x[0-9A-Fa-f]{4})\s*, # PCI vendor
  39. \s*(0x[0-9A-Fa-f]{4})\s*, # PCI device
  40. \s*\"([^\"]*)\"\s*, # Image
  41. \s*\"([^\"]*)\"\s* # Description
  42. \)/x ) {
  43. ( my $vendor, my $device, my $image, my $desc ) = ( lc $1, lc $2, $3, $4 );
  44. rom ( "pci", $image, $desc, $vendor, $device );
  45. } elsif ( /^\s*ISA_ROM\s*\(
  46. \s*\"([^\"]*)\"\s*, # Image
  47. \s*\"([^\"]*)\"\s* # Description
  48. \)/x ) {
  49. ( my $image, my $desc ) = ( $1, $2 );
  50. rom ( "isa", $image, $desc );
  51. } else {
  52. warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n";
  53. }
  54. }
  55. close DRV;