From: Thomas Huth <huth@tuxfamily.org>
To: qemu-devel@nongnu.org
Cc: Laurent Vivier <laurent@vivier.eu>
Subject: [Qemu-devel] [PATCH 1/2] hw/m68k: QOMify the ColdFire interrupt controller
Date: Sun, 12 Feb 2017 23:50:34 +0100 [thread overview]
Message-ID: <1486939835-3452-2-git-send-email-huth@tuxfamily.org> (raw)
In-Reply-To: <1486939835-3452-1-git-send-email-huth@tuxfamily.org>
Use type_init() and friends to adapt the ColdFire interrupt
controller to the latest QEMU device conventions.
Signed-off-by: Thomas Huth <huth@tuxfamily.org>
---
hw/m68k/mcf_intc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 44 insertions(+), 4 deletions(-)
diff --git a/hw/m68k/mcf_intc.c b/hw/m68k/mcf_intc.c
index cf58132..8198afa 100644
--- a/hw/m68k/mcf_intc.c
+++ b/hw/m68k/mcf_intc.c
@@ -9,10 +9,16 @@
#include "qemu-common.h"
#include "cpu.h"
#include "hw/hw.h"
+#include "hw/sysbus.h"
#include "hw/m68k/mcf.h"
#include "exec/address-spaces.h"
+#define TYPE_MCF_INTC "mcf-intc"
+#define MCF_INTC(obj) OBJECT_CHECK(mcf_intc_state, (obj), TYPE_MCF_INTC)
+
typedef struct {
+ SysBusDevice parent_obj;
+
MemoryRegion iomem;
uint64_t ipr;
uint64_t imr;
@@ -138,8 +144,10 @@ static void mcf_intc_set_irq(void *opaque, int irq, int level)
mcf_intc_update(s);
}
-static void mcf_intc_reset(mcf_intc_state *s)
+static void mcf_intc_reset(DeviceState *dev)
{
+ mcf_intc_state *s = MCF_INTC(dev);
+
s->imr = ~0ull;
s->ipr = 0;
s->ifr = 0;
@@ -154,17 +162,49 @@ static const MemoryRegionOps mcf_intc_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
+static void mcf_intc_instance_init(Object *obj)
+{
+ mcf_intc_state *s = MCF_INTC(obj);
+
+ memory_region_init_io(&s->iomem, obj, &mcf_intc_ops, s, "mcf", 0x100);
+}
+
+static void mcf_intc_class_init(ObjectClass *oc, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(oc);
+
+ set_bit(DEVICE_CATEGORY_MISC, dc->categories);
+ dc->reset = mcf_intc_reset;
+}
+
+static const TypeInfo mcf_intc_gate_info = {
+ .name = TYPE_MCF_INTC,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(mcf_intc_state),
+ .instance_init = mcf_intc_instance_init,
+ .class_init = mcf_intc_class_init,
+};
+
+static void mcf_intc_register_types(void)
+{
+ type_register_static(&mcf_intc_gate_info);
+}
+
+type_init(mcf_intc_register_types)
+
qemu_irq *mcf_intc_init(MemoryRegion *sysmem,
hwaddr base,
M68kCPU *cpu)
{
+ DeviceState *dev;
mcf_intc_state *s;
- s = g_malloc0(sizeof(mcf_intc_state));
+ dev = qdev_create(NULL, TYPE_MCF_INTC);
+ qdev_init_nofail(dev);
+
+ s = MCF_INTC(dev);
s->cpu = cpu;
- mcf_intc_reset(s);
- memory_region_init_io(&s->iomem, NULL, &mcf_intc_ops, s, "mcf", 0x100);
memory_region_add_subregion(sysmem, base, &s->iomem);
return qemu_allocate_irqs(mcf_intc_set_irq, s, 64);
--
2.7.4
next prev parent reply other threads:[~2017-02-12 22:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-12 22:50 [Qemu-devel] [PATCH 0/2] m68k: Update MCF interrupt controller and MAINTAINERS Thomas Huth
2017-02-12 22:50 ` Thomas Huth [this message]
2017-02-14 8:27 ` [Qemu-devel] [PATCH 1/2] hw/m68k: QOMify the ColdFire interrupt controller Laurent Vivier
2017-02-12 22:50 ` [Qemu-devel] [PATCH 2/2] MAINTAINERS: Add odd fixer the ColdFire boards Thomas Huth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1486939835-3452-2-git-send-email-huth@tuxfamily.org \
--to=huth@tuxfamily.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).