[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>
This commit is contained in:
committed by
Michael Brown
parent
956f6a7227
commit
3f4c179a14
+7
-5
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user