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 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 " Length:\t0x%02x (%d)\n", $rom->{length}, ( $rom->{length} * 512 );
  34. printf " Checksum:\t0x%02x (0x%02x)\n", $rom->{checksum}, $rom->checksum;
  35. printf " Init:\t\t0x%04x\n", $rom->{init};
  36. printf " UNDI header:\t0x%04x\n", $rom->{undi_header};
  37. printf " PCI header:\t0x%04x\n", $rom->{pci_header};
  38. printf " PnP header:\t0x%04x\n", $rom->{pnp_header};
  39. printf "\n";
  40. my $pci = $rom->pci_header();
  41. if ( $pci ) {
  42. printf "PCI header:\n\n";
  43. printf " Signature:\t%s\n", $pci->{signature};
  44. printf " Vendor id:\t0x%04x\n", $pci->{vendor_id};
  45. printf " Device id:\t0x%04x\n", $pci->{device_id};
  46. printf " Device class:\t0x%02x%02x%02x\n",
  47. $pci->{base_class}, $pci->{sub_class}, $pci->{prog_intf};
  48. printf " Image length:\t0x%04x (%d)\n",
  49. $pci->{image_length}, ( $pci->{image_length} * 512 );
  50. printf " Runtime length:\t0x%04x (%d)\n",
  51. $pci->{runtime_length}, ( $pci->{runtime_length} * 512 );
  52. printf " Config header:\t0x%04x\n", $pci->{conf_header};
  53. printf " CLP entry:\t0x%04x\n", $pci->{clp_entry};
  54. printf "\n";
  55. }
  56. my $pnp = $rom->pnp_header();
  57. if ( $pnp ) {
  58. printf "PnP header:\n\n";
  59. printf " Signature:\t%s\n", $pnp->{signature};
  60. printf " Checksum:\t0x%02x (0x%02x)\n", $pnp->{checksum}, $pnp->checksum;
  61. printf " Manufacturer:\t0x%04x \"%s\"\n",
  62. $pnp->{manufacturer}, $pnp->manufacturer;
  63. printf " Product:\t0x%04x \"%s\"\n", $pnp->{product}, $pnp->product;
  64. printf " BCV:\t\t0x%04x\n", $pnp->{bcv};
  65. printf " BDV:\t\t0x%04x\n", $pnp->{bdv};
  66. printf " BEV:\t\t0x%04x\n", $pnp->{bev};
  67. printf "\n";
  68. }