[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] vga: improve VGA logic
From: |
Blue Swirl |
Subject: |
[Qemu-devel] [PATCH 1/6] vga: improve VGA logic |
Date: |
Sat, 10 Dec 2011 16:44:13 +0000 |
Improve VGA selection logic, push check for device availabilty to vl.c.
Create the devices at board level unconditionally.
Remove now unused pci_try_create*() functions.
Make PCI VGA devices optional.
Signed-off-by: Blue Swirl <address@hidden>
---
hw/alpha_pci.c | 11 +++------
hw/boards.h | 1 -
hw/cirrus_vga.c | 5 ----
hw/mips_malta.c | 11 ++------
hw/mips_r4k.c | 2 +-
hw/pc.c | 13 +++-------
hw/pc.h | 16 -------------
hw/pci.c | 20 -----------------
hw/pci.h | 4 ---
hw/ppc_newworld.c | 2 +-
hw/ppc_oldworld.c | 3 +-
hw/ppc_prep.c | 2 +-
hw/qdev.c | 5 ++++
hw/qdev.h | 1 +
hw/s390-virtio.c | 1 -
hw/spapr.c | 1 -
hw/sun4u.c | 3 +-
hw/vga-pci.c | 6 -----
hw/vmware_vga.c | 1 -
hw/vmware_vga.h | 19 ----------------
vl.c | 62 ++++++++++++++++++++++++++++++++++++++--------------
21 files changed, 69 insertions(+), 120 deletions(-)
delete mode 100644 hw/vmware_vga.h
diff --git a/hw/alpha_pci.c b/hw/alpha_pci.c
index e975702..eaeacc4 100644
--- a/hw/alpha_pci.c
+++ b/hw/alpha_pci.c
@@ -10,7 +10,6 @@
#include "alpha_sys.h"
#include "qemu-log.h"
#include "sysemu.h"
-#include "vmware_vga.h"
/* PCI IO reads/writes, to byte-word addressable memory. */
@@ -118,17 +117,15 @@ void alpha_pci_vga_setup(PCIBus *pci_bus)
return;
#endif
case VGA_CIRRUS:
- pci_cirrus_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "cirrus-vga");
return;
case VGA_VMWARE:
- if (pci_vmsvga_init(pci_bus)) {
- return;
- }
- break;
+ pci_create_simple(pci_bus, -1, "vmware-svga");
+ return;
}
/* If VGA is enabled at all, and one of the above didn't work, then
fallback to Standard VGA. */
if (vga_interface_type != VGA_NONE) {
- pci_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "VGA");
}
}
diff --git a/hw/boards.h b/hw/boards.h
index 716fd7b..f6d3784 100644
--- a/hw/boards.h
+++ b/hw/boards.h
@@ -22,7 +22,6 @@ typedef struct QEMUMachine {
unsigned int no_serial:1,
no_parallel:1,
use_virtcon:1,
- no_vga:1,
no_floppy:1,
no_cdrom:1,
no_sdcard:1;
diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index c7e365b..a11444c 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -2955,11 +2955,6 @@ static int pci_cirrus_vga_initfn(PCIDevice *dev)
return 0;
}
-void pci_cirrus_vga_init(PCIBus *bus)
-{
- pci_create_simple(bus, -1, "cirrus-vga");
-}
-
static PCIDeviceInfo cirrus_vga_info = {
.qdev.name = "cirrus-vga",
.qdev.desc = "Cirrus CLGD 54xx VGA",
diff --git a/hw/mips_malta.c b/hw/mips_malta.c
index bb49749..f0ce98f 100644
--- a/hw/mips_malta.c
+++ b/hw/mips_malta.c
@@ -34,7 +34,6 @@
#include "mips_cpudevs.h"
#include "pci.h"
#include "usb-uhci.h"
-#include "vmware_vga.h"
#include "qemu-char.h"
#include "sysemu.h"
#include "arch_init.h"
@@ -978,15 +977,11 @@ void mips_malta_init (ram_addr_t ram_size,
/* Optional PCI video card */
if (cirrus_vga_enabled) {
- pci_cirrus_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "cirrus-vga");
} else if (vmsvga_enabled) {
- if (!pci_vmsvga_init(pci_bus)) {
- fprintf(stderr, "Warning: vmware_vga not available,"
- " using standard VGA instead\n");
- pci_vga_init(pci_bus);
- }
+ pci_create_simple(pci_bus, -1, "vmware-svga");
} else if (std_vga_enabled) {
- pci_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "VGA");
}
}
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index d0564d4..5f32bd9 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -274,7 +274,7 @@ void mips_r4k_init (ram_addr_t ram_size,
}
}
- isa_vga_init();
+ isa_create_simple("isa-vga");
if (nd_table[0].vlan)
isa_ne2000_init(0x300, 9, &nd_table[0]);
diff --git a/hw/pc.c b/hw/pc.c
index 33778fe..d7bf515 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -27,7 +27,6 @@
#include "fdc.h"
#include "ide.h"
#include "pci.h"
-#include "vmware_vga.h"
#include "monitor.h"
#include "fw_cfg.h"
#include "hpet_emul.h"
@@ -1073,17 +1072,13 @@ void pc_vga_init(PCIBus *pci_bus)
{
if (cirrus_vga_enabled) {
if (pci_bus) {
- pci_cirrus_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "cirrus-vga");
} else {
isa_cirrus_vga_init(get_system_memory());
}
} else if (vmsvga_enabled) {
if (pci_bus) {
- if (!pci_vmsvga_init(pci_bus)) {
- fprintf(stderr, "Warning: vmware_vga not available,"
- " using standard VGA instead\n");
- pci_vga_init(pci_bus);
- }
+ pci_create_simple(pci_bus, -1, "vmware-svga");
} else {
fprintf(stderr, "%s: vmware_vga: no PCI bus\n", __FUNCTION__);
}
@@ -1096,9 +1091,9 @@ void pc_vga_init(PCIBus *pci_bus)
#endif
} else if (std_vga_enabled) {
if (pci_bus) {
- pci_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "VGA");
} else {
- isa_vga_init();
+ isa_create_simple("isa-vga");
}
}
}
diff --git a/hw/pc.h b/hw/pc.h
index b7b7e40..77877c6 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -205,26 +205,10 @@ enum vga_retrace_method {
extern enum vga_retrace_method vga_retrace_method;
-static inline int isa_vga_init(void)
-{
- ISADevice *dev;
-
- dev = isa_try_create("isa-vga");
- if (!dev) {
- fprintf(stderr, "Warning: isa-vga not available\n");
- return 0;
- }
- qdev_init_nofail(&dev->qdev);
- return 1;
-}
-
-int pci_vga_init(PCIBus *bus);
int isa_vga_mm_init(target_phys_addr_t vram_base,
target_phys_addr_t ctrl_base, int it_shift,
MemoryRegion *address_space);
-/* cirrus_vga.c */
-void pci_cirrus_vga_init(PCIBus *bus);
void isa_cirrus_vga_init(MemoryRegion *address_space);
/* ne2000.c */
diff --git a/hw/pci.c b/hw/pci.c
index 399227f..396414a 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -1572,21 +1572,6 @@ PCIDevice *pci_create_multifunction(PCIBus
*bus, int devfn, bool multifunction,
return DO_UPCAST(PCIDevice, qdev, dev);
}
-PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
- bool multifunction,
- const char *name)
-{
- DeviceState *dev;
-
- dev = qdev_try_create(&bus->qbus, name);
- if (!dev) {
- return NULL;
- }
- qdev_prop_set_uint32(dev, "addr", devfn);
- qdev_prop_set_bit(dev, "multifunction", multifunction);
- return DO_UPCAST(PCIDevice, qdev, dev);
-}
-
PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
bool multifunction,
const char *name)
@@ -1606,11 +1591,6 @@ PCIDevice *pci_create_simple(PCIBus *bus, int
devfn, const char *name)
return pci_create_simple_multifunction(bus, devfn, false, name);
}
-PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name)
-{
- return pci_try_create_multifunction(bus, devfn, false, name);
-}
-
static int pci_find_space(PCIDevice *pdev, uint8_t size)
{
int config_size = pci_config_size(pdev);
diff --git a/hw/pci.h b/hw/pci.h
index 625e717..160ba93 100644
--- a/hw/pci.h
+++ b/hw/pci.h
@@ -469,12 +469,8 @@ PCIDevice *pci_create_multifunction(PCIBus *bus,
int devfn, bool multifunction,
PCIDevice *pci_create_simple_multifunction(PCIBus *bus, int devfn,
bool multifunction,
const char *name);
-PCIDevice *pci_try_create_multifunction(PCIBus *bus, int devfn,
- bool multifunction,
- const char *name);
PCIDevice *pci_create(PCIBus *bus, int devfn, const char *name);
PCIDevice *pci_create_simple(PCIBus *bus, int devfn, const char *name);
-PCIDevice *pci_try_create(PCIBus *bus, int devfn, const char *name);
static inline int pci_is_express(const PCIDevice *d)
{
diff --git a/hw/ppc_newworld.c b/hw/ppc_newworld.c
index 8c84f9e..7270bcc 100644
--- a/hw/ppc_newworld.c
+++ b/hw/ppc_newworld.c
@@ -319,7 +319,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
machine_arch = ARCH_MAC99;
}
/* init basic PC hardware */
- pci_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "VGA");
escc_mem = escc_init(0, pic[0x25], pic[0x24],
serial_hds[0], serial_hds[1], ESCC_CLOCK, 4);
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index aac3526..0bd5075 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -239,7 +239,8 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
pci_bus = pci_grackle_init(0xfec00000, pic,
get_system_memory(),
get_system_io());
- pci_vga_init(pci_bus);
+
+ pci_create_simple(pci_bus, -1, "VGA");
escc_mem = escc_init(0, pic[0x0f], pic[0x10], serial_hds[0],
serial_hds[1], ESCC_CLOCK, 4);
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index f22d5b9..22a2238 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -639,7 +639,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
memory_region_add_subregion(sysmem, 0x80000000, PPC_io_memory);
/* init basic PC hardware */
- pci_vga_init(pci_bus);
+ pci_create_simple(pci_bus, -1, "VGA");
// openpic = openpic_init(0x00000000, 0xF0000000, 1);
// pit = pit_init(0x40, 0);
rtc_init(2000, NULL);
diff --git a/hw/qdev.c b/hw/qdev.c
index 106407f..1a2d870 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -80,6 +80,11 @@ static DeviceInfo *qdev_find_info(BusInfo
*bus_info, const char *name)
return NULL;
}
+bool qdev_exists(const char *name)
+{
+ return !!qdev_find_info(NULL, name);
+}
+
static DeviceState *qdev_create_from_info(BusState *bus, DeviceInfo *info)
{
DeviceState *dev;
diff --git a/hw/qdev.h b/hw/qdev.h
index 36a4198..57d8997 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -123,6 +123,7 @@ typedef struct GlobalProperty {
DeviceState *qdev_create(BusState *bus, const char *name);
DeviceState *qdev_try_create(BusState *bus, const char *name);
+bool qdev_exists(const char *name);
int qdev_device_help(QemuOpts *opts);
DeviceState *qdev_device_add(QemuOpts *opts);
int qdev_init(DeviceState *dev) QEMU_WARN_UNUSED_RESULT;
diff --git a/hw/s390-virtio.c b/hw/s390-virtio.c
index 61b67e8..1c1bbf5 100644
--- a/hw/s390-virtio.c
+++ b/hw/s390-virtio.c
@@ -316,7 +316,6 @@ static QEMUMachine s390_machine = {
.no_serial = 1,
.no_parallel = 1,
.use_virtcon = 1,
- .no_vga = 1,
.max_cpus = 255,
.is_default = 1,
};
diff --git a/hw/spapr.c b/hw/spapr.c
index 2b901f1..3d15a81 100644
--- a/hw/spapr.c
+++ b/hw/spapr.c
@@ -600,7 +600,6 @@ static QEMUMachine spapr_machine = {
.desc = "pSeries Logical Partition (PAPR compliant)",
.init = ppc_spapr_init,
.max_cpus = MAX_CPUS,
- .no_vga = 1,
.no_parallel = 1,
.use_scsi = 1,
};
diff --git a/hw/sun4u.c b/hw/sun4u.c
index 97600a9..c3d1e90 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -761,7 +761,8 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
irq = qemu_allocate_irqs(cpu_set_irq, env, MAX_PILS);
pci_bus = pci_apb_init(APB_SPECIAL_BASE, APB_MEM_BASE, irq, &pci_bus2,
&pci_bus3);
- pci_vga_init(pci_bus);
+
+ pci_create_simple(pci_bus, -1, "VGA");
// XXX Should be pci_bus3
pci_ebus_init(pci_bus, -1);
diff --git a/hw/vga-pci.c b/hw/vga-pci.c
index 14bfadb..68fddd9 100644
--- a/hw/vga-pci.c
+++ b/hw/vga-pci.c
@@ -70,12 +70,6 @@ static int pci_vga_initfn(PCIDevice *dev)
return 0;
}
-int pci_vga_init(PCIBus *bus)
-{
- pci_create_simple(bus, -1, "VGA");
- return 0;
-}
-
static PCIDeviceInfo vga_info = {
.qdev.name = "VGA",
.qdev.size = sizeof(PCIVGAState),
diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c
index af70bde..bf38350 100644
--- a/hw/vmware_vga.c
+++ b/hw/vmware_vga.c
@@ -25,7 +25,6 @@
#include "loader.h"
#include "console.h"
#include "pci.h"
-#include "vmware_vga.h"
#undef VERBOSE
#define HW_RECT_ACCEL
diff --git a/hw/vmware_vga.h b/hw/vmware_vga.h
deleted file mode 100644
index 5132573..0000000
--- a/hw/vmware_vga.h
+++ /dev/null
@@ -1,19 +0,0 @@
-#ifndef QEMU_VMWARE_VGA_H
-#define QEMU_VMWARE_VGA_H
-
-#include "qemu-common.h"
-
-/* vmware_vga.c */
-static inline bool pci_vmsvga_init(PCIBus *bus)
-{
- PCIDevice *dev;
-
- dev = pci_try_create(bus, -1, "vmware-svga");
- if (!dev || qdev_init(&dev->qdev) < 0) {
- return false;
- } else {
- return true;
- }
-}
-
-#endif
diff --git a/vl.c b/vl.c
index 5372a96..bb79d6e 100644
--- a/vl.c
+++ b/vl.c
@@ -271,7 +271,6 @@ static int default_serial = 1;
static int default_parallel = 1;
static int default_virtcon = 1;
static int default_monitor = 1;
-static int default_vga = 1;
static int default_floppy = 1;
static int default_cdrom = 1;
static int default_sdcard = 1;
@@ -290,11 +289,6 @@ static struct {
{ .driver = "virtio-serial-pci", .flag = &default_virtcon },
{ .driver = "virtio-serial-s390", .flag = &default_virtcon },
{ .driver = "virtio-serial", .flag = &default_virtcon },
- { .driver = "VGA", .flag = &default_vga },
- { .driver = "cirrus-vga", .flag = &default_vga },
- { .driver = "vmware-svga", .flag = &default_vga },
- { .driver = "isa-vga", .flag = &default_vga },
- { .driver = "qxl-vga", .flag = &default_vga },
};
static void res_free(void)
@@ -1538,18 +1532,48 @@ static const QEMUOption qemu_options[] = {
#undef GEN_DOCS
{ NULL },
};
+
+static bool vga_available(void)
+{
+ return qdev_exists("VGA") || qdev_exists("isa-vga");
+}
+
+static bool cirrus_vga_available(void)
+{
+ return qdev_exists("cirrus-vga") || qdev_exists("isa-cirrus-vga");
+}
+
+static bool vmware_vga_available(void)
+{
+ return qdev_exists("vmware-svga");
+}
+
static void select_vgahw (const char *p)
{
const char *opts;
- default_vga = 0;
vga_interface_type = VGA_NONE;
if (strstart(p, "std", &opts)) {
- vga_interface_type = VGA_STD;
+ if (vga_available()) {
+ vga_interface_type = VGA_STD;
+ } else {
+ fprintf(stderr, "Error: standard VGA not available\n");
+ exit(0);
+ }
} else if (strstart(p, "cirrus", &opts)) {
- vga_interface_type = VGA_CIRRUS;
+ if (cirrus_vga_available()) {
+ vga_interface_type = VGA_CIRRUS;
+ } else {
+ fprintf(stderr, "Error: Cirrus VGA not available\n");
+ exit(0);
+ }
} else if (strstart(p, "vmware", &opts)) {
- vga_interface_type = VGA_VMWARE;
+ if (vmware_vga_available()) {
+ vga_interface_type = VGA_VMWARE;
+ } else {
+ fprintf(stderr, "Error: VMWare SVGA not available\n");
+ exit(0);
+ }
} else if (strstart(p, "xenfb", &opts)) {
vga_interface_type = VGA_XENFB;
} else if (strstart(p, "qxl", &opts)) {
@@ -2168,6 +2192,7 @@ int main(int argc, char **argv, char **envp)
const char *loadvm = NULL;
QEMUMachine *machine;
const char *cpu_model;
+ const char *vga_model = NULL;
const char *pid_file = NULL;
const char *incoming = NULL;
#ifdef CONFIG_VNC
@@ -2589,7 +2614,7 @@ int main(int argc, char **argv, char **envp)
rtc_utc = 0;
break;
case QEMU_OPTION_vga:
- select_vgahw (optarg);
+ vga_model = optarg;
break;
case QEMU_OPTION_g:
{
@@ -2982,7 +3007,6 @@ int main(int argc, char **argv, char **envp)
default_parallel = 0;
default_virtcon = 0;
default_monitor = 0;
- default_vga = 0;
default_net = 0;
default_floppy = 0;
default_cdrom = 0;
@@ -3144,9 +3168,6 @@ int main(int argc, char **argv, char **envp)
if (!machine->use_virtcon) {
default_virtcon = 0;
}
- if (machine->no_vga) {
- default_vga = 0;
- }
if (machine->no_floppy) {
default_floppy = 0;
}
@@ -3182,8 +3203,6 @@ int main(int argc, char **argv, char **envp)
if (default_virtcon)
add_device_config(DEV_VIRTCON, "vc:80Cx24C");
}
- if (default_vga)
- vga_interface_type = VGA_CIRRUS;
socket_init();
@@ -3334,6 +3353,15 @@ int main(int argc, char **argv, char **envp)
module_call_init(MODULE_INIT_DEVICE);
+ /* must be after qdev registration but before machine init */
+ if (vga_model) {
+ select_vgahw(vga_model);
+ } else if (cirrus_vga_available()) {
+ select_vgahw("cirrus");
+ } else {
+ select_vgahw("none");
+ }
+
if (qemu_opts_foreach(qemu_find_opts("device"), device_help_func,
NULL, 0) != 0)
exit(0);
--
1.7.2.5
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 1/6] vga: improve VGA logic,
Blue Swirl <=