From patchwork Mon Mar 2 23:01:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mark Cave-Ayland X-Patchwork-Id: 445460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 2998E1400D5 for ; Tue, 3 Mar 2015 10:02:25 +1100 (AEDT) Received: from localhost ([::1]:60261 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSZLz-000851-6x for incoming@patchwork.ozlabs.org; Mon, 02 Mar 2015 18:02:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51429) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSZLW-0006zK-7O for qemu-devel@nongnu.org; Mon, 02 Mar 2015 18:01:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YSZLU-00062u-JH for qemu-devel@nongnu.org; Mon, 02 Mar 2015 18:01:54 -0500 Received: from s16892447.onlinehome-server.info ([82.165.15.123]:53717) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YSZLU-00061g-DY for qemu-devel@nongnu.org; Mon, 02 Mar 2015 18:01:52 -0500 Received: from 5d60c2ed.skybroadband.com ([93.96.194.237] helo=kentang.lan) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1YSZLM-0002p4-15; Mon, 02 Mar 2015 23:01:45 +0000 From: Mark Cave-Ayland To: qemu-devel@nongnu.org Date: Mon, 2 Mar 2015 23:01:12 +0000 Message-Id: <1425337280-21997-2-git-send-email-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1425337280-21997-1-git-send-email-mark.cave-ayland@ilande.co.uk> References: <1425337280-21997-1-git-send-email-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 93.96.194.237 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Cc: Mark Cave-Ayland , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , =?UTF-8?q?Andreas=20F=C3=A4rber?= Subject: [Qemu-devel] [PATCH 1/9] m48t59: move ISA ports/memory regions registration to QOM constructor X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Hervé Poussineau -device m48t59_isa can now be used to create a fully functional nvram. Signed-off-by: Hervé Poussineau CC: Andreas Färber Signed-off-by: Mark Cave-Ayland --- hw/timer/m48t59.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/hw/timer/m48t59.c b/hw/timer/m48t59.c index 31509d5..967a313 100644 --- a/hw/timer/m48t59.c +++ b/hw/timer/m48t59.c @@ -658,10 +658,9 @@ M48t59State *m48t59_init(qemu_irq IRQ, hwaddr mem_base, d = SYSBUS_M48T59(dev); state = &d->state; sysbus_connect_irq(s, 0, IRQ); - memory_region_init_io(&d->io, OBJECT(d), &m48t59_io_ops, state, - "m48t59", 4); if (io_base != 0) { - memory_region_add_subregion(get_system_io(), io_base, &d->io); + memory_region_add_subregion(get_system_io(), io_base, + sysbus_mmio_get_region(dev, 1)); } if (mem_base != 0) { sysbus_mmio_map(s, 0, mem_base); @@ -687,11 +686,6 @@ M48t59State *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size, d = ISA_M48T59(isadev); s = &d->state; - memory_region_init_io(&d->io, OBJECT(d), &m48t59_io_ops, s, "m48t59", 4); - if (io_base != 0) { - isa_register_ioport(isadev, &d->io, io_base); - } - return s; } @@ -715,19 +709,28 @@ static void m48t59_isa_realize(DeviceState *dev, Error **errp) isa_init_irq(isadev, &s->IRQ, 8); m48t59_realize_common(s, errp); + memory_region_init_io(&d->io, OBJECT(dev), &m48t59_io_ops, s, "m48t59", 4); + if (s->io_base != 0) { + isa_register_ioport(isadev, &d->io, s->io_base); + } + + return 0; } static int m48t59_init1(SysBusDevice *dev) { M48t59SysBusState *d = SYSBUS_M48T59(dev); + Object *o = OBJECT(dev); M48t59State *s = &d->state; Error *err = NULL; sysbus_init_irq(dev, &s->IRQ); - memory_region_init_io(&s->iomem, OBJECT(d), &nvram_ops, s, - "m48t59.nvram", s->size); + memory_region_init_io(&s->iomem, o, &nvram_ops, s, "m48t59.nvram", + s->size); + memory_region_init_io(&d->io, o, &m48t59_io_ops, s, "m48t59", 4); sysbus_init_mmio(dev, &s->iomem); + sysbus_init_mmio(dev, &d->io); m48t59_realize_common(s, &err); if (err != NULL) { error_free(err); @@ -751,8 +754,6 @@ static void m48t59_isa_class_init(ObjectClass *klass, void *data) dc->realize = m48t59_isa_realize; dc->reset = m48t59_reset_isa; dc->props = m48t59_isa_properties; - /* Reason: needs to be wired up by m48t59_init_isa() */ - dc->cannot_instantiate_with_device_add_yet = true; } static const TypeInfo m48t59_isa_info = {