From patchwork Wed Oct 28 12:29:25 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 37102 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 2C3D3B7BCC for ; Wed, 28 Oct 2009 23:47:02 +1100 (EST) Received: from localhost ([127.0.0.1]:42221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N37vX-0002Yu-8X for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2009 08:46:59 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N37f7-0004HT-8H for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:30:01 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N37f1-0004CH-2d for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:59 -0400 Received: from [199.232.76.173] (port=45173 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N37ez-0004Be-TP for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37495) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N37ez-0004tI-4l for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:53 -0400 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9SCTgrt018918; Wed, 28 Oct 2009 08:29:42 -0400 Received: from localhost.localdomain (vpn1-5-215.ams2.redhat.com [10.36.5.215]) by int-mx05.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9SCTYGU005218; Wed, 28 Oct 2009 08:29:40 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Oct 2009 13:29:25 +0100 Message-Id: <1472da1d031928f3f078aa52153830c7b1c80903.1256731509.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.18 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Cc: Subject: [Qemu-devel] [PATCH 04/10] es1370: port 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 Signed-off-by: Juan Quintela --- hw/es1370.c | 77 +++++++++++++++++++++++++++------------------------------- 1 files changed, 36 insertions(+), 41 deletions(-) diff --git a/hw/es1370.c b/hw/es1370.c index 9071a48..8e0eddd 100644 --- a/hw/es1370.c +++ b/hw/es1370.c @@ -924,48 +924,28 @@ static void es1370_map (PCIDevice *pci_dev, int region_num, register_ioport_read (addr, 0x40, 4, es1370_readl, s); } -static void es1370_save (QEMUFile *f, void *opaque) -{ - ES1370State *s = opaque; - size_t i; - - pci_device_save (&s->dev, f); - for (i = 0; i < NB_CHANNELS; ++i) { - struct chan *d = &s->chan[i]; - qemu_put_be32s (f, &d->shift); - qemu_put_be32s (f, &d->leftover); - qemu_put_be32s (f, &d->scount); - qemu_put_be32s (f, &d->frame_addr); - qemu_put_be32s (f, &d->frame_cnt); +static const VMStateDescription vmstate_es1370_channel = { + .name = "es1370_channel", + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 2, + .fields = (VMStateField []) { + VMSTATE_UINT32(shift, struct chan), + VMSTATE_UINT32(leftover, struct chan), + VMSTATE_UINT32(scount, struct chan), + VMSTATE_UINT32(frame_addr, struct chan), + VMSTATE_UINT32(frame_cnt, struct chan), + VMSTATE_END_OF_LIST() } - qemu_put_be32s (f, &s->ctl); - qemu_put_be32s (f, &s->status); - qemu_put_be32s (f, &s->mempage); - qemu_put_be32s (f, &s->codec); - qemu_put_be32s (f, &s->sctl); -} +}; -static int es1370_load (QEMUFile *f, void *opaque, int version_id) +static int es1370_post_load (void *opaque, int version_id) { - int ret; uint32_t ctl, sctl; ES1370State *s = opaque; size_t i; - if (version_id != 2) - return -EINVAL; - - ret = pci_device_load (&s->dev, f); - if (ret) - return ret; - for (i = 0; i < NB_CHANNELS; ++i) { - struct chan *d = &s->chan[i]; - qemu_get_be32s (f, &d->shift); - qemu_get_be32s (f, &d->leftover); - qemu_get_be32s (f, &d->scount); - qemu_get_be32s (f, &d->frame_addr); - qemu_get_be32s (f, &d->frame_cnt); if (i == ADC_CHANNEL) { if (s->adc_voice) { AUD_close_in (&s->card, s->adc_voice); @@ -980,18 +960,33 @@ static int es1370_load (QEMUFile *f, void *opaque, int version_id) } } - qemu_get_be32s (f, &ctl); - qemu_get_be32s (f, &s->status); - qemu_get_be32s (f, &s->mempage); - qemu_get_be32s (f, &s->codec); - qemu_get_be32s (f, &sctl); - + ctl = s->ctl; + sctl = s->sctl; s->ctl = 0; s->sctl = 0; es1370_update_voices (s, ctl, sctl); return 0; } +static const VMStateDescription vmstate_es1370 = { + .name = "es1370", + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 2, + .post_load = es1370_post_load, + .fields = (VMStateField []) { + VMSTATE_PCI_DEVICE(dev, ES1370State), + VMSTATE_STRUCT_ARRAY(chan, ES1370State, NB_CHANNELS, 2, + vmstate_es1370_channel, struct chan), + VMSTATE_UINT32(ctl, ES1370State), + VMSTATE_UINT32(status, ES1370State), + VMSTATE_UINT32(mempage, ES1370State), + VMSTATE_UINT32(codec, ES1370State), + VMSTATE_UINT32(sctl, ES1370State), + VMSTATE_END_OF_LIST() + } +}; + static void es1370_on_reset (void *opaque) { ES1370State *s = opaque; @@ -1028,7 +1023,7 @@ static int es1370_initfn (PCIDevice *dev) c[0x3f] = 0x80; pci_register_bar (&s->dev, 0, 256, PCI_ADDRESS_SPACE_IO, es1370_map); - register_savevm ("es1370", 0, 2, es1370_save, es1370_load, s); + vmstate_register (0, &vmstate_es1370, s); qemu_register_reset (es1370_on_reset, s); AUD_register_card ("es1370", &s->card);