summaryrefslogtreecommitdiffstats
path: root/src/util/disrom.pl
diff options
context:
space:
mode:
authorPetr Borsodi2019-01-16 17:37:57 +0100
committerMichael Brown2019-01-21 12:56:35 +0100
commit3f4c179a149c4feb3f0ea777aeddffa06bed0a27 (patch)
treeacfed83628d28b2572aa270262dd95b50c6947b6 /src/util/disrom.pl
parent[zbin] Fix compiler warning with GCC 9 (diff)
downloadipxe-3f4c179a149c4feb3f0ea777aeddffa06bed0a27.tar.gz
ipxe-3f4c179a149c4feb3f0ea777aeddffa06bed0a27.tar.xz
ipxe-3f4c179a149c4feb3f0ea777aeddffa06bed0a27.zip
[util] Improve processing of ROM images in Option::ROM
The Option::ROM module now compares the Code Type in the PCIR header to 0x00 (PC-AT) in order to check the presence of other header types (PnP, UNDI, iPXE, etc). The validity of these headers are checked not only by offset, but by range and signature checks also. The image checksum and initial size also depends on Code Type. Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/util/disrom.pl')
-rwxr-xr-xsrc/util/disrom.pl12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/util/disrom.pl b/src/util/disrom.pl
index 920a86b2..71eee590 100755
--- a/src/util/disrom.pl
+++ b/src/util/disrom.pl
@@ -28,8 +28,9 @@ my $romfile = shift || "-";
my $rom = new Option::ROM;
$rom->load ( $romfile );
-do {
+my $index = 0;
+do {
die "Not an option ROM image\n"
unless $rom->{signature} == ROM_SIGNATURE;
@@ -38,15 +39,16 @@ do {
die "ROM image truncated (is $filelength, should be $romlength)\n"
if $filelength < $romlength;
+ printf "Index: %d, offset: 0x%08x\n\n", $index++, $rom->file_offset;
printf "ROM header:\n\n";
printf " %-16s 0x%02x (%d)\n", "Length:",
$rom->{length}, ( $rom->{length} * 512 );
printf " %-16s 0x%02x (%s0x%02x)\n", "Checksum:", $rom->{checksum},
- ( ( $rom->checksum == 0 ) ? "" : "INCORRECT: " ), $rom->checksum;
- printf " %-16s 0x%04x\n", "Init:", $rom->{init};
- printf " %-16s 0x%04x\n", "UNDI header:", $rom->{undi_header};
+ ( ( $rom->checksum () == 0 ) ? "" : "INCORRECT: " ), $rom->checksum () if ( exists $rom->{checksum} );
+ printf " %-16s 0x%04x\n", "Init:", $rom->{init} if ( defined $rom->{init} );
+ printf " %-16s 0x%04x\n", "UNDI header:", $rom->{undi_header} if ( exists $rom->{undi_header} );
printf " %-16s 0x%04x\n", "PCI header:", $rom->{pci_header};
- printf " %-16s 0x%04x\n", "PnP header:", $rom->{pnp_header};
+ printf " %-16s 0x%04x\n", "PnP header:", $rom->{pnp_header} if ( exists $rom->{pnp_header} );
printf "\n";
my $pci = $rom->pci_header();