From patchwork Wed Oct 14 11:37:47 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 35950 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 6C0BAB7043 for ; Wed, 14 Oct 2009 22:51:13 +1100 (EST) Received: from localhost ([127.0.0.1]:46403 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My2Nq-000121-PL for incoming@patchwork.ozlabs.org; Wed, 14 Oct 2009 07:51:10 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1My2Bf-0002Lr-N0 for qemu-devel@nongnu.org; Wed, 14 Oct 2009 07:38:36 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1My2Ba-0002Fu-Ll for qemu-devel@nongnu.org; Wed, 14 Oct 2009 07:38:34 -0400 Received: from [199.232.76.173] (port=41241 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My2BZ-0002FJ-JO for qemu-devel@nongnu.org; Wed, 14 Oct 2009 07:38:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:10071) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1My2BZ-0006Cu-2G for qemu-devel@nongnu.org; Wed, 14 Oct 2009 07:38:29 -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 n9EBcSR2013905 for ; Wed, 14 Oct 2009 07:38:28 -0400 Received: from localhost.localdomain (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9EBcIEw006321; Wed, 14 Oct 2009 07:38:27 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 14 Oct 2009 13:37:47 +0200 Message-Id: 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 07/13] ide: port microdrive 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/ide/microdrive.c | 61 +++++++++++++++------------------------------------ 1 files changed, 18 insertions(+), 43 deletions(-) diff --git a/hw/ide/microdrive.c b/hw/ide/microdrive.c index 49a9b93..9f7789d 100644 --- a/hw/ide/microdrive.c +++ b/hw/ide/microdrive.c @@ -300,48 +300,23 @@ static void md_common_write(void *opaque, uint32_t at, uint16_t value) } } -static void md_save(QEMUFile *f, void *opaque) -{ - MicroDriveState *s = opaque; - int i; - - qemu_put_8s(f, &s->opt); - qemu_put_8s(f, &s->stat); - qemu_put_8s(f, &s->pins); - - qemu_put_8s(f, &s->ctrl); - qemu_put_be16s(f, &s->io); - qemu_put_byte(f, s->cycle); - - idebus_save(f, &s->bus); - - for (i = 0; i < 2; i ++) - ide_save(f, &s->bus.ifs[i]); -} - -static int md_load(QEMUFile *f, void *opaque, int version_id) -{ - MicroDriveState *s = opaque; - int i; - - if (version_id != 0 && version_id != 3) - return -EINVAL; - - qemu_get_8s(f, &s->opt); - qemu_get_8s(f, &s->stat); - qemu_get_8s(f, &s->pins); - - qemu_get_8s(f, &s->ctrl); - qemu_get_be16s(f, &s->io); - s->cycle = qemu_get_byte(f); - - idebus_load(f, &s->bus, version_id); - - for (i = 0; i < 2; i ++) - ide_load(f, &s->bus.ifs[i], version_id); - - return 0; -} +const VMStateDescription vmstate_microdrive = { + .name = "microdrive", + .version_id = 3, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .fields = (VMStateField []) { + VMSTATE_UINT8(opt, MicroDriveState), + VMSTATE_UINT8(stat, MicroDriveState), + VMSTATE_UINT8(pins, MicroDriveState), + VMSTATE_UINT8(ctrl, MicroDriveState), + VMSTATE_UINT16(io, MicroDriveState), + VMSTATE_UINT8(cycle, MicroDriveState), + VMSTATE_IDE_BUS(bus, MicroDriveState), + VMSTATE_IDE_DRIVES(bus.ifs, MicroDriveState), + VMSTATE_END_OF_LIST() + } +}; static const uint8_t dscm1xxxx_cis[0x14a] = { [0x000] = CISTPL_DEVICE, /* 5V Device Information */ @@ -569,7 +544,7 @@ PCMCIACardState *dscm1xxxx_init(DriveInfo *bdrv) md->bus.ifs[0].mdata_size = METADATA_SIZE; md->bus.ifs[0].mdata_storage = (uint8_t *) qemu_mallocz(METADATA_SIZE); - register_savevm("microdrive", -1, 3, md_save, md_load, md); + vmstate_register(-1, &vmstate_microdrive, md); return &md->card; }