Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[prefix] Add .xrom prefix for a ROM that loads itself by PCI accesses
The standard option ROM format provides a header indicating the size
of the entire ROM, which the BIOS will reserve space for, load, and
call as necessary. However, this space is strictly limited to 128k for
all ROMs. gPXE ameliorates this somewhat by reserving space for itself
in high memory and relocating the majority of its code there, but on
systems prior to PCI3 enough space must still be present to load the
ROM in the first place. Even on PCI3 systems, the BIOS often limits the
size of ROM it will load to a bit over 64kB.

These space problems can be solved by providing an artificially small
size in the ROM header: just enough to let the prefix code (at the
beginning of the ROM image) be loaded by the BIOS. To the BIOS, the
gPXE ROM will appear to be only a few kilobytes; it can then load
the rest of itself by accessing the ROM directly using the PCI
interface reserved for that task.

There are a few problems with this approach. First, gPXE needs to find
an unmapped region in memory to map the ROM so it can read from it;
this is done using the crude but effective approach of scanning high
memory (over 0xF0000000) for a sufficiently large region of all-ones
(0xFF) reads. (In x86 architecture, all-ones is returned for accesses
to memory regions that no mapped device can satisfy.) This is not
provably valid in all situations, but has worked well in practice.
More importantly, this type of ROM access can only work if the PCI ROM
BAR exists at all. NICs on physical add-in PCI cards generally must
have the BAR in order for the BIOS to be able to load their ROM, but
ISA cards and LAN-on-Motherboard cards will both fail to load gPXE
using this scheme.

Due to these uncertainties, it is recommended that .xrom only be used
when a regular .rom image is infeasible due to crowded option ROM
space. However, when it works it could allow loading gPXE images
as large as a flash chip one could find - 128kB or even higher.

Signed-off-by: Marty Connor <mdc@etherboot.org>
  • Loading branch information
rwcr authored and Marty Connor committed Jan 20, 2010
1 parent fa4aec8 commit 06a8398
Show file tree
Hide file tree
Showing 6 changed files with 409 additions and 22 deletions.
2 changes: 2 additions & 0 deletions src/Makefile.housekeeping
Expand Up @@ -831,6 +831,8 @@ endif # defined(BIN)
FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
-i$(IDENT) -s 0 $@
FINALISE_hrom = $(FINALISE_rom)
FINALISE_xrom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
-i$(IDENT) -n -s 0 $@

# Some ROMs require specific flags to be passed to makerom.pl
#
Expand Down
2 changes: 2 additions & 0 deletions src/arch/i386/Makefile.pcbios
Expand Up @@ -12,6 +12,7 @@ LDFLAGS += -N --no-check-sections
#
MEDIA += rom
MEDIA += hrom
MEDIA += xrom
MEDIA += pxe
MEDIA += kpxe
MEDIA += kkpxe
Expand All @@ -32,6 +33,7 @@ MEDIA += exe
#
PAD_rom = $(PADIMG) --blksize=512 --byte=0xff $@
PAD_hrom = $(PAD_rom)
PAD_xrom = $(PAD_rom)
PAD_dsk = $(PADIMG) --blksize=512 $@
PAD_hd = $(PADIMG) --blksize=32768 $@

Expand Down

0 comments on commit 06a8398

Please sign in to comment.