From patchwork Mon Aug 31 14:07:14 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Juan Quintela X-Patchwork-Id: 32640 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 585EAB7B6D for ; Tue, 1 Sep 2009 00:22:45 +1000 (EST) Received: from localhost ([127.0.0.1]:35425 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mi7mK-0000Rq-OY for incoming@patchwork.ozlabs.org; Mon, 31 Aug 2009 10:22:40 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Mi7aJ-0004j4-DV for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:15 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Mi7aE-0004f5-95 for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:14 -0400 Received: from [199.232.76.173] (port=43326 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Mi7aD-0004et-Vt for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65030) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1Mi7aD-0003Cy-En for qemu-devel@nongnu.org; Mon, 31 Aug 2009 10:10:09 -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 n7VEA8QL012835; Mon, 31 Aug 2009 10:10:08 -0400 Received: from localhost.localdomain (vpn1-4-222.ams2.redhat.com [10.36.4.222]) by int-mx04.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n7VEA0oO003480; Mon, 31 Aug 2009 10:10:07 -0400 From: Juan Quintela To: qemu-devel@nongnu.org Date: Mon, 31 Aug 2009 16:07:14 +0200 Message-Id: <8245bf88efe372cc4e04c1aaeb35fcfd29d8c06b.1251725415.git.quintela@redhat.com> 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. Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH 04/23] vga: split vga_{load, save} into pci and common parts 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 Once there adjust VGAState <-> VGACommonState Export vga_common_save/vga_common_load (nreeded by wmvare_vga Remove vga.pci_dev field, it is not needed anymore Signed-off-by: Juan Quintela --- hw/vga.c | 52 ++++++++++++++++++++++++++++++++++------------------ hw/vga_int.h | 3 ++- hw/vmware_vga.c | 1 + 3 files changed, 37 insertions(+), 19 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index d1de04e..2b7091c 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -2126,14 +2126,11 @@ static CPUWriteMemoryFunc * const vga_mem_write[3] = { vga_mem_writel, }; -static void vga_save(QEMUFile *f, void *opaque) +void vga_common_save(QEMUFile *f, void *opaque) { - VGAState *s = opaque; + VGACommonState *s = opaque; int i; - if (s->pci_dev) - pci_device_save(s->pci_dev, f); - qemu_put_be32s(f, &s->latch); qemu_put_8s(f, &s->sr_index); qemu_put_buffer(f, s->sr, 8); @@ -2170,20 +2167,14 @@ static void vga_save(QEMUFile *f, void *opaque) #endif } -static int vga_load(QEMUFile *f, void *opaque, int version_id) +int vga_common_load(QEMUFile *f, void *opaque, int version_id) { - VGAState *s = opaque; - int is_vbe, i, ret; + VGACommonState *s = opaque; + int is_vbe, i; if (version_id > 2) return -EINVAL; - if (s->pci_dev && version_id >= 2) { - ret = pci_device_load(s->pci_dev, f); - if (ret < 0) - return ret; - } - qemu_get_be32s(f, &s->latch); qemu_get_8s(f, &s->sr_index); qemu_get_buffer(f, s->sr, 8); @@ -2229,9 +2220,33 @@ static int vga_load(QEMUFile *f, void *opaque, int version_id) typedef struct PCIVGAState { PCIDevice dev; - VGAState vga; + VGACommonState vga; } PCIVGAState; +static void pci_vga_save(QEMUFile *f, void *opaque) +{ + PCIVGAState *s = opaque; + + pci_device_save(&s->dev, f); + vga_common_save(f, &s->vga); +} + +static int pci_vga_load(QEMUFile *f, void *opaque, int version_id) +{ + PCIVGAState *s = opaque; + int ret; + + if (version_id > 2) + return -EINVAL; + + if (version_id >= 2) { + ret = pci_device_load(&s->dev, f); + if (ret < 0) + return ret; + } + return vga_common_load(f, &s->vga, version_id); +} + void vga_dirty_log_start(VGAState *s) { if (kvm_enabled() && s->map_addr) @@ -2315,7 +2330,6 @@ void vga_init(VGAState *s) int vga_io_memory; qemu_register_reset(vga_reset, s); - register_savevm("vga", 0, 2, vga_save, vga_load, s); register_ioport_write(0x3c0, 16, 1, vga_ioport_write, s); @@ -2428,7 +2442,7 @@ static void vga_mm_init(VGAState *s, target_phys_addr_t vram_base, s_ioport_ctrl = cpu_register_io_memory(vga_mm_read_ctrl, vga_mm_write_ctrl, s); vga_io_memory = cpu_register_io_memory(vga_mem_read, vga_mem_write, s); - register_savevm("vga", 0, 2, vga_save, vga_load, s); + register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s); cpu_register_physical_memory(ctrl_base, 0x100000, s_ioport_ctrl); s->bank_offset = 0; @@ -2444,6 +2458,7 @@ int isa_vga_init(void) vga_common_init(s, VGA_RAM_SIZE); vga_init(s); + register_savevm("vga", 0, 2, vga_common_save, vga_common_load, s); s->ds = graphic_console_init(s->update, s->invalidate, s->screen_dump, s->text_update, s); @@ -2497,7 +2512,8 @@ static int pci_vga_initfn(PCIDevice *dev) // vga + console init vga_common_init(s, VGA_RAM_SIZE); vga_init(s); - s->pci_dev = &d->dev; + register_savevm("vga", 0, 2, pci_vga_save, pci_vga_load, d); + s->ds = graphic_console_init(s->update, s->invalidate, s->screen_dump, s->text_update, s); diff --git a/hw/vga_int.h b/hw/vga_int.h index b44790d..54b3d5a 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -110,7 +110,6 @@ typedef struct VGACommonState { uint32_t bios_offset; uint32_t bios_size; int it_shift; - PCIDevice *pci_dev; uint32_t latch; uint8_t sr_index; uint8_t sr[256]; @@ -194,6 +193,8 @@ void vga_common_reset(VGACommonState *s); void vga_dirty_log_start(VGACommonState *s); +void vga_common_save(QEMUFile *f, void *opaque); +int vga_common_load(QEMUFile *f, void *opaque, int version_id); uint32_t vga_ioport_read(void *opaque, uint32_t addr); void vga_ioport_write(void *opaque, uint32_t addr, uint32_t val); uint32_t vga_mem_readb(void *opaque, target_phys_addr_t addr); diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index c6bce5a..a273f35 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -1131,6 +1131,7 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) #ifdef EMBED_STDVGA vga_common_init(&s->vga, vga_ram_size); vga_init(&s->vga); + register_savevm("vga", 0, 2, vga_common_save, vga_common_load, &s->vga); #else s->vram_size = vga_ram_size; s->vram_offset = qemu_ram_alloc(vga_ram_size);