From patchwork Sun Feb 12 22:50:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Huth X-Patchwork-Id: 9568609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E2C860476 for ; Sun, 12 Feb 2017 22:54:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 510AD26E91 for ; Sun, 12 Feb 2017 22:54:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 455312810E; Sun, 12 Feb 2017 22:54:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C3EFE26E91 for ; Sun, 12 Feb 2017 22:54:26 +0000 (UTC) Received: from localhost ([::1]:53701 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cd32H-0005FU-Ru for patchwork-qemu-devel@patchwork.kernel.org; Sun, 12 Feb 2017 17:54:25 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34736) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cd2yo-00031Q-G7 for qemu-devel@nongnu.org; Sun, 12 Feb 2017 17:50:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cd2yl-00030Q-FC for qemu-devel@nongnu.org; Sun, 12 Feb 2017 17:50:50 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:34442) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cd2yl-000304-8b for qemu-devel@nongnu.org; Sun, 12 Feb 2017 17:50:47 -0500 Received: by mail-wr0-f193.google.com with SMTP id 89so21778952wrr.1 for ; Sun, 12 Feb 2017 14:50:45 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ntru7rnGd8Mk4nzS8ARk454xlq42cuFtHVMoXix85Tw=; b=i7gm8VN8AOtIpIsQ3mBHgng71pGDEN5bbnCYYZmvbkvC4485D4Qr61o6pVeg2cdrT1 i1f6R6MsX+JTFCHRNb5ovkGGpPZ5E6w1bsTAmWvwnymbv4f9LzKkGeY3wUjd3ufuCzaj FYL31UyK4HvZ00rnD5A1oESqH9fell/c37jQBTY1CjFxhAsROb6G1FIfkrTdJG63ucak 8RWF9PeFqTLpma5ciFwDWcRSjcDdZfeSWQymn+FaC2ZXhEDyT1sBxOttnC4+i06cOIMe JZEC3Oj27z9+0olZG9fRpXKZFoHe/LWJkmAF4cgfdNp9PXZcMsJcSqmRdvRF1HUR18ca 5fmg== X-Gm-Message-State: AMke39kJh47AdddRTMcGKACSBcg+wGc+kndDXupv9Ic8JtjZ5bIT3m5zoXt4S58vzqyYGA== X-Received: by 10.223.170.195 with SMTP id i3mr19066781wrc.123.1486939844615; Sun, 12 Feb 2017 14:50:44 -0800 (PST) Received: from thl530.multi.box (pD9575B07.dip0.t-ipconnect.de. [217.87.91.7]) by smtp.gmail.com with ESMTPSA id 61sm11464447wrs.29.2017.02.12.14.50.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 12 Feb 2017 14:50:44 -0800 (PST) From: Thomas Huth To: qemu-devel@nongnu.org Date: Sun, 12 Feb 2017 23:50:34 +0100 Message-Id: <1486939835-3452-2-git-send-email-huth@tuxfamily.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1486939835-3452-1-git-send-email-huth@tuxfamily.org> References: <1486939835-3452-1-git-send-email-huth@tuxfamily.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.193 Subject: [Qemu-devel] [PATCH 1/2] hw/m68k: QOMify the ColdFire interrupt controller X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Use type_init() and friends to adapt the ColdFire interrupt controller to the latest QEMU device conventions. Signed-off-by: Thomas Huth Reviewed-by: Laurent Vivier --- 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);