]> xenbits.xensource.com Git - people/andrewcoop/seabios.git/commitdiff
e820: Rename memmap.c to e820map.c and use consistent "e820_" prefix
authorKevin O'Connor <kevin@koconnor.net>
Tue, 29 Sep 2015 13:40:46 +0000 (09:40 -0400)
committerKevin O'Connor <kevin@koconnor.net>
Thu, 15 Oct 2015 14:52:13 +0000 (10:52 -0400)
Rename memmap.c to e820map.c as the code in that file only deals with
maintaining the e820 map.  Move all the e820 definitions to new file
e820map.h and use a consistent "e820_" prefix on all exported
functions.

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
14 files changed:
Makefile
src/e820map.c [new file with mode: 0644]
src/e820map.h [new file with mode: 0644]
src/fw/coreboot.c
src/fw/csm.c
src/fw/paravirt.c
src/fw/pciinit.c
src/fw/xen.c
src/hw/ramdisk.c
src/malloc.c
src/memmap.c [deleted file]
src/memmap.h
src/post.c
src/system.c

index 3a0d2e858eb5e0fc3e15bb2f14b5fd5f0d23021d..e5f28d421880ff61f94e9458f2b593a0a6a69b14 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ SRCBOTH=misc.c stacks.c output.c string.c block.c cdrom.c disk.c mouse.c kbd.c \
     hw/blockcmd.c hw/floppy.c hw/ata.c hw/ramdisk.c \
     hw/lsi-scsi.c hw/esp-scsi.c hw/megasas.c
 SRC16=$(SRCBOTH)
-SRC32FLAT=$(SRCBOTH) post.c memmap.c malloc.c romfile.c x86.c optionroms.c \
+SRC32FLAT=$(SRCBOTH) post.c e820map.c malloc.c romfile.c x86.c optionroms.c \
     pmm.c font.c boot.c bootsplash.c jpeg.c bmp.c tcgbios.c sha1.c \
     hw/ahci.c hw/pvscsi.c hw/usb-xhci.c hw/usb-hub.c hw/sdcard.c \
     fw/coreboot.c fw/lzmadecode.c fw/multiboot.c fw/csm.c fw/biostables.c \
