|
|
1.1 root 1: #!/usr/bin/perl -w
2: #
3: # Copyright (C) 2008 Michael Brown <[email protected]>.
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:
19: use strict;
20: use warnings;
21:
22: use FindBin;
23: use lib "$FindBin::Bin";
24: use Option::ROM qw ( :all );
25:
26: my $romfile = shift || "-";
27: my $rom = new Option::ROM;
28: $rom->load ( $romfile );
29:
30: die "Not an option ROM image\n"
31: unless $rom->{signature} == ROM_SIGNATURE;
32:
33: my $romlength = ( $rom->{length} * 512 );
34: my $filelength = $rom->length;
35: die "ROM image truncated (is $filelength, should be $romlength)\n"
36: if $filelength < $romlength;
37:
38: printf "ROM header:\n\n";
39: printf " %-16s 0x%02x (%d)\n", "Length:", $rom->{length}, ( $rom->{length} * 512 );
40: printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $rom->{checksum},
41: ( ( $rom->checksum == 0 ) ? "" : "INCORRECT: " ), $rom->checksum;
42: printf " %-16s 0x%04x\n", "Init:", $rom->{init};
43: printf " %-16s 0x%04x\n", "UNDI header:", $rom->{undi_header};
44: printf " %-16s 0x%04x\n", "PCI header:", $rom->{pci_header};
45: printf " %-16s 0x%04x\n", "PnP header:", $rom->{pnp_header};
46: printf "\n";
47:
48: my $pci = $rom->pci_header();
49: if ( $pci ) {
50: printf "PCI header:\n\n";
51: printf " %-16s %s\n", "Signature:", $pci->{signature};
52: printf " %-16s 0x%04x\n", "Vendor ID:", $pci->{vendor_id};
53: printf " %-16s 0x%04x\n", "Device ID:", $pci->{device_id};
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: if ( exists $pci->{conf_header} ) {
61: printf " %-16s 0x%04x\n", "Config header:", $pci->{conf_header};
62: printf " %-16s 0x%04x\n", "CLP entry:", $pci->{clp_entry};
63: }
64: printf "\n";
65: }
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: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.