Enable optionroms to use freed space due to CONFIG_RELOCATE_INIT.
authorKevin O'Connor <kevin@koconnor.net>
Thu, 16 Sep 2010 02:06:19 +0000 (22:06 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Sat, 25 Sep 2010 15:34:31 +0000 (11:34 -0400)
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
src/pmm.c

index cde5b4d125a4c92d4971f7927ed3a93dd79f36df..f26a3aa95ccf9b85515cf2ed45221783a9c53157 100644 (file)
@@ -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)
index f5e58ad836a58b260485d39bbdda6500300b9dd5..bb90ff068bc27723c85829e0896e8b27ef703d98 100644 (file)
--- 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