qemu-q35: die if started on wrong machine

The QEMU machine "PC" doesn't support MCFG.
Die after console init if the user selected the wrong qemu machine
and print a message to use the correct machine type.

Without this patch ramstage dies with non-helpful message:
"get_pbus: dev is NULL!"

Change-Id: I9d1b24176de971c5f827091bc5bc1bac8426f3f6
Signed-off-by: Patrick Rudolph <siro@das-labor.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31425
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net>
This commit is contained in:
Patrick Rudolph 2019-02-14 19:47:03 +01:00 committed by Martin Roth
parent 26210fa040
commit fbdeb4af75
2 changed files with 21 additions and 0 deletions

View File

@ -14,6 +14,7 @@
#include <device/pci_ops.h> #include <device/pci_ops.h>
#include <bootblock_common.h> #include <bootblock_common.h>
#include <southbridge/intel/i82801ix/i82801ix.h> #include <southbridge/intel/i82801ix/i82801ix.h>
#include <console/console.h>
/* Just define these here, there is no gm35.h file to include. */ /* Just define these here, there is no gm35.h file to include. */
#define D0F0_PCIEXBAR_LO 0x60 #define D0F0_PCIEXBAR_LO 0x60
@ -39,6 +40,12 @@ static void bootblock_northbridge_init(void)
pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_HI, reg); pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_HI, reg);
reg = CONFIG_MMCONF_BASE_ADDRESS | 1; /* 256MiB - 0-255 buses. */ reg = CONFIG_MMCONF_BASE_ADDRESS | 1; /* 256MiB - 0-255 buses. */
pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_LO, reg); pci_io_write_config32(PCI_DEV(0,0,0), D0F0_PCIEXBAR_LO, reg);
/* MCFG is now active. If it's not qemu was started for machine PC */
if (CONFIG(BOOTBLOCK_CONSOLE) &&
(pci_read_config32(PCI_DEV(0, 0, 0), D0F0_PCIEXBAR_LO) !=
(CONFIG_MMCONF_BASE_ADDRESS | 1)))
die("You must run qemu for machine Q35 (-M q35)");
} }
static void enable_spi_prefetch(void) static void enable_spi_prefetch(void)

View File

@ -22,6 +22,18 @@
#include <timestamp.h> #include <timestamp.h>
#include <southbridge/intel/i82801ix/i82801ix.h> #include <southbridge/intel/i82801ix/i82801ix.h>
#include <program_loading.h> #include <program_loading.h>
#include <device/pci_ops.h>
#define D0F0_PCIEXBAR_LO 0x60
static void mainboard_machine_check(void)
{
/* Check that MCFG is active. If it's not qemu was started for machine PC */
if (!CONFIG(BOOTBLOCK_CONSOLE) &&
(pci_read_config32(PCI_DEV(0, 0, 0), D0F0_PCIEXBAR_LO) !=
(CONFIG_MMCONF_BASE_ADDRESS | 1)))
die("You must run qemu for machine Q35 (-M q35)");
}
asmlinkage void car_stage_entry(void) asmlinkage void car_stage_entry(void)
{ {
@ -29,6 +41,8 @@ asmlinkage void car_stage_entry(void)
i82801ix_early_init(); i82801ix_early_init();
console_init(); console_init();
mainboard_machine_check();
cbmem_recovery(0); cbmem_recovery(0);
timestamp_add_now(TS_START_ROMSTAGE); timestamp_add_now(TS_START_ROMSTAGE);