summaryrefslogtreecommitdiff
path: root/arch/x86/cpu/qemu
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/cpu/qemu')
-rw-r--r--arch/x86/cpu/qemu/dram.c18
-rw-r--r--arch/x86/cpu/qemu/e820.c62
-rw-r--r--arch/x86/cpu/qemu/qemu.c20
3 files changed, 55 insertions, 45 deletions
diff --git a/arch/x86/cpu/qemu/dram.c b/arch/x86/cpu/qemu/dram.c
index 62a301c0fd3..ba3638e6acc 100644
--- a/arch/x86/cpu/qemu/dram.c
+++ b/arch/x86/cpu/qemu/dram.c
@@ -4,7 +4,9 @@
*/
#include <init.h>
+#include <spl.h>
#include <asm/global_data.h>
+#include <asm/mtrr.h>
#include <asm/post.h>
#include <asm/arch/qemu.h>
#include <linux/sizes.h>
@@ -44,6 +46,22 @@ int dram_init(void)
gd->ram_size += qemu_get_high_memory_size();
post_code(POST_DRAM);
+ if (xpl_phase() == PHASE_BOARD_F) {
+ u64 total = gd->ram_size;
+ int ret;
+
+ if (total > SZ_2G + SZ_1G)
+ total += SZ_1G;
+ ret = mtrr_add_request(MTRR_TYPE_WRBACK, 0, total);
+ if (ret != -ENOSYS) {
+ if (ret)
+ return log_msg_ret("mta", ret);
+ ret = mtrr_commit(false);
+ if (ret)
+ return log_msg_ret("mtc", ret);
+ }
+ }
+
return 0;
}
diff --git a/arch/x86/cpu/qemu/e820.c b/arch/x86/cpu/qemu/e820.c
index 17a04f86479..078d1d86b02 100644
--- a/arch/x86/cpu/qemu/e820.c
+++ b/arch/x86/cpu/qemu/e820.c
@@ -6,6 +6,7 @@
* (C) Copyright 2019 Bin Meng <bmeng.cn@gmail.com>
*/
+#include <bloblist.h>
#include <env_internal.h>
#include <malloc.h>
#include <asm/e820.h>
@@ -19,51 +20,34 @@ 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
+ * if we use bloblist to allocate high memory for storing ACPI tables,
+ * we need to reserve that region in e820 tables, otherwise the kernel
+ * will reclaim them and data will be corrupted. The ACPI tables may not
+ * have been written yet, so use the whole bloblist size
*/
- 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++;
+ if (IS_ENABLED(CONFIG_BLOBLIST_TABLES)) {
+ e820_to_addr(&ctx, E820_RAM, (ulong)gd->bloblist);
+ e820_next(&ctx, E820_ACPI, bloblist_get_total_size());
+ } else {
+ /* If using memalign() reserve that whole region instead */
+ e820_to_addr(&ctx, E820_RAM, gd->relocaddr - TOTAL_MALLOC_LEN);
+ e820_next(&ctx, E820_ACPI, 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);
}
diff --git a/arch/x86/cpu/qemu/qemu.c b/arch/x86/cpu/qemu/qemu.c
index 563f63e2bc8..e846ccd44aa 100644
--- a/arch/x86/cpu/qemu/qemu.c
+++ b/arch/x86/cpu/qemu/qemu.c
@@ -15,14 +15,21 @@
#include <asm/arch/qemu.h>
#include <asm/u-boot-x86.h>
-static bool i440fx;
-
#if CONFIG_IS_ENABLED(QFW_PIO)
U_BOOT_DRVINFO(x86_qfw_pio) = {
.name = "qfw_pio",
};
#endif
+static bool is_i440fx(void)
+{
+ u16 device;
+
+ pci_read_config16(PCI_BDF(0, 0, 0), PCI_DEVICE_ID, &device);
+
+ return device == PCI_DEVICE_ID_INTEL_82441;
+}
+
static void enable_pm_piix(void)
{
u8 en;
@@ -50,16 +57,17 @@ static void enable_pm_ich9(void)
void qemu_chipset_init(void)
{
- u16 device, xbcs;
+ bool i440fx;
+ u16 xbcs;
int pam, i;
+ i440fx = is_i440fx();
+
/*
* i440FX and Q35 chipset have different PAM register offset, but with
* the same bitfield layout. Here we determine the offset based on its
* PCI device ID.
*/
- pci_read_config16(PCI_BDF(0, 0, 0), PCI_DEVICE_ID, &device);
- i440fx = (device == PCI_DEVICE_ID_INTEL_82441);
pam = i440fx ? I440FX_PAM : Q35_PAM;
/*
@@ -123,7 +131,7 @@ int mp_determine_pci_dstirq(int bus, int dev, int func, int pirq)
{
u8 irq;
- if (i440fx) {
+ if (is_i440fx()) {
/*
* Not like most x86 platforms, the PIRQ[A-D] on PIIX3 are not
* connected to I/O APIC INTPIN#16-19. Instead they are routed