From patchwork Thu Aug 20 17:42:41 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 31771 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 bilbo.ozlabs.org (Postfix) with ESMTPS id E1915B7B68 for ; Fri, 21 Aug 2009 04:25:19 +1000 (EST) Received: from localhost ([127.0.0.1]:60480 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeCK0-0000q7-U1 for incoming@patchwork.ozlabs.org; Thu, 20 Aug 2009 14:25:13 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeBhb-0006WT-6I for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:31 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeBhY-0006Sn-1J for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:29 -0400 Received: from [199.232.76.173] (port=39164 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeBhX-0006SX-4b for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:18571) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MeBhW-00070r-Hd for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:26 -0400 Received: from int-mx04.intmail.prod.int.phx2.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.17]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n7KHjPwj021596 for ; Thu, 20 Aug 2009 13:45:25 -0400 Received: from localhost.localdomain (vpn2-8-130.ams2.redhat.com [10.36.8.130]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7KHis4i012471; Thu, 20 Aug 2009 13:45:23 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 20 Aug 2009 19:42:41 +0200 Message-Id: <4a8664e688583e0c277ccee7f467cdff89ff8c6f.1250788880.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.17 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 23/23] Port ACPI to VMState 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 This uses a run_after_load() function, and VMSTATE_PCI_DEVICE() It could be made smaller changing the type of pm_io_space_update() to return an int. Signed-off-by: Juan Quintela --- hw/acpi.c | 55 +++++++++++++++++++++---------------------------------- 1 files changed, 21 insertions(+), 34 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index 37a5d98..6eddd0e 100644 --- a/hw/acpi.c +++ b/hw/acpi.c @@ -440,46 +440,33 @@ static void pm_write_config(PCIDevice *d, pm_io_space_update((PIIX4PMState *)d); } -static void pm_save(QEMUFile* f,void *opaque) +static int vmstate_acpi_after_load(void *opaque) { PIIX4PMState *s = opaque; - pci_device_save(&s->dev, f); - - qemu_put_be16s(f, &s->pmsts); - qemu_put_be16s(f, &s->pmen); - qemu_put_be16s(f, &s->pmcntrl); - qemu_put_8s(f, &s->apmc); - qemu_put_8s(f, &s->apms); - qemu_put_timer(f, s->tmr_timer); - qemu_put_be64(f, s->tmr_overflow_time); -} - -static int pm_load(QEMUFile* f,void* opaque,int version_id) -{ - PIIX4PMState *s = opaque; - int ret; - - if (version_id > 1) - return -EINVAL; - - ret = pci_device_load(&s->dev, f); - if (ret < 0) - return ret; - - qemu_get_be16s(f, &s->pmsts); - qemu_get_be16s(f, &s->pmen); - qemu_get_be16s(f, &s->pmcntrl); - qemu_get_8s(f, &s->apmc); - qemu_get_8s(f, &s->apms); - qemu_get_timer(f, s->tmr_timer); - s->tmr_overflow_time=qemu_get_be64(f); - pm_io_space_update(s); - return 0; } +static const VMStateDescription vmstate_acpi = { + .name = "piix4_pm", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .run_after_load = vmstate_acpi_after_load, + .fields = (VMStateField []) { + VMSTATE_PCI_DEVICE(dev, PIIX4PMState), + VMSTATE_UINT16(pmsts, PIIX4PMState), + VMSTATE_UINT16(pmen, PIIX4PMState), + VMSTATE_UINT16(pmcntrl, PIIX4PMState), + VMSTATE_UINT8(apmc, PIIX4PMState), + VMSTATE_UINT8(apms, PIIX4PMState), + VMSTATE_TIMER(tmr_timer, PIIX4PMState), + VMSTATE_INT64(tmr_overflow_time, PIIX4PMState), + VMSTATE_END_OF_LIST() + } +}; + static void piix4_reset(void *opaque) { PIIX4PMState *s = opaque; @@ -561,7 +548,7 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base, qemu_system_powerdown = *qemu_allocate_irqs(piix4_powerdown, s, 1); - register_savevm("piix4_pm", 0, 1, pm_save, pm_load, s); + vmstate_register(0, &vmstate_acpi, s); s->smbus = i2c_init_bus(NULL, "i2c"); s->irq = sci_irq;