From patchwork Thu Aug 20 17:42:31 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 31762 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 3F601B7B7B for ; Fri, 21 Aug 2009 04:07:31 +1000 (EST) Received: from localhost ([127.0.0.1]:44698 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeC2p-000083-3U for incoming@patchwork.ozlabs.org; Thu, 20 Aug 2009 14:07:27 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MeBhS-0006N5-PK for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:22 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MeBhL-0006HD-8f for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:19 -0400 Received: from [199.232.76.173] (port=39152 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MeBhK-0006Gt-PV for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:14 -0400 Received: from mx1.redhat.com ([209.132.183.28]:12860) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1MeBhK-0006yT-3y for qemu-devel@nongnu.org; Thu, 20 Aug 2009 13:45:14 -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 n7KHjCEN003834 for ; Thu, 20 Aug 2009 13:45:12 -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 n7KHis4Y012471; Thu, 20 Aug 2009 13:45:11 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Thu, 20 Aug 2009 19:42:31 +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 13/23] Port i8254 to new VMState design 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/i8254.c | 66 +++++++++++++++++++++++++++++++++-------------------------- 1 files changed, 37 insertions(+), 29 deletions(-) diff --git a/hw/i8254.c b/hw/i8254.c index 44e4531..6a8cd3e 100644 --- a/hw/i8254.c +++ b/hw/i8254.c @@ -389,35 +389,31 @@ static void pit_irq_timer(void *opaque) pit_irq_timer_update(s, s->next_transition_time); } -static void pit_save(QEMUFile *f, void *opaque) -{ - PITState *pit = opaque; - PITChannelState *s; - int i; - - for(i = 0; i < 3; i++) { - s = &pit->channels[i]; - qemu_put_be32(f, s->count); - qemu_put_be16s(f, &s->latched_count); - qemu_put_8s(f, &s->count_latched); - qemu_put_8s(f, &s->status_latched); - qemu_put_8s(f, &s->status); - qemu_put_8s(f, &s->read_state); - qemu_put_8s(f, &s->write_state); - qemu_put_8s(f, &s->write_latch); - qemu_put_8s(f, &s->rw_mode); - qemu_put_8s(f, &s->mode); - qemu_put_8s(f, &s->bcd); - qemu_put_8s(f, &s->gate); - qemu_put_be64(f, s->count_load_time); - if (s->irq_timer) { - qemu_put_be64(f, s->next_transition_time); - qemu_put_timer(f, s->irq_timer); - } +static const VMStateDescription vmstate_pit_channel = { + .name = "pit channel", + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 2, + .fields = (VMStateField []) { + VMSTATE_INT32(count, PITChannelState), + VMSTATE_UINT16(latched_count, PITChannelState), + VMSTATE_UINT8(count_latched, PITChannelState), + VMSTATE_UINT8(status_latched, PITChannelState), + VMSTATE_UINT8(status, PITChannelState), + VMSTATE_UINT8(read_state, PITChannelState), + VMSTATE_UINT8(write_state, PITChannelState), + VMSTATE_UINT8(write_latch, PITChannelState), + VMSTATE_UINT8(rw_mode, PITChannelState), + VMSTATE_UINT8(mode, PITChannelState), + VMSTATE_UINT8(bcd, PITChannelState), + VMSTATE_UINT8(gate, PITChannelState), + VMSTATE_INT64(count_load_time, PITChannelState), + VMSTATE_INT64(next_transition_time, PITChannelState), + VMSTATE_END_OF_LIST() } -} +}; -static int pit_load(QEMUFile *f, void *opaque, int version_id) +static int pit_load_old(QEMUFile *f, void *opaque, int version_id) { PITState *pit = opaque; PITChannelState *s; @@ -449,6 +445,19 @@ static int pit_load(QEMUFile *f, void *opaque, int version_id) return 0; } +static const VMStateDescription vmstate_pit = { + .name = "i8254", + .version_id = 2, + .minimum_version_id = 2, + .minimum_version_id_old = 1, + .load_state_old = pit_load_old, + .fields = (VMStateField []) { + VMSTATE_STRUCT_ARRAY(channels, PITState, 3, 2, vmstate_pit_channel, PITChannelState), + VMSTATE_TIMER(channels[0].irq_timer, PITState), + VMSTATE_END_OF_LIST() + } +}; + static void pit_reset(void *opaque) { PITState *pit = opaque; @@ -495,8 +504,7 @@ PITState *pit_init(int base, qemu_irq irq) s->irq_timer = qemu_new_timer(vm_clock, pit_irq_timer, s); s->irq = irq; - register_savevm("i8254", base, 1, pit_save, pit_load, pit); - + vmstate_register(base, &vmstate_pit, pit); qemu_register_reset(pit_reset, pit); register_ioport_write(base, 4, 1, pit_ioport_write, pit); register_ioport_read(base, 3, 1, pit_ioport_read, pit);