summary refs log tree commit diff stats
path: root/hw/vga.c
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2012-05-24 09:59:44 +0200
committerGerd Hoffmann <kraxel@redhat.com>2012-06-22 10:46:12 +0200
commit4a1e244eb65c646bdd938d9d137ace42d76c95a7 (patch)
tree312ebcb456904968061be48cecbee7b5197e26f3 /hw/vga.c
parente9c6149f6ae6873f14a12eea554925b6aa4c4dec (diff)
downloadfocaccia-qemu-4a1e244eb65c646bdd938d9d137ace42d76c95a7.tar.gz
focaccia-qemu-4a1e244eb65c646bdd938d9d137ace42d76c95a7.zip
vga: make vram size configurable
Zap the global VGA_RAM_SIZE #define, make the vga ram size configurable
for standard vga and vmware vga.  cirrus and qxl are left with a fixed
size (and private VGA_RAM_SIZE #define) for now.

qxl needs some non-trivial adjustments in the mode list handling deal
with a runtime-configurable size, which calls for a separate qxl patch.

cirrus emulates cards which have 2 MB (isa) and 4 MB (pci), so I guess
it would make sense to use these sizes.  That change would break
migration though, so I left it fixed at 8 MB size.  Making it
configurabls is pretty pointless for cirrus as we have to match real
hardware.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw/vga.c')
-rw-r--r--hw/vga.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/hw/vga.c b/hw/vga.c
index d784df7df4..acb3f7d924 100644
--- a/hw/vga.c
+++ b/hw/vga.c
@@ -2225,7 +2225,7 @@ const VMStateDescription vmstate_vga_common = {
     }
 };
 
-void vga_common_init(VGACommonState *s, int vga_ram_size)
+void vga_common_init(VGACommonState *s)
 {
     int i, j, v, b;
 
@@ -2252,16 +2252,23 @@ void vga_common_init(VGACommonState *s, int vga_ram_size)
         expand4to8[i] = v;
     }
 
+    /* valid range: 1 MB -> 256 MB */
+    s->vram_size = 1024 * 1024;
+    while (s->vram_size < (s->vram_size_mb << 20) &&
+           s->vram_size < (256 << 20)) {
+        s->vram_size <<= 1;
+    }
+    s->vram_size_mb = s->vram_size >> 20;
+
 #ifdef CONFIG_BOCHS_VBE
     s->is_vbe_vmstate = 1;
 #else
     s->is_vbe_vmstate = 0;
 #endif
-    memory_region_init_ram(&s->vram, "vga.vram", vga_ram_size);
+    memory_region_init_ram(&s->vram, "vga.vram", s->vram_size);
     vmstate_register_ram_global(&s->vram);
     xen_register_framebuffer(&s->vram);
     s->vram_ptr = memory_region_get_ram_ptr(&s->vram);
-    s->vram_size = vga_ram_size;
     s->get_bpp = vga_get_bpp;
     s->get_offsets = vga_get_offsets;
     s->get_resolution = vga_get_resolution;