WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH 4 of 4] ioemu: stdvga improvements

To: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 4 of 4] ioemu: stdvga improvements
From: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
Date: Tue, 13 Jan 2009 12:17:59 +0000
Delivery-date: Tue, 13 Jan 2009 04:26:26 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Thunderbird 2.0.0.14 (X11/20080505)
This patch is the "stdvga improvements" patch to qemu-xen-unstable with
the due changes for the new videoram allocation system.

Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>


diff --git a/hw/cirrus_vga.c b/hw/cirrus_vga.c
index 2af2cc9..d6a9235 100644
--- a/hw/cirrus_vga.c
+++ b/hw/cirrus_vga.c
@@ -291,8 +291,6 @@ typedef struct CirrusVGAState {
     int last_hw_cursor_y_end;
     int real_vram_size; /* XXX: suppress that */
     CPUWriteMemoryFunc **cirrus_linear_write;
-    uint32_t map_addr;
-    uint32_t map_end;
 } CirrusVGAState;
 
 typedef struct PCICirrusVGAState {
@@ -2642,52 +2640,9 @@ static CPUWriteMemoryFunc *cirrus_linear_bitblt_write[3] 
= {
 };
 
 
-static void set_vram_mapping(CirrusVGAState *s, unsigned long begin, unsigned 
long end)
-{
-    unsigned long i;
-    struct xen_add_to_physmap xatp;
-    int rc;
-
-    if (end > begin + VGA_RAM_SIZE)
-        end = begin + VGA_RAM_SIZE;
-
-    fprintf(logfile,"mapping vram to %lx - %lx\n", begin, end);
-
-    xatp.domid = domid;
-    xatp.space = XENMAPSPACE_gmfn;
-
-    for (i = 0; i < (end - begin) >> TARGET_PAGE_BITS; i++) {
-        xatp.idx = (s->vram_gmfn >> TARGET_PAGE_BITS) + i;
-        xatp.gpfn = (begin >> TARGET_PAGE_BITS) + i;
-        rc = xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp);
-        if (rc) {
-            fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN 
%"PRI_xen_pfn" failed: %d\n", xatp.idx, xatp.gpfn, rc);
-            return;
-        }
-    }
-
-    (void)xc_domain_pin_memory_cacheattr(
-        xc_handle, domid,
-        begin >> TARGET_PAGE_BITS,
-        end >> TARGET_PAGE_BITS,
-        XEN_DOMCTL_MEM_CACHEATTR_WB);
-
-    s->vram_gmfn = begin;
-}
-
-static void unset_vram_mapping(CirrusVGAState *s, unsigned long begin, 
unsigned long end)
-{
-    if (s->vram_gmfn) {
-        /* We can put it there for xend to save it efficiently */
-        set_vram_mapping(s, 0xff000000, 0xff000000 + VGA_RAM_SIZE);
-    }
-}
-
 void cirrus_restart_acc(CirrusVGAState *s)
 {
     set_vram_mapping(s, s->lfb_addr, s->lfb_end);
-    s->map_addr = s->lfb_addr;
-    s->map_end = s->lfb_end;
 }
 
 /* Compute the memory access functions */
