]> xenbits.xensource.com Git - seabios.git/commitdiff
Eliminate separate BiosTableSpace[] space for f-segment allocations.
authorKevin O'Connor <kevin@koconnor.net>
Wed, 20 Feb 2013 02:35:20 +0000 (21:35 -0500)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 20 Feb 2013 02:57:24 +0000 (21:57 -0500)
The BiosTableSpace variable was used to ensure there was sufficient
space in the f-segment for malloc_fseg() calls.  However, it added 2K
to the final image size to reserve that space.

Update the build to determine where to put the f-segment allocations.
In most cases (when code relocation is enabled) allocations can be
done in the space free'd from the "init" sections and no additional
space needs to be reserved in the final image.  This also has the
benefit of not fragmenting the f-segment allocation space.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
src/config.h
src/pmm.c
tools/layoutrom.py

index 71c0b7e6375ad1b07e8df4f33682c8ecaba56415..f3918773d76b601607b6eb26c4f69120a4475f1e 100644 (file)
@@ -16,8 +16,6 @@
 
 // Maximum number of map entries in the e820 map
 #define CONFIG_MAX_E820 32
-// Space to reserve in f-segment for dynamic allocations
-#define CONFIG_MAX_BIOSTABLE 2048
 // Space to reserve in high-memory for tables
 #define CONFIG_MAX_HIGHTABLE (64*1024)
 // Largest supported externaly facing drive id
index 9fca8dc5481468746ee9ad4c0aa57dc7060f63d7..dbe34a1db9995e4bcc9dfe0324a62e8ef3ff2a19 100644 (file)
--- a/src/pmm.c
+++ b/src/pmm.c
@@ -216,9 +216,6 @@ rom_confirm(u32 size)
  * Setup
  ****************************************************************/
 
-// Space for bios tables built an run-time.
-char BiosTableSpace[CONFIG_MAX_BIOSTABLE] __aligned(MALLOC_MIN_ALIGN) VARFSEG;
-
 void
 malloc_preinit(void)
 {
@@ -320,12 +317,9 @@ malloc_init(void)
     RomBase = findLast(&ZoneLow);
 
     // Add space available in f-segment to ZoneFSeg
-    addSpace(&ZoneFSeg, BiosTableSpace, &BiosTableSpace[CONFIG_MAX_BIOSTABLE]);
-    extern u8 code32init_end[];
-    if ((u32)code32init_end > BUILD_BIOS_ADDR) {
-        memset((void*)BUILD_BIOS_ADDR, 0, (u32)code32init_end - BUILD_BIOS_ADDR);
-        addSpace(&ZoneFSeg, (void*)BUILD_BIOS_ADDR, code32init_end);
-    }
+    extern u8 zonefseg_start[], zonefseg_end[];
+    memset(zonefseg_start, 0, zonefseg_end - zonefseg_start);
+    addSpace(&ZoneFSeg, zonefseg_start, zonefseg_end);
 
     calcRamSize();
 }
index 70370e4f4fc772be670c9dd99e2c965e87565dc4..6e1c588c0fba1ef2ebb03f19c3a927e43b1fc6dc 100755 (executable)
@@ -59,6 +59,8 @@ def setSectionsStart(sections, endaddr, minalign=1, segoffset=0):
 BUILD_BIOS_ADDR = 0xf0000
 BUILD_BIOS_SIZE = 0x10000
 BUILD_ROM_START = 0xc0000
+# Space to reserve in f-segment for dynamic allocations
+BUILD_MIN_BIOSTABLE = 2048
 
 # Layout the 16bit code.  This ensures sections with fixed offset
 # requirements are placed in the correct location.  It also places the
@@ -159,6 +161,7 @@ class LayoutInfo:
     sections32init = sec32init_start = sec32init_align = None
     sections32low = sec32low_start = sec32low_align = None
     sections32fseg = sec32fseg_start = sec32fseg_align = None
+    zonefseg_start = zonefseg_end = None
     zonelow_base = final_sec32low_start = None
     exportsyms = varlowsyms = None
 
@@ -211,6 +214,15 @@ def doLayout(sections):
     li.sec32flat_start, li.sec32flat_align = setSectionsStart(
         textsections + rodatasections + datasections + bsssections
         , li.sec32fseg_start, 16)
+    li.zonefseg_end = li.sec32flat_start
+    li.zonefseg_start = BUILD_BIOS_ADDR
+    if li.zonefseg_start + BUILD_MIN_BIOSTABLE > li.zonefseg_end:
+        # Not enough ZoneFSeg space - force a minimum space.
+        li.zonefseg_end = li.sec32fseg_start
+        li.zonefseg_start = li.zonefseg_end - BUILD_MIN_BIOSTABLE
+        li.sec32flat_start, li.sec32flat_align = setSectionsStart(
+            textsections + rodatasections + datasections + bsssections
+            , li.zonefseg_start, 16)
 
     # Determine 32flat init positions
     li.sections32init = getSectionsCategory(sections, '32init')
@@ -369,6 +381,8 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
                    , forcedelta=li.final_sec32low_start-li.sec32low_start)
     out += outXRefs(sections32all, exportsyms=li.exportsyms) + """
     _reloc_min_align = 0x%x ;
+    zonefseg_start = 0x%x ;
+    zonefseg_end = 0x%x ;
     zonelow_base = 0x%x ;
     final_varlow_start = 0x%x ;
 
@@ -390,6 +404,8 @@ def writeLinkerScripts(li, out16, out32seg, out32flat):
         code32flat_end = ABSOLUTE(.) ;
     } :text
 """ % (li.sec32init_align,
+       li.zonefseg_start,
+       li.zonefseg_end,
        li.zonelow_base,
        li.final_sec32low_start,
        sec32all_start,