From patchwork Tue Jun 7 15:02:57 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andreas_F=C3=A4rber?= X-Patchwork-Id: 99270 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 96FAAB6FA4 for ; Wed, 8 Jun 2011 01:29:34 +1000 (EST) Received: from localhost ([::1]:35984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTyDh-0007zB-Uj for incoming@patchwork.ozlabs.org; Tue, 07 Jun 2011 11:29:30 -0400 Received: from eggs.gnu.org ([140.186.70.92]:49171) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTxoU-0001iQ-EP for qemu-devel@nongnu.org; Tue, 07 Jun 2011 11:03:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QTxoA-0000QX-9u for qemu-devel@nongnu.org; Tue, 07 Jun 2011 11:03:24 -0400 Received: from fmmailgate02.web.de ([217.72.192.227]:46739) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QTxo9-0000Pz-QF for qemu-devel@nongnu.org; Tue, 07 Jun 2011 11:03:06 -0400 Received: from smtp01.web.de ( [172.20.0.243]) by fmmailgate02.web.de (Postfix) with ESMTP id AA03B1A27BC16; Tue, 7 Jun 2011 17:03:04 +0200 (CEST) Received: from [87.173.124.210] (helo=af.local) by smtp01.web.de with asmtp (WEB.DE 4.110 #2) id 1QTxo8-0006hT-00; Tue, 07 Jun 2011 17:03:04 +0200 From: =?UTF-8?q?Andreas=20F=C3=A4rber?= To: qemu-devel@nongnu.org Date: Tue, 7 Jun 2011 17:02:57 +0200 Message-Id: <1307458978-51287-10-git-send-email-andreas.faerber@web.de> X-Mailer: git-send-email 1.7.5.3 In-Reply-To: <1307458978-51287-9-git-send-email-andreas.faerber@web.de> References: <4DEDD0BA.1080407@redhat.com> <1307458978-51287-1-git-send-email-andreas.faerber@web.de> <1307458978-51287-2-git-send-email-andreas.faerber@web.de> <1307458978-51287-3-git-send-email-andreas.faerber@web.de> <1307458978-51287-4-git-send-email-andreas.faerber@web.de> <1307458978-51287-5-git-send-email-andreas.faerber@web.de> <1307458978-51287-6-git-send-email-andreas.faerber@web.de> <1307458978-51287-7-git-send-email-andreas.faerber@web.de> <1307458978-51287-8-git-send-email-andreas.faerber@web.de> <1307458978-51287-9-git-send-email-andreas.faerber@web.de> MIME-Version: 1.0 X-Sender: Andreas.Faerber@web.de X-Provags-ID: V01U2FsdGVkX1+Jqin57VtVXHDCfuGayt1b9VQU9sO+BXr+bfXX 2jNgNcyTgBAHJcMrStrExw10fYbNABSJ9pwKq9LzaFvicZJRCf gG835gwHb0a3jK2SLNjg== X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4-2.6 X-Received-From: 217.72.192.227 Cc: =?UTF-8?q?Andreas=20F=C3=A4rber?= , hpoussin@reactos.org, kraxel@redhat.com Subject: [Qemu-devel] [RFC v2 09/10] ide: Implement ISA set_state() callback 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 Signed-off-by: Andreas Färber --- hw/ide/isa.c | 27 +++++++++++++++++++++++---- 1 files changed, 23 insertions(+), 4 deletions(-) diff --git a/hw/ide/isa.c b/hw/ide/isa.c index 4ac7453..e6ee263 100644 --- a/hw/ide/isa.c +++ b/hw/ide/isa.c @@ -62,15 +62,33 @@ static const VMStateDescription vmstate_ide_isa = { } }; +static void isa_ide_statefn(ISADevice *dev, bool enabled) +{ + ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev); + + if (enabled) { + ide_init_ioport(&s->bus, s->iobase, s->iobase2); + + isa_init_ioport_range(dev, s->iobase, 8); + isa_init_ioport(dev, s->iobase2); + + isa_init_irq(dev, &s->irq, s->isairq); + } else { + ide_discard_ioport(s->iobase, s->iobase2); + + isa_discard_ioport_range(dev, s->iobase2, 1); + isa_discard_ioport_range(dev, s->iobase, 8); + + isa_discard_irq(dev, s->isairq); + } +} + static int isa_ide_initfn(ISADevice *dev) { ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev); ide_bus_new(&s->bus, &s->dev.qdev, 0); - ide_init_ioport(&s->bus, s->iobase, s->iobase2); - isa_init_irq(dev, &s->irq, s->isairq); - isa_init_ioport_range(dev, s->iobase, 8); - isa_init_ioport(dev, s->iobase2); + isa_ide_statefn(dev, true); ide_init2(&s->bus, s->irq); vmstate_register(&dev->qdev, 0, &vmstate_ide_isa, s); return 0; @@ -102,6 +120,7 @@ static ISADeviceInfo isa_ide_info = { .qdev.fw_name = "ide", .qdev.size = sizeof(ISAIDEState), .init = isa_ide_initfn, + .set_state = isa_ide_statefn, .qdev.reset = isa_ide_reset, .qdev.props = (Property[]) { DEFINE_PROP_HEX32("iobase", ISAIDEState, iobase, 0x1f0),