aboutsummaryrefslogtreecommitdiff
path: root/hw/misc
diff options
context:
space:
mode:
Diffstat (limited to 'hw/misc')
-rw-r--r--hw/misc/macio/cuda.c2
-rw-r--r--hw/misc/macio/macio.c167
-rw-r--r--hw/misc/macio/pmu.c3
-rw-r--r--hw/misc/mos6522.c1
4 files changed, 72 insertions, 101 deletions
diff --git a/hw/misc/macio/cuda.c b/hw/misc/macio/cuda.c
index 853e88bf..7208b90 100644
--- a/hw/misc/macio/cuda.c
+++ b/hw/misc/macio/cuda.c
@@ -27,8 +27,6 @@
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
-#include "hw/input/adb.h"
-#include "hw/misc/mos6522.h"
#include "hw/misc/macio/cuda.h"
#include "qapi/error.h"
#include "qemu/timer.h"
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 08dbdd7..265c0bb 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -53,10 +53,8 @@
*/
static void macio_escc_legacy_setup(MacIOState *s)
{
- ESCCState *escc = ESCC(&s->escc);
- SysBusDevice *sbd = SYS_BUS_DEVICE(escc);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->escc);
MemoryRegion *escc_legacy = g_new(MemoryRegion, 1);
- MemoryRegion *bar = &s->bar;
int i;
static const int maps[] = {
0x00, 0x00, /* Command B */
@@ -80,30 +78,29 @@ static void macio_escc_legacy_setup(MacIOState *s)
memory_region_add_subregion(escc_legacy, maps[i], port);
}
- memory_region_add_subregion(bar, 0x12000, escc_legacy);
+ memory_region_add_subregion(&s->bar, 0x12000, escc_legacy);
}
static void macio_bar_setup(MacIOState *s)
{
- ESCCState *escc = ESCC(&s->escc);
- SysBusDevice *sbd = SYS_BUS_DEVICE(escc);
- MemoryRegion *bar = &s->bar;
+ SysBusDevice *sbd = SYS_BUS_DEVICE(&s->escc);
+ MemoryRegion *bar = sysbus_mmio_get_region(sbd, 0);
- memory_region_add_subregion(bar, 0x13000, sysbus_mmio_get_region(sbd, 0));
+ memory_region_add_subregion(&s->bar, 0x13000, bar);
macio_escc_legacy_setup(s);
}
-static void macio_common_realize(PCIDevice *d, Error **errp)
+static bool macio_common_realize(PCIDevice *d, Error **errp)
{
MacIOState *s = MACIO(d);
- SysBusDevice *sysbus_dev;
+ SysBusDevice *sbd;
if (!qdev_realize(DEVICE(&s->dbdma), BUS(&s->macio_bus), errp)) {
- return;
+ return false;
}
- sysbus_dev = SYS_BUS_DEVICE(&s->dbdma);
+ sbd = SYS_BUS_DEVICE(&s->dbdma);
memory_region_add_subregion(&s->bar, 0x08000,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
qdev_prop_set_uint32(DEVICE(&s->escc), "disabled", 0);
qdev_prop_set_uint32(DEVICE(&s->escc), "frequency", ESCC_CLOCK);
@@ -111,28 +108,29 @@ static void macio_common_realize(PCIDevice *d, Error **errp)
qdev_prop_set_uint32(DEVICE(&s->escc), "chnBtype", escc_serial);
qdev_prop_set_uint32(DEVICE(&s->escc), "chnAtype", escc_serial);
if (!qdev_realize(DEVICE(&s->escc), BUS(&s->macio_bus), errp)) {
- return;
+ return false;
}
macio_bar_setup(s);
pci_register_bar(d, 0, PCI_BASE_ADDRESS_SPACE_MEMORY, &s->bar);
+
+ return true;
}
-static void macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
+static bool macio_realize_ide(MacIOState *s, MACIOIDEState *ide,
qemu_irq irq0, qemu_irq irq1, int dmaid,
Error **errp)
{
- SysBusDevice *sysbus_dev;
+ SysBusDevice *sbd = SYS_BUS_DEVICE(ide);
- sysbus_dev = SYS_BUS_DEVICE(ide);
- sysbus_connect_irq(sysbus_dev, 0, irq0);
- sysbus_connect_irq(sysbus_dev, 1, irq1);
+ sysbus_connect_irq(sbd, 0, irq0);
+ sysbus_connect_irq(sbd, 1, irq1);
qdev_prop_set_uint32(DEVICE(ide), "channel", dmaid);
object_property_set_link(OBJECT(ide), "dbdma", OBJECT(&s->dbdma),
&error_abort);
macio_ide_register_dma(ide);
- qdev_realize(DEVICE(ide), BUS(&s->macio_bus), errp);
+ return qdev_realize(DEVICE(ide), BUS(&s->macio_bus), errp);
}
static void macio_oldworld_realize(PCIDevice *d, Error **errp)
@@ -140,12 +138,9 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
MacIOState *s = MACIO(d);
OldWorldMacIOState *os = OLDWORLD_MACIO(d);
DeviceState *pic_dev = DEVICE(&os->pic);
- Error *err = NULL;
- SysBusDevice *sysbus_dev;
+ SysBusDevice *sbd;
- macio_common_realize(d, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!macio_common_realize(d, errp)) {
return;
}
@@ -153,51 +148,44 @@ static void macio_oldworld_realize(PCIDevice *d, Error **errp)
if (!qdev_realize(DEVICE(&os->pic), BUS(&s->macio_bus), errp)) {
return;
}
- sysbus_dev = SYS_BUS_DEVICE(&os->pic);
+ sbd = SYS_BUS_DEVICE(&os->pic);
memory_region_add_subregion(&s->bar, 0x0,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
s->frequency);
if (!qdev_realize(DEVICE(&s->cuda), BUS(&s->macio_bus), errp)) {
return;
}
- sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
+ sbd = SYS_BUS_DEVICE(&s->cuda);
memory_region_add_subregion(&s->bar, 0x16000,
- sysbus_mmio_get_region(sysbus_dev, 0));
- sysbus_connect_irq(sysbus_dev, 0, qdev_get_gpio_in(pic_dev,
- OLDWORLD_CUDA_IRQ));
+ sysbus_mmio_get_region(sbd, 0));
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(pic_dev, OLDWORLD_CUDA_IRQ));
- sysbus_dev = SYS_BUS_DEVICE(&s->escc);
- sysbus_connect_irq(sysbus_dev, 0, qdev_get_gpio_in(pic_dev,
- OLDWORLD_ESCCB_IRQ));
- sysbus_connect_irq(sysbus_dev, 1, qdev_get_gpio_in(pic_dev,
- OLDWORLD_ESCCA_IRQ));
+ sbd = SYS_BUS_DEVICE(&s->escc);
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(pic_dev, OLDWORLD_ESCCB_IRQ));
+ sysbus_connect_irq(sbd, 1, qdev_get_gpio_in(pic_dev, OLDWORLD_ESCCA_IRQ));
if (!qdev_realize(DEVICE(&os->nvram), BUS(&s->macio_bus), errp)) {
return;
}
- sysbus_dev = SYS_BUS_DEVICE(&os->nvram);
+ sbd = SYS_BUS_DEVICE(&os->nvram);
memory_region_add_subregion(&s->bar, 0x60000,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
pmac_format_nvram_partition(&os->nvram, os->nvram.size);
/* IDE buses */
- macio_realize_ide(s, &os->ide[0],
- qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_IRQ),
- qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_DMA_IRQ),
- 0x16, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!macio_realize_ide(s, &os->ide[0],
+ qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_IRQ),
+ qdev_get_gpio_in(pic_dev, OLDWORLD_IDE0_DMA_IRQ),
+ 0x16, errp)) {
return;
}
- macio_realize_ide(s, &os->ide[1],
- qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_IRQ),
- qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_DMA_IRQ),
- 0x1a, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!macio_realize_ide(s, &os->ide[1],
+ qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_IRQ),
+ qdev_get_gpio_in(pic_dev, OLDWORLD_IDE1_DMA_IRQ),
+ 0x1a, errp)) {
return;
}
}
@@ -220,11 +208,11 @@ static void macio_oldworld_init(Object *obj)
DeviceState *dev;
int i;
- object_initialize_child(OBJECT(s), "pic", &os->pic, TYPE_HEATHROW);
+ object_initialize_child(obj, "pic", &os->pic, TYPE_HEATHROW);
- object_initialize_child(OBJECT(s), "cuda", &s->cuda, TYPE_CUDA);
+ object_initialize_child(obj, "cuda", &s->cuda, TYPE_CUDA);
- object_initialize_child(OBJECT(s), "nvram", &os->nvram, TYPE_MACIO_NVRAM);
+ object_initialize_child(obj, "nvram", &os->nvram, TYPE_MACIO_NVRAM);
dev = DEVICE(&os->nvram);
qdev_prop_set_uint32(dev, "size", MACIO_NVRAM_SIZE);
qdev_prop_set_uint32(dev, "it_shift", 4);
@@ -273,45 +261,36 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
MacIOState *s = MACIO(d);
NewWorldMacIOState *ns = NEWWORLD_MACIO(d);
DeviceState *pic_dev = DEVICE(&ns->pic);
- Error *err = NULL;
- SysBusDevice *sysbus_dev;
+ SysBusDevice *sbd;
MemoryRegion *timer_memory = NULL;
- macio_common_realize(d, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!macio_common_realize(d, errp)) {
return;
}
/* OpenPIC */
qdev_prop_set_uint32(pic_dev, "model", OPENPIC_MODEL_KEYLARGO);
- sysbus_dev = SYS_BUS_DEVICE(&ns->pic);
- sysbus_realize_and_unref(sysbus_dev, &error_fatal);
+ sbd = SYS_BUS_DEVICE(&ns->pic);
+ sysbus_realize_and_unref(sbd, &error_fatal);
memory_region_add_subregion(&s->bar, 0x40000,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
- sysbus_dev = SYS_BUS_DEVICE(&s->escc);
- sysbus_connect_irq(sysbus_dev, 0, qdev_get_gpio_in(pic_dev,
- NEWWORLD_ESCCB_IRQ));
- sysbus_connect_irq(sysbus_dev, 1, qdev_get_gpio_in(pic_dev,
- NEWWORLD_ESCCA_IRQ));
+ sbd = SYS_BUS_DEVICE(&s->escc);
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(pic_dev, NEWWORLD_ESCCB_IRQ));
+ sysbus_connect_irq(sbd, 1, qdev_get_gpio_in(pic_dev, NEWWORLD_ESCCA_IRQ));
/* IDE buses */
- macio_realize_ide(s, &ns->ide[0],
- qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_IRQ),
- qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_DMA_IRQ),
- 0x16, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!macio_realize_ide(s, &ns->ide[0],
+ qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_IRQ),
+ qdev_get_gpio_in(pic_dev, NEWWORLD_IDE0_DMA_IRQ),
+ 0x16, errp)) {
return;
}
- macio_realize_ide(s, &ns->ide[1],
- qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_IRQ),
- qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_DMA_IRQ),
- 0x1a, &err);
- if (err) {
- error_propagate(errp, err);
+ if (!macio_realize_ide(s, &ns->ide[1],
+ qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_IRQ),
+ qdev_get_gpio_in(pic_dev, NEWWORLD_IDE1_DMA_IRQ),
+ 0x1a, errp)) {
return;
}
@@ -326,27 +305,26 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
if (!qdev_realize(DEVICE(&ns->gpio), BUS(&s->macio_bus), errp)) {
return;
}
- sysbus_dev = SYS_BUS_DEVICE(&ns->gpio);
- sysbus_connect_irq(sysbus_dev, 1, qdev_get_gpio_in(pic_dev,
+ sbd = SYS_BUS_DEVICE(&ns->gpio);
+ sysbus_connect_irq(sbd, 1, qdev_get_gpio_in(pic_dev,
NEWWORLD_EXTING_GPIO1));
- sysbus_connect_irq(sysbus_dev, 9, qdev_get_gpio_in(pic_dev,
+ sysbus_connect_irq(sbd, 9, qdev_get_gpio_in(pic_dev,
NEWWORLD_EXTING_GPIO9));
memory_region_add_subregion(&s->bar, 0x50,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
/* PMU */
object_initialize_child(OBJECT(s), "pmu", &s->pmu, TYPE_VIA_PMU);
- object_property_set_link(OBJECT(&s->pmu), "gpio", OBJECT(sysbus_dev),
+ object_property_set_link(OBJECT(&s->pmu), "gpio", OBJECT(sbd),
&error_abort);
qdev_prop_set_bit(DEVICE(&s->pmu), "has-adb", ns->has_adb);
if (!qdev_realize(DEVICE(&s->pmu), BUS(&s->macio_bus), errp)) {
return;
}
- sysbus_dev = SYS_BUS_DEVICE(&s->pmu);
- sysbus_connect_irq(sysbus_dev, 0, qdev_get_gpio_in(pic_dev,
- NEWWORLD_PMU_IRQ));
+ sbd = SYS_BUS_DEVICE(&s->pmu);
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(pic_dev, NEWWORLD_PMU_IRQ));
memory_region_add_subregion(&s->bar, 0x16000,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
} else {
object_unparent(OBJECT(&ns->gpio));
@@ -358,11 +336,10 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
if (!qdev_realize(DEVICE(&s->cuda), BUS(&s->macio_bus), errp)) {
return;
}
- sysbus_dev = SYS_BUS_DEVICE(&s->cuda);
- sysbus_connect_irq(sysbus_dev, 0, qdev_get_gpio_in(pic_dev,
- NEWWORLD_CUDA_IRQ));
+ sbd = SYS_BUS_DEVICE(&s->cuda);
+ sysbus_connect_irq(sbd, 0, qdev_get_gpio_in(pic_dev, NEWWORLD_CUDA_IRQ));
memory_region_add_subregion(&s->bar, 0x16000,
- sysbus_mmio_get_region(sysbus_dev, 0));
+ sysbus_mmio_get_region(sbd, 0));
}
}
@@ -372,9 +349,9 @@ static void macio_newworld_init(Object *obj)
NewWorldMacIOState *ns = NEWWORLD_MACIO(obj);
int i;
- object_initialize_child(OBJECT(s), "pic", &ns->pic, TYPE_OPENPIC);
+ object_initialize_child(obj, "pic", &ns->pic, TYPE_OPENPIC);
- object_initialize_child(OBJECT(s), "gpio", &ns->gpio, TYPE_MACIO_GPIO);
+ object_initialize_child(obj, "gpio", &ns->gpio, TYPE_MACIO_GPIO);
for (i = 0; i < 2; i++) {
macio_init_ide(s, &ns->ide[i], i);
@@ -390,9 +367,9 @@ static void macio_instance_init(Object *obj)
qbus_init(&s->macio_bus, sizeof(s->macio_bus), TYPE_MACIO_BUS,
DEVICE(obj), "macio.0");
- object_initialize_child(OBJECT(s), "dbdma", &s->dbdma, TYPE_MAC_DBDMA);
+ object_initialize_child(obj, "dbdma", &s->dbdma, TYPE_MAC_DBDMA);
- object_initialize_child(OBJECT(s), "escc", &s->escc, TYPE_ESCC);
+ object_initialize_child(obj, "escc", &s->escc, TYPE_ESCC);
}
static const VMStateDescription vmstate_macio_oldworld = {
diff --git a/hw/misc/macio/pmu.c b/hw/misc/macio/pmu.c
index 97ef8c7..8575bc1 100644
--- a/hw/misc/macio/pmu.c
+++ b/hw/misc/macio/pmu.c
@@ -31,10 +31,7 @@
#include "qemu/osdep.h"
#include "hw/qdev-properties.h"
#include "migration/vmstate.h"
-#include "hw/input/adb.h"
#include "hw/irq.h"
-#include "hw/misc/mos6522.h"
-#include "hw/misc/macio/gpio.h"
#include "hw/misc/macio/pmu.h"
#include "qapi/error.h"
#include "qemu/timer.h"
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
index 0ed6311..d6ba47b 100644
--- a/hw/misc/mos6522.c
+++ b/hw/misc/mos6522.c
@@ -25,7 +25,6 @@
*/
#include "qemu/osdep.h"
-#include "hw/input/adb.h"
#include "hw/irq.h"
#include "hw/misc/mos6522.h"
#include "hw/qdev-properties.h"