Eliminate separate BiosTableSpace[] space for f-segment allocations.

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>
diff --git a/tools/layoutrom.py b/tools/layoutrom.py
index 70370e4..6e1c588 100755
--- a/tools/layoutrom.py
+++ b/tools/layoutrom.py
@@ -59,6 +59,8 @@
 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 @@
     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 @@
     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 @@
                    , 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 @@
         code32flat_end = ABSOLUTE(.) ;
     } :text
 """ % (li.sec32init_align,
+       li.zonefseg_start,
+       li.zonefseg_end,
        li.zonelow_base,
        li.final_sec32low_start,
        sec32all_start,