From: "Andreas Färber" <afaerber@suse.de>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
"Andreas Färber" <afaerber@suse.de>,
"Paul Brook" <paul@codesourcery.com>
Subject: [Qemu-devel] [PATCH v3 19/24] arm11mpcore: Convert ARM11MPCorePriveState to QOM realize
Date: Tue, 20 Aug 2013 17:21:11 +0200 [thread overview]
Message-ID: <1377012076-7035-20-git-send-email-afaerber@suse.de> (raw)
In-Reply-To: <1377012076-7035-1-git-send-email-afaerber@suse.de>
Embed child devices and replace SysBus initfn with realizefn.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/arm11mpcore.c | 84 ++++++++++++++++++++++++++++++++++------------------
1 file changed, 56 insertions(+), 28 deletions(-)
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index 9ab2bf5..0fb14e1 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -9,6 +9,8 @@
#include "hw/sysbus.h"
#include "hw/misc/arm11scu.h"
+#include "hw/intc/arm_gic.h"
+#include "hw/timer/arm_mptimer.h"
#include "qemu/timer.h"
/* MPCore private memory region. */
@@ -22,12 +24,12 @@ typedef struct ARM11MPCorePriveState {
uint32_t num_cpu;
MemoryRegion container;
- DeviceState *mptimer;
- DeviceState *wdtimer;
- DeviceState *gic;
uint32_t num_irq;
ARM11SCUState scu;
+ GICState gic;
+ ARMMPTimerState mptimer;
+ ARMMPTimerState wdtimer;
} ARM11MPCorePriveState;
/* Per-CPU private memory mapped IO. */
@@ -36,16 +38,18 @@ typedef struct ARM11MPCorePriveState {
static void mpcore_priv_set_irq(void *opaque, int irq, int level)
{
ARM11MPCorePriveState *s = (ARM11MPCorePriveState *)opaque;
- qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
+
+ qemu_set_irq(qdev_get_gpio_in(DEVICE(&s->gic), irq), level);
}
static void mpcore_priv_map_setup(ARM11MPCorePriveState *s)
{
int i;
SysBusDevice *scubusdev = SYS_BUS_DEVICE(&s->scu);
- SysBusDevice *gicbusdev = SYS_BUS_DEVICE(s->gic);
- SysBusDevice *timerbusdev = SYS_BUS_DEVICE(s->mptimer);
- SysBusDevice *wdtbusdev = SYS_BUS_DEVICE(s->wdtimer);
+ DeviceState *gicdev = DEVICE(&s->gic);
+ SysBusDevice *gicbusdev = SYS_BUS_DEVICE(&s->gic);
+ SysBusDevice *timerbusdev = SYS_BUS_DEVICE(&s->mptimer);
+ SysBusDevice *wdtbusdev = SYS_BUS_DEVICE(&s->wdtimer);
memory_region_add_subregion(&s->container, 0,
sysbus_mmio_get_region(scubusdev, 0));
@@ -76,44 +80,58 @@ static void mpcore_priv_map_setup(ARM11MPCorePriveState *s)
for (i = 0; i < s->num_cpu; i++) {
int ppibase = (s->num_irq - 32) + i * 32;
sysbus_connect_irq(timerbusdev, i,
- qdev_get_gpio_in(s->gic, ppibase + 29));
+ qdev_get_gpio_in(gicdev, ppibase + 29));
sysbus_connect_irq(wdtbusdev, i,
- qdev_get_gpio_in(s->gic, ppibase + 30));
+ qdev_get_gpio_in(gicdev, ppibase + 30));
}
}
-static int mpcore_priv_init(SysBusDevice *sbd)
+static void mpcore_priv_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
ARM11MPCorePriveState *s = ARM11MPCORE_PRIV(dev);
DeviceState *scudev = DEVICE(&s->scu);
+ DeviceState *gicdev = DEVICE(&s->gic);
+ DeviceState *mptimerdev = DEVICE(&s->mptimer);
+ DeviceState *wdtimerdev = DEVICE(&s->wdtimer);
+ Error *err = NULL;
qdev_prop_set_uint32(scudev, "num-cpu", s->num_cpu);
- qdev_init_nofail(scudev);
+ object_property_set_bool(OBJECT(&s->scu), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
- s->gic = qdev_create(NULL, "arm_gic");
- qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
- qdev_prop_set_uint32(s->gic, "num-irq", s->num_irq);
- /* Request the legacy 11MPCore GIC behaviour: */
- qdev_prop_set_uint32(s->gic, "revision", 0);
- qdev_init_nofail(s->gic);
+ qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
+ qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
+ object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
/* Pass through outbound IRQ lines from the GIC */
- sysbus_pass_irq(sbd, SYS_BUS_DEVICE(s->gic));
+ sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->gic));
/* Pass through inbound GPIO lines to the GIC */
qdev_init_gpio_in(dev, mpcore_priv_set_irq, s->num_irq - 32);
- s->mptimer = qdev_create(NULL, "arm_mptimer");
- qdev_prop_set_uint32(s->mptimer, "num-cpu", s->num_cpu);
- qdev_init_nofail(s->mptimer);
+ qdev_prop_set_uint32(mptimerdev, "num-cpu", s->num_cpu);
+ object_property_set_bool(OBJECT(&s->mptimer), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
- s->wdtimer = qdev_create(NULL, "arm_mptimer");
- qdev_prop_set_uint32(s->wdtimer, "num-cpu", s->num_cpu);
- qdev_init_nofail(s->wdtimer);
+ qdev_prop_set_uint32(wdtimerdev, "num-cpu", s->num_cpu);
+ object_property_set_bool(OBJECT(&s->wdtimer), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
mpcore_priv_map_setup(s);
- return 0;
}
static void mpcore_priv_initfn(Object *obj)
@@ -127,6 +145,17 @@ static void mpcore_priv_initfn(Object *obj)
object_initialize(&s->scu, TYPE_ARM11_SCU);
qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default());
+
+ object_initialize(&s->gic, TYPE_ARM_GIC);
+ qdev_set_parent_bus(DEVICE(&s->gic), sysbus_get_default());
+ /* Request the legacy 11MPCore GIC behaviour: */
+ qdev_prop_set_uint32(DEVICE(&s->gic), "revision", 0);
+
+ object_initialize(&s->mptimer, TYPE_ARM_MPTIMER);
+ qdev_set_parent_bus(DEVICE(&s->mptimer), sysbus_get_default());
+
+ object_initialize(&s->wdtimer, TYPE_ARM_MPTIMER);
+ qdev_set_parent_bus(DEVICE(&s->wdtimer), sysbus_get_default());
}
#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
@@ -237,9 +266,8 @@ static Property mpcore_priv_properties[] = {
static void mpcore_priv_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = mpcore_priv_init;
+ dc->realize = mpcore_priv_realize;
dc->props = mpcore_priv_properties;
}
--
1.8.1.4
next prev parent reply other threads:[~2013-08-20 15:21 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-20 15:20 [Qemu-devel] [PATCH v3 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 01/24] cpu/a9mpcore: Split off instance_init Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 02/24] intc/arm_gic: Extract headers hw/intc/arm_gic{, _common}.h Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 03/24] cpu/a9mpcore: Embed GICState Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 04/24] misc/a9scu: QOM cleanups Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 05/24] cpu/a9mpcore: Embed A9SCUState Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 06/24] timer/arm_mptimer: Convert to QOM realize Andreas Färber
2013-08-20 15:20 ` [Qemu-devel] [PATCH v3 07/24] cpu/a9mpcore: Embed ARMMPTimerState Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 08/24] cpu/a9mpcore: Convert to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 09/24] cpu/a9mpcore: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 10/24] cpu/a15mpcore: Split off instance_init Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 11/24] cpu/a15mpcore: Embed GICState Andreas Färber
2013-08-21 21:05 ` Peter Maydell
2013-08-22 10:56 ` Andreas Färber
2013-08-22 11:41 ` Peter Maydell
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 12/24] cpu/a15mpcore: Convert to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 13/24] cpu/a15mpcore: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 14/24] a9scu: Build only once Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 15/24] arm11mpcore: Fix typo in MemoryRegion name Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 16/24] arm11mpcore: Drop unused fields Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 17/24] arm11mpcore: Create container MemoryRegion in instance_init Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 18/24] arm11mpcore: Split off SCU device Andreas Färber
2013-08-20 15:21 ` Andreas Färber [this message]
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 20/24] realview_gic: Convert to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 21/24] realview_gic: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 22/24] arm11mpcore: Convert mpcore_rirq_state to QOM realize Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 23/24] arm11mpcore: Prepare for QOM embedding Andreas Färber
2013-08-20 15:21 ` [Qemu-devel] [PATCH v3 24/24] arm11mpcore: Split off RealView MPCore Andreas Färber
2013-08-21 21:01 ` [Qemu-devel] [PATCH v3 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Peter Maydell
2013-08-22 10:34 ` Andreas Färber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1377012076-7035-20-git-send-email-afaerber@suse.de \
--to=afaerber@suse.de \
--cc=paul@codesourcery.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).