aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Kconfig8
-rw-r--r--src/apm.c3
-rw-r--r--src/ata.c2
-rw-r--r--src/block.c2
-rw-r--r--src/blockcmd.c2
-rw-r--r--src/boot.c4
-rw-r--r--src/coreboot.c8
-rw-r--r--src/esp-scsi.c3
-rw-r--r--src/floppy.c14
-rw-r--r--src/lsi-scsi.c3
-rw-r--r--src/mtrr.c4
-rw-r--r--src/optionroms.c2
-rw-r--r--src/paravirt.c6
-rw-r--r--src/paravirt.h2
-rw-r--r--src/pciinit.c4
-rw-r--r--src/post.c4
-rw-r--r--src/ramdisk.c2
-rw-r--r--src/resume.c6
-rw-r--r--src/shadow.c12
-rw-r--r--src/smm.c9
-rw-r--r--src/smp.c8
-rw-r--r--src/virtio-blk.c4
-rw-r--r--src/virtio-scsi.c2
-rw-r--r--src/xen.c2
-rw-r--r--src/xen.h11
25 files changed, 57 insertions, 70 deletions
diff --git a/src/Kconfig b/src/Kconfig
index c125e00..cdd4f31 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
diff --git a/src/apm.c b/src/apm.c
index 8daf958..b2eac6d 100644
--- a/src/apm.c
+++ b/src/apm.c
@@ -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;
}
diff --git a/src/ata.c b/src/ata.c
index d1d8dff..59ae765 100644
--- a/src/ata.c
+++ b/src/ata.c
@@ -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 e5f3038..c202f5a 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 e033ba7..c3e4b58 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) {
diff --git a/src/boot.c b/src/boot.c
index 85d5051..f70e402 100644
--- a/src/boot.c
+++ b/src/boot.c
@@ -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 5d013cf..5d5e03b 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 4d1f7d2..fe70366 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 e9f8916..2887e78 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 76e9d1d..305610a 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");
diff --git a/src/mtrr.c b/src/mtrr.c
index 2cbf234..0575b14 100644
--- a/src/mtrr.c
+++ b/src/mtrr.c
@@ -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 c9e7d7b..971b9d6 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 6e230ee..73b06ca 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 d32ca13..62b1664 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 34b47b6..1d34653 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;
diff --git a/src/post.c b/src/post.c
index 6c4ff70..2c5e34e 100644
--- a/src/post.c
+++ b/src/post.c
@@ -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 9249a49..b9da2ad 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 ffc84fc..adc3594 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 a2195da..c9e8165 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();
}
diff --git a/src/smm.c b/src/smm.c
index c69f0fd..4128296 100644
--- a/src/smm.c
+++ b/src/smm.c
@@ -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");
diff --git a/src/smp.c b/src/smp.c
index 18bb05f..394dc4b 100644
--- a/src/smp.c
+++ b/src/smp.c
@@ -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 194deaf..6c0cd74 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 4bbff8f..879ddfb 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");
diff --git a/src/xen.c b/src/xen.c
index e075af2..32edcd1 100644
--- a/src/xen.c
+++ b/src/xen.c
@@ -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);
diff --git a/src/xen.h b/src/xen.h
index 9b4178a..f00f840 100644
--- a/src/xen.h
+++ b/src/xen.h
@@ -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) \