From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:41457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJs2j-0003Ag-Cq for qemu-devel@nongnu.org; Fri, 28 Oct 2011 15:24:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RJs2i-00015X-4c for qemu-devel@nongnu.org; Fri, 28 Oct 2011 15:24:41 -0400 Received: from server514d.exghost.com ([72.32.253.69]:3823 helo=server514.appriver.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RJs2h-00015Q-Vh for qemu-devel@nongnu.org; Fri, 28 Oct 2011 15:24:40 -0400 Received: from [72.32.253.65] (HELO FE03.exg4.exghost.com) by server514.appriver.com (CommuniGate Pro SMTP 5.4.1) with ESMTP id 182776701 for qemu-devel@nongnu.org; Fri, 28 Oct 2011 14:24:39 -0500 Message-ID: <4EAB0175.9080507@virtualcomputer.com> Date: Fri, 28 Oct 2011 15:24:37 -0400 From: John Baboval MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 2/2] Variable VRAM size List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org High resolution VGA modes require more than the default 8MB of VGA RAM. Add a command line parameter to allow larger sizes. Signed-off-by: John V. Baboval --- hw/vga.c | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++---- hw/vga_int.h | 4 +++ qemu-options.hx | 3 ++ vl.c | 4 +++ 4 files changed, 70 insertions(+), 5 deletions(-) diff --git a/hw/vga.c b/hw/vga.c index ca79aa1..8003eda 100644 --- a/hw/vga.c +++ b/hw/vga.c @@ -565,23 +565,76 @@ static uint32_t vbe_ioport_read_index(void *opaque, uint32_t addr) return val; } +typedef struct vga_ram_info { + int max_xres; + int max_yres; + int max_bpp; +} vga_ram_info_t; + +static vga_ram_info_t vbe_ram_info(int ramsize) +{ + vga_ram_info_t s; + s.max_bpp = 32; + + switch(ramsize) { + case 8 * 1024 * 1024: + s.max_xres = 1920; + s.max_yres = 1080; + break; + case 16 * 1024 * 1024: + s.max_xres = 2560; + s.max_yres = 1600; + break; + default: + case 32 * 1024 * 1024: + s.max_xres = 2560; + s.max_yres = 2048; + break; + } + return s; +} + +static int vga_ram_sz = VGA_RAM_SIZE; +void set_vga_ram_size(int size) +{ + const char *msg = NULL; + + if (size < 8) + msg = "is too small"; + else if (size > 512) + msg = "is too large"; + else if (size != (size & ~(size - 1))) + msg = "is not a power of 2"; + if (msg) { + fprintf(stderr, "VGA RAM size %d %s\n", size, msg); + exit(1); + } + vga_ram_sz = size * 1024 * 1024; +} + +int vga_ram_size(void) +{ + return vga_ram_sz; +} + static uint32_t vbe_ioport_read_data(void *opaque, uint32_t addr) { VGACommonState *s = opaque; uint32_t val; + vga_ram_info_t vs = vbe_ram_info(s->vram_size); if (s->vbe_index < VBE_DISPI_INDEX_NB) { if (s->vbe_regs[VBE_DISPI_INDEX_ENABLE] & VBE_DISPI_GETCAPS) { switch(s->vbe_index) { /* XXX: do not hardcode ? */ case VBE_DISPI_INDEX_XRES: - val = VBE_DISPI_MAX_XRES; + val = vs.max_xres; break; case VBE_DISPI_INDEX_YRES: - val = VBE_DISPI_MAX_YRES; + val = vs.max_yres; break; case VBE_DISPI_INDEX_BPP: - val = VBE_DISPI_MAX_BPP; + val = vs.max_bpp; break; default: val = s->vbe_regs[s->vbe_index]; @@ -610,6 +663,7 @@ static void vbe_ioport_write_index(void *opaque, uint32_t addr, uint32_t val) static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val) { VGACommonState *s = opaque; + vga_ram_info_t vs = vbe_ram_info(s->vram_size); if (s->vbe_index <= VBE_DISPI_INDEX_NB) { #ifdef DEBUG_BOCHS_VBE @@ -626,12 +680,12 @@ static void vbe_ioport_write_data(void *opaque, uint32_t addr, uint32_t val) } break; case VBE_DISPI_INDEX_XRES: - if ((val <= VBE_DISPI_MAX_XRES) && ((val & 7) == 0)) { + if ((val <= vs.max_xres) && ((val & 7) == 0)) { s->vbe_regs[s->vbe_index] = val; } break; case VBE_DISPI_INDEX_YRES: - if (val <= VBE_DISPI_MAX_YRES) { + if (val <= vs.max_yres) { s->vbe_regs[s->vbe_index] = val; } break; diff --git a/hw/vga_int.h b/hw/vga_int.h index c1e700f..3864fba 100644 --- a/hw/vga_int.h +++ b/hw/vga_int.h @@ -24,6 +24,7 @@ #include #include "memory.h" +#include "console.h" #define MSR_COLOR_EMULATION 0x01 #define MSR_PAGE_SELECT 0x20 @@ -224,6 +225,9 @@ void vga_init_vbe(VGACommonState *s, MemoryRegion *address_space); extern const uint8_t sr_mask[8]; extern const uint8_t gr_mask[16]; +void set_vga_ram_size(int size); +int vga_ram_size(void); + #define VGA_RAM_SIZE (8192 * 1024) #define VGABIOS_FILENAME "vgabios.bin" #define VGABIOS_CIRRUS_FILENAME "vgabios-cirrus.bin" diff --git a/qemu-options.hx b/qemu-options.hx index 5d2a776..00177f3 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -896,6 +896,9 @@ Disable VGA card. @end table ETEXI +DEF("vga-mem", HAS_ARG, QEMU_OPTION_vga_ram_size, + "-vga-mem megs set virtual FB size to megs MB\n", QEMU_ARCH_ALL) + DEF("full-screen", 0, QEMU_OPTION_full_screen, "-full-screen start in full screen\n", QEMU_ARCH_ALL) STEXI diff --git a/vl.c b/vl.c index 1ddb17b..66277d6 100644 --- a/vl.c +++ b/vl.c @@ -126,6 +126,7 @@ int main(int argc, char **argv) #include "hw/xen.h" #include "hw/qdev.h" #include "hw/loader.h" +#include "hw/vga_int.h" #include "bt-host.h" #include "net.h" #include "net/slirp.h" @@ -2585,6 +2586,9 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_vga: select_vgahw (optarg); break; + case QEMU_OPTION_vga_ram_size: + set_vga_ram_size(atoi(optarg)); + break; case QEMU_OPTION_g: { const char *p; -- 1.7.4.1