From patchwork Thu Feb 24 17:57:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 84414 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BB149B70D1 for ; Fri, 25 Feb 2011 05:00:26 +1100 (EST) Received: from localhost ([127.0.0.1]:42408 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsfTw-000799-Pc for incoming@patchwork.ozlabs.org; Thu, 24 Feb 2011 13:00:04 -0500 Received: from [140.186.70.92] (port=43549 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PsfT8-00078P-V3 for qemu-devel@nongnu.org; Thu, 24 Feb 2011 12:59:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PsfT8-0005XR-1a for qemu-devel@nongnu.org; Thu, 24 Feb 2011 12:59:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56179) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PsfT7-0005Wj-MM for qemu-devel@nongnu.org; Thu, 24 Feb 2011 12:59:14 -0500 Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p1OHxCNH029798 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 Feb 2011 12:59:12 -0500 Received: from trasno.mitica (ovpn-113-97.phx2.redhat.com [10.3.113.97]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p1OHw0k5014622; Thu, 24 Feb 2011 12:59:11 -0500 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 24 Feb 2011 18:57:52 +0100 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 55/58] piix4: create PIIX4State X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org It only contains a PCIDevice by know, but it makes easy to use migration code Signed-off-by: Juan Quintela --- hw/piix4.c | 29 +++++++++++++++++------------ 1 files changed, 17 insertions(+), 12 deletions(-) diff --git a/hw/piix4.c b/hw/piix4.c index 72073cd..40cd91a 100644 --- a/hw/piix4.c +++ b/hw/piix4.c @@ -30,10 +30,14 @@ PCIDevice *piix4_dev; +typedef struct PIIX4State { + PCIDevice dev; +} PIIX4State; + static void piix4_reset(void *opaque) { - PCIDevice *d = opaque; - uint8_t *pci_conf = d->config; + PIIX4State *d = opaque; + uint8_t *pci_conf = d->dev.config; pci_conf[0x04] = 0x07; // master, memory and I/O pci_conf[0x05] = 0x00; @@ -70,31 +74,32 @@ static void piix4_reset(void *opaque) static void piix_save(QEMUFile* f, void *opaque) { - PCIDevice *d = opaque; - pci_device_save(d, f); + PIIX4State *d = opaque; + pci_device_save(&d->dev, f); } static int piix_load(QEMUFile* f, void *opaque, int version_id) { - PCIDevice *d = opaque; + PIIX4State *d = opaque; if (version_id != 2) return -EINVAL; - return pci_device_load(d, f); + return pci_device_load(&d->dev, f); } -static int piix4_initfn(PCIDevice *d) +static int piix4_initfn(PCIDevice *dev) { + PIIX4State *d = DO_UPCAST(PIIX4State, dev, dev); uint8_t *pci_conf; - isa_bus_new(&d->qdev); - register_savevm(&d->qdev, "PIIX4", 0, 2, piix_save, piix_load, d); + isa_bus_new(&d->dev.qdev); + register_savevm(&d->dev.qdev, "PIIX4", 0, 2, piix_save, piix_load, d); - pci_conf = d->config; + pci_conf = d->dev.config; pci_config_set_vendor_id(pci_conf, PCI_VENDOR_ID_INTEL); pci_config_set_device_id(pci_conf, PCI_DEVICE_ID_INTEL_82371AB_0); // 82371AB/EB/MB PIIX4 PCI-to-ISA bridge pci_config_set_class(pci_conf, PCI_CLASS_BRIDGE_ISA); - piix4_dev = d; + piix4_dev = &d->dev; qemu_register_reset(piix4_reset, d); return 0; } @@ -111,7 +116,7 @@ static PCIDeviceInfo piix4_info[] = { { .qdev.name = "PIIX4", .qdev.desc = "ISA bridge", - .qdev.size = sizeof(PCIDevice), + .qdev.size = sizeof(PIIX4State), .qdev.no_user = 1, .no_hotplug = 1, .init = piix4_initfn,