From patchwork Thu Dec 17 22:08:06 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Airlie X-Patchwork-Id: 41348 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 27EA7B6EEF for ; Fri, 18 Dec 2009 09:15:03 +1100 (EST) Received: from localhost ([127.0.0.1]:42427 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLOce-0004Dy-6T for incoming@patchwork.ozlabs.org; Thu, 17 Dec 2009 17:15:00 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NLOYS-0001hP-T0 for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:41 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NLOYM-0001cs-UU for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:39 -0500 Received: from [199.232.76.173] (port=36355 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NLOYM-0001co-Sh for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:34 -0500 Received: from mx1.redhat.com ([209.132.183.28]:11989) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NLOYM-0003l4-8N for qemu-devel@nongnu.org; Thu, 17 Dec 2009 17:10:34 -0500 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id nBHMAXX3015983 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 17 Dec 2009 17:10:33 -0500 Received: from localhost.localdomain (dhcp-0-222.bne.redhat.com [10.64.0.222]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id nBHMAUQB005737 for ; Thu, 17 Dec 2009 17:10:32 -0500 From: Dave Airlie To: qemu-devel@nongnu.org Date: Fri, 18 Dec 2009 08:08:06 +1000 Message-Id: <1261087691-8319-2-git-send-email-airlied@gmail.com> In-Reply-To: <1261087691-8319-1-git-send-email-airlied@gmail.com> References: <1261087691-8319-1-git-send-email-airlied@gmail.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [Qemu-devel] [PATCH 1/6] vmware: setup PCI BAR 2 for FIFO as per vmware spec 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 From: Dave Airlie --- hw/vmware_vga.c | 35 ++++++++++++++++++++++++++++++----- 1 files changed, 30 insertions(+), 5 deletions(-) diff --git a/hw/vmware_vga.c b/hw/vmware_vga.c index f3e3749..28bbc3f 100644 --- a/hw/vmware_vga.c +++ b/hw/vmware_vga.c @@ -67,6 +67,11 @@ struct vmsvga_state_s { int syncing; int fb_size; + ram_addr_t fifo_offset; + uint8_t *fifo_ptr; + unsigned int fifo_size; + target_phys_addr_t fifo_base; + union { uint32_t *fifo; struct __attribute__((__packed__)) { @@ -680,7 +685,7 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) return 0x0; case SVGA_REG_VRAM_SIZE: - return s->vga.vram_size - SVGA_FIFO_SIZE; + return s->vga.vram_size; case SVGA_REG_FB_SIZE: return s->fb_size; @@ -701,10 +706,10 @@ static uint32_t vmsvga_value_read(void *opaque, uint32_t address) return caps; case SVGA_REG_MEM_START: - return s->vram_base + s->vga.vram_size - SVGA_FIFO_SIZE; + return s->fifo_base; case SVGA_REG_MEM_SIZE: - return SVGA_FIFO_SIZE; + return s->fifo_size; case SVGA_REG_CONFIG_DONE: return s->config; @@ -790,7 +795,7 @@ static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) case SVGA_REG_CONFIG_DONE: if (value) { - s->fifo = (uint32_t *) &s->vga.vram_ptr[s->vga.vram_size - SVGA_FIFO_SIZE]; + s->fifo = (uint32_t *) s->fifo_ptr; /* Check range and alignment. */ if ((CMD(min) | CMD(max) | CMD(next_cmd) | CMD(stop)) & 3) @@ -1059,7 +1064,7 @@ static int vmsvga_post_load(void *opaque, int version_id) s->invalidated = 1; if (s->config) - s->fifo = (uint32_t *) &s->vga.vram_ptr[s->vga.vram_size - SVGA_FIFO_SIZE]; + s->fifo = (uint32_t *) s->fifo_ptr; return 0; } @@ -1111,6 +1116,10 @@ static void vmsvga_init(struct vmsvga_state_s *s, int vga_ram_size) vmsvga_reset(s); + s->fifo_size = SVGA_FIFO_SIZE; + s->fifo_offset = qemu_ram_alloc(s->fifo_size); + s->fifo_ptr = qemu_get_ram_ptr(s->fifo_offset); + vga_common_init(&s->vga, vga_ram_size); vga_init(&s->vga); vmstate_register(0, &vmstate_vga_common, &s->vga); @@ -1166,6 +1175,19 @@ static void pci_vmsvga_map_mem(PCIDevice *pci_dev, int region_num, iomemtype); } +static void pci_vmsvga_map_fifo(PCIDevice *pci_dev, int region_num, + pcibus_t addr, pcibus_t size, int type) +{ + struct pci_vmsvga_state_s *d = (struct pci_vmsvga_state_s *) pci_dev; + struct vmsvga_state_s *s = &d->chip; + ram_addr_t iomemtype; + + s->fifo_base = addr; + iomemtype = s->fifo_offset | IO_MEM_RAM; + cpu_register_physical_memory(s->fifo_base, s->fifo_size, + iomemtype); +} + static int pci_vmsvga_initfn(PCIDevice *dev) { struct pci_vmsvga_state_s *s = @@ -1189,6 +1211,9 @@ static int pci_vmsvga_initfn(PCIDevice *dev) pci_register_bar(&s->card, 1, VGA_RAM_SIZE, PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_mem); + pci_register_bar(&s->card, 2, SVGA_FIFO_SIZE, + PCI_BASE_ADDRESS_MEM_PREFETCH, pci_vmsvga_map_fifo); + vmsvga_init(&s->chip, VGA_RAM_SIZE); return 0;