Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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., 51 Franklin Street, Fifth Floor, Boston, MA
  18. # 02110-1301, USA.
  19. use strict;
  20. use warnings;
  21. use FindBin;
  22. use lib "$FindBin::Bin";
  23. use Option::ROM qw ( :all );
  24. my $romfile = shift || "-";
  25. my $rom = new Option::ROM;
  26. $rom->load ( $romfile );
  27. do {
  28. die "Not an option ROM image\n"
  29. unless $rom->{signature} == ROM_SIGNATURE;
  30. my $romlength = ( $rom->{length} * 512 );
  31. my $filelength = $rom->length;
  32. die "ROM image truncated (is $filelength, should be $romlength)\n"
  33. if $filelength < $romlength;
  34. printf "ROM header:\n\n";
  35. printf " %-16s 0x%02x (%d)\n", "Length:",
  36. $rom->{length}, ( $rom->{length} * 512 );
  37. printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $rom->{checksum},
  38. ( ( $rom->checksum == 0 ) ? "" : "INCORRECT: " ), $rom->checksum;
  39. printf " %-16s 0x%04x\n", "Init:", $rom->{init};
  40. printf " %-16s 0x%04x\n", "UNDI header:", $rom->{undi_header};
  41. printf " %-16s 0x%04x\n", "PCI header:", $rom->{pci_header};
  42. printf " %-16s 0x%04x\n", "PnP header:", $rom->{pnp_header};
  43. printf "\n";
  44. my $pci = $rom->pci_header();
  45. if ( $pci ) {
  46. printf "PCI header:\n\n";
  47. printf " %-16s %s\n", "Signature:", $pci->{signature};
  48. printf " %-16s 0x%04x\n", "Vendor ID:", $pci->{vendor_id};
  49. printf " %-16s 0x%04x\n", "Device ID:", $pci->{device_id};
  50. if ( $pci->{device_list} ) {
  51. printf " %-16s %s\n", "Device list:",
  52. ( join ( ", ", map { sprintf "0x%04x", $_ } $pci->device_list ) );
  53. }
  54. printf " %-16s 0x%02x%02x%02x\n", "Device class:",
  55. $pci->{base_class}, $pci->{sub_class}, $pci->{prog_intf};
  56. printf " %-16s 0x%04x (%d)\n", "Image length:",
  57. $pci->{image_length}, ( $pci->{image_length} * 512 );
  58. printf " %-16s 0x%04x (%d)\n", "Runtime length:",
  59. $pci->{runtime_length}, ( $pci->{runtime_length} * 512 );
  60. printf " %-16s 0x%02x\n", "Code type:", $pci->{code_type};
  61. if ( exists $pci->{conf_header} ) {
  62. printf " %-16s 0x%04x\n", "Config header:", $pci->{conf_header};
  63. printf " %-16s 0x%04x\n", "CLP entry:", $pci->{clp_entry};
  64. }
  65. printf "\n";
  66. }
  67. my $pnp = $rom->pnp_header();
  68. if ( $pnp ) {
  69. printf "PnP header:\n\n";
  70. printf " %-16s %s\n", "Signature:", $pnp->{signature};
  71. printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $pnp->{checksum},
  72. ( ( $pnp->checksum == 0 ) ? "" : "INCORRECT: " ), $pnp->checksum;
  73. printf " %-16s 0x%04x \"%s\"\n", "Manufacturer:",
  74. $pnp->{manufacturer}, $pnp->manufacturer;
  75. printf " %-16s 0x%04x \"%s\"\n", "Product:",
  76. $pnp->{product}, $pnp->product;
  77. printf " %-16s 0x%04x\n", "BCV:", $pnp->{bcv};
  78. printf " %-16s 0x%04x\n", "BDV:", $pnp->{bdv};
  79. printf " %-16s 0x%04x\n", "BEV:", $pnp->{bev};
  80. printf "\n";
  81. }
  82. my $undi = $rom->undi_header();
  83. if ( $undi ) {
  84. printf "UNDI header:\n\n";
  85. printf " %-16s %s\n", "Signature:", $undi->{signature};
  86. printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $undi->{checksum},
  87. ( ( $undi->checksum == 0 ) ? "" : "INCORRECT: " ), $undi->checksum;
  88. printf " %-16s %d.%d.%d\n", "UNDI version:", $undi->{version_major},
  89. $undi->{version_minor}, $undi->{version_revision};
  90. printf " %-16s 0x%04x\n", "Loader entry:", $undi->{loader_entry};
  91. printf " %-16s 0x%04x\n", "Stack size:", $undi->{stack_size};
  92. printf " %-16s 0x%04x\n", "Data size:", $undi->{data_size};
  93. printf " %-16s 0x%04x\n", "Code size:", $undi->{code_size};
  94. printf " %-16s %s\n", "Bus type:", $undi->{bus_type};
  95. printf "\n";
  96. }
  97. my $ipxe = $rom->ipxe_header();
  98. if ( $ipxe ) {
  99. printf "iPXE header:\n\n";
  100. printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $ipxe->{checksum},
  101. ( ( $ipxe->checksum == 0 ) ? "" : "INCORRECT: " ), $ipxe->checksum;
  102. printf " %-16s 0x%02x (%d)\n", "Shrunk length:",
  103. $ipxe->{shrunk_length}, ( $ipxe->{shrunk_length} * 512 );
  104. printf " %-16s 0x%08x\n", "Build ID:", $ipxe->{build_id};
  105. printf "\n";
  106. }
  107. } while ( $rom = $rom->next_image );