您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

parserom.pl 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 = 0x$vendor\n" if $vendor;
  31. print "PCI_DEVICE_$image = 0x$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. rom ( "pci", lc "${vendor}${device}", $desc, $vendor, $device );
  46. } elsif ( /^\s*ISA_ROM\s*\(
  47. \s*\"([^\"]*)\"\s*, # Image
  48. \s*\"([^\"]*)\"\s* # Description
  49. \)/x ) {
  50. ( my $image, my $desc ) = ( $1, $2 );
  51. rom ( "isa", $image, $desc );
  52. } else {
  53. warn "Malformed PCI_ROM or ISA_ROM macro on line $. of $source\n";
  54. }
  55. }
  56. close DRV;