[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH for-1.2 v7 06/14] gt64xxx: QOM'ify GT64120 PCI host
From: |
Andreas Färber |
Subject: |
[Qemu-devel] [PATCH for-1.2 v7 06/14] gt64xxx: QOM'ify GT64120 PCI host bridge |
Date: |
Mon, 20 Aug 2012 19:08:01 +0200 |
Introduce type constant. Introduce cast macro to drop dummy busdev field
used with FROM_SYSBUS() macro that would've broken SYS_BUS_DEVICE().
Avoid accessing DeviceState indirectly through PCIHostState.
Signed-off-by: Andreas Färber <address@hidden>
Acked-by: Michael S. Tsirkin <address@hidden>
---
hw/gt64xxx.c | 35 ++++++++++++++++++++---------------
1 files changed, 20 insertions(+), 15 deletions(-)
diff --git a/hw/gt64xxx.c b/hw/gt64xxx.c
index 04831bb..0677299 100644
--- a/hw/gt64xxx.c
+++ b/hw/gt64xxx.c
@@ -229,9 +229,14 @@
target_phys_addr_t regname ##_length; \
MemoryRegion regname ##_mem
+#define TYPE_GT64120_PCI_HOST_BRIDGE "gt64120"
+
+#define GT64120_PCI_HOST_BRIDGE(obj) \
+ OBJECT_CHECK(GT64120State, (obj), TYPE_GT64120_PCI_HOST_BRIDGE)
+
typedef struct GT64120State {
- SysBusDevice busdev;
PCIHostState pci;
+
uint32_t regs[GT_REGS];
PCI_MAPPING_ENTRY(PCI0IO);
PCI_MAPPING_ENTRY(ISD);
@@ -1083,31 +1088,31 @@ static void gt64120_reset(void *opaque)
PCIBus *gt64120_register(qemu_irq *pic)
{
- SysBusDevice *s;
GT64120State *d;
+ PCIHostState *phb;
DeviceState *dev;
- dev = qdev_create(NULL, "gt64120");
+ dev = qdev_create(NULL, TYPE_GT64120_PCI_HOST_BRIDGE);
qdev_init_nofail(dev);
- s = sysbus_from_qdev(dev);
- d = FROM_SYSBUS(GT64120State, s);
- d->pci.bus = pci_register_bus(&d->busdev.qdev, "pci",
- gt64120_pci_set_irq, gt64120_pci_map_irq,
- pic,
- get_system_memory(),
- get_system_io(),
- PCI_DEVFN(18, 0), 4);
+ d = GT64120_PCI_HOST_BRIDGE(dev);
+ phb = &d->pci;
+ phb->bus = pci_register_bus(dev, "pci",
+ gt64120_pci_set_irq, gt64120_pci_map_irq,
+ pic,
+ get_system_memory(),
+ get_system_io(),
+ PCI_DEVFN(18, 0), 4);
memory_region_init_io(&d->ISD_mem, &isd_mem_ops, d, "isd-mem", 0x1000);
- pci_create_simple(d->pci.bus, PCI_DEVFN(0, 0), "gt64120_pci");
- return d->pci.bus;
+ pci_create_simple(phb->bus, PCI_DEVFN(0, 0), "gt64120_pci");
+ return phb->bus;
}
static int gt64120_init(SysBusDevice *dev)
{
GT64120State *s;
- s = FROM_SYSBUS(GT64120State, dev);
+ s = GT64120_PCI_HOST_BRIDGE(dev);
/* FIXME: This value is computed from registers during reset, but some
devices (e.g. VGA card) need to know it when they are registered.
@@ -1162,7 +1167,7 @@ static void gt64120_class_init(ObjectClass *klass, void
*data)
}
static const TypeInfo gt64120_info = {
- .name = "gt64120",
+ .name = TYPE_GT64120_PCI_HOST_BRIDGE,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(GT64120State),
.class_init = gt64120_class_init,
--
1.7.7
- [Qemu-devel] [PATCH for-1.2 v7 00/14] pci_host: Convert to QOM, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 05/14] grackle_pci: QOM'ify Grackle PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 03/14] bonito: QOM'ify Bonito PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 04/14] dec_pci: QOM'ify DEC 21154 PCI-PCI bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 02/14] alpha_typhoon: QOM'ify Typhoon PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 01/14] pci: Make host bridge TypeInfos const, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 06/14] gt64xxx: QOM'ify GT64120 PCI host bridge,
Andreas Färber <=
- [Qemu-devel] [PATCH for-1.2 v7 08/14] ppce500_pci: QOM'ify e500 PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 07/14] ppc4xx_pci: QOM'ify ppc4xx PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 09/14] prep_pci: QOM'ify Raven PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 10/14] spapr_pci: QOM'ify sPAPR PCI host bridge, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 12/14] pci_host: Turn into SysBus-derived QOM type, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 14/14] pci: Tidy up PCI host bridges, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 13/14] pci: Derive PCI host bridges from TYPE_PCI_HOST_BRIDGE, Andreas Färber, 2012/08/20
- [Qemu-devel] [PATCH for-1.2 v7 11/14] unin_pci: QOM'ify UniNorth PCI host bridges, Andreas Färber, 2012/08/20