aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2015-05-19 11:47:03 +0100
committerPeter Maydell <peter.maydell@linaro.org>2015-05-19 11:47:03 +0100
commitfdbe454a242105fcfe48b9c44b5499b80ff84160 (patch)
tree0527031f718bf7290bdcd25b37b10079f007ff17
parentfaa261a7fb254866bdd5b6a25ad94677945f21b4 (diff)
parent176c324febd76d6f164347583f5af35b3cb4e5fb (diff)
Merge remote-tracking branch 'remotes/kraxel/tags/pull-vga-20150519-1' into staging
hw/display: qomify vga cards # gpg: Signature made Tue May 19 11:23:09 2015 BST using RSA key ID D3E87138 # gpg: Good signature from "Gerd Hoffmann (work) <kraxel@redhat.com>" # gpg: aka "Gerd Hoffmann <gerd@kraxel.org>" # gpg: aka "Gerd Hoffmann (private) <kraxel@gmail.com>" * remotes/kraxel/tags/pull-vga-20150519-1: vga-pci: QOMify qxl: QOMify cirrus_vga: QOMify Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
-rw-r--r--hw/display/cirrus_vga.c8
-rw-r--r--hw/display/qxl.c44
-rw-r--r--hw/display/qxl.h3
-rw-r--r--hw/display/vga-pci.c48
4 files changed, 65 insertions, 38 deletions
diff --git a/hw/display/cirrus_vga.c b/hw/display/cirrus_vga.c
index 8765a7e1d0..5198037d82 100644
--- a/hw/display/cirrus_vga.c
+++ b/hw/display/cirrus_vga.c
@@ -235,6 +235,10 @@ typedef struct PCICirrusVGAState {
CirrusVGAState cirrus_vga;
} PCICirrusVGAState;
+#define TYPE_PCI_CIRRUS_VGA "cirrus-vga"
+#define PCI_CIRRUS_VGA(obj) \
+ OBJECT_CHECK(PCICirrusVGAState, (obj), TYPE_PCI_CIRRUS_VGA)
+
#define TYPE_ISA_CIRRUS_VGA "isa-cirrus-vga"
#define ISA_CIRRUS_VGA(obj) \
OBJECT_CHECK(ISACirrusVGAState, (obj), TYPE_ISA_CIRRUS_VGA)
@@ -3008,7 +3012,7 @@ static const TypeInfo isa_cirrus_vga_info = {
static void pci_cirrus_vga_realize(PCIDevice *dev, Error **errp)
{
- PCICirrusVGAState *d = DO_UPCAST(PCICirrusVGAState, dev, dev);
+ PCICirrusVGAState *d = PCI_CIRRUS_VGA(dev);
CirrusVGAState *s = &d->cirrus_vga;
PCIDeviceClass *pc = PCI_DEVICE_GET_CLASS(dev);
int16_t device_id = pc->device_id;
@@ -3070,7 +3074,7 @@ static void cirrus_vga_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo cirrus_vga_info = {
- .name = "cirrus-vga",
+ .name = TYPE_PCI_CIRRUS_VGA,
.parent = TYPE_PCI_DEVICE,
.instance_size = sizeof(PCICirrusVGAState),
.class_init = cirrus_vga_class_init,
diff --git a/hw/display/qxl.c b/hw/display/qxl.c
index 0cd314c931..8f40dfb8ac 100644
--- a/hw/display/qxl.c
+++ b/hw/display/qxl.c
@@ -1181,7 +1181,7 @@ static void qxl_hard_reset(PCIQXLDevice *d, int loadvm)
static void qxl_reset_handler(DeviceState *dev)
{
- PCIQXLDevice *d = DO_UPCAST(PCIQXLDevice, pci.qdev, dev);
+ PCIQXLDevice *d = PCI_QXL(PCI_DEVICE(dev));
qxl_hard_reset(d, 0);
}
@@ -2026,7 +2026,7 @@ static void qxl_realize_common(PCIQXLDevice *qxl, Error **errp)
static void qxl_realize_primary(PCIDevice *dev, Error **errp)
{
- PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
+ PCIQXLDevice *qxl = PCI_QXL(dev);
VGACommonState *vga = &qxl->vga;
Error *local_err = NULL;
@@ -2059,7 +2059,7 @@ static void qxl_realize_primary(PCIDevice *dev, Error **errp)
static void qxl_realize_secondary(PCIDevice *dev, Error **errp)
{
static int device_id = 1;
- PCIQXLDevice *qxl = DO_UPCAST(PCIQXLDevice, pci, dev);
+ PCIQXLDevice *qxl = PCI_QXL(dev);
qxl->id = device_id++;
qxl_init_ramsize(qxl);
@@ -2277,28 +2277,42 @@ static Property qxl_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
-static void qxl_primary_class_init(ObjectClass *klass, void *data)
+static void qxl_pci_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
- k->realize = qxl_realize_primary;
- k->romfile = "vgabios-qxl.bin";
k->vendor_id = REDHAT_PCI_VENDOR_ID;
k->device_id = QXL_DEVICE_ID_STABLE;
- k->class_id = PCI_CLASS_DISPLAY_VGA;
set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
- dc->desc = "Spice QXL GPU (primary, vga compatible)";
dc->reset = qxl_reset_handler;
dc->vmsd = &qxl_vmstate;
dc->props = qxl_properties;
+}
+
+static const TypeInfo qxl_pci_type_info = {
+ .name = TYPE_PCI_QXL,
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PCIQXLDevice),
+ .abstract = true,
+ .class_init = qxl_pci_class_init,
+};
+
+static void qxl_primary_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->realize = qxl_realize_primary;
+ k->romfile = "vgabios-qxl.bin";
+ k->class_id = PCI_CLASS_DISPLAY_VGA;
+ dc->desc = "Spice QXL GPU (primary, vga compatible)";
dc->hotpluggable = false;
}
static const TypeInfo qxl_primary_info = {
.name = "qxl-vga",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PCIQXLDevice),
+ .parent = TYPE_PCI_QXL,
.class_init = qxl_primary_class_init,
};
@@ -2308,25 +2322,19 @@ static void qxl_secondary_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->realize = qxl_realize_secondary;
- k->vendor_id = REDHAT_PCI_VENDOR_ID;
- k->device_id = QXL_DEVICE_ID_STABLE;
k->class_id = PCI_CLASS_DISPLAY_OTHER;
- set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
dc->desc = "Spice QXL GPU (secondary)";
- dc->reset = qxl_reset_handler;
- dc->vmsd = &qxl_vmstate;
- dc->props = qxl_properties;
}
static const TypeInfo qxl_secondary_info = {
.name = "qxl",
- .parent = TYPE_PCI_DEVICE,
- .instance_size = sizeof(PCIQXLDevice),
+ .parent = TYPE_PCI_QXL,
.class_init = qxl_secondary_class_init,
};
static void qxl_register_types(void)
{
+ type_register_static(&qxl_pci_type_info);
type_register_static(&qxl_primary_info);
type_register_static(&qxl_secondary_info);
}
diff --git a/hw/display/qxl.h b/hw/display/qxl.h
index 412e346b68..deddd54d2f 100644
--- a/hw/display/qxl.h
+++ b/hw/display/qxl.h
@@ -122,6 +122,9 @@ typedef struct PCIQXLDevice {
QEMUBH *update_area_bh;
} PCIQXLDevice;
+#define TYPE_PCI_QXL "pci-qxl"
+#define PCI_QXL(obj) OBJECT_CHECK(PCIQXLDevice, (obj), TYPE_PCI_QXL)
+
#define PANIC_ON(x) if ((x)) { \
printf("%s: PANIC %s failed\n", __FUNCTION__, #x); \
abort(); \
diff --git a/hw/display/vga-pci.c b/hw/display/vga-pci.c
index aabfc23cd9..ff5dfb2c23 100644
--- a/hw/display/vga-pci.c
+++ b/hw/display/vga-pci.c
@@ -59,6 +59,9 @@ typedef struct PCIVGAState {
MemoryRegion qext;
} PCIVGAState;
+#define TYPE_PCI_VGA "pci-vga"
+#define PCI_VGA(obj) OBJECT_CHECK(PCIVGAState, (obj), TYPE_PCI_VGA)
+
static const VMStateDescription vmstate_vga_pci = {
.name = "vga",
.version_id = 2,
@@ -183,14 +186,14 @@ static void pci_vga_qext_write(void *ptr, hwaddr addr,
static bool vga_get_big_endian_fb(Object *obj, Error **errp)
{
- PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, PCI_DEVICE(obj));
+ PCIVGAState *d = PCI_VGA(PCI_DEVICE(obj));
return d->vga.big_endian_fb;
}
static void vga_set_big_endian_fb(Object *obj, bool value, Error **errp)
{
- PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, PCI_DEVICE(obj));
+ PCIVGAState *d = PCI_VGA(PCI_DEVICE(obj));
d->vga.big_endian_fb = value;
}
@@ -205,7 +208,7 @@ static const MemoryRegionOps pci_vga_qext_ops = {
static void pci_std_vga_realize(PCIDevice *dev, Error **errp)
{
- PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
+ PCIVGAState *d = PCI_VGA(dev);
VGACommonState *s = &d->vga;
/* vga + console init */
@@ -257,7 +260,7 @@ static void pci_std_vga_init(Object *obj)
static void pci_secondary_vga_realize(PCIDevice *dev, Error **errp)
{
- PCIVGAState *d = DO_UPCAST(PCIVGAState, dev, dev);
+ PCIVGAState *d = PCI_VGA(dev);
VGACommonState *s = &d->vga;
/* vga + console init */
@@ -297,8 +300,7 @@ static void pci_secondary_vga_init(Object *obj)
static void pci_secondary_vga_reset(DeviceState *dev)
{
- PCIVGAState *d = DO_UPCAST(PCIVGAState, dev.qdev, dev);
-
+ PCIVGAState *d = PCI_VGA(PCI_DEVICE(dev));
vga_common_reset(&d->vga);
}
@@ -317,6 +319,25 @@ static Property secondary_pci_properties[] = {
DEFINE_PROP_END_OF_LIST(),
};
+static void vga_pci_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->vendor_id = PCI_VENDOR_ID_QEMU;
+ k->device_id = PCI_DEVICE_ID_QEMU_VGA;
+ dc->vmsd = &vmstate_vga_pci;
+ set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
+}
+
+static const TypeInfo vga_pci_type_info = {
+ .name = TYPE_PCI_VGA,
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(PCIVGAState),
+ .abstract = true,
+ .class_init = vga_pci_class_init,
+};
+
static void vga_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
@@ -324,13 +345,9 @@ static void vga_class_init(ObjectClass *klass, void *data)
k->realize = pci_std_vga_realize;
k->romfile = "vgabios-stdvga.bin";
- k->vendor_id = PCI_VENDOR_ID_QEMU;
- k->device_id = PCI_DEVICE_ID_QEMU_VGA;
k->class_id = PCI_CLASS_DISPLAY_VGA;
- dc->vmsd = &vmstate_vga_pci;
dc->props = vga_pci_properties;
dc->hotpluggable = false;
- set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
}
static void secondary_class_init(ObjectClass *klass, void *data)
@@ -339,33 +356,28 @@ static void secondary_class_init(ObjectClass *klass, void *data)
PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
k->realize = pci_secondary_vga_realize;
- k->vendor_id = PCI_VENDOR_ID_QEMU;
- k->device_id = PCI_DEVICE_ID_QEMU_VGA;
k->class_id = PCI_CLASS_DISPLAY_OTHER;
- dc->vmsd = &vmstate_vga_pci;
dc->props = secondary_pci_properties;
dc->reset = pci_secondary_vga_reset;
- set_bit(DEVICE_CATEGORY_DISPLAY, dc->categories);
}
static const TypeInfo vga_info = {
.name = "VGA",
- .parent = TYPE_PCI_DEVICE,
+ .parent = TYPE_PCI_VGA,
.instance_init = pci_std_vga_init,
- .instance_size = sizeof(PCIVGAState),
.class_init = vga_class_init,
};
static const TypeInfo secondary_info = {
.name = "secondary-vga",
- .parent = TYPE_PCI_DEVICE,
+ .parent = TYPE_PCI_VGA,
.instance_init = pci_secondary_vga_init,
- .instance_size = sizeof(PCIVGAState),
.class_init = secondary_class_init,
};
static void vga_register_types(void)
{
+ type_register_static(&vga_pci_type_info);
type_register_static(&vga_info);
type_register_static(&secondary_info);
}