diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2013-02-07 23:32:48 -0500 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2013-02-12 21:03:37 -0500 |
commit | 897fb1133054e9f1e02931ad782223f40485837e (patch) | |
tree | a7edc7ab19a7a96d41593807111ebb417e9346c5 /src | |
parent | 02313b205b0a461579c2799e31dc3f898c0b63ae (diff) | |
download | seabios-897fb1133054e9f1e02931ad782223f40485837e.tar.gz |
Consistently use CONFIG_COREBOOT, CONFIG_QEMU, and runningOnXen().
CONFIG_QEMU means compile to start from QEMU (and possibly
Xen/KVM/Bochs) and definitely running under QEMU (or Xen/KVM/Bochs).
CONFIG_COREBOOT means compile for coreboot and definitely running
under coreboot. Places that used CONFIG_COREBOOT to mean "running on
real hardware" have been changed to use !CONFIG_QEMU.
CONFIG_QEMU_HARDWARE enables support for some virtual hardware devices
even if QEMU didn't start SeaBIOS.
usingXen() is replaced by runningOnXen().
runningOnQEMU() is added to hardware devices that are only safe to
access when we are sure we are running under QEMU (or Xen/KVM/Bochs).
Neither the coreboot nor the csm code currently enable runningOnQEMU,
but future patches may.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/Kconfig | 8 | ||||
-rw-r--r-- | src/apm.c | 3 | ||||
-rw-r--r-- | src/ata.c | 2 | ||||
-rw-r--r-- | src/block.c | 2 | ||||
-rw-r--r-- | src/blockcmd.c | 2 | ||||
-rw-r--r-- | src/boot.c | 4 | ||||
-rw-r--r-- | src/coreboot.c | 8 | ||||
-rw-r--r-- | src/esp-scsi.c | 3 | ||||
-rw-r--r-- | src/floppy.c | 14 | ||||
-rw-r--r-- | src/lsi-scsi.c | 3 | ||||
-rw-r--r-- | src/mtrr.c | 4 | ||||
-rw-r--r-- | src/optionroms.c | 2 | ||||
-rw-r--r-- | src/paravirt.c | 6 | ||||
-rw-r--r-- | src/paravirt.h | 2 | ||||
-rw-r--r-- | src/pciinit.c | 4 | ||||
-rw-r--r-- | src/post.c | 4 | ||||
-rw-r--r-- | src/ramdisk.c | 2 | ||||
-rw-r--r-- | src/resume.c | 6 | ||||
-rw-r--r-- | src/shadow.c | 12 | ||||
-rw-r--r-- | src/smm.c | 9 | ||||
-rw-r--r-- | src/smp.c | 8 | ||||
-rw-r--r-- | src/virtio-blk.c | 4 | ||||
-rw-r--r-- | src/virtio-scsi.c | 2 | ||||
-rw-r--r-- | src/xen.c | 2 | ||||
-rw-r--r-- | src/xen.h | 11 |
25 files changed, 57 insertions, 70 deletions
diff --git a/src/Kconfig b/src/Kconfig index c125e004..cdd4f314 100644 --- a/src/Kconfig +++ b/src/Kconfig @@ -132,25 +132,25 @@ menu "Hardware support" help Support for AHCI disk code. config VIRTIO_BLK - depends on DRIVES && QEMU + depends on DRIVES && QEMU_HARDWARE bool "virtio-blk controllers" default y help Support boot from virtio-blk storage. config VIRTIO_SCSI - depends on DRIVES && QEMU + depends on DRIVES && QEMU_HARDWARE bool "virtio-scsi controllers" default y help Support boot from virtio-scsi storage. config ESP_SCSI - depends on DRIVES && QEMU + depends on DRIVES && QEMU_HARDWARE bool "AMD PCscsi controllers" default y help Support boot from AMD PCscsi storage. config LSI_SCSI - depends on DRIVES && QEMU + depends on DRIVES && QEMU_HARDWARE bool "lsi53c895a scsi controllers" default y help @@ -11,11 +11,12 @@ #include "util.h" // dprintf #include "config.h" // CONFIG_* #include "biosvar.h" // GET_GLOBAL +#include "paravirt.h" // runningOnQEMU static void out_str(const char *str_cs) { - if (CONFIG_COREBOOT) { + if (!runningOnQEMU()) { dprintf(1, "APM request '%s'\n", str_cs); return; } @@ -1008,7 +1008,7 @@ static const struct pci_device_id pci_ata_tbl[] = { static void ata_scan(void) { - if (!CONFIG_COREBOOT && !PCIDevices) { + if (CONFIG_QEMU && !PCIDevices) { // No PCI devices found - probably a QEMU "-M isapc" machine. // Try using ISA ports for ATA controllers. init_controller(NULL, IRQ_ATA1 diff --git a/src/block.c b/src/block.c index e5f3038f..c202f5ae 100644 --- a/src/block.c +++ b/src/block.c @@ -62,7 +62,7 @@ static u8 get_translation(struct drive_s *drive_g) { u8 type = GET_GLOBAL(drive_g->type); - if (! CONFIG_COREBOOT && type == DTYPE_ATA) { + if (CONFIG_QEMU && type == DTYPE_ATA) { // Emulators pass in the translation info via nvram. u8 ataid = GET_GLOBAL(drive_g->cntl_id); u8 channel = ataid / 2; diff --git a/src/blockcmd.c b/src/blockcmd.c index e033ba77..c3e4b589 100644 --- a/src/blockcmd.c +++ b/src/blockcmd.c @@ -165,7 +165,7 @@ scsi_drive_setup(struct drive_s *drive, const char *s, int prio) // but some old USB keys only support a very small subset of SCSI which // does not even include the MODE SENSE command! // - if (! CONFIG_COREBOOT && memcmp(vendor, "QEMU", 5) == 0) { + if (CONFIG_QEMU_HARDWARE && memcmp(vendor, "QEMU", 5) == 0) { struct cdbres_mode_sense_geom geomdata; ret = cdb_mode_sense_geom(&dop, &geomdata); if (ret == 0) { @@ -250,7 +250,7 @@ boot_init(void) if (! CONFIG_BOOT) return; - if (!CONFIG_COREBOOT) { + if (CONFIG_QEMU) { // On emulators, get boot order from nvram. if (inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1) CheckFloppySig = 0; @@ -609,7 +609,7 @@ boot_cdrom(struct drive_s *drive_g) static void boot_cbfs(struct cbfs_file *file) { - if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH) + if (!CONFIG_COREBOOT_FLASH) return; printf("Booting from CBFS...\n"); cbfs_run_payload(file); diff --git a/src/coreboot.c b/src/coreboot.c index 5d013cfc..5d5e03b0 100644 --- a/src/coreboot.c +++ b/src/coreboot.c @@ -294,7 +294,7 @@ struct cbfs_file { static int cbfs_copyfile(struct romfile_s *file, void *dst, u32 maxlen) { - if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH) + if (!CONFIG_COREBOOT_FLASH) return -1; u32 size = file->rawsize; @@ -326,7 +326,7 @@ cbfs_copyfile(struct romfile_s *file, void *dst, u32 maxlen) void coreboot_cbfs_init(void) { - if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH) + if (!CONFIG_COREBOOT_FLASH) return; struct cbfs_header *hdr = *(void **)CBFS_HEADPTR_ADDR; @@ -392,7 +392,7 @@ struct cbfs_payload { void cbfs_run_payload(struct cbfs_file *file) { - if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH || !file) + if (!CONFIG_COREBOOT_FLASH || !file) return; dprintf(1, "Run %s\n", file->filename); struct cbfs_payload *pay = (void*)file + be32_to_cpu(file->offset); @@ -443,7 +443,7 @@ cbfs_run_payload(struct cbfs_file *file) void cbfs_payload_setup(void) { - if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH) + if (!CONFIG_COREBOOT_FLASH) return; struct romfile_s *file = NULL; for (;;) { diff --git a/src/esp-scsi.c b/src/esp-scsi.c index 4d1f7d23..fe703669 100644 --- a/src/esp-scsi.c +++ b/src/esp-scsi.c @@ -18,6 +18,7 @@ #include "pci_regs.h" // PCI_VENDOR_ID #include "boot.h" // bootprio_find_scsi_device #include "blockcmd.h" // scsi_drive_setup +#include "paravirt.h" // runningOnQEMU #include "disk.h" #define ESP_TCLO 0x00 @@ -218,7 +219,7 @@ void esp_scsi_setup(void) { ASSERT32FLAT(); - if (!CONFIG_ESP_SCSI) + if (!CONFIG_ESP_SCSI || !runningOnQEMU()) return; dprintf(3, "init esp\n"); diff --git a/src/floppy.c b/src/floppy.c index e9f89167..2887e78a 100644 --- a/src/floppy.c +++ b/src/floppy.c @@ -125,19 +125,19 @@ floppy_setup(void) return; dprintf(3, "init floppy drives\n"); - if (CONFIG_COREBOOT) { + if (CONFIG_QEMU) { + u8 type = inb_cmos(CMOS_FLOPPY_DRIVE_TYPE); + if (type & 0xf0) + addFloppy(0, type >> 4); + if (type & 0x0f) + addFloppy(1, type & 0x0f); + } else { u8 type = romfile_loadint("etc/floppy0", 0); if (type) addFloppy(0, type); type = romfile_loadint("etc/floppy1", 0); if (type) addFloppy(1, type); - } else { - u8 type = inb_cmos(CMOS_FLOPPY_DRIVE_TYPE); - if (type & 0xf0) - addFloppy(0, type >> 4); - if (type & 0x0f) - addFloppy(1, type & 0x0f); } outb(0x02, PORT_DMA1_MASK_REG); diff --git a/src/lsi-scsi.c b/src/lsi-scsi.c index 76e9d1d7..305610a5 100644 --- a/src/lsi-scsi.c +++ b/src/lsi-scsi.c @@ -18,6 +18,7 @@ #include "pci_regs.h" // PCI_VENDOR_ID #include "boot.h" // bootprio_find_scsi_device #include "blockcmd.h" // scsi_drive_setup +#include "paravirt.h" // runningOnQEMU #include "disk.h" #define LSI_REG_DSTAT 0x0c @@ -197,7 +198,7 @@ void lsi_scsi_setup(void) { ASSERT32FLAT(); - if (!CONFIG_LSI_SCSI) + if (!CONFIG_LSI_SCSI || !runningOnQEMU()) return; dprintf(3, "init lsi53c895a\n"); @@ -6,7 +6,7 @@ #include "util.h" // dprintf #include "config.h" // CONFIG_* -#include "xen.h" // usingXen +#include "paravirt.h" // runningOnXen #include "pci.h" // pcimem_start #define MSR_MTRRcap 0x000000fe @@ -34,7 +34,7 @@ void mtrr_setup(void) { - if (!CONFIG_MTRR_INIT || CONFIG_COREBOOT || usingXen()) + if (!CONFIG_MTRR_INIT || runningOnXen()) return; u32 eax, ebx, ecx, edx, cpuid_features; diff --git a/src/optionroms.c b/src/optionroms.c index c9e7d7bb..971b9d68 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -425,7 +425,7 @@ vgarom_setup(void) // Load some config settings that impact VGA. EnforceChecksum = romfile_loadint("etc/optionroms-checksum", 1); - S3ResumeVga = romfile_loadint("etc/s3-resume-vga-init", !CONFIG_COREBOOT); + S3ResumeVga = romfile_loadint("etc/s3-resume-vga-init", CONFIG_QEMU); ScreenAndDebug = romfile_loadint("etc/screen-and-debug", 1); if (CONFIG_OPTIONROMS_DEPLOYED) { diff --git a/src/paravirt.c b/src/paravirt.c index 6e230ee9..73b06ca0 100644 --- a/src/paravirt.c +++ b/src/paravirt.c @@ -7,7 +7,7 @@ // // This file may be distributed under the terms of the GNU LGPLv3 license. -#include "config.h" // CONFIG_COREBOOT +#include "config.h" // CONFIG_QEMU #include "util.h" // dprintf #include "byteorder.h" // be32_to_cpu #include "ioport.h" // outw @@ -108,7 +108,7 @@ void qemu_cfg_preinit(void) char *sig = "QEMU"; int i; - if (CONFIG_COREBOOT) + if (!CONFIG_QEMU) return; qemu_cfg_present = 1; @@ -384,7 +384,7 @@ struct QemuCfgFile { void qemu_romfile_init(void) { - if (CONFIG_COREBOOT || !qemu_cfg_present) + if (!CONFIG_QEMU || !qemu_cfg_present) return; u32 count; diff --git a/src/paravirt.h b/src/paravirt.h index d32ca13d..62b1664e 100644 --- a/src/paravirt.h +++ b/src/paravirt.h @@ -27,7 +27,7 @@ static inline int runningOnXen(void) { static inline int kvm_para_available(void) { - if (CONFIG_COREBOOT) + if (!CONFIG_QEMU) return 0; unsigned int eax, ebx, ecx, edx; char signature[13]; diff --git a/src/pciinit.c b/src/pciinit.c index 34b47b64..1d34653b 100644 --- a/src/pciinit.c +++ b/src/pciinit.c @@ -11,7 +11,7 @@ #include "pci_regs.h" // PCI_COMMAND #include "ioport.h" // PORT_ATA1_CMD_BASE #include "config.h" // CONFIG_* -#include "xen.h" // usingXen +#include "paravirt.h" // runningOnXen #include "memmap.h" // add_e820 #include "dev-q35.h" @@ -734,7 +734,7 @@ static void pci_bios_map_devices(struct pci_bus *busses) void pci_setup(void) { - if (CONFIG_COREBOOT || usingXen()) { + if (!CONFIG_QEMU || runningOnXen()) { // PCI setup already done by coreboot or Xen - just do probe. pci_probe_devices(); return; @@ -179,7 +179,7 @@ platform_hardware_setup(void) // Setup external BIOS interface tables if (CONFIG_COREBOOT) coreboot_biostable_setup(); - else if (usingXen()) + else if (runningOnXen()) xen_biostable_setup(); else qemu_biostable_setup(); @@ -319,7 +319,7 @@ dopost(void) qemu_cfg_preinit(); if (CONFIG_COREBOOT) coreboot_preinit(); - else if (usingXen()) + else if (runningOnXen()) xen_ramsize_preinit(); else qemu_ramsize_preinit(); diff --git a/src/ramdisk.c b/src/ramdisk.c index 9249a497..b9da2ad3 100644 --- a/src/ramdisk.c +++ b/src/ramdisk.c @@ -88,7 +88,7 @@ ramdisk_copy(struct disk_op_s *op, int iswrite) int process_ramdisk_op(struct disk_op_s *op) { - if (!CONFIG_COREBOOT || !CONFIG_COREBOOT_FLASH || !CONFIG_FLASH_FLOPPY) + if (!CONFIG_FLASH_FLOPPY) return 0; switch (op->command) { diff --git a/src/resume.c b/src/resume.c index ffc84fca..adc35940 100644 --- a/src/resume.c +++ b/src/resume.c @@ -130,11 +130,7 @@ tryReboot(void) dprintf(1, "Attempting a hard reboot\n"); // Setup for reset on qemu. - if (! CONFIG_COREBOOT) { - qemu_prep_reset(); - if (HaveRunPost) - apm_shutdown(); - } + qemu_prep_reset(); // Try keyboard controller reboot. i8042_reboot(); diff --git a/src/shadow.c b/src/shadow.c index a2195da2..c9e8165d 100644 --- a/src/shadow.c +++ b/src/shadow.c @@ -10,7 +10,7 @@ #include "config.h" // CONFIG_* #include "pci_ids.h" // PCI_VENDOR_ID_INTEL #include "pci_regs.h" // PCI_VENDOR_ID -#include "xen.h" // usingXen +#include "paravirt.h" // runningOnXen #include "dev-q35.h" // PCI_VENDOR_ID_INTEL // On the emulators, the bios at 0xf0000 is also at 0xffff0000 @@ -119,7 +119,7 @@ static const struct pci_device_id dram_controller_make_readonly_tbl[] = { void make_bios_writable(void) { - if (CONFIG_COREBOOT || usingXen()) + if (!CONFIG_QEMU || runningOnXen()) return; dprintf(3, "enabling shadow ram\n"); @@ -148,7 +148,7 @@ make_bios_writable(void) void make_bios_readonly(void) { - if (CONFIG_COREBOOT || usingXen()) + if (!CONFIG_QEMU || runningOnXen()) return; dprintf(3, "locking shadow ram\n"); @@ -161,7 +161,7 @@ make_bios_readonly(void) void qemu_prep_reset(void) { - if (CONFIG_COREBOOT) + if (!CONFIG_QEMU || runningOnXen()) return; // QEMU doesn't map 0xc0000-0xfffff back to the original rom on a // reset, so do that manually before invoking a hard reset. @@ -169,4 +169,8 @@ qemu_prep_reset(void) extern u8 code32flat_start[], code32flat_end[]; memcpy(code32flat_start, code32flat_start + BIOS_SRC_OFFSET , code32flat_end - code32flat_start); + + if (HaveRunPost) + // Memory copy failed to work - try to halt the machine. + apm_shutdown(); } @@ -10,7 +10,7 @@ #include "config.h" // CONFIG_* #include "ioport.h" // outb #include "pci_ids.h" // PCI_VENDOR_ID_INTEL -#include "xen.h" // usingXen +#include "paravirt.h" // runningOnXen #include "dev-q35.h" ASM32FLAT( @@ -184,12 +184,7 @@ static const struct pci_device_id smm_init_tbl[] = { void smm_setup(void) { - if (CONFIG_COREBOOT) - // SMM only supported on emulators. - return; - if (!CONFIG_USE_SMM) - return; - if (usingXen()) + if (!CONFIG_USE_SMM || runningOnXen()) return; dprintf(3, "init smm\n"); @@ -113,7 +113,7 @@ smp_setup(void) u32 val = readl(APIC_SVR); writel(APIC_SVR, val | APIC_ENABLED); - if (! CONFIG_COREBOOT) { + if (CONFIG_QEMU) { /* Set LINT0 as Ext_INT, level triggered */ writel(APIC_LINT0, 0x8700); @@ -128,12 +128,12 @@ smp_setup(void) writel(APIC_ICR_LOW, 0x000C4600 | sipi_vector); // Wait for other CPUs to process the SIPI. - if (CONFIG_COREBOOT) { - msleep(10); - } else { + if (CONFIG_QEMU) { u8 cmos_smp_count = inb_cmos(CMOS_BIOS_SMP_COUNT); while (cmos_smp_count + 1 != readl(&CountCPUs)) yield(); + } else { + msleep(10); } // Restore memory. diff --git a/src/virtio-blk.c b/src/virtio-blk.c index 194deaf9..6c0cd74b 100644 --- a/src/virtio-blk.c +++ b/src/virtio-blk.c @@ -77,7 +77,7 @@ virtio_blk_op(struct disk_op_s *op, int write) int process_virtio_blk_op(struct disk_op_s *op) { - if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT) + if (! CONFIG_VIRTIO_BLK) return 0; switch (op->command) { case CMD_READ: @@ -159,7 +159,7 @@ void virtio_blk_setup(void) { ASSERT32FLAT(); - if (! CONFIG_VIRTIO_BLK || CONFIG_COREBOOT) + if (! CONFIG_VIRTIO_BLK) return; dprintf(3, "init virtio-blk\n"); diff --git a/src/virtio-scsi.c b/src/virtio-scsi.c index 4bbff8f4..879ddfb9 100644 --- a/src/virtio-scsi.c +++ b/src/virtio-scsi.c @@ -166,7 +166,7 @@ void virtio_scsi_setup(void) { ASSERT32FLAT(); - if (! CONFIG_VIRTIO_SCSI || CONFIG_COREBOOT) + if (! CONFIG_VIRTIO_SCSI) return; dprintf(3, "init virtio-scsi\n"); @@ -95,7 +95,7 @@ void xen_hypercall_setup(void) xen_extraversion_t extraversion; unsigned long i; - if (!usingXen()) + if (!runningOnXen()) return; cpuid(xen_cpuid_base + 2, &eax, &ebx, &ecx, &edx); @@ -1,22 +1,11 @@ #ifndef __XEN_H #define __XEN_H -#include "config.h" // CONFIG_* -#include "types.h" // u32 - -extern u32 xen_cpuid_base; - void xen_preinit(void); void xen_ramsize_preinit(void); void xen_hypercall_setup(void); void xen_biostable_setup(void); -static inline int usingXen(void) { - if (!CONFIG_XEN) - return 0; - return (xen_cpuid_base != 0); -} - extern unsigned long xen_hypercall_page; #define _hypercall0(type, name) \ |