* [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification
@ 2013-09-11 14:37 Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 01/24] a9mpcore: Split off instance_init Andreas Färber
` (24 more replies)
0 siblings, 25 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, Andreas Färber, Claudio Fontana,
Peter Crosthwaite, Mian M. Hamayun
From: Andreas Färber <andreas.faerber@web.de>
Hello Peter,
This series fully QOM'ifies A9MPCore so that it can be embedded for Tegra2.
It goes on to do the same for A15MPCore, which had previously been taken as
template for Cortex-A57 by John Rigby, and since v3 ARM11MPCore.
Separate headers are introduced to only expose device state to whom asks for it.
v4 is a rebase that addresses concerns about potential future GICState
size mismatches by asserting in QOM infrastructure.
Regards,
Andreas
v3 -> v4:
* Rebased; object_initialize() now takes additional size argument.
* Subject prefixes unified.
v2 -> v3:
* Split off hw/intc/arm_gic_common.h from new arm_gic.h (PMM).
* Added patches converting arm11mpcore, too.
* Split off arm11scu from arm11mpcore, following a9scu/a9mpcore model.
* Added patch to enforce building a9scu only once.
* Split off RealView MPCore from ARM11 MPCore using a new arm11mpcore.h.
v1 -> v2:
* Renamed MP_TIMER to MPTIMER (Peter C.).
* Don't include gic_internal.h, introduce new arm_gic.h header (PMM).
* a9mpcore: Init only container MemoryRegion in instance_init (Peter C.).
* a9mpcore/a15mpcore: Replaced all qdev_init_nofail()s for error propagation.
Cc: Peter Maydell <peter.maydell@linaro.org>
Cc: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Cc: Mian M. Hamayun <m.hamayun@virtualopensystems.com>
Cc: Claudio Fontana <claudio.fontana@huawei.com>
Andreas Färber (24):
a9mpcore: Split off instance_init
arm_gic: Extract headers hw/intc/arm_gic{,_common}.h
a9mpcore: Embed GICState
a9scu: QOM cleanups
a9mpcore: Embed A9SCUState
arm_mptimer: Convert to QOM realize
a9mpcore: Embed ARMMPTimerState
a9mpcore: Convert to QOM realize
a9mpcore: Prepare for QOM embedding
a15mpcore: Split off instance_init
a15mpcore: Embed GICState
a15mpcore: Convert to QOM realize
a15mpcore: Prepare for QOM embedding
a9scu: Build only once
arm11mpcore: Fix typo in MemoryRegion name
arm11mpcore: Drop unused fields
arm11mpcore: Create container MemoryRegion in instance_init
arm11mpcore: Split off SCU device
arm11mpcore: Convert ARM11MPCorePriveState to QOM realize
realview_gic: Convert to QOM realize
realview_gic: Prepare for QOM embedding
arm11mpcore: Convert mpcore_rirq_state to QOM realize
arm11mpcore: Prepare for QOM embedding
arm11mpcore: Split off RealView MPCore
default-configs/arm-softmmu.mak | 1 +
hw/cpu/Makefile.objs | 1 +
hw/cpu/a15mpcore.c | 81 ++++++-------
hw/cpu/a9mpcore.c | 120 +++++++++++--------
hw/cpu/arm11mpcore.c | 251 ++++++++++-----------------------------
hw/cpu/realview_mpcore.c | 139 ++++++++++++++++++++++
hw/intc/arm_gic_common.c | 18 +--
hw/intc/gic_internal.h | 80 +------------
hw/intc/realview_gic.c | 58 +++++----
hw/misc/Makefile.objs | 3 +-
hw/misc/a9scu.c | 25 +---
hw/misc/arm11scu.c | 100 ++++++++++++++++
hw/timer/arm_mptimer.c | 60 +++-------
include/hw/cpu/a15mpcore.h | 44 +++++++
include/hw/cpu/a9mpcore.h | 37 ++++++
include/hw/cpu/arm11mpcore.h | 35 ++++++
include/hw/intc/arm_gic.h | 42 +++++++
include/hw/intc/arm_gic_common.h | 92 ++++++++++++++
include/hw/intc/realview_gic.h | 28 +++++
include/hw/misc/a9scu.h | 31 +++++
include/hw/misc/arm11scu.h | 29 +++++
include/hw/timer/arm_mptimer.h | 54 +++++++++
22 files changed, 879 insertions(+), 450 deletions(-)
create mode 100644 hw/cpu/realview_mpcore.c
create mode 100644 hw/misc/arm11scu.c
create mode 100644 include/hw/cpu/a15mpcore.h
create mode 100644 include/hw/cpu/a9mpcore.h
create mode 100644 include/hw/cpu/arm11mpcore.h
create mode 100644 include/hw/intc/arm_gic.h
create mode 100644 include/hw/intc/arm_gic_common.h
create mode 100644 include/hw/intc/realview_gic.h
create mode 100644 include/hw/misc/a9scu.h
create mode 100644 include/hw/misc/arm11scu.h
create mode 100644 include/hw/timer/arm_mptimer.h
--
1.8.1.4
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 01/24] a9mpcore: Split off instance_init
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 02/24] arm_gic: Extract headers hw/intc/arm_gic{, _common}.h Andreas Färber
` (23 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Prepares for QOM realize.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a9mpcore.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index 3e675e3..acbdab5 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -34,6 +34,14 @@ static void a9mp_priv_set_irq(void *opaque, int irq, int level)
qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
}
+static void a9mp_priv_initfn(Object *obj)
+{
+ A9MPPrivState *s = A9MPCORE_PRIV(obj);
+
+ memory_region_init(&s->container, obj, "a9mp-priv-container", 0x2000);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->container);
+}
+
static int a9mp_priv_init(SysBusDevice *dev)
{
A9MPPrivState *s = A9MPCORE_PRIV(dev);
@@ -78,7 +86,6 @@ static int a9mp_priv_init(SysBusDevice *dev)
*
* We should implement the global timer but don't currently do so.
*/
- memory_region_init(&s->container, OBJECT(s), "a9mp-priv-container", 0x2000);
memory_region_add_subregion(&s->container, 0,
sysbus_mmio_get_region(scubusdev, 0));
/* GIC CPU interface */
@@ -94,8 +101,6 @@ static int a9mp_priv_init(SysBusDevice *dev)
memory_region_add_subregion(&s->container, 0x1000,
sysbus_mmio_get_region(gicbusdev, 0));
- sysbus_init_mmio(dev, &s->container);
-
/* Wire up the interrupt from each watchdog and timer.
* For each core the timer is PPI 29 and the watchdog PPI 30.
*/
@@ -134,6 +139,7 @@ static const TypeInfo a9mp_priv_info = {
.name = TYPE_A9MPCORE_PRIV,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(A9MPPrivState),
+ .instance_init = a9mp_priv_initfn,
.class_init = a9mp_priv_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 02/24] arm_gic: Extract headers hw/intc/arm_gic{, _common}.h
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 01/24] a9mpcore: Split off instance_init Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 03/24] a9mpcore: Embed GICState Andreas Färber
` (22 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
Rename NCPU to GIC_NCPU and move GICState away from gic_internal.h.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/intc/arm_gic_common.c | 18 ++++----
hw/intc/gic_internal.h | 80 +---------------------------------
include/hw/intc/arm_gic.h | 42 ++++++++++++++++++
include/hw/intc/arm_gic_common.h | 92 ++++++++++++++++++++++++++++++++++++++++
4 files changed, 145 insertions(+), 87 deletions(-)
create mode 100644 include/hw/intc/arm_gic.h
create mode 100644 include/hw/intc/arm_gic_common.h
diff --git a/hw/intc/arm_gic_common.c b/hw/intc/arm_gic_common.c
index 709b5c2..c765850 100644
--- a/hw/intc/arm_gic_common.c
+++ b/hw/intc/arm_gic_common.c
@@ -64,17 +64,17 @@ static const VMStateDescription vmstate_gic = {
.post_load = gic_post_load,
.fields = (VMStateField[]) {
VMSTATE_BOOL(enabled, GICState),
- VMSTATE_BOOL_ARRAY(cpu_enabled, GICState, NCPU),
+ VMSTATE_BOOL_ARRAY(cpu_enabled, GICState, GIC_NCPU),
VMSTATE_STRUCT_ARRAY(irq_state, GICState, GIC_MAXIRQ, 1,
vmstate_gic_irq_state, gic_irq_state),
VMSTATE_UINT8_ARRAY(irq_target, GICState, GIC_MAXIRQ),
- VMSTATE_UINT8_2DARRAY(priority1, GICState, GIC_INTERNAL, NCPU),
+ VMSTATE_UINT8_2DARRAY(priority1, GICState, GIC_INTERNAL, GIC_NCPU),
VMSTATE_UINT8_ARRAY(priority2, GICState, GIC_MAXIRQ - GIC_INTERNAL),
- VMSTATE_UINT16_2DARRAY(last_active, GICState, GIC_MAXIRQ, NCPU),
- VMSTATE_UINT16_ARRAY(priority_mask, GICState, NCPU),
- VMSTATE_UINT16_ARRAY(running_irq, GICState, NCPU),
- VMSTATE_UINT16_ARRAY(running_priority, GICState, NCPU),
- VMSTATE_UINT16_ARRAY(current_pending, GICState, NCPU),
+ VMSTATE_UINT16_2DARRAY(last_active, GICState, GIC_MAXIRQ, GIC_NCPU),
+ VMSTATE_UINT16_ARRAY(priority_mask, GICState, GIC_NCPU),
+ VMSTATE_UINT16_ARRAY(running_irq, GICState, GIC_NCPU),
+ VMSTATE_UINT16_ARRAY(running_priority, GICState, GIC_NCPU),
+ VMSTATE_UINT16_ARRAY(current_pending, GICState, GIC_NCPU),
VMSTATE_END_OF_LIST()
}
};
@@ -84,9 +84,9 @@ static void arm_gic_common_realize(DeviceState *dev, Error **errp)
GICState *s = ARM_GIC_COMMON(dev);
int num_irq = s->num_irq;
- if (s->num_cpu > NCPU) {
+ if (s->num_cpu > GIC_NCPU) {
error_setg(errp, "requested %u CPUs exceeds GIC maximum %d",
- s->num_cpu, NCPU);
+ s->num_cpu, GIC_NCPU);
return;
}
s->num_irq += GIC_BASE_IRQ;
diff --git a/hw/intc/gic_internal.h b/hw/intc/gic_internal.h
index 1426437..3989fd1 100644
--- a/hw/intc/gic_internal.h
+++ b/hw/intc/gic_internal.h
@@ -21,16 +21,9 @@
#ifndef QEMU_ARM_GIC_INTERNAL_H
#define QEMU_ARM_GIC_INTERNAL_H
-#include "hw/sysbus.h"
+#include "hw/intc/arm_gic.h"
-/* Maximum number of possible interrupts, determined by the GIC architecture */
-#define GIC_MAXIRQ 1020
-/* First 32 are private to each CPU (SGIs and PPIs). */
-#define GIC_INTERNAL 32
-/* Maximum number of possible CPU interfaces, determined by GIC architecture */
-#define NCPU 8
-
-#define ALL_CPU_MASK ((unsigned)(((1 << NCPU) - 1)))
+#define ALL_CPU_MASK ((unsigned)(((1 << GIC_NCPU) - 1)))
/* The NVIC has 16 internal vectors. However these are not exposed
through the normal GIC interface. */
@@ -59,48 +52,6 @@
s->priority2[(irq) - GIC_INTERNAL])
#define GIC_TARGET(irq) s->irq_target[irq]
-typedef struct gic_irq_state {
- /* The enable bits are only banked for per-cpu interrupts. */
- uint8_t enabled;
- uint8_t pending;
- uint8_t active;
- uint8_t level;
- bool model; /* 0 = N:N, 1 = 1:N */
- bool trigger; /* nonzero = edge triggered. */
-} gic_irq_state;
-
-typedef struct GICState {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- qemu_irq parent_irq[NCPU];
- bool enabled;
- bool cpu_enabled[NCPU];
-
- gic_irq_state irq_state[GIC_MAXIRQ];
- uint8_t irq_target[GIC_MAXIRQ];
- uint8_t priority1[GIC_INTERNAL][NCPU];
- uint8_t priority2[GIC_MAXIRQ - GIC_INTERNAL];
- uint16_t last_active[GIC_MAXIRQ][NCPU];
-
- uint16_t priority_mask[NCPU];
- uint16_t running_irq[NCPU];
- uint16_t running_priority[NCPU];
- uint16_t current_pending[NCPU];
-
- uint32_t num_cpu;
-
- MemoryRegion iomem; /* Distributor */
- /* This is just so we can have an opaque pointer which identifies
- * both this GIC and which CPU interface we should be accessing.
- */
- struct GICState *backref[NCPU];
- MemoryRegion cpuiomem[NCPU+1]; /* CPU interfaces */
- uint32_t num_irq;
- uint32_t revision;
-} GICState;
-
/* The special cases for the revision property: */
#define REV_11MPCORE 0
#define REV_NVIC 0xffffffff
@@ -111,31 +62,4 @@ void gic_complete_irq(GICState *s, int cpu, int irq);
void gic_update(GICState *s);
void gic_init_irqs_and_distributor(GICState *s, int num_irq);
-#define TYPE_ARM_GIC_COMMON "arm_gic_common"
-#define ARM_GIC_COMMON(obj) \
- OBJECT_CHECK(GICState, (obj), TYPE_ARM_GIC_COMMON)
-#define ARM_GIC_COMMON_CLASS(klass) \
- OBJECT_CLASS_CHECK(ARMGICCommonClass, (klass), TYPE_ARM_GIC_COMMON)
-#define ARM_GIC_COMMON_GET_CLASS(obj) \
- OBJECT_GET_CLASS(ARMGICCommonClass, (obj), TYPE_ARM_GIC_COMMON)
-
-typedef struct ARMGICCommonClass {
- SysBusDeviceClass parent_class;
- void (*pre_save)(GICState *s);
- void (*post_load)(GICState *s);
-} ARMGICCommonClass;
-
-#define TYPE_ARM_GIC "arm_gic"
-#define ARM_GIC(obj) \
- OBJECT_CHECK(GICState, (obj), TYPE_ARM_GIC)
-#define ARM_GIC_CLASS(klass) \
- OBJECT_CLASS_CHECK(ARMGICClass, (klass), TYPE_ARM_GIC)
-#define ARM_GIC_GET_CLASS(obj) \
- OBJECT_GET_CLASS(ARMGICClass, (obj), TYPE_ARM_GIC)
-
-typedef struct ARMGICClass {
- ARMGICCommonClass parent_class;
- DeviceRealize parent_realize;
-} ARMGICClass;
-
#endif /* !QEMU_ARM_GIC_INTERNAL_H */
diff --git a/include/hw/intc/arm_gic.h b/include/hw/intc/arm_gic.h
new file mode 100644
index 0000000..0971e37
--- /dev/null
+++ b/include/hw/intc/arm_gic.h
@@ -0,0 +1,42 @@
+/*
+ * ARM GIC support
+ *
+ * Copyright (c) 2012 Linaro Limited
+ * Written by Peter Maydell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HW_ARM_GIC_H
+#define HW_ARM_GIC_H
+
+#include "arm_gic_common.h"
+
+#define TYPE_ARM_GIC "arm_gic"
+#define ARM_GIC(obj) \
+ OBJECT_CHECK(GICState, (obj), TYPE_ARM_GIC)
+#define ARM_GIC_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ARMGICClass, (klass), TYPE_ARM_GIC)
+#define ARM_GIC_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ARMGICClass, (obj), TYPE_ARM_GIC)
+
+typedef struct ARMGICClass {
+ /*< private >*/
+ ARMGICCommonClass parent_class;
+ /*< public >*/
+
+ DeviceRealize parent_realize;
+} ARMGICClass;
+
+#endif
diff --git a/include/hw/intc/arm_gic_common.h b/include/hw/intc/arm_gic_common.h
new file mode 100644
index 0000000..4f381bd
--- /dev/null
+++ b/include/hw/intc/arm_gic_common.h
@@ -0,0 +1,92 @@
+/*
+ * ARM GIC support
+ *
+ * Copyright (c) 2012 Linaro Limited
+ * Written by Peter Maydell
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HW_ARM_GIC_COMMON_H
+#define HW_ARM_GIC_COMMON_H
+
+#include "hw/sysbus.h"
+
+/* Maximum number of possible interrupts, determined by the GIC architecture */
+#define GIC_MAXIRQ 1020
+/* First 32 are private to each CPU (SGIs and PPIs). */
+#define GIC_INTERNAL 32
+/* Maximum number of possible CPU interfaces, determined by GIC architecture */
+#define GIC_NCPU 8
+
+typedef struct gic_irq_state {
+ /* The enable bits are only banked for per-cpu interrupts. */
+ uint8_t enabled;
+ uint8_t pending;
+ uint8_t active;
+ uint8_t level;
+ bool model; /* 0 = N:N, 1 = 1:N */
+ bool trigger; /* nonzero = edge triggered. */
+} gic_irq_state;
+
+typedef struct GICState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ qemu_irq parent_irq[GIC_NCPU];
+ bool enabled;
+ bool cpu_enabled[GIC_NCPU];
+
+ gic_irq_state irq_state[GIC_MAXIRQ];
+ uint8_t irq_target[GIC_MAXIRQ];
+ uint8_t priority1[GIC_INTERNAL][GIC_NCPU];
+ uint8_t priority2[GIC_MAXIRQ - GIC_INTERNAL];
+ uint16_t last_active[GIC_MAXIRQ][GIC_NCPU];
+
+ uint16_t priority_mask[GIC_NCPU];
+ uint16_t running_irq[GIC_NCPU];
+ uint16_t running_priority[GIC_NCPU];
+ uint16_t current_pending[GIC_NCPU];
+
+ uint32_t num_cpu;
+
+ MemoryRegion iomem; /* Distributor */
+ /* This is just so we can have an opaque pointer which identifies
+ * both this GIC and which CPU interface we should be accessing.
+ */
+ struct GICState *backref[GIC_NCPU];
+ MemoryRegion cpuiomem[GIC_NCPU + 1]; /* CPU interfaces */
+ uint32_t num_irq;
+ uint32_t revision;
+} GICState;
+
+#define TYPE_ARM_GIC_COMMON "arm_gic_common"
+#define ARM_GIC_COMMON(obj) \
+ OBJECT_CHECK(GICState, (obj), TYPE_ARM_GIC_COMMON)
+#define ARM_GIC_COMMON_CLASS(klass) \
+ OBJECT_CLASS_CHECK(ARMGICCommonClass, (klass), TYPE_ARM_GIC_COMMON)
+#define ARM_GIC_COMMON_GET_CLASS(obj) \
+ OBJECT_GET_CLASS(ARMGICCommonClass, (obj), TYPE_ARM_GIC_COMMON)
+
+typedef struct ARMGICCommonClass {
+ /*< private >*/
+ SysBusDeviceClass parent_class;
+ /*< public >*/
+
+ void (*pre_save)(GICState *s);
+ void (*post_load)(GICState *s);
+} ARMGICCommonClass;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 03/24] a9mpcore: Embed GICState
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 01/24] a9mpcore: Split off instance_init Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 02/24] arm_gic: Extract headers hw/intc/arm_gic{, _common}.h Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 04/24] a9scu: QOM cleanups Andreas Färber
` (21 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Prepares for conversion to QOM realize.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a9mpcore.c | 25 ++++++++++++++++---------
1 file changed, 16 insertions(+), 9 deletions(-)
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index acbdab5..c57b149 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -9,6 +9,7 @@
*/
#include "hw/sysbus.h"
+#include "hw/intc/arm_gic.h"
#define TYPE_A9MPCORE_PRIV "a9mpcore_priv"
#define A9MPCORE_PRIV(obj) \
@@ -23,15 +24,17 @@ typedef struct A9MPPrivState {
MemoryRegion container;
DeviceState *mptimer;
DeviceState *wdt;
- DeviceState *gic;
DeviceState *scu;
uint32_t num_irq;
+
+ GICState gic;
} A9MPPrivState;
static void a9mp_priv_set_irq(void *opaque, int irq, int level)
{
A9MPPrivState *s = (A9MPPrivState *)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 a9mp_priv_initfn(Object *obj)
@@ -40,19 +43,23 @@ static void a9mp_priv_initfn(Object *obj)
memory_region_init(&s->container, obj, "a9mp-priv-container", 0x2000);
sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->container);
+
+ object_initialize(&s->gic, sizeof(s->gic), TYPE_ARM_GIC);
+ qdev_set_parent_bus(DEVICE(&s->gic), sysbus_get_default());
}
static int a9mp_priv_init(SysBusDevice *dev)
{
A9MPPrivState *s = A9MPCORE_PRIV(dev);
+ DeviceState *gicdev;
SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;
int i;
- 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);
- qdev_init_nofail(s->gic);
- gicbusdev = SYS_BUS_DEVICE(s->gic);
+ gicdev = DEVICE(&s->gic);
+ qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
+ qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
+ qdev_init_nofail(gicdev);
+ gicbusdev = SYS_BUS_DEVICE(&s->gic);
/* Pass through outbound IRQ lines from the GIC */
sysbus_pass_irq(dev, gicbusdev);
@@ -107,9 +114,9 @@ static int a9mp_priv_init(SysBusDevice *dev)
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));
}
return 0;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 04/24] a9scu: QOM cleanups
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (2 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 03/24] a9mpcore: Embed GICState Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 05/24] a9mpcore: Embed A9SCUState Andreas Färber
` (20 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
From: Andreas Färber <andreas.faerber@web.de>
Rename A9SCUState::busdev field to parent_obj and turn realizefn into an
instance_init function to allow early MMIO mapping.
Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/misc/a9scu.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c
index 601b573..2661014 100644
--- a/hw/misc/a9scu.c
+++ b/hw/misc/a9scu.c
@@ -13,7 +13,10 @@
/* A9MP private memory region. */
typedef struct A9SCUState {
- SysBusDevice busdev;
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
MemoryRegion iomem;
uint32_t control;
uint32_t status;
@@ -114,12 +117,12 @@ static void a9_scu_reset(DeviceState *dev)
s->control = 0;
}
-static void a9_scu_realize(DeviceState *dev, Error ** errp)
+static void a9_scu_init(Object *obj)
{
- A9SCUState *s = A9_SCU(dev);
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ A9SCUState *s = A9_SCU(obj);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- memory_region_init_io(&s->iomem, OBJECT(dev), &a9_scu_ops, s,
+ memory_region_init_io(&s->iomem, obj, &a9_scu_ops, s,
"a9-scu", 0x100);
sysbus_init_mmio(sbd, &s->iomem);
}
@@ -144,7 +147,6 @@ static void a9_scu_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- dc->realize = a9_scu_realize;
dc->props = a9_scu_properties;
dc->vmsd = &vmstate_a9_scu;
dc->reset = a9_scu_reset;
@@ -154,6 +156,7 @@ static const TypeInfo a9_scu_info = {
.name = TYPE_A9_SCU,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(A9SCUState),
+ .instance_init = a9_scu_init,
.class_init = a9_scu_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 05/24] a9mpcore: Embed A9SCUState
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (3 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 04/24] a9scu: QOM cleanups Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 06/24] arm_mptimer: Convert to QOM realize Andreas Färber
` (19 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Prepares for QOM realize.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a9mpcore.c | 16 ++++++++++------
hw/misc/a9scu.c | 18 +-----------------
include/hw/misc/a9scu.h | 31 +++++++++++++++++++++++++++++++
3 files changed, 42 insertions(+), 23 deletions(-)
create mode 100644 include/hw/misc/a9scu.h
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index c57b149..df92e3f 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -10,6 +10,7 @@
#include "hw/sysbus.h"
#include "hw/intc/arm_gic.h"
+#include "hw/misc/a9scu.h"
#define TYPE_A9MPCORE_PRIV "a9mpcore_priv"
#define A9MPCORE_PRIV(obj) \
@@ -24,10 +25,10 @@ typedef struct A9MPPrivState {
MemoryRegion container;
DeviceState *mptimer;
DeviceState *wdt;
- DeviceState *scu;
uint32_t num_irq;
GICState gic;
+ A9SCUState scu;
} A9MPPrivState;
static void a9mp_priv_set_irq(void *opaque, int irq, int level)
@@ -46,12 +47,15 @@ static void a9mp_priv_initfn(Object *obj)
object_initialize(&s->gic, sizeof(s->gic), TYPE_ARM_GIC);
qdev_set_parent_bus(DEVICE(&s->gic), sysbus_get_default());
+
+ object_initialize(&s->scu, sizeof(s->scu), TYPE_A9_SCU);
+ qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default());
}
static int a9mp_priv_init(SysBusDevice *dev)
{
A9MPPrivState *s = A9MPCORE_PRIV(dev);
- DeviceState *gicdev;
+ DeviceState *gicdev, *scudev;
SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;
int i;
@@ -67,10 +71,10 @@ static int a9mp_priv_init(SysBusDevice *dev)
/* Pass through inbound GPIO lines to the GIC */
qdev_init_gpio_in(DEVICE(dev), a9mp_priv_set_irq, s->num_irq - 32);
- s->scu = qdev_create(NULL, "a9-scu");
- qdev_prop_set_uint32(s->scu, "num-cpu", s->num_cpu);
- qdev_init_nofail(s->scu);
- scubusdev = SYS_BUS_DEVICE(s->scu);
+ scudev = DEVICE(&s->scu);
+ qdev_prop_set_uint32(scudev, "num-cpu", s->num_cpu);
+ qdev_init_nofail(scudev);
+ scubusdev = SYS_BUS_DEVICE(&s->scu);
s->mptimer = qdev_create(NULL, "arm_mptimer");
qdev_prop_set_uint32(s->mptimer, "num-cpu", s->num_cpu);
diff --git a/hw/misc/a9scu.c b/hw/misc/a9scu.c
index 2661014..4434945 100644
--- a/hw/misc/a9scu.c
+++ b/hw/misc/a9scu.c
@@ -8,23 +8,7 @@
* This code is licensed under the GPL.
*/
-#include "hw/sysbus.h"
-
-/* A9MP private memory region. */
-
-typedef struct A9SCUState {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- MemoryRegion iomem;
- uint32_t control;
- uint32_t status;
- uint32_t num_cpu;
-} A9SCUState;
-
-#define TYPE_A9_SCU "a9-scu"
-#define A9_SCU(obj) OBJECT_CHECK(A9SCUState, (obj), TYPE_A9_SCU)
+#include "hw/misc/a9scu.h"
static uint64_t a9_scu_read(void *opaque, hwaddr offset,
unsigned size)
diff --git a/include/hw/misc/a9scu.h b/include/hw/misc/a9scu.h
new file mode 100644
index 0000000..efb0c30
--- /dev/null
+++ b/include/hw/misc/a9scu.h
@@ -0,0 +1,31 @@
+/*
+ * Cortex-A9MPCore Snoop Control Unit (SCU) emulation.
+ *
+ * Copyright (c) 2009 CodeSourcery.
+ * Copyright (c) 2011 Linaro Limited.
+ * Written by Paul Brook, Peter Maydell.
+ *
+ * This code is licensed under the GPL.
+ */
+#ifndef HW_MISC_A9SCU_H
+#define HW_MISC_A9SCU_H
+
+#include "hw/sysbus.h"
+
+/* A9MP private memory region. */
+
+typedef struct A9SCUState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ MemoryRegion iomem;
+ uint32_t control;
+ uint32_t status;
+ uint32_t num_cpu;
+} A9SCUState;
+
+#define TYPE_A9_SCU "a9-scu"
+#define A9_SCU(obj) OBJECT_CHECK(A9SCUState, (obj), TYPE_A9_SCU)
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 06/24] arm_mptimer: Convert to QOM realize
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (4 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 05/24] a9mpcore: Embed A9SCUState Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 07/24] a9mpcore: Embed ARMMPTimerState Andreas Färber
` (18 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
From: Andreas Färber <andreas.faerber@web.de>
Split the SysBusDevice initfn into instance_init and realizefn.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/timer/arm_mptimer.c | 25 +++++++++++++++----------
1 file changed, 15 insertions(+), 10 deletions(-)
diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index 8020c9f..2853db4 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -225,8 +225,18 @@ static void arm_mptimer_reset(DeviceState *dev)
}
}
-static int arm_mptimer_init(SysBusDevice *dev)
+static void arm_mptimer_init(Object *obj)
{
+ ARMMPTimerState *s = ARM_MPTIMER(obj);
+
+ memory_region_init_io(&s->iomem, obj, &arm_thistimer_ops, s,
+ "arm_mptimer_timer", 0x20);
+ sysbus_init_mmio(SYS_BUS_DEVICE(obj), &s->iomem);
+}
+
+static void arm_mptimer_realize(DeviceState *dev, Error **errp)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
ARMMPTimerState *s = ARM_MPTIMER(dev);
int i;
@@ -243,19 +253,14 @@ static int arm_mptimer_init(SysBusDevice *dev)
* * timer for core 1
* and so on.
*/
- memory_region_init_io(&s->iomem, OBJECT(s), &arm_thistimer_ops, s,
- "arm_mptimer_timer", 0x20);
- sysbus_init_mmio(dev, &s->iomem);
for (i = 0; i < s->num_cpu; i++) {
TimerBlock *tb = &s->timerblock[i];
tb->timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, timerblock_tick, tb);
- sysbus_init_irq(dev, &tb->irq);
+ sysbus_init_irq(sbd, &tb->irq);
memory_region_init_io(&tb->iomem, OBJECT(s), &timerblock_ops, tb,
"arm_mptimer_timerblock", 0x20);
- sysbus_init_mmio(dev, &tb->iomem);
+ sysbus_init_mmio(sbd, &tb->iomem);
}
-
- return 0;
}
static const VMStateDescription vmstate_timerblock = {
@@ -292,9 +297,8 @@ static Property arm_mptimer_properties[] = {
static void arm_mptimer_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
- sbc->init = arm_mptimer_init;
+ dc->realize = arm_mptimer_realize;
dc->vmsd = &vmstate_arm_mptimer;
dc->reset = arm_mptimer_reset;
dc->no_user = 1;
@@ -305,6 +309,7 @@ static const TypeInfo arm_mptimer_info = {
.name = TYPE_ARM_MPTIMER,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(ARMMPTimerState),
+ .instance_init = arm_mptimer_init,
.class_init = arm_mptimer_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 07/24] a9mpcore: Embed ARMMPTimerState
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (5 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 06/24] arm_mptimer: Convert to QOM realize Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 08/24] a9mpcore: Convert to QOM realize Andreas Färber
` (17 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Prepares for QOM realize.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a9mpcore.c | 29 ++++++++++++++---------
hw/timer/arm_mptimer.c | 35 ++++-----------------------
include/hw/timer/arm_mptimer.h | 54 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 76 insertions(+), 42 deletions(-)
create mode 100644 include/hw/timer/arm_mptimer.h
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index df92e3f..db3907e 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -11,6 +11,7 @@
#include "hw/sysbus.h"
#include "hw/intc/arm_gic.h"
#include "hw/misc/a9scu.h"
+#include "hw/timer/arm_mptimer.h"
#define TYPE_A9MPCORE_PRIV "a9mpcore_priv"
#define A9MPCORE_PRIV(obj) \
@@ -23,12 +24,12 @@ typedef struct A9MPPrivState {
uint32_t num_cpu;
MemoryRegion container;
- DeviceState *mptimer;
- DeviceState *wdt;
uint32_t num_irq;
GICState gic;
A9SCUState scu;
+ ARMMPTimerState mptimer;
+ ARMMPTimerState wdt;
} A9MPPrivState;
static void a9mp_priv_set_irq(void *opaque, int irq, int level)
@@ -50,12 +51,18 @@ static void a9mp_priv_initfn(Object *obj)
object_initialize(&s->scu, sizeof(s->scu), TYPE_A9_SCU);
qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default());
+
+ object_initialize(&s->mptimer, sizeof(s->mptimer), TYPE_ARM_MPTIMER);
+ qdev_set_parent_bus(DEVICE(&s->mptimer), sysbus_get_default());
+
+ object_initialize(&s->wdt, sizeof(s->wdt), TYPE_ARM_MPTIMER);
+ qdev_set_parent_bus(DEVICE(&s->wdt), sysbus_get_default());
}
static int a9mp_priv_init(SysBusDevice *dev)
{
A9MPPrivState *s = A9MPCORE_PRIV(dev);
- DeviceState *gicdev, *scudev;
+ DeviceState *gicdev, *scudev, *mptimerdev, *wdtdev;
SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;
int i;
@@ -76,15 +83,15 @@ static int a9mp_priv_init(SysBusDevice *dev)
qdev_init_nofail(scudev);
scubusdev = SYS_BUS_DEVICE(&s->scu);
- s->mptimer = qdev_create(NULL, "arm_mptimer");
- qdev_prop_set_uint32(s->mptimer, "num-cpu", s->num_cpu);
- qdev_init_nofail(s->mptimer);
- timerbusdev = SYS_BUS_DEVICE(s->mptimer);
+ mptimerdev = DEVICE(&s->mptimer);
+ qdev_prop_set_uint32(mptimerdev, "num-cpu", s->num_cpu);
+ qdev_init_nofail(mptimerdev);
+ timerbusdev = SYS_BUS_DEVICE(&s->mptimer);
- s->wdt = qdev_create(NULL, "arm_mptimer");
- qdev_prop_set_uint32(s->wdt, "num-cpu", s->num_cpu);
- qdev_init_nofail(s->wdt);
- wdtbusdev = SYS_BUS_DEVICE(s->wdt);
+ wdtdev = DEVICE(&s->wdt);
+ qdev_prop_set_uint32(wdtdev, "num-cpu", s->num_cpu);
+ qdev_init_nofail(wdtdev);
+ wdtbusdev = SYS_BUS_DEVICE(&s->wdt);
/* Memory map (addresses are offsets from PERIPHBASE):
* 0x0000-0x00ff -- Snoop Control Unit
diff --git a/hw/timer/arm_mptimer.c b/hw/timer/arm_mptimer.c
index 2853db4..d9f9494 100644
--- a/hw/timer/arm_mptimer.c
+++ b/hw/timer/arm_mptimer.c
@@ -19,7 +19,7 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "hw/sysbus.h"
+#include "hw/timer/arm_mptimer.h"
#include "qemu/timer.h"
#include "qom/cpu.h"
@@ -27,34 +27,6 @@
* which is used in both the ARM11MPCore and Cortex-A9MP.
*/
-#define MAX_CPUS 4
-
-/* State of a single timer or watchdog block */
-typedef struct {
- uint32_t count;
- uint32_t load;
- uint32_t control;
- uint32_t status;
- int64_t tick;
- QEMUTimer *timer;
- qemu_irq irq;
- MemoryRegion iomem;
-} TimerBlock;
-
-#define TYPE_ARM_MPTIMER "arm_mptimer"
-#define ARM_MPTIMER(obj) \
- OBJECT_CHECK(ARMMPTimerState, (obj), TYPE_ARM_MPTIMER)
-
-typedef struct {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- uint32_t num_cpu;
- TimerBlock timerblock[MAX_CPUS];
- MemoryRegion iomem;
-} ARMMPTimerState;
-
static inline int get_current_cpu(ARMMPTimerState *s)
{
if (current_cpu->cpu_index >= s->num_cpu) {
@@ -240,8 +212,9 @@ static void arm_mptimer_realize(DeviceState *dev, Error **errp)
ARMMPTimerState *s = ARM_MPTIMER(dev);
int i;
- if (s->num_cpu < 1 || s->num_cpu > MAX_CPUS) {
- hw_error("%s: num-cpu must be between 1 and %d\n", __func__, MAX_CPUS);
+ if (s->num_cpu < 1 || s->num_cpu > ARM_MPTIMER_MAX_CPUS) {
+ hw_error("%s: num-cpu must be between 1 and %d\n",
+ __func__, ARM_MPTIMER_MAX_CPUS);
}
/* We implement one timer block per CPU, and expose multiple MMIO regions:
* * region 0 is "timer for this core"
diff --git a/include/hw/timer/arm_mptimer.h b/include/hw/timer/arm_mptimer.h
new file mode 100644
index 0000000..b34cba0
--- /dev/null
+++ b/include/hw/timer/arm_mptimer.h
@@ -0,0 +1,54 @@
+/*
+ * Private peripheral timer/watchdog blocks for ARM 11MPCore and A9MP
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Copyright (c) 2011 Linaro Limited
+ * Written by Paul Brook, Peter Maydell
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef HW_TIMER_ARM_MPTIMER_H
+#define HW_TIMER_ARM_MPTIMER_H
+
+#include "hw/sysbus.h"
+
+#define ARM_MPTIMER_MAX_CPUS 4
+
+/* State of a single timer or watchdog block */
+typedef struct {
+ uint32_t count;
+ uint32_t load;
+ uint32_t control;
+ uint32_t status;
+ int64_t tick;
+ QEMUTimer *timer;
+ qemu_irq irq;
+ MemoryRegion iomem;
+} TimerBlock;
+
+#define TYPE_ARM_MPTIMER "arm_mptimer"
+#define ARM_MPTIMER(obj) \
+ OBJECT_CHECK(ARMMPTimerState, (obj), TYPE_ARM_MPTIMER)
+
+typedef struct {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ uint32_t num_cpu;
+ TimerBlock timerblock[ARM_MPTIMER_MAX_CPUS];
+ MemoryRegion iomem;
+} ARMMPTimerState;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 08/24] a9mpcore: Convert to QOM realize
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (6 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 07/24] a9mpcore: Embed ARMMPTimerState Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 09/24] a9mpcore: Prepare for QOM embedding Andreas Färber
` (16 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a9mpcore.c | 36 ++++++++++++++++++++++++++----------
1 file changed, 26 insertions(+), 10 deletions(-)
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index db3907e..a162ff0 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -59,38 +59,56 @@ static void a9mp_priv_initfn(Object *obj)
qdev_set_parent_bus(DEVICE(&s->wdt), sysbus_get_default());
}
-static int a9mp_priv_init(SysBusDevice *dev)
+static void a9mp_priv_realize(DeviceState *dev, Error **errp)
{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
A9MPPrivState *s = A9MPCORE_PRIV(dev);
DeviceState *gicdev, *scudev, *mptimerdev, *wdtdev;
SysBusDevice *timerbusdev, *wdtbusdev, *gicbusdev, *scubusdev;
+ Error *err = NULL;
int i;
gicdev = DEVICE(&s->gic);
qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
- qdev_init_nofail(gicdev);
+ object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
gicbusdev = SYS_BUS_DEVICE(&s->gic);
/* Pass through outbound IRQ lines from the GIC */
- sysbus_pass_irq(dev, gicbusdev);
+ sysbus_pass_irq(sbd, gicbusdev);
/* Pass through inbound GPIO lines to the GIC */
- qdev_init_gpio_in(DEVICE(dev), a9mp_priv_set_irq, s->num_irq - 32);
+ qdev_init_gpio_in(dev, a9mp_priv_set_irq, s->num_irq - 32);
scudev = DEVICE(&s->scu);
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;
+ }
scubusdev = SYS_BUS_DEVICE(&s->scu);
mptimerdev = DEVICE(&s->mptimer);
qdev_prop_set_uint32(mptimerdev, "num-cpu", s->num_cpu);
- qdev_init_nofail(mptimerdev);
+ object_property_set_bool(OBJECT(&s->mptimer), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
timerbusdev = SYS_BUS_DEVICE(&s->mptimer);
wdtdev = DEVICE(&s->wdt);
qdev_prop_set_uint32(wdtdev, "num-cpu", s->num_cpu);
- qdev_init_nofail(wdtdev);
+ object_property_set_bool(OBJECT(&s->wdt), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
wdtbusdev = SYS_BUS_DEVICE(&s->wdt);
/* Memory map (addresses are offsets from PERIPHBASE):
@@ -129,7 +147,6 @@ static int a9mp_priv_init(SysBusDevice *dev)
sysbus_connect_irq(wdtbusdev, i,
qdev_get_gpio_in(gicdev, ppibase + 30));
}
- return 0;
}
static Property a9mp_priv_properties[] = {
@@ -147,9 +164,8 @@ static Property a9mp_priv_properties[] = {
static void a9mp_priv_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = a9mp_priv_init;
+ dc->realize = a9mp_priv_realize;
dc->props = a9mp_priv_properties;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 09/24] a9mpcore: Prepare for QOM embedding
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (7 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 08/24] a9mpcore: Convert to QOM realize Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 10/24] a15mpcore: Split off instance_init Andreas Färber
` (15 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a9mpcore.c | 24 +-----------------------
include/hw/cpu/a9mpcore.h | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 38 insertions(+), 23 deletions(-)
create mode 100644 include/hw/cpu/a9mpcore.h
diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c
index a162ff0..918a7d1 100644
--- a/hw/cpu/a9mpcore.c
+++ b/hw/cpu/a9mpcore.c
@@ -8,29 +8,7 @@
* This code is licensed under the GPL.
*/
-#include "hw/sysbus.h"
-#include "hw/intc/arm_gic.h"
-#include "hw/misc/a9scu.h"
-#include "hw/timer/arm_mptimer.h"
-
-#define TYPE_A9MPCORE_PRIV "a9mpcore_priv"
-#define A9MPCORE_PRIV(obj) \
- OBJECT_CHECK(A9MPPrivState, (obj), TYPE_A9MPCORE_PRIV)
-
-typedef struct A9MPPrivState {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- uint32_t num_cpu;
- MemoryRegion container;
- uint32_t num_irq;
-
- GICState gic;
- A9SCUState scu;
- ARMMPTimerState mptimer;
- ARMMPTimerState wdt;
-} A9MPPrivState;
+#include "hw/cpu/a9mpcore.h"
static void a9mp_priv_set_irq(void *opaque, int irq, int level)
{
diff --git a/include/hw/cpu/a9mpcore.h b/include/hw/cpu/a9mpcore.h
new file mode 100644
index 0000000..010489b
--- /dev/null
+++ b/include/hw/cpu/a9mpcore.h
@@ -0,0 +1,37 @@
+/*
+ * Cortex-A9MPCore internal peripheral emulation.
+ *
+ * Copyright (c) 2009 CodeSourcery.
+ * Copyright (c) 2011 Linaro Limited.
+ * Written by Paul Brook, Peter Maydell.
+ *
+ * This code is licensed under the GPL.
+ */
+#ifndef HW_CPU_A9MPCORE_H
+#define HW_CPU_A9MPCORE_H
+
+#include "hw/sysbus.h"
+#include "hw/intc/arm_gic.h"
+#include "hw/misc/a9scu.h"
+#include "hw/timer/arm_mptimer.h"
+
+#define TYPE_A9MPCORE_PRIV "a9mpcore_priv"
+#define A9MPCORE_PRIV(obj) \
+ OBJECT_CHECK(A9MPPrivState, (obj), TYPE_A9MPCORE_PRIV)
+
+typedef struct A9MPPrivState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ uint32_t num_cpu;
+ MemoryRegion container;
+ uint32_t num_irq;
+
+ GICState gic;
+ A9SCUState scu;
+ ARMMPTimerState mptimer;
+ ARMMPTimerState wdt;
+} A9MPPrivState;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 10/24] a15mpcore: Split off instance_init
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (8 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 09/24] a9mpcore: Prepare for QOM embedding Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 11/24] a15mpcore: Embed GICState Andreas Färber
` (14 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Prepares for QOM realize.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a15mpcore.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
index 9abba67..af29c35 100644
--- a/hw/cpu/a15mpcore.c
+++ b/hw/cpu/a15mpcore.c
@@ -44,6 +44,15 @@ static void a15mp_priv_set_irq(void *opaque, int irq, int level)
qemu_set_irq(qdev_get_gpio_in(s->gic, irq), level);
}
+static void a15mp_priv_initfn(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ A15MPPrivState *s = A15MPCORE_PRIV(obj);
+
+ memory_region_init(&s->container, obj, "a15mp-priv-container", 0x8000);
+ sysbus_init_mmio(sbd, &s->container);
+}
+
static int a15mp_priv_init(SysBusDevice *dev)
{
A15MPPrivState *s = A15MPCORE_PRIV(dev);
@@ -92,14 +101,11 @@ static int a15mp_priv_init(SysBusDevice *dev)
* 0x5000-0x5fff -- GIC virtual interface control (not modelled)
* 0x6000-0x7fff -- GIC virtual CPU interface (not modelled)
*/
- memory_region_init(&s->container, OBJECT(s),
- "a15mp-priv-container", 0x8000);
memory_region_add_subregion(&s->container, 0x1000,
sysbus_mmio_get_region(busdev, 0));
memory_region_add_subregion(&s->container, 0x2000,
sysbus_mmio_get_region(busdev, 1));
- sysbus_init_mmio(dev, &s->container);
return 0;
}
@@ -128,6 +134,7 @@ static const TypeInfo a15mp_priv_info = {
.name = TYPE_A15MPCORE_PRIV,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(A15MPPrivState),
+ .instance_init = a15mp_priv_initfn,
.class_init = a15mp_priv_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 11/24] a15mpcore: Embed GICState
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (9 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 10/24] a15mpcore: Split off instance_init Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 12/24] a15mpcore: Convert to QOM realize Andreas Färber
` (13 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
This covers both emulated and KVM GIC.
Prepares for QOM realize.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a15mpcore.c | 39 ++++++++++++++++++++++++---------------
1 file changed, 24 insertions(+), 15 deletions(-)
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
index af29c35..b2614e7 100644
--- a/hw/cpu/a15mpcore.c
+++ b/hw/cpu/a15mpcore.c
@@ -20,6 +20,7 @@
#include "hw/sysbus.h"
#include "sysemu/kvm.h"
+#include "hw/intc/arm_gic.h"
/* A15MP private memory region. */
@@ -35,41 +36,49 @@ typedef struct A15MPPrivState {
uint32_t num_cpu;
uint32_t num_irq;
MemoryRegion container;
- DeviceState *gic;
+
+ GICState gic;
} A15MPPrivState;
static void a15mp_priv_set_irq(void *opaque, int irq, int level)
{
A15MPPrivState *s = (A15MPPrivState *)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 a15mp_priv_initfn(Object *obj)
{
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
A15MPPrivState *s = A15MPCORE_PRIV(obj);
+ DeviceState *gicdev;
+ const char *gictype = "arm_gic";
+
+ if (kvm_irqchip_in_kernel()) {
+ gictype = "kvm-arm-gic";
+ }
memory_region_init(&s->container, obj, "a15mp-priv-container", 0x8000);
sysbus_init_mmio(sbd, &s->container);
+
+ object_initialize(&s->gic, sizeof(s->gic), gictype);
+ gicdev = DEVICE(&s->gic);
+ qdev_set_parent_bus(gicdev, sysbus_get_default());
+ qdev_prop_set_uint32(gicdev, "revision", 2);
}
static int a15mp_priv_init(SysBusDevice *dev)
{
A15MPPrivState *s = A15MPCORE_PRIV(dev);
+ DeviceState *gicdev;
SysBusDevice *busdev;
- const char *gictype = "arm_gic";
int i;
- if (kvm_irqchip_in_kernel()) {
- gictype = "kvm-arm-gic";
- }
-
- s->gic = qdev_create(NULL, gictype);
- qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
- qdev_prop_set_uint32(s->gic, "num-irq", s->num_irq);
- qdev_prop_set_uint32(s->gic, "revision", 2);
- qdev_init_nofail(s->gic);
- busdev = SYS_BUS_DEVICE(s->gic);
+ gicdev = DEVICE(&s->gic);
+ qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
+ qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
+ qdev_init_nofail(gicdev);
+ busdev = SYS_BUS_DEVICE(&s->gic);
/* Pass through outbound IRQ lines from the GIC */
sysbus_pass_irq(dev, busdev);
@@ -87,10 +96,10 @@ static int a15mp_priv_init(SysBusDevice *dev)
* since a real A15 always has TrustZone but QEMU doesn't.
*/
qdev_connect_gpio_out(cpudev, 0,
- qdev_get_gpio_in(s->gic, ppibase + 30));
+ qdev_get_gpio_in(gicdev, ppibase + 30));
/* virtual timer */
qdev_connect_gpio_out(cpudev, 1,
- qdev_get_gpio_in(s->gic, ppibase + 27));
+ qdev_get_gpio_in(gicdev, ppibase + 27));
}
/* Memory map (addresses are offsets from PERIPHBASE):
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 12/24] a15mpcore: Convert to QOM realize
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (10 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 11/24] a15mpcore: Embed GICState Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 13/24] a15mpcore: Prepare for QOM embedding Andreas Färber
` (12 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Turn SysBusDevice initfn into a QOM realizefn.
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a15mpcore.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
index b2614e7..10dc35a 100644
--- a/hw/cpu/a15mpcore.c
+++ b/hw/cpu/a15mpcore.c
@@ -67,24 +67,30 @@ static void a15mp_priv_initfn(Object *obj)
qdev_prop_set_uint32(gicdev, "revision", 2);
}
-static int a15mp_priv_init(SysBusDevice *dev)
+static void a15mp_priv_realize(DeviceState *dev, Error **errp)
{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
A15MPPrivState *s = A15MPCORE_PRIV(dev);
DeviceState *gicdev;
SysBusDevice *busdev;
int i;
+ Error *err = NULL;
gicdev = DEVICE(&s->gic);
qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu);
qdev_prop_set_uint32(gicdev, "num-irq", s->num_irq);
- qdev_init_nofail(gicdev);
+ object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
busdev = SYS_BUS_DEVICE(&s->gic);
/* Pass through outbound IRQ lines from the GIC */
- sysbus_pass_irq(dev, busdev);
+ sysbus_pass_irq(sbd, busdev);
/* Pass through inbound GPIO lines to the GIC */
- qdev_init_gpio_in(DEVICE(dev), a15mp_priv_set_irq, s->num_irq - 32);
+ qdev_init_gpio_in(dev, a15mp_priv_set_irq, s->num_irq - 32);
/* Wire the outputs from each CPU's generic timer to the
* appropriate GIC PPI inputs
@@ -114,8 +120,6 @@ static int a15mp_priv_init(SysBusDevice *dev)
sysbus_mmio_get_region(busdev, 0));
memory_region_add_subregion(&s->container, 0x2000,
sysbus_mmio_get_region(busdev, 1));
-
- return 0;
}
static Property a15mp_priv_properties[] = {
@@ -133,8 +137,8 @@ static Property a15mp_priv_properties[] = {
static void a15mp_priv_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = a15mp_priv_init;
+
+ dc->realize = a15mp_priv_realize;
dc->props = a15mp_priv_properties;
/* We currently have no savable state */
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 13/24] a15mpcore: Prepare for QOM embedding
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (11 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 12/24] a15mpcore: Convert to QOM realize Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 14/24] a9scu: Build only once Andreas Färber
` (11 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
From: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Andreas Färber <andreas.faerber@web.de>
---
hw/cpu/a15mpcore.c | 21 +--------------------
include/hw/cpu/a15mpcore.h | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 45 insertions(+), 20 deletions(-)
create mode 100644 include/hw/cpu/a15mpcore.h
diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c
index 10dc35a..acc419e 100644
--- a/hw/cpu/a15mpcore.c
+++ b/hw/cpu/a15mpcore.c
@@ -18,27 +18,8 @@
* with this program; if not, see <http://www.gnu.org/licenses/>.
*/
-#include "hw/sysbus.h"
+#include "hw/cpu/a15mpcore.h"
#include "sysemu/kvm.h"
-#include "hw/intc/arm_gic.h"
-
-/* A15MP private memory region. */
-
-#define TYPE_A15MPCORE_PRIV "a15mpcore_priv"
-#define A15MPCORE_PRIV(obj) \
- OBJECT_CHECK(A15MPPrivState, (obj), TYPE_A15MPCORE_PRIV)
-
-typedef struct A15MPPrivState {
- /*< private >*/
- SysBusDevice parent_obj;
- /*< public >*/
-
- uint32_t num_cpu;
- uint32_t num_irq;
- MemoryRegion container;
-
- GICState gic;
-} A15MPPrivState;
static void a15mp_priv_set_irq(void *opaque, int irq, int level)
{
diff --git a/include/hw/cpu/a15mpcore.h b/include/hw/cpu/a15mpcore.h
new file mode 100644
index 0000000..b423533
--- /dev/null
+++ b/include/hw/cpu/a15mpcore.h
@@ -0,0 +1,44 @@
+/*
+ * Cortex-A15MPCore internal peripheral emulation.
+ *
+ * Copyright (c) 2012 Linaro Limited.
+ * Written by Peter Maydell.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef HW_CPU_A15MPCORE_H
+#define HW_CPU_A15MPCORE_H
+
+#include "hw/sysbus.h"
+#include "hw/intc/arm_gic.h"
+
+/* A15MP private memory region. */
+
+#define TYPE_A15MPCORE_PRIV "a15mpcore_priv"
+#define A15MPCORE_PRIV(obj) \
+ OBJECT_CHECK(A15MPPrivState, (obj), TYPE_A15MPCORE_PRIV)
+
+typedef struct A15MPPrivState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ uint32_t num_cpu;
+ uint32_t num_irq;
+ MemoryRegion container;
+
+ GICState gic;
+} A15MPPrivState;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 14/24] a9scu: Build only once
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (12 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 13/24] a15mpcore: Prepare for QOM embedding Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 15/24] arm11mpcore: Fix typo in MemoryRegion name Andreas Färber
` (10 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
It does not have a target or ARMCPU dependency.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/misc/Makefile.objs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index 2578e29..5636299 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -10,6 +10,7 @@ obj-$(CONFIG_VMPORT) += vmport.o
# ARM devices
common-obj-$(CONFIG_PL310) += arm_l2x0.o
+common-obj-$(CONFIG_A9SCU) += a9scu.o
# PKUnity SoC devices
common-obj-$(CONFIG_PUV3) += puv3_pm.o
@@ -22,7 +23,6 @@ obj-$(CONFIG_LINUX) += vfio.o
endif
obj-$(CONFIG_REALVIEW) += arm_sysctl.o
-obj-$(CONFIG_A9SCU) += a9scu.o
obj-$(CONFIG_NSERIES) += cbus.o
obj-$(CONFIG_ECCMEMCTL) += eccmemctl.o
obj-$(CONFIG_EXYNOS4) += exynos4210_pmu.o
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 15/24] arm11mpcore: Fix typo in MemoryRegion name
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (13 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 14/24] a9scu: Build only once Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 16/24] arm11mpcore: Drop unused fields Andreas Färber
` (9 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
"mpcode" -> "mpcore"
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/arm11mpcore.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index a786c62..27cd32b 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -93,7 +93,7 @@ static void mpcore_priv_map_setup(ARM11MPCorePriveState *s)
SysBusDevice *timerbusdev = SYS_BUS_DEVICE(s->mptimer);
SysBusDevice *wdtbusdev = SYS_BUS_DEVICE(s->wdtimer);
memory_region_init(&s->container, OBJECT(s),
- "mpcode-priv-container", 0x2000);
+ "mpcore-priv-container", 0x2000);
memory_region_init_io(&s->iomem, OBJECT(s),
&mpcore_scu_ops, s, "mpcore-scu", 0x100);
memory_region_add_subregion(&s->container, 0, &s->iomem);
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 16/24] arm11mpcore: Drop unused fields
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (14 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 15/24] arm11mpcore: Fix typo in MemoryRegion name Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 17/24] arm11mpcore: Create container MemoryRegion in instance_init Andreas Färber
` (8 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/arm11mpcore.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index 27cd32b..8719634 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -20,8 +20,6 @@ typedef struct ARM11MPCorePriveState {
SysBusDevice parent_obj;
uint32_t scu_control;
- int iomemtype;
- uint32_t old_timer_status[8];
uint32_t num_cpu;
MemoryRegion iomem;
MemoryRegion container;
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 17/24] arm11mpcore: Create container MemoryRegion in instance_init
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (15 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 16/24] arm11mpcore: Drop unused fields Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 18/24] arm11mpcore: Split off SCU device Andreas Färber
` (7 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
This allows to map the region directly after object initialization.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/arm11mpcore.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index 8719634..5f80e7b 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -90,8 +90,6 @@ static void mpcore_priv_map_setup(ARM11MPCorePriveState *s)
SysBusDevice *gicbusdev = SYS_BUS_DEVICE(s->gic);
SysBusDevice *timerbusdev = SYS_BUS_DEVICE(s->mptimer);
SysBusDevice *wdtbusdev = SYS_BUS_DEVICE(s->wdtimer);
- memory_region_init(&s->container, OBJECT(s),
- "mpcore-priv-container", 0x2000);
memory_region_init_io(&s->iomem, OBJECT(s),
&mpcore_scu_ops, s, "mpcore-scu", 0x100);
memory_region_add_subregion(&s->container, 0, &s->iomem);
@@ -155,10 +153,19 @@ static int mpcore_priv_init(SysBusDevice *sbd)
qdev_init_nofail(s->wdtimer);
mpcore_priv_map_setup(s);
- sysbus_init_mmio(sbd, &s->container);
return 0;
}
+static void mpcore_priv_initfn(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ ARM11MPCorePriveState *s = ARM11MPCORE_PRIV(obj);
+
+ memory_region_init(&s->container, OBJECT(s),
+ "mpcore-priv-container", 0x2000);
+ sysbus_init_mmio(sbd, &s->container);
+}
+
#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
#define REALVIEW_MPCORE_RIRQ(obj) \
OBJECT_CHECK(mpcore_rirq_state, (obj), TYPE_REALVIEW_MPCORE_RIRQ)
@@ -277,6 +284,7 @@ static const TypeInfo mpcore_priv_info = {
.name = TYPE_ARM11MPCORE_PRIV,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(ARM11MPCorePriveState),
+ .instance_init = mpcore_priv_initfn,
.class_init = mpcore_priv_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 18/24] arm11mpcore: Split off SCU device
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (16 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 17/24] arm11mpcore: Create container MemoryRegion in instance_init Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 19/24] arm11mpcore: Convert ARM11MPCorePriveState to QOM realize Andreas Färber
` (6 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
Inspired by a9scu.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
default-configs/arm-softmmu.mak | 1 +
hw/cpu/arm11mpcore.c | 65 ++++++--------------------
hw/misc/Makefile.objs | 1 +
hw/misc/arm11scu.c | 100 ++++++++++++++++++++++++++++++++++++++++
include/hw/misc/arm11scu.h | 29 ++++++++++++
5 files changed, 145 insertions(+), 51 deletions(-)
create mode 100644 hw/misc/arm11scu.c
create mode 100644 include/hw/misc/arm11scu.h
diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak
index ac0815d..52d263a 100644
--- a/default-configs/arm-softmmu.mak
+++ b/default-configs/arm-softmmu.mak
@@ -62,6 +62,7 @@ CONFIG_BITBANG_I2C=y
CONFIG_FRAMEBUFFER=y
CONFIG_XILINX_SPIPS=y
+CONFIG_ARM11SCU=y
CONFIG_A9SCU=y
CONFIG_MARVELL_88W8618=y
CONFIG_OMAP=y
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index 5f80e7b..5dcc73a 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -8,6 +8,7 @@
*/
#include "hw/sysbus.h"
+#include "hw/misc/arm11scu.h"
#include "qemu/timer.h"
/* MPCore private memory region. */
@@ -19,64 +20,18 @@
typedef struct ARM11MPCorePriveState {
SysBusDevice parent_obj;
- uint32_t scu_control;
uint32_t num_cpu;
- MemoryRegion iomem;
MemoryRegion container;
DeviceState *mptimer;
DeviceState *wdtimer;
DeviceState *gic;
uint32_t num_irq;
+
+ ARM11SCUState scu;
} ARM11MPCorePriveState;
/* Per-CPU private memory mapped IO. */
-static uint64_t mpcore_scu_read(void *opaque, hwaddr offset,
- unsigned size)
-{
- ARM11MPCorePriveState *s = (ARM11MPCorePriveState *)opaque;
- int id;
- /* SCU */
- switch (offset) {
- case 0x00: /* Control. */
- return s->scu_control;
- case 0x04: /* Configuration. */
- id = ((1 << s->num_cpu) - 1) << 4;
- return id | (s->num_cpu - 1);
- case 0x08: /* CPU status. */
- return 0;
- case 0x0c: /* Invalidate all. */
- return 0;
- default:
- qemu_log_mask(LOG_GUEST_ERROR,
- "mpcore_priv_read: Bad offset %x\n", (int)offset);
- return 0;
- }
-}
-
-static void mpcore_scu_write(void *opaque, hwaddr offset,
- uint64_t value, unsigned size)
-{
- ARM11MPCorePriveState *s = (ARM11MPCorePriveState *)opaque;
- /* SCU */
- switch (offset) {
- case 0: /* Control register. */
- s->scu_control = value & 1;
- break;
- case 0x0c: /* Invalidate all. */
- /* This is a no-op as cache is not emulated. */
- break;
- default:
- qemu_log_mask(LOG_GUEST_ERROR,
- "mpcore_priv_read: Bad offset %x\n", (int)offset);
- }
-}
-
-static const MemoryRegionOps mpcore_scu_ops = {
- .read = mpcore_scu_read,
- .write = mpcore_scu_write,
- .endianness = DEVICE_NATIVE_ENDIAN,
-};
static void mpcore_priv_set_irq(void *opaque, int irq, int level)
{
@@ -87,12 +42,13 @@ static void mpcore_priv_set_irq(void *opaque, int irq, int 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);
- memory_region_init_io(&s->iomem, OBJECT(s),
- &mpcore_scu_ops, s, "mpcore-scu", 0x100);
- memory_region_add_subregion(&s->container, 0, &s->iomem);
+
+ memory_region_add_subregion(&s->container, 0,
+ sysbus_mmio_get_region(scubusdev, 0));
/* GIC CPU interfaces: "current CPU" at 0x100, then specific CPUs
* at 0x200, 0x300...
*/
@@ -130,6 +86,10 @@ static int mpcore_priv_init(SysBusDevice *sbd)
{
DeviceState *dev = DEVICE(sbd);
ARM11MPCorePriveState *s = ARM11MPCORE_PRIV(dev);
+ DeviceState *scudev = DEVICE(&s->scu);
+
+ qdev_prop_set_uint32(scudev, "num-cpu", s->num_cpu);
+ qdev_init_nofail(scudev);
s->gic = qdev_create(NULL, "arm_gic");
qdev_prop_set_uint32(s->gic, "num-cpu", s->num_cpu);
@@ -164,6 +124,9 @@ static void mpcore_priv_initfn(Object *obj)
memory_region_init(&s->container, OBJECT(s),
"mpcore-priv-container", 0x2000);
sysbus_init_mmio(sbd, &s->container);
+
+ object_initialize(&s->scu, sizeof(s->scu), TYPE_ARM11_SCU);
+ qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default());
}
#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
diff --git a/hw/misc/Makefile.objs b/hw/misc/Makefile.objs
index 5636299..a30bf5e 100644
--- a/hw/misc/Makefile.objs
+++ b/hw/misc/Makefile.objs
@@ -11,6 +11,7 @@ obj-$(CONFIG_VMPORT) += vmport.o
# ARM devices
common-obj-$(CONFIG_PL310) += arm_l2x0.o
common-obj-$(CONFIG_A9SCU) += a9scu.o
+common-obj-$(CONFIG_ARM11SCU) += arm11scu.o
# PKUnity SoC devices
common-obj-$(CONFIG_PUV3) += puv3_pm.o
diff --git a/hw/misc/arm11scu.c b/hw/misc/arm11scu.c
new file mode 100644
index 0000000..a791675
--- /dev/null
+++ b/hw/misc/arm11scu.c
@@ -0,0 +1,100 @@
+/*
+ * ARM11MPCore Snoop Control Unit (SCU) emulation
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Copyright (c) 2013 SUSE LINUX Products GmbH
+ * Written by Paul Brook and Andreas Färber
+ *
+ * This code is licensed under the GPL.
+ */
+
+#include "hw/misc/arm11scu.h"
+
+static uint64_t mpcore_scu_read(void *opaque, hwaddr offset,
+ unsigned size)
+{
+ ARM11SCUState *s = (ARM11SCUState *)opaque;
+ int id;
+ /* SCU */
+ switch (offset) {
+ case 0x00: /* Control. */
+ return s->control;
+ case 0x04: /* Configuration. */
+ id = ((1 << s->num_cpu) - 1) << 4;
+ return id | (s->num_cpu - 1);
+ case 0x08: /* CPU status. */
+ return 0;
+ case 0x0c: /* Invalidate all. */
+ return 0;
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "mpcore_priv_read: Bad offset %x\n", (int)offset);
+ return 0;
+ }
+}
+
+static void mpcore_scu_write(void *opaque, hwaddr offset,
+ uint64_t value, unsigned size)
+{
+ ARM11SCUState *s = (ARM11SCUState *)opaque;
+ /* SCU */
+ switch (offset) {
+ case 0: /* Control register. */
+ s->control = value & 1;
+ break;
+ case 0x0c: /* Invalidate all. */
+ /* This is a no-op as cache is not emulated. */
+ break;
+ default:
+ qemu_log_mask(LOG_GUEST_ERROR,
+ "mpcore_priv_read: Bad offset %x\n", (int)offset);
+ }
+}
+
+static const MemoryRegionOps mpcore_scu_ops = {
+ .read = mpcore_scu_read,
+ .write = mpcore_scu_write,
+ .endianness = DEVICE_NATIVE_ENDIAN,
+};
+
+static void arm11_scu_realize(DeviceState *dev, Error **errp)
+{
+}
+
+static void arm11_scu_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ ARM11SCUState *s = ARM11_SCU(obj);
+
+ memory_region_init_io(&s->iomem, OBJECT(s),
+ &mpcore_scu_ops, s, "mpcore-scu", 0x100);
+ sysbus_init_mmio(sbd, &s->iomem);
+}
+
+static Property arm11_scu_properties[] = {
+ DEFINE_PROP_UINT32("num-cpu", ARM11SCUState, num_cpu, 1),
+ DEFINE_PROP_END_OF_LIST()
+};
+
+static void arm11_scu_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ dc->realize = arm11_scu_realize;
+ dc->props = arm11_scu_properties;
+}
+
+static const TypeInfo arm11_scu_type_info = {
+ .name = TYPE_ARM11_SCU,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(ARM11SCUState),
+ .instance_init = arm11_scu_init,
+ .class_init = arm11_scu_class_init,
+};
+
+static void arm11_scu_register_types(void)
+{
+ type_register_static(&arm11_scu_type_info);
+}
+
+type_init(arm11_scu_register_types)
diff --git a/include/hw/misc/arm11scu.h b/include/hw/misc/arm11scu.h
new file mode 100644
index 0000000..5ad0f3d
--- /dev/null
+++ b/include/hw/misc/arm11scu.h
@@ -0,0 +1,29 @@
+/*
+ * ARM11MPCore Snoop Control Unit (SCU) emulation
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Copyright (c) 2013 SUSE LINUX Products GmbH
+ * Written by Paul Brook and Andreas Färber
+ *
+ * This code is licensed under the GPL.
+ */
+
+#ifndef HW_MISC_ARM11SCU_H
+#define HW_MISC_ARM11SCU_H
+
+#include "hw/sysbus.h"
+
+#define TYPE_ARM11_SCU "arm11-scu"
+#define ARM11_SCU(obj) OBJECT_CHECK(ARM11SCUState, (obj), TYPE_ARM11_SCU)
+
+typedef struct ARM11SCUState {
+ /*< private >*/
+ SysBusDevice parent_obj;
+ /*< public >*/
+
+ uint32_t control;
+ uint32_t num_cpu;
+ MemoryRegion iomem;
+} ARM11SCUState;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 19/24] arm11mpcore: Convert ARM11MPCorePriveState to QOM realize
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (17 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 18/24] arm11mpcore: Split off SCU device Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 20/24] realview_gic: Convert " Andreas Färber
` (5 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
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 5dcc73a..f372283 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, sizeof(s->scu), TYPE_ARM11_SCU);
qdev_set_parent_bus(DEVICE(&s->scu), sysbus_get_default());
+
+ object_initialize(&s->gic, sizeof(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, sizeof(s->mptimer), TYPE_ARM_MPTIMER);
+ qdev_set_parent_bus(DEVICE(&s->mptimer), sysbus_get_default());
+
+ object_initialize(&s->wdtimer, sizeof(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
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 20/24] realview_gic: Convert to QOM realize
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (18 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 19/24] arm11mpcore: Convert ARM11MPCorePriveState to QOM realize Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 21/24] realview_gic: Prepare for QOM embedding Andreas Färber
` (4 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
Embed GICState and replace SysBus initfn with realizefn.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/intc/realview_gic.c | 51 ++++++++++++++++++++++++++++++++++----------------
1 file changed, 35 insertions(+), 16 deletions(-)
diff --git a/hw/intc/realview_gic.c b/hw/intc/realview_gic.c
index ce80447..4ff48bb 100644
--- a/hw/intc/realview_gic.c
+++ b/hw/intc/realview_gic.c
@@ -8,40 +8,46 @@
*/
#include "hw/sysbus.h"
+#include "hw/intc/arm_gic.h"
#define TYPE_REALVIEW_GIC "realview_gic"
#define REALVIEW_GIC(obj) \
OBJECT_CHECK(RealViewGICState, (obj), TYPE_REALVIEW_GIC)
-typedef struct {
+typedef struct RealViewGICState {
SysBusDevice parent_obj;
- DeviceState *gic;
MemoryRegion container;
+
+ GICState gic;
} RealViewGICState;
static void realview_gic_set_irq(void *opaque, int irq, int level)
{
RealViewGICState *s = (RealViewGICState *)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 int realview_gic_init(SysBusDevice *sbd)
+static void realview_gic_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
RealViewGICState *s = REALVIEW_GIC(dev);
SysBusDevice *busdev;
+ Error *err = NULL;
/* The GICs on the RealView boards have a fixed nonconfigurable
* number of interrupt lines, so we don't need to expose this as
* a qdev property.
*/
int numirq = 96;
- s->gic = qdev_create(NULL, "arm_gic");
- qdev_prop_set_uint32(s->gic, "num-cpu", 1);
- qdev_prop_set_uint32(s->gic, "num-irq", numirq);
- qdev_init_nofail(s->gic);
- busdev = SYS_BUS_DEVICE(s->gic);
+ qdev_prop_set_uint32(DEVICE(&s->gic), "num-irq", numirq);
+ object_property_set_bool(OBJECT(&s->gic), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
+ busdev = SYS_BUS_DEVICE(&s->gic);
/* Pass through outbound IRQ lines from the GIC */
sysbus_pass_irq(sbd, busdev);
@@ -49,27 +55,40 @@ static int realview_gic_init(SysBusDevice *sbd)
/* Pass through inbound GPIO lines to the GIC */
qdev_init_gpio_in(dev, realview_gic_set_irq, numirq - 32);
- memory_region_init(&s->container, OBJECT(s),
- "realview-gic-container", 0x2000);
memory_region_add_subregion(&s->container, 0,
sysbus_mmio_get_region(busdev, 1));
memory_region_add_subregion(&s->container, 0x1000,
sysbus_mmio_get_region(busdev, 0));
+}
+
+static void realview_gic_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ RealViewGICState *s = REALVIEW_GIC(obj);
+ DeviceState *gicdev;
+
+ memory_region_init(&s->container, OBJECT(s),
+ "realview-gic-container", 0x2000);
sysbus_init_mmio(sbd, &s->container);
- return 0;
+
+ object_initialize(&s->gic, sizeof(s->gic), TYPE_ARM_GIC);
+ gicdev = DEVICE(&s->gic);
+ qdev_set_parent_bus(gicdev, sysbus_get_default());
+ qdev_prop_set_uint32(gicdev, "num-cpu", 1);
}
-static void realview_gic_class_init(ObjectClass *klass, void *data)
+static void realview_gic_class_init(ObjectClass *oc, void *data)
{
- SysBusDeviceClass *sdc = SYS_BUS_DEVICE_CLASS(klass);
+ DeviceClass *dc = DEVICE_CLASS(oc);
- sdc->init = realview_gic_init;
+ dc->realize = realview_gic_realize;
}
static const TypeInfo realview_gic_info = {
.name = TYPE_REALVIEW_GIC,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(RealViewGICState),
+ .instance_init = realview_gic_init,
.class_init = realview_gic_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 21/24] realview_gic: Prepare for QOM embedding
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (19 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 20/24] realview_gic: Convert " Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 22/24] arm11mpcore: Convert mpcore_rirq_state to QOM realize Andreas Färber
` (3 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber
Move state struct, type constant and cast macro to a new header.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/intc/realview_gic.c | 15 +--------------
include/hw/intc/realview_gic.h | 28 ++++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 14 deletions(-)
create mode 100644 include/hw/intc/realview_gic.h
diff --git a/hw/intc/realview_gic.c b/hw/intc/realview_gic.c
index 4ff48bb..6c81296 100644
--- a/hw/intc/realview_gic.c
+++ b/hw/intc/realview_gic.c
@@ -7,20 +7,7 @@
* This code is licensed under the GPL.
*/
-#include "hw/sysbus.h"
-#include "hw/intc/arm_gic.h"
-
-#define TYPE_REALVIEW_GIC "realview_gic"
-#define REALVIEW_GIC(obj) \
- OBJECT_CHECK(RealViewGICState, (obj), TYPE_REALVIEW_GIC)
-
-typedef struct RealViewGICState {
- SysBusDevice parent_obj;
-
- MemoryRegion container;
-
- GICState gic;
-} RealViewGICState;
+#include "hw/intc/realview_gic.h"
static void realview_gic_set_irq(void *opaque, int irq, int level)
{
diff --git a/include/hw/intc/realview_gic.h b/include/hw/intc/realview_gic.h
new file mode 100644
index 0000000..1783ea1
--- /dev/null
+++ b/include/hw/intc/realview_gic.h
@@ -0,0 +1,28 @@
+/*
+ * ARM RealView Emulation Baseboard Interrupt Controller
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Written by Paul Brook
+ *
+ * This code is licensed under the GPL.
+ */
+
+#ifndef HW_INTC_REALVIEW_GIC_H
+#define HW_INTC_REALVIEW_GIC_H
+
+#include "hw/sysbus.h"
+#include "hw/intc/arm_gic.h"
+
+#define TYPE_REALVIEW_GIC "realview_gic"
+#define REALVIEW_GIC(obj) \
+ OBJECT_CHECK(RealViewGICState, (obj), TYPE_REALVIEW_GIC)
+
+typedef struct RealViewGICState {
+ SysBusDevice parent_obj;
+
+ MemoryRegion container;
+
+ GICState gic;
+} RealViewGICState;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 22/24] arm11mpcore: Convert mpcore_rirq_state to QOM realize
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (20 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 21/24] realview_gic: Prepare for QOM embedding Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 23/24] arm11mpcore: Prepare for QOM embedding Andreas Färber
` (2 subsequent siblings)
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
Embed ARM11MPCorePriveState and RealViewGICState and replace SysBus
initfn with realizefn.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/arm11mpcore.c | 58 +++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 44 insertions(+), 14 deletions(-)
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index f372283..578e3d3 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -10,6 +10,7 @@
#include "hw/sysbus.h"
#include "hw/misc/arm11scu.h"
#include "hw/intc/arm_gic.h"
+#include "hw/intc/realview_gic.h"
#include "hw/timer/arm_mptimer.h"
#include "qemu/timer.h"
@@ -168,10 +169,12 @@ static void mpcore_priv_initfn(Object *obj)
typedef struct {
SysBusDevice parent_obj;
- SysBusDevice *priv;
qemu_irq cpuic[32];
qemu_irq rvic[4][64];
uint32_t num_cpu;
+
+ ARM11MPCorePriveState priv;
+ RealViewGICState gic[4];
} mpcore_rirq_state;
/* Map baseboard IRQs onto CPU IRQ lines. */
@@ -198,34 +201,61 @@ static void mpcore_rirq_set_irq(void *opaque, int irq, int level)
}
}
-static int realview_mpcore_init(SysBusDevice *sbd)
+static void realview_mpcore_realize(DeviceState *dev, Error **errp)
{
- DeviceState *dev = DEVICE(sbd);
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(dev);
+ DeviceState *priv = DEVICE(&s->priv);
DeviceState *gic;
- DeviceState *priv;
+ SysBusDevice *gicbusdev;
+ Error *err = NULL;
int n;
int i;
- priv = qdev_create(NULL, TYPE_ARM11MPCORE_PRIV);
qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
- qdev_init_nofail(priv);
- s->priv = SYS_BUS_DEVICE(priv);
- sysbus_pass_irq(sbd, s->priv);
+ object_property_set_bool(OBJECT(&s->priv), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
+ sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
for (i = 0; i < 32; i++) {
s->cpuic[i] = qdev_get_gpio_in(priv, i);
}
/* ??? IRQ routing is hardcoded to "normal" mode. */
for (n = 0; n < 4; n++) {
- gic = sysbus_create_simple("realview_gic", 0x10040000 + n * 0x10000,
- s->cpuic[10 + n]);
+ object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
+ gic = DEVICE(&s->gic[n]);
+ gicbusdev = SYS_BUS_DEVICE(&s->gic[n]);
+ sysbus_mmio_map(gicbusdev, 0, 0x10040000 + n * 0x10000);
+ sysbus_connect_irq(gicbusdev, 0, s->cpuic[10 + n]);
for (i = 0; i < 64; i++) {
s->rvic[n][i] = qdev_get_gpio_in(gic, i);
}
}
qdev_init_gpio_in(dev, mpcore_rirq_set_irq, 64);
- sysbus_init_mmio(sbd, sysbus_mmio_get_region(s->priv, 0));
- return 0;
+}
+
+static void mpcore_rirq_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(obj);
+ SysBusDevice *privbusdev;
+ int i;
+
+ object_initialize(&s->priv, sizeof(s->priv), TYPE_ARM11MPCORE_PRIV);
+ qdev_set_parent_bus(DEVICE(&s->priv), sysbus_get_default());
+ privbusdev = SYS_BUS_DEVICE(&s->priv);
+ sysbus_init_mmio(sbd, sysbus_mmio_get_region(privbusdev, 0));
+
+ for (i = 0; i < 4; i++) {
+ object_initialize(&s->gic[i], sizeof(s->gic[i]), TYPE_REALVIEW_GIC);
+ qdev_set_parent_bus(DEVICE(&s->gic[i]), sysbus_get_default());
+ }
}
static Property mpcore_rirq_properties[] = {
@@ -236,9 +266,8 @@ static Property mpcore_rirq_properties[] = {
static void mpcore_rirq_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
- SysBusDeviceClass *k = SYS_BUS_DEVICE_CLASS(klass);
- k->init = realview_mpcore_init;
+ dc->realize = realview_mpcore_realize;
dc->props = mpcore_rirq_properties;
}
@@ -246,6 +275,7 @@ static const TypeInfo mpcore_rirq_info = {
.name = TYPE_REALVIEW_MPCORE_RIRQ,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(mpcore_rirq_state),
+ .instance_init = mpcore_rirq_init,
.class_init = mpcore_rirq_class_init,
};
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 23/24] arm11mpcore: Prepare for QOM embedding
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (21 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 22/24] arm11mpcore: Convert mpcore_rirq_state to QOM realize Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore Andreas Färber
2013-09-13 15:38 ` [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Peter Maydell
24 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
Move state struct, type constant and cast macro to a new header.
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/arm11mpcore.c | 27 +--------------------------
include/hw/cpu/arm11mpcore.h | 35 +++++++++++++++++++++++++++++++++++
2 files changed, 36 insertions(+), 26 deletions(-)
create mode 100644 include/hw/cpu/arm11mpcore.h
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index 578e3d3..0ec27c7 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -7,33 +7,8 @@
* This code is licensed under the GPL.
*/
-#include "hw/sysbus.h"
-#include "hw/misc/arm11scu.h"
-#include "hw/intc/arm_gic.h"
+#include "hw/cpu/arm11mpcore.h"
#include "hw/intc/realview_gic.h"
-#include "hw/timer/arm_mptimer.h"
-#include "qemu/timer.h"
-
-/* MPCore private memory region. */
-
-#define TYPE_ARM11MPCORE_PRIV "arm11mpcore_priv"
-#define ARM11MPCORE_PRIV(obj) \
- OBJECT_CHECK(ARM11MPCorePriveState, (obj), TYPE_ARM11MPCORE_PRIV)
-
-typedef struct ARM11MPCorePriveState {
- SysBusDevice parent_obj;
-
- uint32_t num_cpu;
- MemoryRegion container;
- uint32_t num_irq;
-
- ARM11SCUState scu;
- GICState gic;
- ARMMPTimerState mptimer;
- ARMMPTimerState wdtimer;
-} ARM11MPCorePriveState;
-
-/* Per-CPU private memory mapped IO. */
static void mpcore_priv_set_irq(void *opaque, int irq, int level)
diff --git a/include/hw/cpu/arm11mpcore.h b/include/hw/cpu/arm11mpcore.h
new file mode 100644
index 0000000..6196109
--- /dev/null
+++ b/include/hw/cpu/arm11mpcore.h
@@ -0,0 +1,35 @@
+/*
+ * ARM11MPCore internal peripheral emulation.
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Written by Paul Brook
+ *
+ * This code is licensed under the GPL.
+ */
+
+#ifndef HW_CPU_ARM11MPCORE_H
+#define HW_CPU_ARM11MPCORE_H
+
+#include "hw/sysbus.h"
+#include "hw/misc/arm11scu.h"
+#include "hw/intc/arm_gic.h"
+#include "hw/timer/arm_mptimer.h"
+
+#define TYPE_ARM11MPCORE_PRIV "arm11mpcore_priv"
+#define ARM11MPCORE_PRIV(obj) \
+ OBJECT_CHECK(ARM11MPCorePriveState, (obj), TYPE_ARM11MPCORE_PRIV)
+
+typedef struct ARM11MPCorePriveState {
+ SysBusDevice parent_obj;
+
+ uint32_t num_cpu;
+ MemoryRegion container;
+ uint32_t num_irq;
+
+ ARM11SCUState scu;
+ GICState gic;
+ ARMMPTimerState mptimer;
+ ARMMPTimerState wdtimer;
+} ARM11MPCorePriveState;
+
+#endif
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (22 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 23/24] arm11mpcore: Prepare for QOM embedding Andreas Färber
@ 2013-09-11 14:37 ` Andreas Färber
2013-09-13 15:33 ` Peter Maydell
2013-09-13 15:38 ` [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Peter Maydell
24 siblings, 1 reply; 29+ messages in thread
From: Andreas Färber @ 2013-09-11 14:37 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Andreas Färber, Paul Brook
Signed-off-by: Andreas Färber <afaerber@suse.de>
---
hw/cpu/Makefile.objs | 1 +
hw/cpu/arm11mpcore.c | 121 -----------------------------------------
hw/cpu/realview_mpcore.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 140 insertions(+), 121 deletions(-)
create mode 100644 hw/cpu/realview_mpcore.c
diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs
index df287c1..6381238 100644
--- a/hw/cpu/Makefile.objs
+++ b/hw/cpu/Makefile.objs
@@ -1,4 +1,5 @@
obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
+obj-$(CONFIG_REALVIEW) += realview_mpcore.o
obj-$(CONFIG_A9MPCORE) += a9mpcore.o
obj-$(CONFIG_A15MPCORE) += a15mpcore.o
obj-$(CONFIG_ICC_BUS) += icc_bus.o
diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
index 0ec27c7..717d3e4 100644
--- a/hw/cpu/arm11mpcore.c
+++ b/hw/cpu/arm11mpcore.c
@@ -134,126 +134,6 @@ static void mpcore_priv_initfn(Object *obj)
qdev_set_parent_bus(DEVICE(&s->wdtimer), sysbus_get_default());
}
-#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
-#define REALVIEW_MPCORE_RIRQ(obj) \
- OBJECT_CHECK(mpcore_rirq_state, (obj), TYPE_REALVIEW_MPCORE_RIRQ)
-
-/* Dummy PIC to route IRQ lines. The baseboard has 4 independent IRQ
- controllers. The output of these, plus some of the raw input lines
- are fed into a single SMP-aware interrupt controller on the CPU. */
-typedef struct {
- SysBusDevice parent_obj;
-
- qemu_irq cpuic[32];
- qemu_irq rvic[4][64];
- uint32_t num_cpu;
-
- ARM11MPCorePriveState priv;
- RealViewGICState gic[4];
-} mpcore_rirq_state;
-
-/* Map baseboard IRQs onto CPU IRQ lines. */
-static const int mpcore_irq_map[32] = {
- -1, -1, -1, -1, 1, 2, -1, -1,
- -1, -1, 6, -1, 4, 5, -1, -1,
- -1, 14, 15, 0, 7, 8, -1, -1,
- -1, -1, -1, -1, 9, 3, -1, -1,
-};
-
-static void mpcore_rirq_set_irq(void *opaque, int irq, int level)
-{
- mpcore_rirq_state *s = (mpcore_rirq_state *)opaque;
- int i;
-
- for (i = 0; i < 4; i++) {
- qemu_set_irq(s->rvic[i][irq], level);
- }
- if (irq < 32) {
- irq = mpcore_irq_map[irq];
- if (irq >= 0) {
- qemu_set_irq(s->cpuic[irq], level);
- }
- }
-}
-
-static void realview_mpcore_realize(DeviceState *dev, Error **errp)
-{
- SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
- mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(dev);
- DeviceState *priv = DEVICE(&s->priv);
- DeviceState *gic;
- SysBusDevice *gicbusdev;
- Error *err = NULL;
- int n;
- int i;
-
- qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
- object_property_set_bool(OBJECT(&s->priv), true, "realized", &err);
- if (err != NULL) {
- error_propagate(errp, err);
- return;
- }
- sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
- for (i = 0; i < 32; i++) {
- s->cpuic[i] = qdev_get_gpio_in(priv, i);
- }
- /* ??? IRQ routing is hardcoded to "normal" mode. */
- for (n = 0; n < 4; n++) {
- object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", &err);
- if (err != NULL) {
- error_propagate(errp, err);
- return;
- }
- gic = DEVICE(&s->gic[n]);
- gicbusdev = SYS_BUS_DEVICE(&s->gic[n]);
- sysbus_mmio_map(gicbusdev, 0, 0x10040000 + n * 0x10000);
- sysbus_connect_irq(gicbusdev, 0, s->cpuic[10 + n]);
- for (i = 0; i < 64; i++) {
- s->rvic[n][i] = qdev_get_gpio_in(gic, i);
- }
- }
- qdev_init_gpio_in(dev, mpcore_rirq_set_irq, 64);
-}
-
-static void mpcore_rirq_init(Object *obj)
-{
- SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
- mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(obj);
- SysBusDevice *privbusdev;
- int i;
-
- object_initialize(&s->priv, sizeof(s->priv), TYPE_ARM11MPCORE_PRIV);
- qdev_set_parent_bus(DEVICE(&s->priv), sysbus_get_default());
- privbusdev = SYS_BUS_DEVICE(&s->priv);
- sysbus_init_mmio(sbd, sysbus_mmio_get_region(privbusdev, 0));
-
- for (i = 0; i < 4; i++) {
- object_initialize(&s->gic[i], sizeof(s->gic[i]), TYPE_REALVIEW_GIC);
- qdev_set_parent_bus(DEVICE(&s->gic[i]), sysbus_get_default());
- }
-}
-
-static Property mpcore_rirq_properties[] = {
- DEFINE_PROP_UINT32("num-cpu", mpcore_rirq_state, num_cpu, 1),
- DEFINE_PROP_END_OF_LIST(),
-};
-
-static void mpcore_rirq_class_init(ObjectClass *klass, void *data)
-{
- DeviceClass *dc = DEVICE_CLASS(klass);
-
- dc->realize = realview_mpcore_realize;
- dc->props = mpcore_rirq_properties;
-}
-
-static const TypeInfo mpcore_rirq_info = {
- .name = TYPE_REALVIEW_MPCORE_RIRQ,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(mpcore_rirq_state),
- .instance_init = mpcore_rirq_init,
- .class_init = mpcore_rirq_class_init,
-};
-
static Property mpcore_priv_properties[] = {
DEFINE_PROP_UINT32("num-cpu", ARM11MPCorePriveState, num_cpu, 1),
/* The ARM11 MPCORE TRM says the on-chip controller may have
@@ -286,7 +166,6 @@ static const TypeInfo mpcore_priv_info = {
static void arm11mpcore_register_types(void)
{
- type_register_static(&mpcore_rirq_info);
type_register_static(&mpcore_priv_info);
}
diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c
new file mode 100644
index 0000000..c39a2da
--- /dev/null
+++ b/hw/cpu/realview_mpcore.c
@@ -0,0 +1,139 @@
+/*
+ * RealView ARM11MPCore internal peripheral emulation
+ *
+ * Copyright (c) 2006-2007 CodeSourcery.
+ * Copyright (c) 2013 SUSE LINUX Products GmbH
+ * Written by Paul Brook and Andreas Färber
+ *
+ * This code is licensed under the GPL.
+ */
+
+#include "hw/cpu/arm11mpcore.h"
+#include "hw/intc/realview_gic.h"
+
+#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
+#define REALVIEW_MPCORE_RIRQ(obj) \
+ OBJECT_CHECK(mpcore_rirq_state, (obj), TYPE_REALVIEW_MPCORE_RIRQ)
+
+/* Dummy PIC to route IRQ lines. The baseboard has 4 independent IRQ
+ controllers. The output of these, plus some of the raw input lines
+ are fed into a single SMP-aware interrupt controller on the CPU. */
+typedef struct {
+ SysBusDevice parent_obj;
+
+ qemu_irq cpuic[32];
+ qemu_irq rvic[4][64];
+ uint32_t num_cpu;
+
+ ARM11MPCorePriveState priv;
+ RealViewGICState gic[4];
+} mpcore_rirq_state;
+
+/* Map baseboard IRQs onto CPU IRQ lines. */
+static const int mpcore_irq_map[32] = {
+ -1, -1, -1, -1, 1, 2, -1, -1,
+ -1, -1, 6, -1, 4, 5, -1, -1,
+ -1, 14, 15, 0, 7, 8, -1, -1,
+ -1, -1, -1, -1, 9, 3, -1, -1,
+};
+
+static void mpcore_rirq_set_irq(void *opaque, int irq, int level)
+{
+ mpcore_rirq_state *s = (mpcore_rirq_state *)opaque;
+ int i;
+
+ for (i = 0; i < 4; i++) {
+ qemu_set_irq(s->rvic[i][irq], level);
+ }
+ if (irq < 32) {
+ irq = mpcore_irq_map[irq];
+ if (irq >= 0) {
+ qemu_set_irq(s->cpuic[irq], level);
+ }
+ }
+}
+
+static void realview_mpcore_realize(DeviceState *dev, Error **errp)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
+ mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(dev);
+ DeviceState *priv = DEVICE(&s->priv);
+ DeviceState *gic;
+ SysBusDevice *gicbusdev;
+ Error *err = NULL;
+ int n;
+ int i;
+
+ qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
+ object_property_set_bool(OBJECT(&s->priv), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
+ sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
+ for (i = 0; i < 32; i++) {
+ s->cpuic[i] = qdev_get_gpio_in(priv, i);
+ }
+ /* ??? IRQ routing is hardcoded to "normal" mode. */
+ for (n = 0; n < 4; n++) {
+ object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", &err);
+ if (err != NULL) {
+ error_propagate(errp, err);
+ return;
+ }
+ gic = DEVICE(&s->gic[n]);
+ gicbusdev = SYS_BUS_DEVICE(&s->gic[n]);
+ sysbus_mmio_map(gicbusdev, 0, 0x10040000 + n * 0x10000);
+ sysbus_connect_irq(gicbusdev, 0, s->cpuic[10 + n]);
+ for (i = 0; i < 64; i++) {
+ s->rvic[n][i] = qdev_get_gpio_in(gic, i);
+ }
+ }
+ qdev_init_gpio_in(dev, mpcore_rirq_set_irq, 64);
+}
+
+static void mpcore_rirq_init(Object *obj)
+{
+ SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
+ mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(obj);
+ SysBusDevice *privbusdev;
+ int i;
+
+ object_initialize(&s->priv, sizeof(s->priv), TYPE_ARM11MPCORE_PRIV);
+ qdev_set_parent_bus(DEVICE(&s->priv), sysbus_get_default());
+ privbusdev = SYS_BUS_DEVICE(&s->priv);
+ sysbus_init_mmio(sbd, sysbus_mmio_get_region(privbusdev, 0));
+
+ for (i = 0; i < 4; i++) {
+ object_initialize(&s->gic[i], sizeof(s->gic[i]), TYPE_REALVIEW_GIC);
+ qdev_set_parent_bus(DEVICE(&s->gic[i]), sysbus_get_default());
+ }
+}
+
+static Property mpcore_rirq_properties[] = {
+ DEFINE_PROP_UINT32("num-cpu", mpcore_rirq_state, num_cpu, 1),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void mpcore_rirq_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+
+ dc->realize = realview_mpcore_realize;
+ dc->props = mpcore_rirq_properties;
+}
+
+static const TypeInfo mpcore_rirq_info = {
+ .name = TYPE_REALVIEW_MPCORE_RIRQ,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(mpcore_rirq_state),
+ .instance_init = mpcore_rirq_init,
+ .class_init = mpcore_rirq_class_init,
+};
+
+static void realview_mpcore_register_types(void)
+{
+ type_register_static(&mpcore_rirq_info);
+}
+
+type_init(realview_mpcore_register_types)
--
1.8.1.4
^ permalink raw reply related [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore Andreas Färber
@ 2013-09-13 15:33 ` Peter Maydell
2013-09-13 15:40 ` Andreas Färber
0 siblings, 1 reply; 29+ messages in thread
From: Peter Maydell @ 2013-09-13 15:33 UTC (permalink / raw)
To: Andreas Färber; +Cc: QEMU Developers, Paul Brook
On 11 September 2013 15:37, Andreas Färber <afaerber@suse.de> wrote:
> Signed-off-by: Andreas Färber <afaerber@suse.de>
> ---
> hw/cpu/Makefile.objs | 1 +
> hw/cpu/arm11mpcore.c | 121 -----------------------------------------
> hw/cpu/realview_mpcore.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 140 insertions(+), 121 deletions(-)
> create mode 100644 hw/cpu/realview_mpcore.c
>
> diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs
> index df287c1..6381238 100644
> --- a/hw/cpu/Makefile.objs
> +++ b/hw/cpu/Makefile.objs
> @@ -1,4 +1,5 @@
> obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
> +obj-$(CONFIG_REALVIEW) += realview_mpcore.o
> obj-$(CONFIG_A9MPCORE) += a9mpcore.o
> obj-$(CONFIG_A15MPCORE) += a15mpcore.o
> obj-$(CONFIG_ICC_BUS) += icc_bus.o
> diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
> index 0ec27c7..717d3e4 100644
> --- a/hw/cpu/arm11mpcore.c
> +++ b/hw/cpu/arm11mpcore.c
> @@ -134,126 +134,6 @@ static void mpcore_priv_initfn(Object *obj)
> qdev_set_parent_bus(DEVICE(&s->wdtimer), sysbus_get_default());
> }
>
> -#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
> -#define REALVIEW_MPCORE_RIRQ(obj) \
> - OBJECT_CHECK(mpcore_rirq_state, (obj), TYPE_REALVIEW_MPCORE_RIRQ)
> -
> -/* Dummy PIC to route IRQ lines. The baseboard has 4 independent IRQ
> - controllers. The output of these, plus some of the raw input lines
> - are fed into a single SMP-aware interrupt controller on the CPU. */
> -typedef struct {
> - SysBusDevice parent_obj;
> -
> - qemu_irq cpuic[32];
> - qemu_irq rvic[4][64];
> - uint32_t num_cpu;
> -
> - ARM11MPCorePriveState priv;
> - RealViewGICState gic[4];
> -} mpcore_rirq_state;
> -
> -/* Map baseboard IRQs onto CPU IRQ lines. */
> -static const int mpcore_irq_map[32] = {
> - -1, -1, -1, -1, 1, 2, -1, -1,
> - -1, -1, 6, -1, 4, 5, -1, -1,
> - -1, 14, 15, 0, 7, 8, -1, -1,
> - -1, -1, -1, -1, 9, 3, -1, -1,
> -};
> -
> -static void mpcore_rirq_set_irq(void *opaque, int irq, int level)
> -{
> - mpcore_rirq_state *s = (mpcore_rirq_state *)opaque;
> - int i;
> -
> - for (i = 0; i < 4; i++) {
> - qemu_set_irq(s->rvic[i][irq], level);
> - }
> - if (irq < 32) {
> - irq = mpcore_irq_map[irq];
> - if (irq >= 0) {
> - qemu_set_irq(s->cpuic[irq], level);
> - }
> - }
> -}
> -
> -static void realview_mpcore_realize(DeviceState *dev, Error **errp)
> -{
> - SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
> - mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(dev);
> - DeviceState *priv = DEVICE(&s->priv);
> - DeviceState *gic;
> - SysBusDevice *gicbusdev;
> - Error *err = NULL;
> - int n;
> - int i;
> -
> - qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
> - object_property_set_bool(OBJECT(&s->priv), true, "realized", &err);
> - if (err != NULL) {
> - error_propagate(errp, err);
> - return;
> - }
> - sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
> - for (i = 0; i < 32; i++) {
> - s->cpuic[i] = qdev_get_gpio_in(priv, i);
> - }
> - /* ??? IRQ routing is hardcoded to "normal" mode. */
> - for (n = 0; n < 4; n++) {
> - object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", &err);
> - if (err != NULL) {
> - error_propagate(errp, err);
> - return;
> - }
> - gic = DEVICE(&s->gic[n]);
> - gicbusdev = SYS_BUS_DEVICE(&s->gic[n]);
> - sysbus_mmio_map(gicbusdev, 0, 0x10040000 + n * 0x10000);
> - sysbus_connect_irq(gicbusdev, 0, s->cpuic[10 + n]);
> - for (i = 0; i < 64; i++) {
> - s->rvic[n][i] = qdev_get_gpio_in(gic, i);
> - }
> - }
> - qdev_init_gpio_in(dev, mpcore_rirq_set_irq, 64);
> -}
> -
> -static void mpcore_rirq_init(Object *obj)
> -{
> - SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
> - mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(obj);
> - SysBusDevice *privbusdev;
> - int i;
> -
> - object_initialize(&s->priv, sizeof(s->priv), TYPE_ARM11MPCORE_PRIV);
> - qdev_set_parent_bus(DEVICE(&s->priv), sysbus_get_default());
> - privbusdev = SYS_BUS_DEVICE(&s->priv);
> - sysbus_init_mmio(sbd, sysbus_mmio_get_region(privbusdev, 0));
> -
> - for (i = 0; i < 4; i++) {
> - object_initialize(&s->gic[i], sizeof(s->gic[i]), TYPE_REALVIEW_GIC);
> - qdev_set_parent_bus(DEVICE(&s->gic[i]), sysbus_get_default());
> - }
> -}
> -
> -static Property mpcore_rirq_properties[] = {
> - DEFINE_PROP_UINT32("num-cpu", mpcore_rirq_state, num_cpu, 1),
> - DEFINE_PROP_END_OF_LIST(),
> -};
> -
> -static void mpcore_rirq_class_init(ObjectClass *klass, void *data)
> -{
> - DeviceClass *dc = DEVICE_CLASS(klass);
> -
> - dc->realize = realview_mpcore_realize;
> - dc->props = mpcore_rirq_properties;
> -}
> -
> -static const TypeInfo mpcore_rirq_info = {
> - .name = TYPE_REALVIEW_MPCORE_RIRQ,
> - .parent = TYPE_SYS_BUS_DEVICE,
> - .instance_size = sizeof(mpcore_rirq_state),
> - .instance_init = mpcore_rirq_init,
> - .class_init = mpcore_rirq_class_init,
> -};
> -
> static Property mpcore_priv_properties[] = {
> DEFINE_PROP_UINT32("num-cpu", ARM11MPCorePriveState, num_cpu, 1),
> /* The ARM11 MPCORE TRM says the on-chip controller may have
> @@ -286,7 +166,6 @@ static const TypeInfo mpcore_priv_info = {
>
> static void arm11mpcore_register_types(void)
> {
> - type_register_static(&mpcore_rirq_info);
> type_register_static(&mpcore_priv_info);
> }
>
> diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c
> new file mode 100644
> index 0000000..c39a2da
> --- /dev/null
> +++ b/hw/cpu/realview_mpcore.c
> @@ -0,0 +1,139 @@
> +/*
> + * RealView ARM11MPCore internal peripheral emulation
This isn't really internal to anything, or at least if
properly modelled it shouldn't be. It's part of the
board: as the comment notes there are 4 GIC instances
on the board, which are wired up to the 11MPCore's
internal GIC. Ideally it ought to be untangled and
it shouldn't specifically own an 11MPCorePrivState
object. That said, we were already mismodelling this
I think so I'm happy to let this patch go through as-is.
> + ARM11MPCorePriveState priv;
You might add a patch somewhere fixing the typo
(PriveState->PrivState).
-- PMM
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
` (23 preceding siblings ...)
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore Andreas Färber
@ 2013-09-13 15:38 ` Peter Maydell
2013-09-18 17:06 ` Andreas Färber
24 siblings, 1 reply; 29+ messages in thread
From: Peter Maydell @ 2013-09-13 15:38 UTC (permalink / raw)
To: Andreas Färber
Cc: Peter Crosthwaite, Andreas Färber, Claudio Fontana,
QEMU Developers, Mian M. Hamayun
On 11 September 2013 15:37, Andreas Färber <afaerber@suse.de> wrote:
> From: Andreas Färber <andreas.faerber@web.de>
>
> Hello Peter,
>
> This series fully QOM'ifies A9MPCore so that it can be embedded for Tegra2.
> It goes on to do the same for A15MPCore, which had previously been taken as
> template for Cortex-A57 by John Rigby, and since v3 ARM11MPCore.
>
> Separate headers are introduced to only expose device state to whom asks for it.
Thanks; this version looks good to me. I had a few
remarks on the realview stuff at the end but none that I
think require delaying this patchset further.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
I'm assuming you'll take this through your qom tree...
-- PMM
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore
2013-09-13 15:33 ` Peter Maydell
@ 2013-09-13 15:40 ` Andreas Färber
0 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-13 15:40 UTC (permalink / raw)
To: Peter Maydell; +Cc: QEMU Developers, Paul Brook
Am 13.09.2013 17:33, schrieb Peter Maydell:
> On 11 September 2013 15:37, Andreas Färber <afaerber@suse.de> wrote:
>> Signed-off-by: Andreas Färber <afaerber@suse.de>
>> ---
>> hw/cpu/Makefile.objs | 1 +
>> hw/cpu/arm11mpcore.c | 121 -----------------------------------------
>> hw/cpu/realview_mpcore.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++
>> 3 files changed, 140 insertions(+), 121 deletions(-)
>> create mode 100644 hw/cpu/realview_mpcore.c
>>
>> diff --git a/hw/cpu/Makefile.objs b/hw/cpu/Makefile.objs
>> index df287c1..6381238 100644
>> --- a/hw/cpu/Makefile.objs
>> +++ b/hw/cpu/Makefile.objs
>> @@ -1,4 +1,5 @@
>> obj-$(CONFIG_ARM11MPCORE) += arm11mpcore.o
>> +obj-$(CONFIG_REALVIEW) += realview_mpcore.o
>> obj-$(CONFIG_A9MPCORE) += a9mpcore.o
>> obj-$(CONFIG_A15MPCORE) += a15mpcore.o
>> obj-$(CONFIG_ICC_BUS) += icc_bus.o
>> diff --git a/hw/cpu/arm11mpcore.c b/hw/cpu/arm11mpcore.c
>> index 0ec27c7..717d3e4 100644
>> --- a/hw/cpu/arm11mpcore.c
>> +++ b/hw/cpu/arm11mpcore.c
>> @@ -134,126 +134,6 @@ static void mpcore_priv_initfn(Object *obj)
>> qdev_set_parent_bus(DEVICE(&s->wdtimer), sysbus_get_default());
>> }
>>
>> -#define TYPE_REALVIEW_MPCORE_RIRQ "realview_mpcore"
>> -#define REALVIEW_MPCORE_RIRQ(obj) \
>> - OBJECT_CHECK(mpcore_rirq_state, (obj), TYPE_REALVIEW_MPCORE_RIRQ)
>> -
>> -/* Dummy PIC to route IRQ lines. The baseboard has 4 independent IRQ
>> - controllers. The output of these, plus some of the raw input lines
>> - are fed into a single SMP-aware interrupt controller on the CPU. */
>> -typedef struct {
>> - SysBusDevice parent_obj;
>> -
>> - qemu_irq cpuic[32];
>> - qemu_irq rvic[4][64];
>> - uint32_t num_cpu;
>> -
>> - ARM11MPCorePriveState priv;
>> - RealViewGICState gic[4];
>> -} mpcore_rirq_state;
>> -
>> -/* Map baseboard IRQs onto CPU IRQ lines. */
>> -static const int mpcore_irq_map[32] = {
>> - -1, -1, -1, -1, 1, 2, -1, -1,
>> - -1, -1, 6, -1, 4, 5, -1, -1,
>> - -1, 14, 15, 0, 7, 8, -1, -1,
>> - -1, -1, -1, -1, 9, 3, -1, -1,
>> -};
>> -
>> -static void mpcore_rirq_set_irq(void *opaque, int irq, int level)
>> -{
>> - mpcore_rirq_state *s = (mpcore_rirq_state *)opaque;
>> - int i;
>> -
>> - for (i = 0; i < 4; i++) {
>> - qemu_set_irq(s->rvic[i][irq], level);
>> - }
>> - if (irq < 32) {
>> - irq = mpcore_irq_map[irq];
>> - if (irq >= 0) {
>> - qemu_set_irq(s->cpuic[irq], level);
>> - }
>> - }
>> -}
>> -
>> -static void realview_mpcore_realize(DeviceState *dev, Error **errp)
>> -{
>> - SysBusDevice *sbd = SYS_BUS_DEVICE(dev);
>> - mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(dev);
>> - DeviceState *priv = DEVICE(&s->priv);
>> - DeviceState *gic;
>> - SysBusDevice *gicbusdev;
>> - Error *err = NULL;
>> - int n;
>> - int i;
>> -
>> - qdev_prop_set_uint32(priv, "num-cpu", s->num_cpu);
>> - object_property_set_bool(OBJECT(&s->priv), true, "realized", &err);
>> - if (err != NULL) {
>> - error_propagate(errp, err);
>> - return;
>> - }
>> - sysbus_pass_irq(sbd, SYS_BUS_DEVICE(&s->priv));
>> - for (i = 0; i < 32; i++) {
>> - s->cpuic[i] = qdev_get_gpio_in(priv, i);
>> - }
>> - /* ??? IRQ routing is hardcoded to "normal" mode. */
>> - for (n = 0; n < 4; n++) {
>> - object_property_set_bool(OBJECT(&s->gic[n]), true, "realized", &err);
>> - if (err != NULL) {
>> - error_propagate(errp, err);
>> - return;
>> - }
>> - gic = DEVICE(&s->gic[n]);
>> - gicbusdev = SYS_BUS_DEVICE(&s->gic[n]);
>> - sysbus_mmio_map(gicbusdev, 0, 0x10040000 + n * 0x10000);
>> - sysbus_connect_irq(gicbusdev, 0, s->cpuic[10 + n]);
>> - for (i = 0; i < 64; i++) {
>> - s->rvic[n][i] = qdev_get_gpio_in(gic, i);
>> - }
>> - }
>> - qdev_init_gpio_in(dev, mpcore_rirq_set_irq, 64);
>> -}
>> -
>> -static void mpcore_rirq_init(Object *obj)
>> -{
>> - SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
>> - mpcore_rirq_state *s = REALVIEW_MPCORE_RIRQ(obj);
>> - SysBusDevice *privbusdev;
>> - int i;
>> -
>> - object_initialize(&s->priv, sizeof(s->priv), TYPE_ARM11MPCORE_PRIV);
>> - qdev_set_parent_bus(DEVICE(&s->priv), sysbus_get_default());
>> - privbusdev = SYS_BUS_DEVICE(&s->priv);
>> - sysbus_init_mmio(sbd, sysbus_mmio_get_region(privbusdev, 0));
>> -
>> - for (i = 0; i < 4; i++) {
>> - object_initialize(&s->gic[i], sizeof(s->gic[i]), TYPE_REALVIEW_GIC);
>> - qdev_set_parent_bus(DEVICE(&s->gic[i]), sysbus_get_default());
>> - }
>> -}
>> -
>> -static Property mpcore_rirq_properties[] = {
>> - DEFINE_PROP_UINT32("num-cpu", mpcore_rirq_state, num_cpu, 1),
>> - DEFINE_PROP_END_OF_LIST(),
>> -};
>> -
>> -static void mpcore_rirq_class_init(ObjectClass *klass, void *data)
>> -{
>> - DeviceClass *dc = DEVICE_CLASS(klass);
>> -
>> - dc->realize = realview_mpcore_realize;
>> - dc->props = mpcore_rirq_properties;
>> -}
>> -
>> -static const TypeInfo mpcore_rirq_info = {
>> - .name = TYPE_REALVIEW_MPCORE_RIRQ,
>> - .parent = TYPE_SYS_BUS_DEVICE,
>> - .instance_size = sizeof(mpcore_rirq_state),
>> - .instance_init = mpcore_rirq_init,
>> - .class_init = mpcore_rirq_class_init,
>> -};
>> -
>> static Property mpcore_priv_properties[] = {
>> DEFINE_PROP_UINT32("num-cpu", ARM11MPCorePriveState, num_cpu, 1),
>> /* The ARM11 MPCORE TRM says the on-chip controller may have
>> @@ -286,7 +166,6 @@ static const TypeInfo mpcore_priv_info = {
>>
>> static void arm11mpcore_register_types(void)
>> {
>> - type_register_static(&mpcore_rirq_info);
>> type_register_static(&mpcore_priv_info);
>> }
>>
>> diff --git a/hw/cpu/realview_mpcore.c b/hw/cpu/realview_mpcore.c
>> new file mode 100644
>> index 0000000..c39a2da
>> --- /dev/null
>> +++ b/hw/cpu/realview_mpcore.c
>> @@ -0,0 +1,139 @@
>> +/*
>> + * RealView ARM11MPCore internal peripheral emulation
>
> This isn't really internal to anything, or at least if
> properly modelled it shouldn't be. It's part of the
> board: as the comment notes there are 4 GIC instances
> on the board, which are wired up to the 11MPCore's
> internal GIC. Ideally it ought to be untangled and
> it shouldn't specifically own an 11MPCorePrivState
> object. That said, we were already mismodelling this
> I think so I'm happy to let this patch go through as-is.
>
>> + ARM11MPCorePriveState priv;
>
> You might add a patch somewhere fixing the typo
> (PriveState->PrivState).
Will do, thanks.
Background of the split is an investigation of dc->vmsd assignments for
my VMState RFC. Similar split-offs for board-private devices will
follow, e.g., musicpal.
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification
2013-09-13 15:38 ` [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Peter Maydell
@ 2013-09-18 17:06 ` Andreas Färber
0 siblings, 0 replies; 29+ messages in thread
From: Andreas Färber @ 2013-09-18 17:06 UTC (permalink / raw)
To: Peter Maydell
Cc: Peter Crosthwaite, Claudio Fontana, QEMU Developers,
Mian M. Hamayun
Am 13.09.2013 17:38, schrieb Peter Maydell:
> On 11 September 2013 15:37, Andreas Färber <afaerber@suse.de> wrote:
>> From: Andreas Färber <andreas.faerber@web.de>
>>
>> Hello Peter,
>>
>> This series fully QOM'ifies A9MPCore so that it can be embedded for Tegra2.
>> It goes on to do the same for A15MPCore, which had previously been taken as
>> template for Cortex-A57 by John Rigby, and since v3 ARM11MPCore.
>>
>> Separate headers are introduced to only expose device state to whom asks for it.
>
> Thanks; this version looks good to me. I had a few
> remarks on the realview stuff at the end but none that I
> think require delaying this patchset further.
>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
>
> I'm assuming you'll take this through your qom tree...
Thanks, I've queued them on qom-next now and will look into tweaking the
realview file header, possibly adding a TODO so that it doesn't get
forgotten.
https://github.com/afaerber/qemu-cpu/commits/qom-next
Andreas
--
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2013-09-18 17:06 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-09-11 14:37 [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 01/24] a9mpcore: Split off instance_init Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 02/24] arm_gic: Extract headers hw/intc/arm_gic{, _common}.h Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 03/24] a9mpcore: Embed GICState Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 04/24] a9scu: QOM cleanups Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 05/24] a9mpcore: Embed A9SCUState Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 06/24] arm_mptimer: Convert to QOM realize Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 07/24] a9mpcore: Embed ARMMPTimerState Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 08/24] a9mpcore: Convert to QOM realize Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 09/24] a9mpcore: Prepare for QOM embedding Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 10/24] a15mpcore: Split off instance_init Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 11/24] a15mpcore: Embed GICState Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 12/24] a15mpcore: Convert to QOM realize Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 13/24] a15mpcore: Prepare for QOM embedding Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 14/24] a9scu: Build only once Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 15/24] arm11mpcore: Fix typo in MemoryRegion name Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 16/24] arm11mpcore: Drop unused fields Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 17/24] arm11mpcore: Create container MemoryRegion in instance_init Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 18/24] arm11mpcore: Split off SCU device Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 19/24] arm11mpcore: Convert ARM11MPCorePriveState to QOM realize Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 20/24] realview_gic: Convert " Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 21/24] realview_gic: Prepare for QOM embedding Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 22/24] arm11mpcore: Convert mpcore_rirq_state to QOM realize Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 23/24] arm11mpcore: Prepare for QOM embedding Andreas Färber
2013-09-11 14:37 ` [Qemu-devel] [PATCH v4 24/24] arm11mpcore: Split off RealView MPCore Andreas Färber
2013-09-13 15:33 ` Peter Maydell
2013-09-13 15:40 ` Andreas Färber
2013-09-13 15:38 ` [Qemu-devel] [PATCH v4 00/24] arm: ARM11MPCore+A9MPCore+A15MPCore QOM'ification Peter Maydell
2013-09-18 17:06 ` Andreas Färber
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).