x86: qemu: Use the new e820 API
Move over to use this API before making the code even more complicated. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
+12
-36
@@ -19,51 +19,27 @@ unsigned int install_e820_map(unsigned int max_entries,
|
||||
struct e820_entry *entries)
|
||||
{
|
||||
u64 high_mem_size;
|
||||
int n = 0;
|
||||
struct e820_ctx ctx;
|
||||
|
||||
entries[n].addr = 0;
|
||||
entries[n].size = ISA_START_ADDRESS;
|
||||
entries[n].type = E820_RAM;
|
||||
n++;
|
||||
e820_init(&ctx, entries, max_entries);
|
||||
|
||||
entries[n].addr = ISA_START_ADDRESS;
|
||||
entries[n].size = ISA_END_ADDRESS - ISA_START_ADDRESS;
|
||||
entries[n].type = E820_RESERVED;
|
||||
n++;
|
||||
e820_next(&ctx, E820_RAM, ISA_START_ADDRESS);
|
||||
e820_next(&ctx, E820_RESERVED, ISA_END_ADDRESS);
|
||||
|
||||
/*
|
||||
* since we use memalign(malloc) to allocate high memory for
|
||||
* storing ACPI tables, we need to reserve them in e820 tables,
|
||||
* otherwise kernel will reclaim them and data will be corrupted
|
||||
*/
|
||||
entries[n].addr = ISA_END_ADDRESS;
|
||||
entries[n].size = gd->relocaddr - TOTAL_MALLOC_LEN - ISA_END_ADDRESS;
|
||||
entries[n].type = E820_RAM;
|
||||
n++;
|
||||
|
||||
/* for simplicity, reserve entire malloc space */
|
||||
entries[n].addr = gd->relocaddr - TOTAL_MALLOC_LEN;
|
||||
entries[n].size = TOTAL_MALLOC_LEN;
|
||||
entries[n].type = E820_RESERVED;
|
||||
n++;
|
||||
|
||||
entries[n].addr = gd->relocaddr;
|
||||
entries[n].size = qemu_get_low_memory_size() - gd->relocaddr;
|
||||
entries[n].type = E820_RESERVED;
|
||||
n++;
|
||||
|
||||
entries[n].addr = CONFIG_PCIE_ECAM_BASE;
|
||||
entries[n].size = CONFIG_PCIE_ECAM_SIZE;
|
||||
entries[n].type = E820_RESERVED;
|
||||
n++;
|
||||
e820_to_addr(&ctx, E820_RAM, gd->relocaddr - TOTAL_MALLOC_LEN);
|
||||
e820_next(&ctx, E820_RESERVED, TOTAL_MALLOC_LEN);
|
||||
e820_to_addr(&ctx, E820_RAM, qemu_get_low_memory_size());
|
||||
e820_add(&ctx, E820_RESERVED, CONFIG_PCIE_ECAM_BASE,
|
||||
CONFIG_PCIE_ECAM_SIZE);
|
||||
|
||||
high_mem_size = qemu_get_high_memory_size();
|
||||
if (high_mem_size) {
|
||||
entries[n].addr = SZ_4G;
|
||||
entries[n].size = high_mem_size;
|
||||
entries[n].type = E820_RAM;
|
||||
n++;
|
||||
}
|
||||
if (high_mem_size)
|
||||
e820_add(&ctx, E820_RAM, SZ_4G, high_mem_size);
|
||||
|
||||
return n;
|
||||
return e820_finish(&ctx);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user