diff --git a/src/e820map.c b/src/e820map.c
new file mode 100644 (file)
index 0000000..901ccdf
--- /dev/null
@@ -0,0 +1,152 @@
+// Support for building memory maps suitable for int 15 e820 calls.
+//
+// Copyright (C) 2008,2009  Kevin O'Connor <kevin@koconnor.net>
+//
+// This file may be distributed under the terms of the GNU LGPLv3 license.
+
+#include "config.h" // BUILD_MAX_E820
+#include "e820map.h" // struct e820entry
+#include "output.h" // dprintf
+#include "string.h" // memmove
+
+
+/****************************************************************
+ * e820 memory map
+ ****************************************************************/
+
+// Info on e820 map location and size.
+struct e820entry e820_list[BUILD_MAX_E820] VARFSEG;
+int e820_count VARFSEG;
+
+// Remove an entry from the e820_list.
+static void
+remove_e820(int i)
+{
+    e820_count--;
+    memmove(&e820_list[i], &e820_list[i+1]
+            , sizeof(e820_list[0]) * (e820_count - i));
+}
+
+// Insert an entry in the e820_list at the given position.
+static void
+insert_e820(int i, u64 start, u64 size, u32 type)
+{
+    if (e820_count >= BUILD_MAX_E820) {
+        warn_noalloc();
+        return;
+    }
+
+    memmove(&e820_list[i+1], &e820_list[i]
+            , sizeof(e820_list[0]) * (e820_count - i));
+    e820_count++;
+    struct e820entry *e = &e820_list[i];
+    e->start = start;
+    e->size = size;
+    e->type = type;
+}
+
+static const char *
+e820_type_name(u32 type)
+{
+    switch (type) {
+    case E820_RAM:      return "RAM";
+    case E820_RESERVED: return "RESERVED";
+    case E820_ACPI:     return "ACPI";
+    case E820_NVS:      return "NVS";
+    case E820_UNUSABLE: return "UNUSABLE";
+    default:            return "UNKNOWN";
+    }
+}
+
+// Show the current e820_list.
+static void
+dump_map(void)
+{
+    dprintf(1, "e820 map has %d items:\n", e820_count);
+    int i;
+    for (i=0; i<e820_count; i++) {
+        struct e820entry *e = &e820_list[i];
+        u64 e_end = e->start + e->size;
+        dprintf(1, "  %d: %016llx - %016llx = %d %s\n", i
+                , e->start, e_end, e->type, e820_type_name(e->type));
+    }
+}
+
+#define E820_HOLE         ((u32)-1) // Used internally to remove entries
+
+// Add a new entry to the list.  This scans for overlaps and keeps the
+// list sorted.
+void
+e820_add(u64 start, u64 size, u32 type)
+{
+    dprintf(8, "Add to e820 map: %08x %08x %d\n", (u32)start, (u32)size, type);
+
+    if (! size)
+        // Huh?  Nothing to do.
+        return;
+
+    // Find position of new item (splitting existing item if needed).
+    u64 end = start + size;
+    int i;
+    for (i=0; i<e820_count; i++) {
+        struct e820entry *e = &e820_list[i];
+        u64 e_end = e->start + e->size;
+        if (start > e_end)
+            continue;
+        // Found position - check if an existing item needs to be split.
+        if (start > e->start) {
+            if (type == e->type) {
+                // Same type - merge them.
+                size += start - e->start;
+                start = e->start;
+            } else {
+                // Split existing item.
+                e->size = start - e->start;
+                i++;
+                if (e_end > end)
+                    insert_e820(i, end, e_end - end, e->type);
+            }
+        }
+        break;
+    }
+    // Remove/adjust existing items that are overlapping.
+    while (i<e820_count) {
+        struct e820entry *e = &e820_list[i];
+        if (end < e->start)
+            // No overlap - done.
+            break;
+        u64 e_end = e->start + e->size;
+        if (end >= e_end) {
+            // Existing item completely overlapped - remove it.
+            remove_e820(i);
+            continue;
+        }
+        // Not completely overlapped - adjust its start.
+        e->start = end;
+        e->size = e_end - end;
+        if (type == e->type) {
+            // Same type - merge them.
+            size += e->size;
+            remove_e820(i);
+        }
+        break;
+    }
+    // Insert new item.
+    if (type != E820_HOLE)
+        insert_e820(i, start, size, type);
+    //dump_map();
+}
+
+// Remove any definitions in a memory range (make a memory hole).
+void
+e820_remove(u64 start, u64 size)
+{
+    e820_add(start, size, E820_HOLE);
+}
+
+// Report on final memory locations.
+void
+e820_prepboot(void)
+{
+    dump_map();
+}
diff --git a/src/e820map.h b/src/e820map.h
new file mode 100644 (file)
index 0000000..de8b523
--- /dev/null
@@ -0,0 +1,26 @@
+#ifndef __E820MAP_H
+#define __E820MAP_H
+
+#include "types.h" // u64
+
+#define E820_RAM          1
+#define E820_RESERVED     2
+#define E820_ACPI         3
+#define E820_NVS          4
+#define E820_UNUSABLE     5
+
+struct e820entry {
+    u64 start;
+    u64 size;
+    u32 type;
+};
+
+void e820_add(u64 start, u64 size, u32 type);
+void e820_remove(u64 start, u64 size);
+void e820_prepboot(void);
+
+// e820 map storage
+extern struct e820entry e820_list[];
+extern int e820_count;
+
+#endif // e820map.h
index b077fe1688b97c3475f5df8730248f39be5501e4..a47f524246782845d12e8f0aee299ac44a5a86cc 100644 (file)
@@ -7,10 +7,10 @@
 #include "block.h" // MAXDESCSIZE
 #include "byteorder.h" // be32_to_cpu
 #include "config.h" // CONFIG_*
+#include "e820map.h" // e820_add
 #include "hw/pci.h" // pci_probe_devices
 #include "lzmadecode.h" // LzmaDecode
 #include "malloc.h" // free
-#include "memmap.h" // add_e820
 #include "output.h" // dprintf
 #include "paravirt.h" // PlatformRunningOn
 #include "romfile.h" // romfile_findprefix
