From patchwork Wed Oct 28 12:29:24 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 37097 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 6CECDB7BE7 for ; Wed, 28 Oct 2009 23:38:28 +1100 (EST) Received: from localhost ([127.0.0.1]:51872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N37nF-0007Uf-0a for incoming@patchwork.ozlabs.org; Wed, 28 Oct 2009 08:38:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N37f4-0004F8-Pw for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:58 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N37f0-0004C9-T8 for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:58 -0400 Received: from [199.232.76.173] (port=45174 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N37ez-0004Bf-UJ for qemu-devel@nongnu.org; Wed, 28 Oct 2009 08:29:54 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10665) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N37ez-0004tO-9R 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 n9SCTesD030230; Wed, 28 Oct 2009 08:29:40 -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 n9SCTYGT005218; Wed, 28 Oct 2009 08:29:39 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 28 Oct 2009 13:29:24 +0100 Message-Id: <9b15ffa8b77e07a2f4d988cac8a64d24804d3600.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 03/10] sb16: 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/sb16.c | 168 ++++++++++++++++++++++--------------------------------------- 1 files changed, 61 insertions(+), 107 deletions(-) diff --git a/hw/sb16.c b/hw/sb16.c index 8654b7d..c72ef4c 100644 --- a/hw/sb16.c +++ b/hw/sb16.c @@ -1251,115 +1251,10 @@ static void SB_audio_callback (void *opaque, int free) s->audio_free = free; } -static void SB_save (QEMUFile *f, void *opaque) +static int sb16_post_load (void *opaque, int version_id) { SB16State *s = opaque; - qemu_put_be32 (f, s->irq); - qemu_put_be32 (f, s->dma); - qemu_put_be32 (f, s->hdma); - qemu_put_be32 (f, s->port); - qemu_put_be32 (f, s->ver); - qemu_put_be32 (f, s->in_index); - qemu_put_be32 (f, s->out_data_len); - qemu_put_be32 (f, s->fmt_stereo); - qemu_put_be32 (f, s->fmt_signed); - qemu_put_be32 (f, s->fmt_bits); - qemu_put_be32s (f, &s->fmt); - qemu_put_be32 (f, s->dma_auto); - qemu_put_be32 (f, s->block_size); - qemu_put_be32 (f, s->fifo); - qemu_put_be32 (f, s->freq); - qemu_put_be32 (f, s->time_const); - qemu_put_be32 (f, s->speaker); - qemu_put_be32 (f, s->needed_bytes); - qemu_put_be32 (f, s->cmd); - qemu_put_be32 (f, s->use_hdma); - qemu_put_be32 (f, s->highspeed); - qemu_put_be32 (f, s->can_write); - qemu_put_be32 (f, s->v2x6); - - qemu_put_8s (f, &s->csp_param); - qemu_put_8s (f, &s->csp_value); - qemu_put_8s (f, &s->csp_mode); - qemu_put_8s (f, &s->csp_param); - qemu_put_buffer (f, s->csp_regs, 256); - qemu_put_8s (f, &s->csp_index); - qemu_put_buffer (f, s->csp_reg83, 4); - qemu_put_be32 (f, s->csp_reg83r); - qemu_put_be32 (f, s->csp_reg83w); - - qemu_put_buffer (f, s->in2_data, sizeof (s->in2_data)); - qemu_put_buffer (f, s->out_data, sizeof (s->out_data)); - qemu_put_8s (f, &s->test_reg); - qemu_put_8s (f, &s->last_read_byte); - - qemu_put_be32 (f, s->nzero); - qemu_put_be32 (f, s->left_till_irq); - qemu_put_be32 (f, s->dma_running); - qemu_put_be32 (f, s->bytes_per_second); - qemu_put_be32 (f, s->align); - - qemu_put_be32 (f, s->mixer_nreg); - qemu_put_buffer (f, s->mixer_regs, 256); -} - -static int SB_load (QEMUFile *f, void *opaque, int version_id) -{ - SB16State *s = opaque; - - if (version_id != 1) { - return -EINVAL; - } - - s->irq=qemu_get_be32 (f); - s->dma=qemu_get_be32 (f); - s->hdma=qemu_get_be32 (f); - s->port=qemu_get_be32 (f); - s->ver=qemu_get_be32 (f); - s->in_index=qemu_get_be32 (f); - s->out_data_len=qemu_get_be32 (f); - s->fmt_stereo=qemu_get_be32 (f); - s->fmt_signed=qemu_get_be32 (f); - s->fmt_bits=qemu_get_be32 (f); - qemu_get_be32s (f, &s->fmt); - s->dma_auto=qemu_get_be32 (f); - s->block_size=qemu_get_be32 (f); - s->fifo=qemu_get_be32 (f); - s->freq=qemu_get_be32 (f); - s->time_const=qemu_get_be32 (f); - s->speaker=qemu_get_be32 (f); - s->needed_bytes=qemu_get_be32 (f); - s->cmd=qemu_get_be32 (f); - s->use_hdma=qemu_get_be32 (f); - s->highspeed=qemu_get_be32 (f); - s->can_write=qemu_get_be32 (f); - s->v2x6=qemu_get_be32 (f); - - qemu_get_8s (f, &s->csp_param); - qemu_get_8s (f, &s->csp_value); - qemu_get_8s (f, &s->csp_mode); - qemu_get_8s (f, &s->csp_param); - qemu_get_buffer (f, s->csp_regs, 256); - qemu_get_8s (f, &s->csp_index); - qemu_get_buffer (f, s->csp_reg83, 4); - s->csp_reg83r=qemu_get_be32 (f); - s->csp_reg83w=qemu_get_be32 (f); - - qemu_get_buffer (f, s->in2_data, sizeof (s->in2_data)); - qemu_get_buffer (f, s->out_data, sizeof (s->out_data)); - qemu_get_8s (f, &s->test_reg); - qemu_get_8s (f, &s->last_read_byte); - - s->nzero=qemu_get_be32 (f); - s->left_till_irq=qemu_get_be32 (f); - s->dma_running=qemu_get_be32 (f); - s->bytes_per_second=qemu_get_be32 (f); - s->align=qemu_get_be32 (f); - - s->mixer_nreg=qemu_get_be32 (f); - qemu_get_buffer (f, s->mixer_regs, 256); - if (s->voice) { AUD_close_out (&s->card, s->voice); s->voice = NULL; @@ -1392,6 +1287,65 @@ static int SB_load (QEMUFile *f, void *opaque, int version_id) return 0; } +static const VMStateDescription vmstate_sb16 = { + .name = "sb16", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .post_load = sb16_post_load, + .fields = (VMStateField []) { + VMSTATE_UINT32(irq, SB16State), + VMSTATE_UINT32(dma, SB16State), + VMSTATE_UINT32(hdma, SB16State), + VMSTATE_UINT32(port, SB16State), + VMSTATE_UINT32(ver, SB16State), + VMSTATE_INT32(in_index, SB16State), + VMSTATE_INT32(out_data_len, SB16State), + VMSTATE_INT32(fmt_stereo, SB16State), + VMSTATE_INT32(fmt_signed, SB16State), + VMSTATE_INT32(fmt_bits, SB16State), + VMSTATE_UINT32(fmt, SB16State), + VMSTATE_INT32(dma_auto, SB16State), + VMSTATE_INT32(block_size, SB16State), + VMSTATE_INT32(fifo, SB16State), + VMSTATE_INT32(freq, SB16State), + VMSTATE_INT32(time_const, SB16State), + VMSTATE_INT32(speaker, SB16State), + VMSTATE_INT32(needed_bytes, SB16State), + VMSTATE_INT32(cmd, SB16State), + VMSTATE_INT32(use_hdma, SB16State), + VMSTATE_INT32(highspeed, SB16State), + VMSTATE_INT32(can_write, SB16State), + VMSTATE_INT32(v2x6, SB16State), + + VMSTATE_UINT8(csp_param, SB16State), + VMSTATE_UINT8(csp_value, SB16State), + VMSTATE_UINT8(csp_mode, SB16State), + VMSTATE_UINT8(csp_param, SB16State), + VMSTATE_BUFFER(csp_regs, SB16State), + VMSTATE_UINT8(csp_index, SB16State), + VMSTATE_BUFFER(csp_reg83, SB16State), + VMSTATE_INT32(csp_reg83r, SB16State), + VMSTATE_INT32(csp_reg83w, SB16State), + + VMSTATE_BUFFER(in2_data, SB16State), + VMSTATE_BUFFER(out_data, SB16State), + VMSTATE_UINT8(test_reg, SB16State), + VMSTATE_UINT8(last_read_byte, SB16State), + + VMSTATE_INT32(nzero, SB16State), + VMSTATE_INT32(left_till_irq, SB16State), + VMSTATE_INT32(dma_running, SB16State), + VMSTATE_INT32(bytes_per_second, SB16State), + VMSTATE_INT32(align, SB16State), + + VMSTATE_INT32(mixer_nreg, SB16State), + VMSTATE_BUFFER(mixer_regs, SB16State), + + VMSTATE_END_OF_LIST() + } +}; + static int sb16_initfn (ISADevice *dev) { static const uint8_t dsp_write_ports[] = {0x6, 0xc}; @@ -1434,7 +1388,7 @@ static int sb16_initfn (ISADevice *dev) DMA_register_channel (s->dma, SB_read_DMA, s); s->can_write = 1; - register_savevm ("sb16", 0, 1, SB_save, SB_load, s); + vmstate_register (0, &vmstate_sb16, s); AUD_register_card ("sb16", &s->card); return 0; }