瀏覽代碼

[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>
tags/v1.20.1
Michael Brown 10 年之前
父節點
當前提交
ee0c24902a
共有 1 個檔案被更改,包括 2 行新增3 行删除
  1. 2
    3
      src/util/Option/ROM.pm

+ 2
- 3
src/util/Option/ROM.pm 查看文件

@@ -266,11 +266,10 @@ sub set {
266 266
 
267 267
   # Split out any data belonging to the next image
268 268
   delete $self->{next_image};
269
-  my $length = ( $hash->{length} * 512 );
270 269
   my $pci_header = $hash->pci_header();
271
-  if ( ( $length < length $data ) &&
272
-       ( defined $pci_header ) &&
270
+  if ( ( defined $pci_header ) &&
273 271
        ( ! ( $pci_header->{last_image} & PCI_LAST_IMAGE ) ) ) {
272
+    my $length = ( $pci_header->{image_length} * 512 );
274 273
     my $remainder = substr ( $data, $length );
275 274
     $data = substr ( $data, 0, $length );
276 275
     $self->{next_image} = new Option::ROM;

Loading…
取消
儲存