@@ -184,12 +184,12 @@ coreboot_preinit(void)
         u32 type = m->type;
         if (type == CB_MEM_TABLE)
             type = E820_RESERVED;
-        add_e820(m->start, m->size, type);
+        e820_add(m->start, m->size, type);
     }
 
     // Ughh - coreboot likes to set a map at 0x0000-0x1000, but this
     // confuses grub.  So, override it.
-    add_e820(0, 16*1024, E820_RAM);
+    e820_add(0, 16*1024, E820_RAM);
 
     struct cb_cbmem_ref *cbref = find_cb_subtable(cbh, CB_TAG_CBMEM_CONSOLE);
     if (cbref) {
@@ -210,7 +210,7 @@ coreboot_preinit(void)
 fail:
     // No table found..  Use 16Megs as a dummy value.
     dprintf(1, "Unable to find coreboot table!\n");
-    add_e820(0, 16*1024*1024, E820_RAM);
+    e820_add(0, 16*1024*1024, E820_RAM);
     return;
 }
 
index aee2f90e15a1f2189c97d141d96c92fe98ea0fb1..0467560b2951591db0b1e9e2b0a6cf67f4becf44 100644 (file)
@@ -4,20 +4,20 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "bregs.h"
+#include "bregs.h" // struct bregs
 #include "config.h" // CONFIG_*
+#include "e820map.h" // e820_add
 #include "farptr.h" // MAKE_FLATPTR
-#include "hw/pci.h"
-#include "hw/pic.h"
+#include "hw/pci.h" // pci_probe_devices
+#include "hw/pic.h" // pic_irqmask_read
 #include "malloc.h" // csm_malloc_preinit
-#include "memmap.h"
 #include "output.h" // dprintf
+#include "paravirt.h" // qemu_preinit
 #include "stacks.h" // wait_threads
 #include "std/acpi.h" // RSDP_SIGNATURE
 #include "std/bda.h" // struct bios_data_area_s
 #include "std/optionrom.h" // struct rom_header
 #include "util.h" // copy_smbios
-#include "paravirt.h" // qemu_preinit
 
 #define UINT8 u8
 #define UINT16 u16
@@ -147,11 +147,11 @@ handle_csm_0002(struct bregs *regs)
     struct e820entry *p = (void *)csm_compat_table.E820Pointer;
     int i;
     for (i=0; i < csm_compat_table.E820Length / sizeof(struct e820entry); i++)
-        add_e820(p[i].start, p[i].size, p[i].type);
+        e820_add(p[i].start, p[i].size, p[i].type);
 
     if (csm_init_table->HiPmmMemorySizeInBytes > BUILD_MAX_HIGHTABLE) {
         u32 hi_pmm_end = csm_init_table->HiPmmMemory + csm_init_table->HiPmmMemorySizeInBytes;
-        add_e820(hi_pmm_end - BUILD_MAX_HIGHTABLE, BUILD_MAX_HIGHTABLE, E820_RESERVED);
+        e820_add(hi_pmm_end - BUILD_MAX_HIGHTABLE, BUILD_MAX_HIGHTABLE, E820_RESERVED);
     }
 
     // For PCIBIOS 1ab10e
index db22ae8fc28b2f250b6fa063933c007ca005fbab..acb44b9167bea7c4896337aebfb36d1b75e3c409 100644 (file)
 
 #include "byteorder.h" // be32_to_cpu
 #include "config.h" // CONFIG_QEMU
+#include "e820map.h" // e820_add
 #include "hw/pci.h" // create_pirtable
 #include "hw/pci_regs.h" // PCI_DEVICE_ID
 #include "hw/rtc.h" // CMOS_*
 #include "malloc.h" // malloc_tmp
-#include "memmap.h" // add_e820
 #include "output.h" // dprintf
 #include "paravirt.h" // qemu_cfg_preinit
 #include "romfile.h" // romfile_loadint
@@ -114,10 +114,10 @@ qemu_preinit(void)
                | (rtc_read(CMOS_MEM_EXTMEM_HIGH) << 18))
               + 1 * 1024 * 1024);
     RamSize = rs;
-    add_e820(0, rs, E820_RAM);
+    e820_add(0, rs, E820_RAM);
 
     /* reserve 256KB BIOS area at the end of 4 GB */
