[romprefix] Add .mrom format, allowing loading of large ROMs

Add an infrastructure allowing the prefix to provide an open_payload()
method for obtaining out-of-band access to the whole iPXE image.  Add
a mechanism within this infrastructure that allows raw access to the
expansion ROM BAR by temporarily borrowing an address from a suitable
memory BAR on the same PCI card.

For cards that have a memory BAR that is at least as large as their
expansion ROM BAR, this allows large iPXE ROMs to be supported even on
systems where PMM fails, or where option ROM space pressure makes it
impossible to use PMM shrinking.  The BIOS sees only a stub ROM of
approximately 3kB in size; the remainder (which can be well over 64kB)
is loaded only at the time iPXE is invoked.

As a nice side-effect, an iPXE .mrom image will continue to work even
if its PMM-allocated areas are overwritten between initialisation and
invocation.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown
2010-04-25 15:57:00 +01:00
parent d8c1f2e94f
commit 132c391712
5 changed files with 518 additions and 9 deletions

View File

@@ -32,6 +32,16 @@ FILE_LICENCE ( GPL2_OR_LATER )
*/
#define ROM_BANNER_TIMEOUT ( 2 * ( 18 * BANNER_TIMEOUT ) / 10 )
/* Allow payload to be excluded from ROM size
*/
#if ROMPREFIX_EXCLUDE_PAYLOAD
#define ZINFO_TYPE_ADxB "ADHB"
#define ZINFO_TYPE_ADxW "ADHW"
#else
#define ZINFO_TYPE_ADxB "ADDB"
#define ZINFO_TYPE_ADxW "ADDW"
#endif
.text
.code16
.arch i386
@@ -53,7 +63,7 @@ checksum:
.size romheader, . - romheader
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
.ascii "ADDB"
.ascii ZINFO_TYPE_ADxB
.long romheader_size
.long 512
.long 0
@@ -83,11 +93,11 @@ pciheader_runtime_length:
.size pciheader, . - pciheader
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
.ascii "ADDW"
.ascii ZINFO_TYPE_ADxW
.long pciheader_image_length
.long 512
.long 0
.ascii "ADDW"
.ascii ZINFO_TYPE_ADxW
.long pciheader_runtime_length
.long 512
.long 0
@@ -179,6 +189,9 @@ init:
movw %bx, %gs
movw %di, %bx
/* Store PCI bus:dev.fn address */
movw %ax, init_pci_busdevfn
/* Print message as early as possible */
movw $init_message, %si
xorw %di, %di
@@ -320,8 +333,7 @@ pmm_scan:
/* We have PMM and so a 1kB stack: preserve whole registers */
pushal
/* Allocate image source PMM block */
movzbl romheader_size, %ecx
shll $5, %ecx
movzwl image_source_len_pgh, %ecx
movl $PMM_HANDLE_BASE_IMAGE_SOURCE, %ebx
movw $get_pmm_image_source, %bp
call get_pmm
@@ -552,6 +564,13 @@ init_message_done:
.asciz "\n\n"
.size init_message_done, . - init_message_done
/* PCI bus:dev.fn
*
*/
init_pci_busdevfn:
.word 0xffff
.size init_pci_busdevfn, . - init_pci_busdevfn
/* Image source area
*
* May be either zero (indicating to use option ROM space as source),
@@ -562,6 +581,19 @@ image_source:
.long 0
.size image_source, . - image_source
/* Image source area length (in paragraphs)
*
*/
image_source_len_pgh:
.word 0
.size image_source_len_pgh, . - image_source_len_pgh
.section ".zinfo.fixup", "a", @progbits /* Compressor fixups */
.ascii "ADDW"
.long image_source_len_pgh
.long 16
.long 0
.previous
/* Shrunk ROM size (in 512-byte sectors)
*
*/