Reserve space for buffers in f-segment; don't allocate from freespace.

Define the e820list as a regular array.
Define a buffer for run-time built bios tables.
Reserving the space in advance should help prevent run-time errors
    when space becomes tight.
diff --git a/src/config.h b/src/config.h
index d573726..044e110 100644
--- a/src/config.h
+++ b/src/config.h
@@ -76,6 +76,8 @@
 #define CONFIG_VGAHOOKS 0
 // Maximum number of map entries in the e820 map
 #define CONFIG_MAX_E820 32
+// Space to reserve in f-segment for run-time built bios tables.
+#define CONFIG_MAX_BIOSTABLE 512
 
 /* define it if the (emulated) hardware supports SMM mode */
 #define CONFIG_USE_SMM 1
diff --git a/src/memmap.c b/src/memmap.c
index 01b00d8..3d03248 100644
--- a/src/memmap.c
+++ b/src/memmap.c
@@ -122,29 +122,16 @@
     //dump_map();
 }
 
-// Symbols defined in romlayout.S
-extern char freespace1_start, freespace1_end;
-
-u32 bios_table_cur_addr, bios_table_end_addr;
-
 // Prep for memmap stuff - init bios table locations.
 void
 memmap_setup()
 {
-    bios_table_cur_addr = (u32)&freespace1_start;
-    bios_table_end_addr = (u32)&freespace1_end;
+    bios_table_cur_addr = (u32)BiosTableSpace;
+    bios_table_end_addr = bios_table_cur_addr + CONFIG_MAX_BIOSTABLE;
     dprintf(1, "bios_table_addr: 0x%08x end=0x%08x\n",
             bios_table_cur_addr, bios_table_end_addr);
 
-    bios_table_cur_addr = ALIGN(bios_table_cur_addr, 4);
-    u32 msize = CONFIG_MAX_E820 * sizeof(e820_list[0]);
-    if (bios_table_cur_addr + msize > bios_table_end_addr) {
-        dprintf(1, "No room for e820 map!\n");
-        return;
-    }
     e820_count = 0;
-    e820_list = (void*)bios_table_cur_addr;
-    bios_table_cur_addr += msize;
 }
 
 // Report on final memory locations.
@@ -155,8 +142,8 @@
 
     dprintf(1, "final bios_table_addr: 0x%08x (used %d%%)\n"
             , bios_table_cur_addr
-            , (100 * (bios_table_cur_addr - (u32)&freespace1_start)
-               / ((u32)&freespace1_end - (u32)&freespace1_start)));
+            , (100 * (bios_table_cur_addr - (u32)&BiosTableSpace)
+               / CONFIG_MAX_BIOSTABLE));
     if (bios_table_cur_addr > bios_table_end_addr)
         BX_PANIC("bios_table_end_addr overflow!\n");
 }
diff --git a/src/memmap.h b/src/memmap.h
index 8a6bd79..8338c43 100644
--- a/src/memmap.h
+++ b/src/memmap.h
@@ -21,10 +21,11 @@
 void memmap_finalize();
 
 // e820 map storage (defined in system.c)
-extern struct e820entry *e820_list;
+extern struct e820entry e820_list[];
 extern int e820_count;
 
-// Space for exported bios tables.
+// Space for exported bios tables (defined in misc.c)
 extern u32 bios_table_cur_addr, bios_table_end_addr;
+extern char BiosTableSpace[];
 
 #endif // e820map.h
diff --git a/src/misc.c b/src/misc.c
index 0c5f608..ec15262 100644
--- a/src/misc.c
+++ b/src/misc.c
@@ -14,6 +14,9 @@
 u32 RamSize VAR16_32;
 // Amount of continuous ram >4Gig
 u64 RamSizeOver4G;
+// Space for bios tables built an run-time.
+u32 bios_table_cur_addr, bios_table_end_addr;
+char BiosTableSpace[CONFIG_MAX_BIOSTABLE] VAR16_32;
 
 
 /****************************************************************
diff --git a/src/system.c b/src/system.c
index ebb8d41..1d0b23b 100644
--- a/src/system.c
+++ b/src/system.c
@@ -267,7 +267,7 @@
 }
 
 // Info on e820 map location and size.
-struct e820entry *e820_list VAR16_32;
+struct e820entry e820_list[CONFIG_MAX_E820] VAR16_32;
 int e820_count VAR16_32;
 
 static void
@@ -279,14 +279,15 @@
         return;
     }
 
-    struct e820entry *l = GET_GLOBAL(e820_list);
-    memcpy_far(MAKE_FARPTR(regs->es, regs->di), &l[regs->bx], sizeof(l[0]));
+    memcpy_far(MAKE_FARPTR(regs->es, regs->di)
+               , MAKE_FARPTR(SEG_BIOS, &e820_list[regs->bx])
+               , sizeof(e820_list[0]));
     if (regs->bx == count-1)
         regs->ebx = 0;
     else
         regs->ebx++;
     regs->eax = 0x534D4150;
-    regs->ecx = sizeof(l[0]);
+    regs->ecx = sizeof(e820_list[0]);
     set_success(regs);
 }