-    add_e820(0xfffc0000, 256*1024, E820_RESERVED);
+    e820_add(0xfffc0000, 256*1024, E820_RESERVED);
 
     dprintf(1, "RamSize: 0x%08x [cmos]\n", RamSize);
 }
@@ -302,7 +302,7 @@ qemu_cfg_e820(void)
                 }
                 /* fall through */
             case E820_RESERVED:
-                add_e820(table[i].address, table[i].length, table[i].type);
+                e820_add(table[i].address, table[i].length, table[i].type);
                 break;
             default:
                 /*
@@ -324,13 +324,13 @@ qemu_cfg_e820(void)
         int i;
         for (i = 0; i < count32; i++) {
             qemu_cfg_read(&entry, sizeof(entry));
-            add_e820(entry.address, entry.length, entry.type);
+            e820_add(entry.address, entry.length, entry.type);
         }
     } else if (runningOnKVM()) {
         // Backwards compatibility - provide hard coded range.
         // 4 pages before the bios, 3 pages for vmx tss pages, the
         // other page for EPT real mode pagetable
-        add_e820(0xfffbc000, 4*4096, E820_RESERVED);
+        e820_add(0xfffbc000, 4*4096, E820_RESERVED);
     }
 
     // Check for memory over 4Gig in cmos
@@ -338,7 +338,7 @@ qemu_cfg_e820(void)
                 | ((u32)rtc_read(CMOS_MEM_HIGHMEM_MID) << 24)
                 | ((u64)rtc_read(CMOS_MEM_HIGHMEM_HIGH) << 32));
     RamSizeOver4G = high;
-    add_e820(0x100000000ull, high, E820_RAM);
+    e820_add(0x100000000ull, high, E820_RAM);
     dprintf(1, "RamSizeOver4G: 0x%016llx [cmos]\n", RamSizeOver4G);
 }
 
index 3ad84baea5c42501af6066bb8bb9f619ae367f35..7b8aab7c487ea38e4caaf2afbacc592df02d9bc1 100644 (file)
@@ -9,13 +9,13 @@
 #include "config.h" // CONFIG_*
 #include "dev-q35.h" // Q35_HOST_BRIDGE_PCIEXBAR_ADDR
 #include "dev-piix.h" // PIIX_*
+#include "e820map.h" // e820_add
 #include "hw/ata.h" // PORT_ATA1_CMD_BASE
 #include "hw/pci.h" // pci_config_readl
 #include "hw/pci_ids.h" // PCI_VENDOR_ID_INTEL
 #include "hw/pci_regs.h" // PCI_COMMAND
 #include "list.h" // struct hlist_node
 #include "malloc.h" // free
-#include "memmap.h" // add_e820
 #include "output.h" // dprintf
 #include "paravirt.h" // RamSize
 #include "romfile.h" // romfile_loadint
@@ -186,7 +186,7 @@ static void mch_isa_bridge_setup(struct pci_device *dev, void *arg)
     /* set root complex register block BAR */
     pci_config_writel(bdf, ICH9_LPC_RCBA,
                       ICH9_LPC_RCBA_ADDR | ICH9_LPC_RCBA_EN);
-    add_e820(ICH9_LPC_RCBA_ADDR, 16*1024, E820_RESERVED);
+    e820_add(ICH9_LPC_RCBA_ADDR, 16*1024, E820_RESERVED);
 
     acpi_pm1a_cnt = acpi_pm_base + 0x04;
     pmtimer_setup(acpi_pm_base + 0x08);
@@ -400,7 +400,7 @@ static void mch_mem_addr_setup(struct pci_device *dev, void *arg)
     pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR, 0);
     pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR + 4, upper);
     pci_config_writel(bdf, Q35_HOST_BRIDGE_PCIEXBAR, lower);
-    add_e820(addr, size, E820_RESERVED);
+    e820_add(addr, size, E820_RESERVED);
 
     /* setup pci i/o window (above mmconfig) */
     pcimem_start = addr + size;
index dd8e8afd431dbc6c0d13e67f5cf2cb935302f5f4..3f19ef2dcfffcb9d22135c3fcf50ebe174e6bf0f 100644 (file)
@@ -4,16 +4,17 @@
 //
 // This file may be distributed under the terms of the GNU LGPLv3 license.
 
