On Wed, Feb 13, 2013 at 09:50:13AM +0000, David Woodhouse wrote:
However, if the Xen SeaBIOS image also wants some parts of CONFIG_QEMU like the fw_cfg support, then I do start to wonder if it's actually worth making that change anyway. It was a nice cleanup, with a bunch of s/if (CONFIG_QEMU && !runningOnXen())/if (CONFIG_QEMU)/ and s/if (!CONFIG_QEMU || runningOnXen())/if (!CONFIG_QEMU)/
Another way to tackle this might be to just group all the qemu and xen calls into paravirt.c. That retains runningOnXen, but it's not spread around as much. See patch below as an idea.
-Kevin
diff --git a/src/coreboot.c b/src/coreboot.c index c0c6653..0d44834 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -13,6 +13,8 @@ #include "disk.h" // MAXDESCSIZE #include "config.h" // CONFIG_* #include "acpi.h" // find_pmtimer +#include "pci.h" // pci_probe_devices +
/**************************************************************** * Memory map @@ -125,6 +127,9 @@ const char *CBvendor = "", *CBpart = ""; void coreboot_preinit(void) { + if (!CONFIG_COREBOOT) + return; + dprintf(3, "Attempting to find coreboot table\n");
// Find coreboot table. @@ -204,10 +209,14 @@ scan_tables(u32 start, u32 size) }
void -coreboot_biostable_setup(void) +coreboot_platform_setup(void) { + if (!CONFIG_COREBOOT) + return; + pci_probe_devices(); + struct cb_memory *cbm = CBMemTable; - if (! CONFIG_COREBOOT || !cbm) + if (!cbm) return;
dprintf(3, "Relocating coreboot bios tables\n"); diff --git a/src/mtrr.c b/src/mtrr.c index 0575b14..56f85f9 100644 --- a/src/mtrr.c +++ b/src/mtrr.c @@ -6,7 +6,6 @@
#include "util.h" // dprintf #include "config.h" // CONFIG_* -#include "paravirt.h" // runningOnXen #include "pci.h" // pcimem_start
#define MSR_MTRRcap 0x000000fe @@ -34,7 +33,7 @@
void mtrr_setup(void) { - if (!CONFIG_MTRR_INIT || runningOnXen()) + if (!CONFIG_MTRR_INIT) return;
u32 eax, ebx, ecx, edx, cpuid_features; diff --git a/src/paravirt.c b/src/paravirt.c index aa4a421..f76b47f 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -19,6 +19,7 @@ #include "acpi.h" // acpi_setup #include "mptable.h" // mptable_setup #include "pci.h" // create_pirtable +#include "xen.h" // xen_biostable_setup
/* This CPUID returns the signature 'KVMKVMKVM' in ebx, ecx, and edx. It * should be used to determine that a VM is running under KVM. @@ -45,11 +46,16 @@ static void kvm_preinit(void) }
void -qemu_ramsize_preinit(void) +qemu_preinit(void) { if (!CONFIG_QEMU) return;
+ if (runningOnXen()) { + xen_ramsize_preinit(); + return; + } + PlatformRunningOn = PF_QEMU; kvm_preinit();
@@ -77,8 +83,27 @@ qemu_ramsize_preinit(void) }
void -qemu_biostable_setup(void) +qemu_platform_setup(void) { + if (!CONFIG_QEMU) + return; + + if (runningOnXen()) { + pci_probe_devices(); + xen_hypercall_setup(); + xen_biostable_setup(); + return; + } + + // Initialize pci + pci_setup(); + smm_setup(); + + // Initialize mtrr and smp + mtrr_setup(); + smp_setup(); + + // Create bios tables pirtable_setup(); mptable_setup(); smbios_setup(); diff --git a/src/paravirt.h b/src/paravirt.h index 4438273..96b35ba 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -23,8 +23,8 @@ static inline int runningOnKVM(void) { return CONFIG_QEMU && GET_GLOBAL(PlatformRunningOn) & PF_KVM; }
-void qemu_ramsize_preinit(void); -void qemu_biostable_setup(void); +void qemu_preinit(void); +void qemu_platform_setup(void); void qemu_cfg_init(void);
#endif diff --git a/src/pciinit.c b/src/pciinit.c index 1d34653..d757ab6 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -11,7 +11,6 @@ #include "pci_regs.h" // PCI_COMMAND #include "ioport.h" // PORT_ATA1_CMD_BASE #include "config.h" // CONFIG_* -#include "paravirt.h" // runningOnXen #include "memmap.h" // add_e820 #include "dev-q35.h"
@@ -734,11 +733,8 @@ static void pci_bios_map_devices(struct pci_bus *busses) void pci_setup(void) { - if (!CONFIG_QEMU || runningOnXen()) { - // PCI setup already done by coreboot or Xen - just do probe. - pci_probe_devices(); + if (!CONFIG_QEMU) return; - }
dprintf(3, "pci setup\n");
diff --git a/src/post.c b/src/post.c index 3af3638..f2eded9 100644 --- a/src/post.c +++ b/src/post.c @@ -159,24 +159,9 @@ platform_hardware_setup(void) mathcp_setup(); timer_setup();
- // Initialize pci - pci_setup(); - smm_setup(); - - // Initialize mtrr and smp - mtrr_setup(); - smp_setup(); - - // Setup Xen hypercalls - xen_hypercall_setup(); - - // Setup external BIOS interface tables - if (CONFIG_COREBOOT) - coreboot_biostable_setup(); - else if (runningOnXen()) - xen_biostable_setup(); - else - qemu_biostable_setup(); + // Platform specific setup + qemu_platform_setup(); + coreboot_platform_setup(); }
void @@ -314,12 +299,8 @@ void VISIBLE32INIT dopost(void) { // Detect ram and setup internal malloc. - if (CONFIG_COREBOOT) - coreboot_preinit(); - else if (runningOnXen()) - xen_ramsize_preinit(); - else - qemu_ramsize_preinit(); + qemu_preinit(); + coreboot_preinit(); malloc_preinit();
// Relocate initialization code and call maininit(). diff --git a/src/smm.c b/src/smm.c index 4128296..490a626 100644 --- a/src/smm.c +++ b/src/smm.c @@ -10,7 +10,6 @@ #include "config.h" // CONFIG_* #include "ioport.h" // outb #include "pci_ids.h" // PCI_VENDOR_ID_INTEL -#include "paravirt.h" // runningOnXen #include "dev-q35.h"
ASM32FLAT( @@ -184,7 +183,7 @@ static const struct pci_device_id smm_init_tbl[] = { void smm_setup(void) { - if (!CONFIG_USE_SMM || runningOnXen()) + if (!CONFIG_USE_SMM) return;
dprintf(3, "init smm\n"); diff --git a/src/util.h b/src/util.h index 0659d24..8875d95 100644 --- a/src/util.h +++ b/src/util.h @@ -327,7 +327,7 @@ int apic_id_is_present(u8 apic_id); extern const char *CBvendor, *CBpart; struct cbfs_file; void cbfs_run_payload(struct cbfs_file *file); -void coreboot_biostable_setup(void); +void coreboot_platform_setup(void); void cbfs_payload_setup(void); void coreboot_preinit(void); void coreboot_cbfs_init(void);