From 3f4c179a149c4feb3f0ea777aeddffa06bed0a27 Mon Sep 17 00:00:00 2001 From: Petr Borsodi Date: Wed, 16 Jan 2019 17:37:57 +0100 Subject: [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 --- src/util/disrom.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'src/util/disrom.pl') 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(); -- cgit v1.2.3-55-g7522