-#include "config.h"
+#include "config.h" // CONFIG_XEN
+#include "e820map.h" // e820_add
 #include "hw/serialio.h" // DebugOutputPort
 #include "malloc.h" // memalign_high
-#include "memmap.h" // add_e820
+#include "memmap.h" // PAGE_SIZE
 #include "output.h" // dprintf
 #include "paravirt.h" // PlatformRunningOn
 #include "string.h" // memcpy
 #include "util.h" // copy_acpi_rsdp
 #include "x86.h" // cpuid
-#include "xen.h"
+#include "xen.h" // xen_extraversion_t
 
 #define INFO_PHYSICAL_ADDRESS 0x00001000
 
@@ -142,6 +143,6 @@ void xen_ramsize_preinit(void)
 
     for (i = 0; i < info->e820_nr; i++) {
         struct e820entry *e = &e820[i];
-        add_e820(e->start, e->size, e->type);
+        e820_add(e->start, e->size, e->type);
     }
 }
index 4cdf95f9e541a7ce4cb2c3f50d2408e8dc72feb3..adec1d1b355aef21098b0de89ad31c46c5e9b45d 100644 (file)
@@ -7,8 +7,9 @@
 #include "biosvar.h" // GET_GLOBALFLAT
 #include "block.h" // struct drive_s
 #include "bregs.h" // struct bregs
+#include "e820map.h" // e820_add
 #include "malloc.h" // memalign_tmphigh
-#include "memmap.h" // add_e820
+#include "memmap.h" // PAGE_SIZE
 #include "output.h" // dprintf
 #include "romfile.h" // romfile_findprefix
 #include "stacks.h" // call16_int
@@ -41,7 +42,7 @@ ramdisk_setup(void)
         warn_noalloc();
         return;
     }
-    add_e820((u32)pos, size, E820_RESERVED);
+    e820_add((u32)pos, size, E820_RESERVED);
 
     // Copy image into ram.
     int ret = file->copy(file, pos, size);
index 5c05a8aefc8e6036437f411745cef907905a92e6..efd09b38e3edfe86b696360f1291339e7bdb8692 100644 (file)
@@ -6,9 +6,10 @@
 
 #include "biosvar.h" // GET_BDA
 #include "config.h" // BUILD_BIOS_ADDR
+#include "e820map.h" // struct e820entry
 #include "list.h" // hlist_node
 #include "malloc.h" // _malloc
-#include "memmap.h" // struct e820entry
+#include "memmap.h" // PAGE_SIZE
 #include "output.h" // dprintf
 #include "stacks.h" // wait_preempt
 #include "std/optionrom.h" // OPTION_ROM_ALIGN
@@ -399,7 +400,7 @@ malloc_preinit(void)
     e820_remove(BUILD_LOWRAM_END, BUILD_BIOS_ADDR-BUILD_LOWRAM_END);
 
     // Mark known areas as reserved.
-    add_e820(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED);
+    e820_add(BUILD_BIOS_ADDR, BUILD_BIOS_SIZE, E820_RESERVED);
 
     // Populate temp high ram
     u32 highram = 0;
@@ -427,7 +428,7 @@ malloc_preinit(void)
     if (highram) {
         addSpace(&ZoneHigh, (void*)highram
                  , (void*)highram + BUILD_MAX_HIGHTABLE);
-        add_e820(highram, BUILD_MAX_HIGHTABLE, E820_RESERVED);
+        e820_add(highram, BUILD_MAX_HIGHTABLE, E820_RESERVED);
     }
 }
 
@@ -521,7 +522,7 @@ malloc_prepboot(void)
 
     // Reserve more low-mem if needed.
     u32 endlow = GET_BDA(mem_size_kb)*1024;
-    add_e820(endlow, BUILD_LOWRAM_END-endlow, E820_RESERVED);
+    e820_add(endlow, BUILD_LOWRAM_END-endlow, E820_RESERVED);
 
     // Clear unused f-seg ram.
     struct allocinfo_s *info = findLast(&ZoneFSeg);