@@ -2708,19 +2663,16 @@ static void cirrus_update_memory_access(CirrusVGAState 
*s)
 
        mode = s->gr[0x05] & 0x7;
        if (mode < 4 || mode > 5 || ((s->gr[0x0B] & 0x4) == 0)) {
-            if (s->lfb_addr && s->lfb_end && !s->map_addr) {
+            if (s->lfb_addr && s->lfb_end && s->vram_gmfn != s->lfb_addr) {
                 set_vram_mapping(s, s->lfb_addr, s->lfb_end);
-                s->map_addr = s->lfb_addr;
-                s->map_end = s->lfb_end;
             }
             s->cirrus_linear_write[0] = cirrus_linear_mem_writeb;
             s->cirrus_linear_write[1] = cirrus_linear_mem_writew;
             s->cirrus_linear_write[2] = cirrus_linear_mem_writel;
         } else {
         generic_io:
-            if (s->lfb_addr && s->lfb_end && s->map_addr) {
-                unset_vram_mapping(s, s->map_addr, s->map_end);
-                s->map_addr = s->map_end = 0;
+            if (s->lfb_addr && s->lfb_end && s->vram_gmfn != s->lfb_addr) {
+                unset_vram_mapping(s);
             }
             s->cirrus_linear_write[0] = cirrus_linear_writeb;
             s->cirrus_linear_write[1] = cirrus_linear_writew;
@@ -3135,7 +3087,7 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque)
     /* XXX: we do not save the bitblt state - we assume we do not save
        the state when the blitter is active */
 
-    vga_acc = (!!s->map_addr);
+    vga_acc = (s->lfb_addr == s->vram_gmfn);
     qemu_put_8s(f, &vga_acc);
     /* XXX old versions saved rubbish here, keeping for compatibility */
     qemu_put_be32(f, 0xffffffff);
@@ -3146,7 +3098,7 @@ static void cirrus_vga_save(QEMUFile *f, void *opaque)
     qemu_put_be64s(f, &s->vram_gmfn);
     if (!s->vram_gmfn && !vga_acc)
         /* Old guest: VRAM is not mapped, we have to save it ourselves */
-        qemu_put_buffer(f, s->vram_ptr, VGA_RAM_SIZE);
+        qemu_put_buffer(f, s->vram_ptr, s->vram_size);
 }
 
 static int cirrus_vga_load(QEMUFile *f, void *opaque, int version_id)
@@ -3214,15 +3166,11 @@ static int cirrus_vga_load(QEMUFile *f, void *opaque, 
int version_id)
         /* Old guest, VRAM is not mapped, we have to restore it
          * ourselves */
         s->vram_gmfn = vga_acc ? s->lfb_addr : 0xff000000;
-        xen_vga_populate_vram(s->vram_gmfn);
+        xen_vga_populate_vram(s->vram_gmfn, s->vram_size);
     }
-    xen_vga_vram_map(s->vram_gmfn);
+    xen_vga_vram_map(s->vram_gmfn, s->vram_size);
     if (version_id < 3 || (!vga_acc && !t))
-        qemu_get_buffer(f, s->vram_ptr, VGA_RAM_SIZE);
-    if (vga_acc) {
-        s->map_addr = s->lfb_addr;
-        s->map_end = s->lfb_end;
-    }
+        qemu_get_buffer(f, s->vram_ptr, s->vram_size);
 
     /* force refresh */
     s->graphic_mode = -1;
