Procházet zdrojové kódy

[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>
tags/v1.20.1
Michael Brown před 10 roky
rodič
revize
3937274cfb
1 změnil soubory, kde provedl 17 přidání a 7 odebrání
  1. 17
    7
      src/arch/i386/prefix/mromprefix.S

+ 17
- 7
src/arch/i386/prefix/mromprefix.S Zobrazit soubor

@@ -30,6 +30,8 @@ FILE_LICENCE ( GPL2_OR_LATER )
30 30
 #define PCI_BAR_5			0x24
31 31
 #define PCI_BAR_EXPROM			0x30
32 32
 
33
+#define PCIR_SIGNATURE ( 'P' + ( 'C' << 8 ) + ( 'I' << 16 ) + ( 'R' << 24 ) )
34
+
33 35
 #define ROMPREFIX_EXCLUDE_PAYLOAD 1
34 36
 #define ROMPREFIX_MORE_IMAGES 1
35 37
 #define _pcirom_start _mrom_start
@@ -158,18 +160,26 @@ find_mem_bar:
158 160
 	call	pci_write_config_dword
159 161
 
160 162
 	/* Locate our ROM image */
161
-1:	movl	$0xaa55, %ecx		/* 55aa signature */
163
+1:	movl	$0xaa55, %ecx				/* 55aa signature */
162 164
 	addr32 es cmpw %cx, (%eax)
163
-	je	2f
164
-	stc
165
-	movl	%eax, %esi		/* Report failure address */
166
-	jmp	99f
167
-2:	addr32 es cmpl $_build_id, build_id(%eax)
165
+	jne	2f
166
+	movl	$PCIR_SIGNATURE, %ecx			/* PCIR signature */
167
+	addr32 es movzwl 0x18(%eax), %edx
168
+	addr32 es cmpl %ecx, (%eax,%edx)
169
+	jne	2f
170
+	addr32 es cmpl $_build_id, build_id(%eax)	/* iPXE build ID */
168 171
 	je	3f
169
-	addr32 es movzbl 2(%eax), %ecx
172
+	movl	$0x80, %ecx				/* Last image */
173
+	addr32 es testb %cl, 0x15(%eax,%edx)
174
+	jnz	2f
175
+	addr32 es movzwl 0x10(%eax,%edx), %ecx		/* PCIR image length */
170 176
 	shll	$9, %ecx
171 177
 	addl	%ecx, %eax
172 178
 	jmp	1b
179
+2:	/* Failure */
180
+	stc
181
+	movl	%eax, %esi		/* Report failure address */
182
+	jmp	99f
173 183
 3:
174 184
 
175 185
 	/* Copy payload to buffer, or set buffer address to BAR address */

Načítá se…
Zrušit
Uložit