From patchwork Wed Oct 14 17:35:07 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 36018 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 DE202B7B72 for ; Thu, 15 Oct 2009 05:06:55 +1100 (EST) Received: from localhost ([127.0.0.1]:42726 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My8FQ-0001qb-48 for incoming@patchwork.ozlabs.org; Wed, 14 Oct 2009 14:06:52 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1My7lc-0002Va-K9 for qemu-devel@nongnu.org; Wed, 14 Oct 2009 13:36:04 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1My7lU-0002RM-9Z for qemu-devel@nongnu.org; Wed, 14 Oct 2009 13:36:00 -0400 Received: from [199.232.76.173] (port=55258 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1My7lU-0002RG-4Q for qemu-devel@nongnu.org; Wed, 14 Oct 2009 13:35:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6124) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1My7lT-0008Oz-DS for qemu-devel@nongnu.org; Wed, 14 Oct 2009 13:35:55 -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 n9EHZs8B011098 for ; Wed, 14 Oct 2009 13:35:54 -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 n9EHZXG3001016; Wed, 14 Oct 2009 13:35:53 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Wed, 14 Oct 2009 19:35:07 +0200 Message-Id: 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/16] vmware_vga: 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/vmware_vga.c | 114 ++++++++++++++++++++---------------------------------- 1 files changed, 42 insertions(+), 72 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index d0a19dd..de3d0a1 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -1051,55 +1051,9 @@ static CPUWriteMemoryFunc * const vmsvga_vram_write[] = { }; #endif -static void vmsvga_save(struct vmsvga_state_s *s, QEMUFile *f) +static int vmsvga_post_load(void *opaque, int version_id) { - int i; - qemu_put_be32(f, s->depth); - qemu_put_be32(f, s->enable); - qemu_put_be32(f, s->config); - qemu_put_be32(f, s->cursor.id); - qemu_put_be32(f, s->cursor.x); - qemu_put_be32(f, s->cursor.y); - qemu_put_be32(f, s->cursor.on); - qemu_put_be32(f, s->index); - for (i = 0; i < s->scratch_size; i++) { - qemu_put_be32s(f, &s->scratch[i]); - } - qemu_put_be32(f, s->new_width); - qemu_put_be32(f, s->new_height); - qemu_put_be32s(f, &s->guest); - qemu_put_be32s(f, &s->svgaid); - qemu_put_be32(f, s->syncing); - qemu_put_be32(f, s->fb_size); -} - -static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f) -{ - int depth; - int i; - depth=qemu_get_be32(f); - s->enable=qemu_get_be32(f); - s->config=qemu_get_be32(f); - s->cursor.id=qemu_get_be32(f); - s->cursor.x=qemu_get_be32(f); - s->cursor.y=qemu_get_be32(f); - s->cursor.on=qemu_get_be32(f); - s->index=qemu_get_be32(f); - for (i = 0; i < s->scratch_size; i++) { - qemu_get_be32s(f, &s->scratch[i]); - } - s->new_width=qemu_get_be32(f); - s->new_height=qemu_get_be32(f); - qemu_get_be32s(f, &s->guest); - qemu_get_be32s(f, &s->svgaid); - s->syncing=qemu_get_be32(f); - s->fb_size=qemu_get_be32(f); - - if (depth != s->depth) { - printf("%s: need colour depth of %i bits to resume operation.\n", - __FUNCTION__, depth); - return -EINVAL; - } + struct vmsvga_state_s *s = opaque; s->invalidated = 1; if (s->config) @@ -1108,6 +1062,45 @@ static int vmsvga_load(struct vmsvga_state_s *s, QEMUFile *f) return 0; } +const VMStateDescription vmstate_vmware_vga_internal = { + .name = "vmware_vga_internal", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .post_load = vmsvga_post_load, + .fields = (VMStateField []) { + VMSTATE_INT32_EQUAL(depth, struct vmsvga_state_s), + VMSTATE_INT32(enable, struct vmsvga_state_s), + VMSTATE_INT32(config, struct vmsvga_state_s), + VMSTATE_INT32(cursor.id, struct vmsvga_state_s), + VMSTATE_INT32(cursor.x, struct vmsvga_state_s), + VMSTATE_INT32(cursor.y, struct vmsvga_state_s), + VMSTATE_INT32(cursor.on, struct vmsvga_state_s), + VMSTATE_INT32(index, struct vmsvga_state_s), + VMSTATE_UINT32_VARRAY(scratch, struct vmsvga_state_s, scratch_size), + VMSTATE_INT32(new_width, struct vmsvga_state_s), + VMSTATE_INT32(new_height, struct vmsvga_state_s), + VMSTATE_UINT32(guest, struct vmsvga_state_s), + VMSTATE_UINT32(svgaid, struct vmsvga_state_s), + VMSTATE_INT32(syncing, struct vmsvga_state_s), + VMSTATE_INT32(fb_size, struct vmsvga_state_s), + VMSTATE_END_OF_LIST() + } +}; + +const VMStateDescription vmstate_vmware_vga = { + .name = "vmware_vga", + .version_id = 0, + .minimum_version_id = 0, + .minimum_version_id_old = 0, + .fields = (VMStateField []) { + VMSTATE_PCI_DEVICE(card, struct pci_vmsvga_state_s), + VMSTATE_STRUCT(chip, struct pci_vmsvga_state_s, 0, + vmstate_vmware_vga_internal, struct vmsvga_state_s), + VMSTATE_END_OF_LIST() + } +}; + static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) { s->scratch_size = SVGA_SCRATCH_SIZE; @@ -1131,29 +1124,6 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) #endif } -static void pci_vmsvga_save(QEMUFile *f, void *opaque) -{ - struct pci_vmsvga_state_s *s = opaque; - pci_device_save(&s->card, f); - vmsvga_save(&s->chip, f); -} - -static int pci_vmsvga_load(QEMUFile *f, void *opaque, int version_id) -{ - struct pci_vmsvga_state_s *s = opaque; - int ret; - - ret = pci_device_load(&s->card, f); - if (ret < 0) - return ret; - - ret = vmsvga_load(&s->chip, f); - if (ret < 0) - return ret; - - return 0; -} - static void pci_vmsvga_map_ioport(PCIDevice *pci_dev, int region_num, uint32_t addr, uint32_t size, int type) { @@ -1217,7 +1187,7 @@ static int pci_vmsvga_initfn(PCIDevice *dev) vmsvga_init(&s->chip, VGA_RAM_SIZE); - register_savevm("vmware_vga", 0, 0, pci_vmsvga_save, pci_vmsvga_load, s); + vmstate_register(0, &vmstate_vmware_vga, s); return 0; }