@@ -533,7 +534,7 @@ malloc_prepboot(void)
     info = findLast(&ZoneHigh);
     if (info) {
         u32 giveback = ALIGN_DOWN(info->allocend - info->dataend, PAGE_SIZE);
-        add_e820((u32)info->dataend, giveback, E820_RAM);
+        e820_add((u32)info->dataend, giveback, E820_RAM);
         dprintf(1, "Returned %d bytes of ZoneHigh\n", giveback);
     }
 
diff --git a/src/memmap.c b/src/memmap.c
deleted file mode 100644 (file)
index 8c0c38d..0000000
+++ /dev/null
@@ -1,152 +0,0 @@
-// Support for building memory maps suitable for int 15 e820 calls.
-//
-// Copyright (C) 2008,2009  Kevin O'Connor <kevin@koconnor.net>
-//
-// This file may be distributed under the terms of the GNU LGPLv3 license.
-
-#include "config.h" // BUILD_MAX_E820
-#include "memmap.h" // struct e820entry
-#include "output.h" // dprintf
-#include "string.h" // memmove
-
-
-/****************************************************************
- * e820 memory map
- ****************************************************************/
-
-// Info on e820 map location and size.
-struct e820entry e820_list[BUILD_MAX_E820] VARFSEG;
-int e820_count VARFSEG;
-
-// Remove an entry from the e820_list.
-static void
-remove_e820(int i)
-{
-    e820_count--;
-    memmove(&e820_list[i], &e820_list[i+1]
-            , sizeof(e820_list[0]) * (e820_count - i));
-}
-
-// Insert an entry in the e820_list at the given position.
-static void
-insert_e820(int i, u64 start, u64 size, u32 type)
-{
-    if (e820_count >= BUILD_MAX_E820) {
-        warn_noalloc();
-        return;
-    }
-
-    memmove(&e820_list[i+1], &e820_list[i]
-            , sizeof(e820_list[0]) * (e820_count - i));
-    e820_count++;
-    struct e820entry *e = &e820_list[i];
-    e->start = start;
-    e->size = size;
-    e->type = type;
-}
-
-static const char *
-e820_type_name(u32 type)
-{
-    switch (type) {
-    case E820_RAM:      return "RAM";
-    case E820_RESERVED: return "RESERVED";
-    case E820_ACPI:     return "ACPI";
-    case E820_NVS:      return "NVS";
-    case E820_UNUSABLE: return "UNUSABLE";
-    default:            return "UNKNOWN";
-    }
-}
-
-// Show the current e820_list.
-static void
-dump_map(void)
-{
-    dprintf(1, "e820 map has %d items:\n", e820_count);
-    int i;
-    for (i=0; i<e820_count; i++) {
-        struct e820entry *e = &e820_list[i];
-        u64 e_end = e->start + e->size;
-        dprintf(1, "  %d: %016llx - %016llx = %d %s\n", i
-                , e->start, e_end, e->type, e820_type_name(e->type));
-    }
-}
-
-#define E820_HOLE         ((u32)-1) // Used internally to remove entries
-
-// Add a new entry to the list.  This scans for overlaps and keeps the
-// list sorted.
-void
-add_e820(u64 start, u64 size, u32 type)
-{
-    dprintf(8, "Add to e820 map: %08x %08x %d\n", (u32)start, (u32)size, type);
-
-    if (! size)
-        // Huh?  Nothing to do.
-        return;
-
-    // Find position of new item (splitting existing item if needed).
-    u64 end = start + size;
-    int i;
-    for (i=0; i<e820_count; i++) {
-        struct e820entry *e = &e820_list[i];
-        u64 e_end = e->start + e->size;
-        if (start > e_end)
-            continue;
-        // Found position - check if an existing item needs to be split.
-        if (start > e->start) {
-            if (type == e->type) {
-                // Same type - merge them.
-                size += start - e->start;
-                start = e->start;
-            } else {
-                // Split existing item.
-                e->size = start - e->start;
-                i++;
-                if (e_end > end)
-                    insert_e820(i, end, e_end - end, e->type);
-            }
-        }
-        break;
-    }
-    // Remove/adjust existing items that are overlapping.
-    while (i<e820_count) {
-        struct e820entry *e = &e820_list[i];
-        if (end < e->start)
-            // No overlap - done.
-            break;
-        u64 e_end = e->start + e->size;
-        if (end >= e_end) {
-            // Existing item completely overlapped - remove it.
-            remove_e820(i);
-            continue;
-        }
-        // Not completely overlapped - adjust its start.
-        e->start = end;
-        e->size = e_end - end;
-        if (type == e->type) {
-            // Same type - merge them.
-            size += e->size;
-            remove_e820(i);
-        }
-        break;
-    }
-    // Insert new item.
-    if (type != E820_HOLE)
-        insert_e820(i, start, size, type);
-    //dump_map();
-}
-
-// Remove any definitions in a memory range (make a memory hole).
-void
-e820_remove(u64 start, u64 size)
-{
-    add_e820(start, size, E820_HOLE);
-}
-
-// Report on final memory locations.
-void
-memmap_prepboot(void)
-{
-    dump_map();
-}
index e7d94ee651e6613caa8f8e28cbbbf03a2f764b3b..c4399825d38d4211ff24e794201d21b106f19366 100644 (file)
@@ -1,29 +1,7 @@
-#ifndef __E820MAP_H
-#define __E820MAP_H
-
-#include "types.h" // u64
-
-#define E820_RAM          1
-#define E820_RESERVED     2
-#define E820_ACPI         3
-#define E820_NVS          4
-#define E820_UNUSABLE     5
-
-struct e820entry {
-    u64 start;
-    u64 size;
-    u32 type;
-};
-
-void add_e820(u64 start, u64 size, u32 type);
-void e820_remove(u64 start, u64 size);
-void memmap_prepboot(void);
+#ifndef __MEMMAP_H
+#define __MEMMAP_H
 
 // A typical OS page size
 #define PAGE_SIZE 4096
 
