diff options
author | Michael Brown | 2014-08-26 12:42:42 +0200 |
---|---|---|
committer | Michael Brown | 2014-08-26 16:17:56 +0200 |
commit | ee0c24902a07c78ed939dfeee3b32f1c7a633ebb (patch) | |
tree | 7d8908a1978eff8860fcc84ce936a15809971308 /src/util/Option | |
parent | [prefix] Report both %esi and %ecx when opening payload fails (diff) | |
download | ipxe-ee0c24902a07c78ed939dfeee3b32f1c7a633ebb.tar.gz ipxe-ee0c24902a07c78ed939dfeee3b32f1c7a633ebb.tar.xz ipxe-ee0c24902a07c78ed939dfeee3b32f1c7a633ebb.zip |
[util] Use PCI length field to obtain length of individual images
Option::ROM currently uses the initialisation length field (single
byte at offset 0x02) to determine the length of a ROM image within a
multi-image ROM file. For PCI ROM images with a code type other than
0, the initialisation length field may not be present.
Fix by using the PCI header's image length field instead. Note that
this does not prevent us from correctly handling ISA ROMs, since ISA
ROMs do not support multiple images within a single ROM BAR anyway.
Inspired-by: Swift Geek <swiftgeek@gmail.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/util/Option')
-rw-r--r-- | src/util/Option/ROM.pm | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/src/util/Option/ROM.pm b/src/util/Option/ROM.pm index fb37ce4b..6c396730 100644 --- a/src/util/Option/ROM.pm +++ b/src/util/Option/ROM.pm @@ -266,11 +266,10 @@ sub set { # Split out any data belonging to the next image delete $self->{next_image}; - my $length = ( $hash->{length} * 512 ); my $pci_header = $hash->pci_header(); - if ( ( $length < length $data ) && - ( defined $pci_header ) && + if ( ( defined $pci_header ) && ( ! ( $pci_header->{last_image} & PCI_LAST_IMAGE ) ) ) { + my $length = ( $pci_header->{image_length} * 512 ); my $remainder = substr ( $data, $length ); $data = substr ( $data, 0, $length ); $self->{next_image} = new Option::ROM; |