You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

disrom.pl 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/perl -w
  2. #
  3. # Copyright (C) 2008 Michael Brown <mbrown@fensystems.co.uk>.
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License as
  7. # published by the Free Software Foundation; either version 2 of the
  8. # License, or any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. use strict;
  19. use warnings;
  20. use FindBin;
  21. use lib "$FindBin::Bin";
  22. use Option::ROM qw ( :all );
  23. my $romfile = shift || "-";
  24. my $rom = new Option::ROM;
  25. $rom->load ( $romfile );
  26. die "Not an option ROM image\n"
  27. unless $rom->{signature} == ROM_SIGNATURE;
  28. my $romlength = ( $rom->{length} * 512 );
  29. my $filelength = $rom->length;
  30. die "ROM image truncated (is $filelength, should be $romlength)\n"
  31. if $filelength < $romlength;
  32. printf "ROM header:\n\n";
  33. printf " %-16s 0x%02x (%d)\n", "Length:", $rom->{length}, ( $rom->{length} * 512 );
  34. printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $rom->{checksum},
  35. ( ( $rom->checksum == 0 ) ? "" : "INCORRECT: " ), $rom->checksum;
  36. printf " %-16s 0x%04x\n", "Init:", $rom->{init};
  37. printf " %-16s 0x%04x\n", "UNDI header:", $rom->{undi_header};
  38. printf " %-16s 0x%04x\n", "PCI header:", $rom->{pci_header};
  39. printf " %-16s 0x%04x\n", "PnP header:", $rom->{pnp_header};
  40. printf "\n";
  41. my $pci = $rom->pci_header();
  42. if ( $pci ) {
  43. printf "PCI header:\n\n";
  44. printf " %-16s %s\n", "Signature:", $pci->{signature};
  45. printf " %-16s 0x%04x\n", "Vendor ID:", $pci->{vendor_id};
  46. printf " %-16s 0x%04x\n", "Device ID:", $pci->{device_id};
  47. printf " %-16s 0x%02x%02x%02x\n", "Device class:",
  48. $pci->{base_class}, $pci->{sub_class}, $pci->{prog_intf};
  49. printf " %-16s 0x%04x (%d)\n", "Image length:",
  50. $pci->{image_length}, ( $pci->{image_length} * 512 );
  51. printf " %-16s 0x%04x (%d)\n", "Runtime length:",
  52. $pci->{runtime_length}, ( $pci->{runtime_length} * 512 );
  53. if ( exists $pci->{conf_header} ) {
  54. printf " %-16s 0x%04x\n", "Config header:", $pci->{conf_header};
  55. printf " %-16s 0x%04x\n", "CLP entry:", $pci->{clp_entry};
  56. }
  57. printf "\n";
  58. }
  59. my $pnp = $rom->pnp_header();
  60. if ( $pnp ) {
  61. printf "PnP header:\n\n";
  62. printf " %-16s %s\n", "Signature:", $pnp->{signature};
  63. printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $pnp->{checksum},
  64. ( ( $pnp->checksum == 0 ) ? "" : "INCORRECT: " ), $pnp->checksum;
  65. printf " %-16s 0x%04x \"%s\"\n", "Manufacturer:",
  66. $pnp->{manufacturer}, $pnp->manufacturer;
  67. printf " %-16s 0x%04x \"%s\"\n", "Product:",
  68. $pnp->{product}, $pnp->product;
  69. printf " %-16s 0x%04x\n", "BCV:", $pnp->{bcv};
  70. printf " %-16s 0x%04x\n", "BDV:", $pnp->{bdv};
  71. printf " %-16s 0x%04x\n", "BEV:", $pnp->{bev};
  72. printf "\n";
  73. }