This patch series enables SeaBIOS to relocate itself out of the e-segment, which enables that space to be used by optionroms.
Before this patch series, SeaBIOS would typically use about half of the e-segment. A full debugging build could use nearly all of the e-segment. With this series, SeaBIOS shouldn't need anything beyond the standard f-segment. Future features can likely be added without fear of limiting optionroms.
To support relocation, the build determines which parts of the 32bit code is one-time initialization code. It separates that out and stores relocation information for it. The run-time code can then copy the initialization code to high memory and run it at that location. The one-time init code could be called again on a soft-reboot, but SeaBIOS now detects this case and attempts a hard-reboot.
Unfortunately, both qemu and kvm don't appear to have a reliable way to hard-reboot - normal reboots don't reset the 0xc0000-0xfffff memory. I've worked around this on qemu by manually resetting that memory. However, kvm doesn't keep a pristine copy of the bios at 0xffff0000. Until this is fixed, this patch series will cause a soft-reboot on kvm to result in a shutdown instead of a reboot.
Some details on the patches: Patches 1-4 enhance the build scripts. Patches 5-7 handle soft-reboots. Patches 8-11 enhance the runtime to support relocation.
-Kevin
Kevin O'Connor (11): Use str.startswith() in python scripts. Modify tools/layoutrom.py to use classes instead of tuples. Separate out init code from the rest of the 32bit flat code. Enhance build to emit relocation information. Try to hard-reboot processor on rerun of post under coreboot. Don't do shadow copying of optionroms when CONFIG_OPTIONROMS_DEPLOYED. Try to hard-reboot on rerun of post even on emulators. Add memalign_tmp() helper function. Move init code from _start() to post(). Move the 32bit init code to high memory at runtime. Enable optionroms to use freed space due to CONFIG_RELOCATE_INIT.
Makefile | 6 +- src/apm.c | 14 +- src/config.h | 2 + src/ioport.h | 1 + src/optionroms.c | 18 ++- src/pci.c | 10 + src/pci.h | 1 + src/pmm.c | 8 - src/post.c | 164 +++++++++++++++--- src/ps2port.c | 16 ++- src/ps2port.h | 3 +- src/shadow.c | 40 +++-- src/stacks.c | 4 +- src/types.h | 10 +- src/util.h | 13 ++- tools/checkrom.py | 9 +- tools/checkstack.py | 14 +- tools/layoutrom.py | 465 ++++++++++++++++++++++++++++++++------------------- 18 files changed, 535 insertions(+), 263 deletions(-)