@@ -3355,6 +3303,11 @@ void isa_cirrus_vga_init(DisplayState *ds, uint8_t 
*vga_ram_base,
 
     s = qemu_mallocz(sizeof(CirrusVGAState));
 
+    if (vga_ram_size != 4*1024*1024) {
+        fprintf(stderr, "The -videoram option does not work with the cirrus 
vga model. Video ram set to 4M. \n");
+        vga_ram_size = 4*1024*1024;
+    }
+
     vga_common_init((VGAState *)s,
                     ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     cirrus_init_common(s, CIRRUS_ID_CLGD5430, 0);
@@ -3376,10 +3329,9 @@ static void cirrus_pci_lfb_map(PCIDevice *d, int 
region_num,
     cpu_register_physical_memory(addr, s->vram_size,
                                 s->cirrus_linear_io_addr);
     s->lfb_addr = addr;
-    s->lfb_end = addr + VGA_RAM_SIZE;
+    s->lfb_end = addr + s->vram_size;
 
-    if (s->map_addr && (s->lfb_addr != s->map_addr) &&
-        (s->lfb_end != s->map_end))
+    if (s->lfb_addr != s->vram_gmfn)
         fprintf(logfile, "cirrus vga map change while on lfb mode\n");
 
     cpu_register_physical_memory(addr + 0x1000000, 0x400000,
@@ -3425,6 +3377,10 @@ void pci_cirrus_vga_init(PCIBus *bus, DisplayState *ds, 
uint8_t *vga_ram_base,
 
     /* setup VGA */
     s = &d->cirrus_vga;
+    if (vga_ram_size != 4*1024*1024) {
+        fprintf(stderr, "The -videoram option does not work with the cirrus 
vga model. Video ram set to 4M. \n");
+        vga_ram_size = 4*1024*1024;
+    }
     vga_common_init((VGAState *)s,
                     ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     cirrus_init_common(s, device_id, 1);
diff --git a/hw/mips_mipssim.c b/hw/mips_mipssim.c
index bd5266a..4c636db 100644
--- a/hw/mips_mipssim.c
+++ b/hw/mips_mipssim.c
@@ -194,7 +194,7 @@ QEMUMachine mips_mipssim_machine = {
     .name = "mipssim",
     .desc = "MIPS MIPSsim platform",
     .init = mips_mipssim_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE /* unused */,
+    .ram_require = BIOS_SIZE /* unused */,
     .nodisk_ok = 1,
     .max_cpus = 1,
 };
diff --git a/hw/mips_r4k.c b/hw/mips_r4k.c
index 399f452..670a1ea 100644
--- a/hw/mips_r4k.c
+++ b/hw/mips_r4k.c
@@ -285,7 +285,7 @@ QEMUMachine mips_machine = {
     .name = "mips",
     .desc = "mips r4k platform",
     .init = mips_r4k_init,
-    .ram_require = VGA_RAM_SIZE + BIOS_SIZE,
+    .ram_require = BIOS_SIZE,
     .nodisk_ok = 1,
     .max_cpus = 1,
 };
diff --git a/hw/pc.c b/hw/pc.c
index a31e4ba..f0492c8 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -1186,7 +1186,7 @@ QEMUMachine pc_machine = {
     .name = "pc",
     .desc = "Standard PC",
     .init = pc_init_pci,
-    .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .ram_require = PC_MAX_BIOS_SIZE,
     .max_cpus = 255,
 };
 
@@ -1194,7 +1194,7 @@ QEMUMachine isapc_machine = {
     .name = "isapc",
     .desc = "ISA-only PC",
     .init = pc_init_isa,
-    .ram_require = VGA_RAM_SIZE + PC_MAX_BIOS_SIZE,
+    .ram_require = PC_MAX_BIOS_SIZE,
     .max_cpus = 1,
 };
 
diff --git a/hw/pc.h b/hw/pc.h
index 455306d..a600000 100644
--- a/hw/pc.h
+++ b/hw/pc.h
@@ -119,12 +119,6 @@ enum vga_retrace_method {
 
 extern enum vga_retrace_method vga_retrace_method;
 
-#ifndef TARGET_SPARC
-#define VGA_RAM_SIZE (8192 * 1024)
-#else
-#define VGA_RAM_SIZE (9 * 1024 * 1024)
-#endif
-
 int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
                  unsigned long vga_ram_offset, int vga_ram_size);
 int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t *vga_ram_base,
diff --git a/hw/ppc_chrp.c b/hw/ppc_chrp.c
index ede2924..da2a0fa 100644
--- a/hw/ppc_chrp.c
+++ b/hw/ppc_chrp.c
@@ -334,6 +334,6 @@ QEMUMachine core99_machine = {
     .name = "mac99",
     .desc = "Mac99 based PowerMAC",
     .init = ppc_core99_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = 1,
 };
diff --git a/hw/ppc_oldworld.c b/hw/ppc_oldworld.c
index 75faeb3..510dd6e 100644
--- a/hw/ppc_oldworld.c
+++ b/hw/ppc_oldworld.c
@@ -369,6 +369,6 @@ QEMUMachine heathrow_machine = {
     .name = "g3bw",
     .desc = "Heathrow based PowerMAC",
     .init = ppc_heathrow_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = 1,
 };
diff --git a/hw/ppc_prep.c b/hw/ppc_prep.c
index 944935d..1e5b3b0 100644
--- a/hw/ppc_prep.c
+++ b/hw/ppc_prep.c
@@ -761,6 +761,6 @@ QEMUMachine prep_machine = {
     .name = "prep",
     .desc = "PowerPC PREP platform",
     .init = ppc_prep_init,
-    .ram_require = BIOS_SIZE + VGA_RAM_SIZE,
+    .ram_require = BIOS_SIZE,
     .max_cpus = 1,
 };
diff --git a/hw/sun4u.c b/hw/sun4u.c
index a70ad20..216629f 100644
--- a/hw/sun4u.c
+++ b/hw/sun4u.c
@@ -587,7 +587,7 @@ QEMUMachine sun4u_machine = {
     .name = "sun4u",
     .desc = "Sun4u platform",
     .init = sun4u_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 16,
 };
@@ -596,7 +596,7 @@ QEMUMachine sun4v_machine = {
     .name = "sun4v",
     .desc = "Sun4v platform",
     .init = sun4v_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 16,
 };
@@ -605,7 +605,7 @@ QEMUMachine niagara_machine = {
     .name = "Niagara",
     .desc = "Sun4v platform, Niagara",
     .init = niagara_init,
-    .ram_require = PROM_SIZE_MAX + VGA_RAM_SIZE,
+    .ram_require = PROM_SIZE_MAX,
     .nodisk_ok = 1,
     .max_cpus = 16,
 };
diff --git a/hw/vga.c b/hw/vga.c
index e1d6dad..6c47b26 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -40,6 +40,11 @@
 
 //#define DEBUG_BOCHS_VBE
 
+// PCI 0x04: command(word), 0x06(word): status
+#define PCI_COMMAND_IOACCESS                0x0001
+#define PCI_COMMAND_MEMACCESS               0x0002
+#define PCI_COMMAND_BUSMASTER               0x0004
+
 /* force some bits to zero */
 const uint8_t sr_mask[8] = {
     (uint8_t)~0xfc,
@@ -612,6 +617,10 @@ static void vbe_ioport_write_data(void *opaque, uint32_t 
addr, uint32_t val)
             if ((val & VBE_DISPI_ENABLED) &&
                 !(s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_ENABLED)) {
                 int h, shift_control;
+                
+                if (s->vram_gmfn != s->lfb_addr) {
+                     set_vram_mapping(s, s->lfb_addr, s->lfb_end);
+                }
 
                 s->vbe_regs[VBE_DISPI_INDEX_VIRT_WIDTH] =
                     s->vbe_regs[VBE_DISPI_INDEX_XRES];
@@ -2078,6 +2087,49 @@ static CPUWriteMemoryFunc *vga_mem_write[3] = {
     vga_mem_writel,
 };
 
+void set_vram_mapping(void *opaque, unsigned long begin, unsigned long end)
+{
+    unsigned long i;
+    struct xen_add_to_physmap xatp;
+    int rc;
+    VGAState *s = (VGAState *) opaque;
+
+    if (end > begin + s->vram_size)
+        end = begin + s->vram_size;
+
+    fprintf(logfile,"mapping vram to %lx - %lx\n", begin, end);
+
+    xatp.domid = domid;
+    xatp.space = XENMAPSPACE_gmfn;
+
+    for (i = 0; i < (end - begin) >> TARGET_PAGE_BITS; i++) {
+        xatp.idx = (s->vram_gmfn >> TARGET_PAGE_BITS) + i;
+        xatp.gpfn = (begin >> TARGET_PAGE_BITS) + i;
+        rc = xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp);
+        if (rc) {
+            fprintf(stderr, "add_to_physmap MFN %"PRI_xen_pfn" to PFN 
%"PRI_xen_pfn" failed: %d\n", xatp.idx, xatp.gpfn, rc);
+            return;
+        }
+    }
+
+    (void)xc_domain_pin_memory_cacheattr(
+        xc_handle, domid,
+        begin >> TARGET_PAGE_BITS,
+        end >> TARGET_PAGE_BITS,
+        XEN_DOMCTL_MEM_CACHEATTR_WB);
+
+    s->vram_gmfn = begin;
+}
+
+void unset_vram_mapping(void *opaque)
+{
+    VGAState *s = (VGAState *) opaque;
+    if (s->vram_gmfn) {
+        /* We can put it there for xend to save it efficiently */
+        set_vram_mapping(s, 0xff000000, 0xff000000 + s->vram_size);
+    }
+}
+
 static void vga_save(QEMUFile *f, void *opaque)
 {
     VGAState *s = opaque;
@@ -2128,7 +2180,7 @@ static void vga_save(QEMUFile *f, void *opaque)
     qemu_put_be64s(f, &s->vram_gmfn);
     if (!s->vram_gmfn)
         /* Old guest: VRAM is not mapped, we have to save it ourselves */
-        qemu_put_buffer(f, s->vram_ptr, VGA_RAM_SIZE);
+        qemu_put_buffer(f, s->vram_ptr, vram_size);
 }
 
 static int vga_load(QEMUFile *f, void *opaque, int version_id)
@@ -2194,12 +2246,12 @@ static int vga_load(QEMUFile *f, void *opaque, int 
version_id)
         if (version_id >= 4) {
             qemu_get_be64s(f, &s->vram_gmfn);
             if (s->vram_gmfn)
-                xen_vga_vram_map(s->vram_gmfn);
+                xen_vga_vram_map(s->vram_gmfn, s->vram_size);
         }
         /* Old guest, VRAM is not mapped, we have to restore it ourselves */
         if (!s->vram_gmfn) {
-            xen_vga_populate_vram(0xff000000);
-            xen_vga_vram_map(0xff000000);
+            xen_vga_populate_vram(0xff000000, s->vram_size);
+            xen_vga_vram_map(0xff000000, s->vram_size);
             s->vram_gmfn = 0xff000000;
             qemu_get_buffer(f, s->vram_ptr, s->vram_size); 
         }
@@ -2224,6 +2276,18 @@ static void vga_map(PCIDevice *pci_dev, int region_num,
         cpu_register_physical_memory(addr, s->bios_size, s->bios_offset);
     } else {
         cpu_register_physical_memory(addr, s->vram_size, s->vram_offset);
+        s->lfb_addr = addr;
+        s->lfb_end = addr + size;
+#ifdef CONFIG_BOCHS_VBE
+        s->vbe_regs[VBE_DISPI_INDEX_LFB_ADDRESS_H] = s->lfb_addr >> 16;
+        s->vbe_regs[VBE_DISPI_INDEX_LFB_ADDRESS_L] = s->lfb_addr & 0xFFFF;
+        s->vbe_regs[VBE_DISPI_INDEX_VIDEO_MEMORY_64K] = s->vram_size >> 16;
+#endif
+   
+        fprintf(stderr, "vga s->lfb_addr = %lx s->lfb_end = %lx \n", (unsigned 
long) s->lfb_addr,(unsigned long) s->lfb_end);
+
+        if (size != s->vram_size)
+            fprintf(stderr, "vga map with size %x != %x\n", size, 
s->vram_size);
     }
 }
 
@@ -2361,7 +2425,7 @@ void vga_bios_init(VGAState *s)
 static VGAState *xen_vga_state;
 
 /* Allocate video memory in the GPFN space */
-void xen_vga_populate_vram(uint64_t vram_addr)
+void xen_vga_populate_vram(uint64_t vram_addr, uint32_t vga_ram_size)
 {
     unsigned long nr_pfn;
     struct xen_remove_from_physmap xrfp;
@@ -2372,7 +2436,7 @@ void xen_vga_populate_vram(uint64_t vram_addr)
     fprintf(logfile, "populating video RAM at %llx\n",
            (unsigned long long)vram_addr);
 
-    nr_pfn = VGA_RAM_SIZE >> TARGET_PAGE_BITS;
+    nr_pfn = vga_ram_size >> TARGET_PAGE_BITS;
 
     pfn_list = malloc(sizeof(*pfn_list) * nr_pfn);
 
@@ -2387,7 +2451,7 @@ void xen_vga_populate_vram(uint64_t vram_addr)
 }
 
 /* Mapping the video memory from GPFN space  */
-void xen_vga_vram_map(uint64_t vram_addr)
+void xen_vga_vram_map(uint64_t vram_addr, uint32_t vga_ram_size)
 {
     unsigned long nr_pfn;
     xen_pfn_t *pfn_list;
@@ -2398,7 +2462,7 @@ void xen_vga_vram_map(uint64_t vram_addr)
     fprintf(logfile, "mapping video RAM from %llx\n",
            (unsigned long long)vram_addr);
 
-    nr_pfn = VGA_RAM_SIZE >> TARGET_PAGE_BITS;
+    nr_pfn = vga_ram_size >> TARGET_PAGE_BITS;
 
     pfn_list = malloc(sizeof(*pfn_list) * nr_pfn);
 
@@ -2462,8 +2526,8 @@ void vga_common_init(VGAState *s, DisplayState *ds, 
uint8_t *vga_ram_base,
     s->get_resolution = vga_get_resolution;
 
     if (!restore) {
-        xen_vga_populate_vram(0xff000000);
-        xen_vga_vram_map(0xff000000);
+        xen_vga_populate_vram(0xff000000, s->vram_size);
+        xen_vga_vram_map(0xff000000, s->vram_size);
         s->vram_gmfn = 0xff000000;
     }
 
@@ -2545,6 +2609,11 @@ int isa_vga_init(DisplayState *ds, uint8_t *vga_ram_base,
     s = qemu_mallocz(sizeof(VGAState));
     if (!s)
         return -1;
+    
+    if (vga_ram_size > 16*1024*1024) {
+        fprintf (stderr, "The stdvga/VBE device model has no use for more than 
16 Megs of vram. Video ram set to 16M. \n");
+        vga_ram_size = 16*1024*1024;
+    }
 
     vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     vga_init(s);
@@ -2572,6 +2641,11 @@ int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t 
*vga_ram_base,
         return -1;
     s = &d->vga_state;
 
+    if (vga_ram_size > 16*1024*1024) {
+        fprintf (stderr, "The stdvga/VBE device model has no use for more than 
16 Megs of vram. Video ram set to 16M. \n");
+        vga_ram_size = 16*1024*1024;
+    }
+
     vga_common_init(s, ds, vga_ram_base, vga_ram_offset, vga_ram_size);
     vga_init(s);
     s->pci_dev = &d->dev;
@@ -2581,9 +2655,14 @@ int pci_vga_init(PCIBus *bus, DisplayState *ds, uint8_t 
*vga_ram_base,
     pci_conf[0x01] = 0x12;
     pci_conf[0x02] = 0x11;
     pci_conf[0x03] = 0x11;
+    pci_conf[0x04] = PCI_COMMAND_IOACCESS | PCI_COMMAND_MEMACCESS /* | 
PCI_COMMAND_BUSMASTER */;
     pci_conf[0x0a] = 0x00; // VGA controller
     pci_conf[0x0b] = 0x03;
     pci_conf[0x0e] = 0x00; // header_type
+    pci_conf[0x2c] = 0x53; /* subsystem vendor: XenSource */
+    pci_conf[0x2d] = 0x58;
+    pci_conf[0x2e] = 0x01; /* subsystem device */
+    pci_conf[0x2f] = 0x00;
 
     /* XXX: vga_ram_size must be a power of two */
     pci_register_io_region(&d->dev, 0, vga_ram_size,
diff --git a/hw/vga_int.h b/hw/vga_int.h
index bd147e5..54a1f7e 100644
--- a/hw/vga_int.h
+++ b/hw/vga_int.h
@@ -28,38 +28,41 @@
 #define ST01_DISP_ENABLE    0x01
 
 /* bochs VBE support */
-//#define CONFIG_BOCHS_VBE
-
-#define VBE_DISPI_MAX_XRES              1600
-#define VBE_DISPI_MAX_YRES              1200
-#define VBE_DISPI_MAX_BPP               32
-
-#define VBE_DISPI_INDEX_ID              0x0
-#define VBE_DISPI_INDEX_XRES            0x1
-#define VBE_DISPI_INDEX_YRES            0x2
-#define VBE_DISPI_INDEX_BPP             0x3
-#define VBE_DISPI_INDEX_ENABLE          0x4
-#define VBE_DISPI_INDEX_BANK            0x5
-#define VBE_DISPI_INDEX_VIRT_WIDTH      0x6
-#define VBE_DISPI_INDEX_VIRT_HEIGHT     0x7
-#define VBE_DISPI_INDEX_X_OFFSET        0x8
-#define VBE_DISPI_INDEX_Y_OFFSET        0x9
-#define VBE_DISPI_INDEX_NB              0xa
-
-#define VBE_DISPI_ID0                   0xB0C0
-#define VBE_DISPI_ID1                   0xB0C1
-#define VBE_DISPI_ID2                   0xB0C2
-#define VBE_DISPI_ID3                   0xB0C3
-#define VBE_DISPI_ID4                   0xB0C4
-
-#define VBE_DISPI_DISABLED              0x00
-#define VBE_DISPI_ENABLED               0x01
-#define VBE_DISPI_GETCAPS               0x02
-#define VBE_DISPI_8BIT_DAC              0x20
-#define VBE_DISPI_LFB_ENABLED           0x40
-#define VBE_DISPI_NOCLEARMEM            0x80
-
-#define VBE_DISPI_LFB_PHYSICAL_ADDRESS  0xE0000000
+#define CONFIG_BOCHS_VBE
+
+#define VBE_DISPI_MAX_XRES               2560
+#define VBE_DISPI_MAX_YRES               1600
+#define VBE_DISPI_MAX_BPP                32
+
+#define VBE_DISPI_INDEX_ID               0x0
+#define VBE_DISPI_INDEX_XRES             0x1
+#define VBE_DISPI_INDEX_YRES             0x2
+#define VBE_DISPI_INDEX_BPP              0x3
+#define VBE_DISPI_INDEX_ENABLE           0x4
+#define VBE_DISPI_INDEX_BANK             0x5
+#define VBE_DISPI_INDEX_VIRT_WIDTH       0x6
+#define VBE_DISPI_INDEX_VIRT_HEIGHT      0x7
+#define VBE_DISPI_INDEX_X_OFFSET         0x8
+#define VBE_DISPI_INDEX_Y_OFFSET         0x9
+#define VBE_DISPI_INDEX_VIDEO_MEMORY_64K 0xa
+#define VBE_DISPI_INDEX_LFB_ADDRESS_H    0xb
+#define VBE_DISPI_INDEX_LFB_ADDRESS_L    0xc
+#define VBE_DISPI_INDEX_NB               0xd
+
+#define VBE_DISPI_ID0                    0xB0C0
+#define VBE_DISPI_ID1                    0xB0C1
+#define VBE_DISPI_ID2                    0xB0C2
+#define VBE_DISPI_ID3                    0xB0C3
+#define VBE_DISPI_ID4                    0xB0C4
+
+#define VBE_DISPI_DISABLED               0x00
+#define VBE_DISPI_ENABLED                0x01
+#define VBE_DISPI_GETCAPS                0x02
+#define VBE_DISPI_8BIT_DAC               0x20
+#define VBE_DISPI_LFB_ENABLED            0x40
+#define VBE_DISPI_NOCLEARMEM             0x80
+
+#define VBE_DISPI_LFB_PHYSICAL_ADDRESS   0xF1000000
 
 #ifdef CONFIG_BOCHS_VBE
 
diff --git a/hw/xen_machine_fv.c b/hw/xen_machine_fv.c
index b85388e..976e7e7 100644
--- a/hw/xen_machine_fv.c
+++ b/hw/xen_machine_fv.c
@@ -288,7 +288,7 @@ QEMUMachine xenfv_machine = {
     "xenfv",
     "Xen Fully-virtualized PC",
     xen_init_fv,
-    (VGA_RAM_SIZE + BIOS_SIZE) | RAMSIZE_FIXED,
+    BIOS_SIZE | RAMSIZE_FIXED,
     .max_cpus = 1,
 };
 
diff --git a/hw/xen_machine_pv.c b/hw/xen_machine_pv.c
index 9c4e33d..2255247 100644
--- a/hw/xen_machine_pv.c
+++ b/hw/xen_machine_pv.c
@@ -77,7 +77,7 @@ QEMUMachine xenpv_machine = {
     "xenpv",
     "Xen Para-virtualized PC",
     xen_init_pv,
-    (VGA_RAM_SIZE + BIOS_SIZE) | RAMSIZE_FIXED,
+    BIOS_SIZE | RAMSIZE_FIXED,
     .max_cpus = 1,
 };
 
diff --git a/qemu-xen.h b/qemu-xen.h
index 120d5d7..ed6a31e 100644
--- a/qemu-xen.h
+++ b/qemu-xen.h
@@ -3,6 +3,7 @@
 
 /* vl.c */
 extern int restore;
+extern int vga_ram_size;
 
 /* xen_machine_fv.c */
 
@@ -24,8 +25,10 @@ void timeoffset_get(void);
 /* xen_platform.c */
 #ifndef QEMU_TOOL
 void pci_xen_platform_init(PCIBus *bus);
-void xen_vga_populate_vram(uint64_t vram_addr);
-void xen_vga_vram_map(uint64_t vram_addr);
+void xen_vga_populate_vram(uint64_t vram_addr, uint32_t size);
+void xen_vga_vram_map(uint64_t vram_addr, uint32_t size);
+void set_vram_mapping(void *opaque, unsigned long begin, unsigned long end);
+void unset_vram_mapping(void *opaque);
 #endif
 
 void ide_unplug_harddisks(void);
diff --git a/vl.c b/vl.c
index e60a9cb..a2ad37d 100644
--- a/vl.c
+++ b/vl.c
@@ -190,7 +190,6 @@ DriveInfo drives_table[MAX_DRIVES+1];
 int nb_drives;
 /* point to the block driver where the snapshots are managed */
 static BlockDriverState *bs_snapshots;
-static int vga_ram_size;
 enum vga_retrace_method vga_retrace_method = VGA_RETRACE_DUMB;
 static DisplayState display_state;
 int nographic;
@@ -205,7 +204,9 @@ static int rtc_utc = 1;
 static int rtc_date_offset = -1; /* -1 means no change */
 int cirrus_vga_enabled = 1;
 int vmsvga_enabled = 0;
+int vga_ram_size = 4 * 1024 * 1024;
 #ifdef TARGET_SPARC
+vga_ram_size += 1024 * 1024;
 int graphic_width = 1024;
 int graphic_height = 768;
 int graphic_depth = 8;
@@ -8455,6 +8456,7 @@ static void help(int exitcode)
 #ifdef TARGET_I386
            "-std-vga        simulate a standard VGA card with VESA Bochs 
Extensions\n"
            "                (default is CL-GD5446 PCI VGA)\n"
+           "-videoram       set amount of memory available to virtual video 
adapter\n"
            "-no-acpi        disable ACPI\n"
 #endif
 #ifdef CONFIG_CURSES
@@ -8549,6 +8551,7 @@ enum {
     QEMU_OPTION_g,
     QEMU_OPTION_vga,
     QEMU_OPTION_std_vga,
+    QEMU_OPTION_videoram,
     QEMU_OPTION_echr,
     QEMU_OPTION_monitor,
     QEMU_OPTION_domainname,
@@ -8661,6 +8664,7 @@ static const QEMUOption qemu_options[] = {
 #endif
     { "localtime", 0, QEMU_OPTION_localtime },
     { "std-vga", 0, QEMU_OPTION_std_vga },
+    { "videoram", HAS_ARG, QEMU_OPTION_videoram },
     { "vga", HAS_ARG, QEMU_OPTION_vga },
     { "echr", HAS_ARG, QEMU_OPTION_echr },
     { "monitor", HAS_ARG, QEMU_OPTION_monitor },
@@ -9080,7 +9084,6 @@ int main(int argc, char **argv)
     cpu_model = NULL;
     initrd_filename = NULL;
     ram_size = 0;
-    vga_ram_size = VGA_RAM_SIZE;
 #ifdef CONFIG_GDBSTUB
     use_gdbstub = 0;
     gdbstub_port = DEFAULT_GDBSTUB_PORT;
@@ -9447,6 +9450,16 @@ int main(int argc, char **argv)
             case QEMU_OPTION_vga:
                 select_vgahw (optarg);
                 break;
+            case QEMU_OPTION_videoram:
+                {
+                    char *ptr;
+                    vga_ram_size = strtol(optarg,&ptr,10);
+                    vga_ram_size *= 1024 * 1024;
+#ifdef TARGET_SPARC
+                    vga_ram_size += (1024 * 1024);
+#endif
+                }
+                break;
             case QEMU_OPTION_g:
                 {
                     const char *p;
@@ -9872,7 +9885,15 @@ int main(int argc, char **argv)
 #endif
 
     /* init the memory */
-    phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED;
+
+    /* If we're on cirrus, set vga_ram_size to 4M whatever the videoram option 
might have set it to */
+    if ( cirrus_vga_enabled && vga_ram_size != 4 * 1024 * 1024 )
+    {
+       fprintf(stderr,"-videoram option does not work with cirrus vga device 
model. Videoram set to 4M.\n");
+       vga_ram_size = 4 * 1024 * 1024;
+    }
+
+    phys_ram_size = (machine->ram_require + vga_ram_size) & ~RAMSIZE_FIXED;
 
     if (machine->ram_require & RAMSIZE_FIXED) {
         if (ram_size > 0) {
diff --git a/xenfbfront.c b/xenfbfront.c
index 3a67ada..69fa494 100644
--- a/xenfbfront.c
+++ b/xenfbfront.c
@@ -24,6 +24,8 @@ static char *kbd_path, *fb_path;
 
 static unsigned char linux2scancode[KEY_MAX + 1];
 
+extern uint32_t vga_ram_size;
+
 int xenfb_connect_vkbd(const char *path)
 {
     kbd_path = strdup(path);
@@ -74,7 +76,7 @@ static void xenfb_pv_resize_shared(DisplayState *ds, int w, 
int h, int depth, in
         fbfront_resize(fb_dev, ds->width, ds->height, ds->linesize, ds->depth, 
offset);
     } else {
         ds->data = xs->nonshared_vram;
-        fbfront_resize(fb_dev, w, h, linesize, ds->depth, VGA_RAM_SIZE);
+        fbfront_resize(fb_dev, w, h, linesize, ds->depth, vga_ram_size);
     }
 }
 
@@ -248,8 +250,8 @@ int xenfb_pv_display_init(DisplayState *ds)
 
     create_thread("kbdfront", kbdfront_thread, (void*) xs);
 
-    ds->data = xs->nonshared_vram = qemu_memalign(PAGE_SIZE, VGA_RAM_SIZE);
-    memset(ds->data, 0, VGA_RAM_SIZE);
+    ds->data = xs->nonshared_vram = qemu_memalign(PAGE_SIZE, vga_ram_size);
+    memset(ds->data, 0, vga_ram_size);
     ds->opaque = xs;
     ds->depth = 32;
     ds->bgr = 0;
@@ -271,7 +273,7 @@ int xenfb_pv_display_start(void *data)
     int kbd_fd, fb_fd;
     int offset = 0;
     unsigned long *mfns;
-    int n = VGA_RAM_SIZE / PAGE_SIZE;
+    int n = vga_ram_size / PAGE_SIZE;
     int i;
 
     if (!fb_path || !kbd_path)
@@ -296,7 +298,7 @@ int xenfb_pv_display_start(void *data)
     if (ds->shared_buf) {
         offset = (void*) ds->data - xs->vga_vram;
     } else {
-        offset = VGA_RAM_SIZE;
+        offset = vga_ram_size;
         ds->data = xs->nonshared_vram;
     }
     if (offset)

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 4 of 4] ioemu: stdvga improvements, Stefano Stabellini <=