-// e820 map storage
-extern struct e820entry e820_list[];
-extern int e820_count;
-
-#endif // e820map.h
+#endif // memmap.h
index e19b06c17b11e1225a65b8ff397e2e0f94ac7db5..89e6eff1bcb6a0fde8e41e118ead6cbca20d2fca 100644 (file)
@@ -8,6 +8,7 @@
 #include "biosvar.h" // SET_BDA
 #include "bregs.h" // struct bregs
 #include "config.h" // CONFIG_*
+#include "e820map.h" // e820_add
 #include "fw/paravirt.h" // qemu_cfg_preinit
 #include "fw/xen.h" // xen_preinit
 #include "hw/ahci.h" // ahci_setup
@@ -24,7 +25,6 @@
 #include "hw/virtio-blk.h" // virtio_blk_setup
 #include "hw/virtio-scsi.h" // virtio_scsi_setup
 #include "malloc.h" // malloc_init
-#include "memmap.h" // add_e820
 #include "output.h" // dprintf
 #include "string.h" // memset
 #include "util.h" // kbd_init
@@ -102,7 +102,7 @@ bda_init(void)
     memset(ebda, 0, sizeof(*ebda));
     ebda->size = esize;
 
-    add_e820((u32)ebda, BUILD_LOWRAM_END-(u32)ebda, E820_RESERVED);
+    e820_add((u32)ebda, BUILD_LOWRAM_END-(u32)ebda, E820_RESERVED);
 
     // Init extra stack
     StackPos = (void*)(&ExtraStack[BUILD_EXTRA_STACK_SIZE] - zonelow_base);
@@ -191,7 +191,7 @@ prepareboot(void)
     cdrom_prepboot();
     pmm_prepboot();
     malloc_prepboot();
-    memmap_prepboot();
+    e820_prepboot();
 
     HaveRunPost = 2;
 
index 60a6fce58a3a10c23e9200140df3df3ba823fdf7..438e60e2c877aa4f497963d99b459fbfa49d2729 100644 (file)
@@ -7,9 +7,9 @@
 
 #include "biosvar.h" // GET_GLOBAL
 #include "bregs.h" // struct bregs
+#include "e820map.h" // E820_RAM
 #include "hw/pic.h" // pic_reset
 #include "malloc.h" // LegacyRamSize
-#include "memmap.h" // E820_RAM
 #include "output.h" // debug_enter
 #include "string.h" // memcpy_far
 #include "util.h" // handle_1553