The E820_HOLE definition is used internally in the e820 manipulation code to remove entries from the e820 map. Introduce the e820_remove() function so that the E820_HOLE definition does not need to be exported from the memmap.c code.
Signed-off-by: Kevin O'Connor kevin@koconnor.net --- src/malloc.c | 2 +- src/memmap.c | 10 +++++++++- src/memmap.h | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/src/malloc.c b/src/malloc.c index c4cb171..5c05a8a 100644 --- a/src/malloc.c +++ b/src/malloc.c @@ -396,7 +396,7 @@ malloc_preinit(void) dprintf(3, "malloc preinit\n");
// Don't declare any memory between 0xa0000 and 0x100000 - add_e820(BUILD_LOWRAM_END, BUILD_BIOS_ADDR-BUILD_LOWRAM_END, E820_HOLE); + 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); diff --git a/src/memmap.c b/src/memmap.c index e03f8d0..8c0c38d 100644 --- a/src/memmap.c +++ b/src/memmap.c @@ -54,7 +54,6 @@ e820_type_name(u32 type) case E820_ACPI: return "ACPI"; case E820_NVS: return "NVS"; case E820_UNUSABLE: return "UNUSABLE"; - case E820_HOLE: return "HOLE"; default: return "UNKNOWN"; } } @@ -73,6 +72,8 @@ dump_map(void) } }
+#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 @@ -136,6 +137,13 @@ add_e820(u64 start, u64 size, u32 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) diff --git a/src/memmap.h b/src/memmap.h index 7bda56e..e7d94ee 100644 --- a/src/memmap.h +++ b/src/memmap.h @@ -8,7 +8,6 @@ #define E820_ACPI 3 #define E820_NVS 4 #define E820_UNUSABLE 5 -#define E820_HOLE ((u32)-1) // Useful for removing entries
struct e820entry { u64 start; @@ -17,6 +16,7 @@ struct e820entry { };
void add_e820(u64 start, u64 size, u32 type); +void e820_remove(u64 start, u64 size); void memmap_prepboot(void);
// A typical OS page size