summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Brown2014-08-26 13:29:54 +0200
committerMichael Brown2014-08-26 16:17:56 +0200
commit3937274cfbde767ff07e839c5b45a21a0b248148 (patch)
tree63618b96512063981aaf444354c29a363ce95de3
parent[util] Use PCI length field to obtain length of individual images (diff)
downloadipxe-3937274cfbde767ff07e839c5b45a21a0b248148.tar.gz
ipxe-3937274cfbde767ff07e839c5b45a21a0b248148.tar.xz
ipxe-3937274cfbde767ff07e839c5b45a21a0b248148.zip
[mromprefix] Use PCI length field to obtain length of individual images
mromprefix.S currently uses the initialisation length field (single byte at offset 0x02) to determine the length of a ROM image within a multi-image ROM BAR. 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. Inspired-by: Swift Geek <swiftgeek@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/arch/i386/prefix/mromprefix.S24
1 files changed, 17 insertions, 7 deletions
diff --git a/src/arch/i386/prefix/mromprefix.S b/src/arch/i386/prefix/mromprefix.S
index 97ddd591e..43f0d97de 100644
--- a/src/arch/i386/prefix/mromprefix.S
+++ b/src/arch/i386/prefix/mromprefix.S
@@ -30,6 +30,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
#define PCI_BAR_5 0x24
#define PCI_BAR_EXPROM 0x30
+#define PCIR_SIGNATURE ( 'P' + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
+
#define ROMPREFIX_EXCLUDE_PAYLOAD 1
#define ROMPREFIX_MORE_IMAGES 1
#define _pcirom_start _mrom_start
@@ -158,18 +160,26 @@ find_mem_bar:
call pci_write_config_dword
/* Locate our ROM image */
-1: movl $0xaa55, %ecx /* 55aa signature */
+1: movl $0xaa55, %ecx /* 55aa signature */
addr32 es cmpw %cx, (%eax)
- je 2f
- stc
- movl %eax, %esi /* Report failure address */
- jmp 99f
-2: addr32 es cmpl $_build_id, build_id(%eax)
+ jne 2f
+ movl $PCIR_SIGNATURE, %ecx /* PCIR signature */
+ addr32 es movzwl 0x18(%eax), %edx
+ addr32 es cmpl %ecx, (%eax,%edx)
+ jne 2f
+ addr32 es cmpl $_build_id, build_id(%eax) /* iPXE build ID */
je 3f
- addr32 es movzbl 2(%eax), %ecx
+ movl $0x80, %ecx /* Last image */
+ addr32 es testb %cl, 0x15(%eax,%edx)
+ jnz 2f
+ addr32 es movzwl 0x10(%eax,%edx), %ecx /* PCIR image length */
shll $9, %ecx
addl %ecx, %eax
jmp 1b
+2: /* Failure */
+ stc
+ movl %eax, %esi /* Report failure address */
+ jmp 99f
3:
/* Copy payload to buffer, or set buffer address to BAR address */