The space in the e-segment is available for option roms after relocating the init code.
Also, zero all of the option rom space when !CONFIG_OPTIONROMS_DEPLOYED. --- src/optionroms.c | 18 +++++++++++------- src/pmm.c | 5 ----- 2 files changed, 11 insertions(+), 12 deletions(-)
diff --git a/src/optionroms.c b/src/optionroms.c index cde5b4d..f26a3aa 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -168,14 +168,15 @@ get_pci_rom(struct rom_header *rom) return pci; }
+// Return start of code in 0xc0000-0xf0000 space. +static inline u32 _max_rom(void) { + extern u8 code32flat_start[], code32init_end[]; + return CONFIG_RELOCATE_INIT ? (u32)code32flat_start : (u32)code32init_end; +} // Return the memory position up to which roms may be located. -static inline u32 -max_rom(void) -{ - extern u8 code32flat_start[]; - if ((u32)code32flat_start > BUILD_BIOS_ADDR) - return BUILD_BIOS_ADDR; - return (u32)code32flat_start; +static inline u32 max_rom(void) { + u32 end = _max_rom(); + return end > BUILD_BIOS_ADDR ? BUILD_BIOS_ADDR : end; }
// Copy a rom to its permanent location below 1MiB @@ -434,6 +435,9 @@ vga_setup(void) // Option roms are already deployed on the system. init_optionrom((void*)BUILD_ROM_START, 0, 1); } else { + // Clear option rom memory + memset((void*)RomEnd, 0, _max_rom() - RomEnd); + // Find and deploy PCI VGA rom. int bdf = VGAbdf = pci_find_vga(); if (bdf >= 0) diff --git a/src/pmm.c b/src/pmm.c index f5e58ad..bb90ff0 100644 --- a/src/pmm.c +++ b/src/pmm.c @@ -197,11 +197,6 @@ malloc_setup(void) ZoneTmpLow.info = ZoneTmpHigh.info = NULL;
// Clear memory in 0xf0000 area. - extern u8 code32flat_start[]; - if ((u32)code32flat_start > BUILD_BIOS_ADDR) - // Clear unused parts of f-segment - memset((void*)BUILD_BIOS_ADDR, 0 - , (u32)code32flat_start - BUILD_BIOS_ADDR); memset(BiosTableSpace, 0, CONFIG_MAX_BIOSTABLE);
// Populate temp high ram