From patchwork Tue Sep 29 20:48:35 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 34466 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 085DFB7C17 for ; Wed, 30 Sep 2009 07:21:28 +1000 (EST) Received: from localhost ([127.0.0.1]:36989 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Msk8T-0000wy-92 for incoming@patchwork.ozlabs.org; Tue, 29 Sep 2009 17:21:25 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Msjdq-00057F-CI for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:46 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Msjdl-00053O-Iv for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:45 -0400 Received: from [199.232.76.173] (port=55221 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Msjdk-000533-Po for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59509) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Msjdj-0002Tt-TA for qemu-devel@nongnu.org; Tue, 29 Sep 2009 16:49:40 -0400 Received: from int-mx03.intmail.prod.int.phx2.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n8TKndJv030494 for ; Tue, 29 Sep 2009 16:49:39 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx03.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n8TKnHXp006885; Tue, 29 Sep 2009 16:49:38 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Tue, 29 Sep 2009 22:48:35 +0200 Message-Id: <147559ff54dafc1e5ce45d256c94cd20518c78e4.1254255997.git.quintela@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.67 on 10.5.11.16 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 16/49] vmstate: port ssd0303 device 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/ssd0303.c | 65 +++++++++++++++++++-------------------------------------- 1 files changed, 22 insertions(+), 43 deletions(-) diff --git a/hw/ssd0303.c b/hw/ssd0303.c index 16aed58..f60930e 100644 --- a/hw/ssd0303.c +++ b/hw/ssd0303.c @@ -261,48 +261,27 @@ static void ssd0303_invalidate_display(void * opaque) s->redraw = 1; } -static void ssd0303_save(QEMUFile *f, void *opaque) -{ - ssd0303_state *s = (ssd0303_state *)opaque; - - qemu_put_be32(f, s->row); - qemu_put_be32(f, s->col); - qemu_put_be32(f, s->start_line); - qemu_put_be32(f, s->mirror); - qemu_put_be32(f, s->flash); - qemu_put_be32(f, s->enabled); - qemu_put_be32(f, s->inverse); - qemu_put_be32(f, s->redraw); - qemu_put_be32(f, s->mode); - qemu_put_be32(f, s->cmd_state); - qemu_put_buffer(f, s->framebuffer, sizeof(s->framebuffer)); - - i2c_slave_save(f, &s->i2c); -} - -static int ssd0303_load(QEMUFile *f, void *opaque, int version_id) -{ - ssd0303_state *s = (ssd0303_state *)opaque; - - if (version_id != 1) - return -EINVAL; - - s->row = qemu_get_be32(f); - s->col = qemu_get_be32(f); - s->start_line = qemu_get_be32(f); - s->mirror = qemu_get_be32(f); - s->flash = qemu_get_be32(f); - s->enabled = qemu_get_be32(f); - s->inverse = qemu_get_be32(f); - s->redraw = qemu_get_be32(f); - s->mode = qemu_get_be32(f); - s->cmd_state = qemu_get_be32(f); - qemu_get_buffer(f, s->framebuffer, sizeof(s->framebuffer)); - - i2c_slave_load(f, &s->i2c); - - return 0; -} +static const VMStateDescription vmstate_ssd0303 = { + .name = "ssd0303_oled", + .version_id = 1, + .minimum_version_id = 1, + .minimum_version_id_old = 1, + .fields = (VMStateField []) { + VMSTATE_INT32(row, ssd0303_state), + VMSTATE_INT32(col, ssd0303_state), + VMSTATE_INT32(start_line, ssd0303_state), + VMSTATE_INT32(mirror, ssd0303_state), + VMSTATE_INT32(flash, ssd0303_state), + VMSTATE_INT32(enabled, ssd0303_state), + VMSTATE_INT32(inverse, ssd0303_state), + VMSTATE_INT32(redraw, ssd0303_state), + VMSTATE_UINT32(mode, ssd0303_state), + VMSTATE_UINT32(cmd_state, ssd0303_state), + VMSTATE_BUFFER(framebuffer, ssd0303_state), + VMSTATE_I2C_SLAVE(i2c, ssd0303_state), + VMSTATE_END_OF_LIST() + } +}; static int ssd0303_init(i2c_slave *i2c) { @@ -312,7 +291,7 @@ static int ssd0303_init(i2c_slave *i2c) ssd0303_invalidate_display, NULL, NULL, s); qemu_console_resize(s->ds, 96 * MAGNIFY, 16 * MAGNIFY); - register_savevm("ssd0303_oled", -1, 1, ssd0303_save, ssd0303_load, s); + vmstate_register(-1, &vmstate_ssd0303, s); return 0; }