mirror of
https://github.com/Fishwaldo/u-boot.git
synced 2025-03-22 23:21:31 +00:00
x86: qemu: Report high memory in the E820 table
Now that we are able to get the size of high memory from QEMU, report its memory range as usable ram. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Aiden Park <aiden.park@intel.com>
This commit is contained in:
parent
ea67d549b8
commit
2495c3a3fd
1 changed files with 40 additions and 19 deletions
|
@ -1,46 +1,67 @@
|
||||||
// SPDX-License-Identifier: GPL-2.0+
|
// SPDX-License-Identifier: GPL-2.0+
|
||||||
/*
|
/*
|
||||||
|
* QEMU x86 specific E820 table generation
|
||||||
|
*
|
||||||
* (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
|
* (C) Copyright 2015 Miao Yan <yanmiaobest@gmail.com>
|
||||||
|
* (C) Copyright 2019 Bin Meng <bmeng.cn@gmail.com>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <env_internal.h>
|
#include <env_internal.h>
|
||||||
#include <asm/e820.h>
|
#include <asm/e820.h>
|
||||||
|
#include <asm/arch/qemu.h>
|
||||||
|
|
||||||
DECLARE_GLOBAL_DATA_PTR;
|
DECLARE_GLOBAL_DATA_PTR;
|
||||||
|
|
||||||
unsigned int install_e820_map(unsigned int max_entries,
|
unsigned int install_e820_map(unsigned int max_entries,
|
||||||
struct e820_entry *entries)
|
struct e820_entry *entries)
|
||||||
{
|
{
|
||||||
entries[0].addr = 0;
|
u64 high_mem_size;
|
||||||
entries[0].size = ISA_START_ADDRESS;
|
int n = 0;
|
||||||
entries[0].type = E820_RAM;
|
|
||||||
|
|
||||||
entries[1].addr = ISA_START_ADDRESS;
|
entries[n].addr = 0;
|
||||||
entries[1].size = ISA_END_ADDRESS - ISA_START_ADDRESS;
|
entries[n].size = ISA_START_ADDRESS;
|
||||||
entries[1].type = E820_RESERVED;
|
entries[n].type = E820_RAM;
|
||||||
|
n++;
|
||||||
|
|
||||||
|
entries[n].addr = ISA_START_ADDRESS;
|
||||||
|
entries[n].size = ISA_END_ADDRESS - ISA_START_ADDRESS;
|
||||||
|
entries[n].type = E820_RESERVED;
|
||||||
|
n++;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* since we use memalign(malloc) to allocate high memory for
|
* since we use memalign(malloc) to allocate high memory for
|
||||||
* storing ACPI tables, we need to reserve them in e820 tables,
|
* storing ACPI tables, we need to reserve them in e820 tables,
|
||||||
* otherwise kernel will reclaim them and data will be corrupted
|
* otherwise kernel will reclaim them and data will be corrupted
|
||||||
*/
|
*/
|
||||||
entries[2].addr = ISA_END_ADDRESS;
|
entries[n].addr = ISA_END_ADDRESS;
|
||||||
entries[2].size = gd->relocaddr - TOTAL_MALLOC_LEN - ISA_END_ADDRESS;
|
entries[n].size = gd->relocaddr - TOTAL_MALLOC_LEN - ISA_END_ADDRESS;
|
||||||
entries[2].type = E820_RAM;
|
entries[n].type = E820_RAM;
|
||||||
|
n++;
|
||||||
|
|
||||||
/* for simplicity, reserve entire malloc space */
|
/* for simplicity, reserve entire malloc space */
|
||||||
entries[3].addr = gd->relocaddr - TOTAL_MALLOC_LEN;
|
entries[n].addr = gd->relocaddr - TOTAL_MALLOC_LEN;
|
||||||
entries[3].size = TOTAL_MALLOC_LEN;
|
entries[n].size = TOTAL_MALLOC_LEN;
|
||||||
entries[3].type = E820_RESERVED;
|
entries[n].type = E820_RESERVED;
|
||||||
|
n++;
|
||||||
|
|
||||||
entries[4].addr = gd->relocaddr;
|
entries[n].addr = gd->relocaddr;
|
||||||
entries[4].size = gd->ram_size - gd->relocaddr;
|
entries[n].size = qemu_get_low_memory_size() - gd->relocaddr;
|
||||||
entries[4].type = E820_RESERVED;
|
entries[n].type = E820_RESERVED;
|
||||||
|
n++;
|
||||||
|
|
||||||
entries[5].addr = CONFIG_PCIE_ECAM_BASE;
|
entries[n].addr = CONFIG_PCIE_ECAM_BASE;
|
||||||
entries[5].size = CONFIG_PCIE_ECAM_SIZE;
|
entries[n].size = CONFIG_PCIE_ECAM_SIZE;
|
||||||
entries[5].type = E820_RESERVED;
|
entries[n].type = E820_RESERVED;
|
||||||
|
n++;
|
||||||
|
|
||||||
return 6;
|
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++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return n;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue