Variable video ram size option
RFC PATCH 1/1 Variable video ram size option
These patches are "extracted" from a patch-set I made for Xen. Any xen-specific parts have been removed. The patches do away with the statically defined VGA_RAM_ SIZE and provides a new -videoram option to enable setting the amount of video ram available to the VM. Shrinking default video ram used to 4 Megs (which is all that the default Cirrus card can use, anyway - previously, there's been a "waste" of 4 megs with the statically defined 8 Megs), but allowing users to specify up to 16 Megs of vram, to support the very high resolutions such as 2560x1600x32 that are available on today's high-end displays. The vgabios patch is needed for this to work, both for the variable size video ram, and to add the new resolutions. The defines for the high resolution and wide-screen modes were taken from what is already in qemu-kvm, so getting this into qemu mainline should get qemu/kvm & xen "in sync" in this regard.
Special thanks to Stefano Stabellini for comments & constructive criticism, and some save/restore fixes on the Xen version of this patch-set.
I'll brace myself for reports of how this patch breaks all the non-x86 architectures that qemu emulates... :)
Regards,
Trolle
vbe.c +12 -6
@@ -38,8 +38,6 @@#include "vbe.h" #include "vbetables.h" -#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64) -// The current OEM Software Revision of this VBE Bios #define VBE_OEM_SOFTWARE_REV 0x0002;
@@ -821,7 +819,8 @@ vbe_info_block.VideoModePtr_Off=DI +34 ;// VBE Total Memory (in 64b blocks) - vbe_info_block.TotalMemory =VBE_TOTAL_VIDEO_MEMORY_DIV_64K ; +outw (VBE_DISPI_IOPORT_INDEX ,VBE_DISPI_INDEX_VIDEO_MEMORY_64K ); + vbe_info_block.TotalMemory =inw (VBE_DISPI_IOPORT_DATA );if (vbe2_info) {
@@ -846,7 +845,8 @@ do { if ((cur_info->info.XResolution <= dispi_get_max_xres()) && - (cur_info->info.BitsPerPixel <= dispi_get_max_bpp())) { + (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) && + (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) { #ifdef DEBUG printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode); #endif
@@ -855,7 +855,7 @@ cur_ptr+=2 ; }else {#ifdef DEBUG -printf ("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n" , cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel); +printf ("VBE mode %x (xres=%x / bpp=%02x) not supported \n" , cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);#endif } cur_info++;
@@ -913,7 +913,13 @@ info.WinFuncPtr =0xC0000000UL ; *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall); } - +outw (VBE_DISPI_IOPORT_INDEX ,VBE_DISPI_INDEX_LFB_ADDRESS_H ); + info.PhysBasePtr =inw (VBE_DISPI_IOPORT_DATA ); + info.PhysBasePtr = info.PhysBasePtr <<16 ; +#if 0 +outw (VBE_DISPI_IOPORT_INDEX ,VBE_DISPI_INDEX_LFB_ADDRESS_L ); + info.PhysBasePtr |=inw (VBE_DISPI_IOPORT_DATA ); +#endif result =0x4f ; }else
vbe.h +33 -31
72 lines not on this page · raw message
vbetables-gen.c +31 -10
57 lines not on this page · raw message
Binary files vgabios-orig/VGABIOS-lgpl-latest.bin and vgabios/VGABIOS-lgpl-latest.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.bin and vgabios/VGABIOS-lgpl-latest.cirrus.bin differ Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.debug.bin and vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin differ Binary files vgabios-orig/VGABIOS-lgpl-latest.debug.bin and vgabios/VGABIOS-lgpl-latest.debug.bin differ
hw/cirrus_vga.c +16 -3
@@ -3310,6 +3310,12 @@ 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 );
@@ -3337,10 +3343,10 @@ s->map_addr = s->map_end =0 ; s->lfb_addr = addr &TARGET_PAGE_MASK ; - s->lfb_end = ((addr +VGA_RAM_SIZE ) +TARGET_PAGE_SIZE -1 ) &TARGET_PAGE_MASK ; + s->lfb_end = ((addr + s->vram_size) +TARGET_PAGE_SIZE -1 ) &TARGET_PAGE_MASK ;/* account for overflow */ -if (s->lfb_end < addr +VGA_RAM_SIZE ) - s->lfb_end = addr +VGA_RAM_SIZE ; +if (s->lfb_end < addr + s->vram_size) + s->lfb_end = addr + s->vram_size; } static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
@@ -3378,6 +3384,13 @@/* 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 );
hw/mips_jazz.c +2 -2
@@ -292,7 +292,7 @@ .name = "magnum", .desc = "MIPS Magnum", .init = mips_magnum_init, - .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = MAGNUM_BIOS_SIZE, .nodisk_ok = 1, .use_scsi = 1, };
@@ -301,7 +301,7 @@ .name = "pica61", .desc = "Acer Pica 61", .init = mips_pica61_init, - .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = MAGNUM_BIOS_SIZE, .nodisk_ok = 1, .use_scsi = 1, };
hw/mips_malta.c +1 -1
@@ -949,6 +949,6 @@ .name = "malta", .desc = "MIPS Malta Core LV", .init = mips_malta_init, - .ram_require = VGA_RAM_SIZE + BIOS_SIZE, + .ram_require = BIOS_SIZE, .nodisk_ok = 1, };
hw/mips_mipssim.c +1 -1
@@ -194,6 +194,6 @@ .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, };
hw/mips_r4k.c +1 -1
@@ -287,6 +287,6 @@ .name = "mips", .desc = "mips r4k platform", .init = mips_r4k_init, - .ram_require = VGA_RAM_SIZE + BIOS_SIZE, + .ram_require = BIOS_SIZE, .nodisk_ok = 1, };
hw/pc.c +2 -2
@@ -1151,7 +1151,7 @@ .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, };
@@ -1159,6 +1159,6 @@ .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, };
hw/pc.h +0 -6
@@ -124,12 +124,6 @@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,
hw/ppc_chrp.c +1 -1
@@ -334,6 +334,6 @@ .name = "mac99", .desc = "Mac99 based PowerMAC", .init = ppc_core99_init, - .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = BIOS_SIZE, .max_cpus = MAX_CPUS, };
hw/ppc_oldworld.c +1 -1
@@ -385,6 +385,6 @@ .name = "g3beige", .desc = "Heathrow based PowerMAC", .init = ppc_heathrow_init, - .ram_require = BIOS_SIZE + VGA_BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = BIOS_SIZE + VGA_BIOS_SIZE, .max_cpus = MAX_CPUS, };
hw/ppc_prep.c +1 -1
@@ -765,6 +765,6 @@ .name = "prep", .desc = "PowerPC PREP platform", .init = ppc_prep_init, - .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = BIOS_SIZE, .max_cpus = MAX_CPUS, };
hw/sun4u.c +3 -3
@@ -600,7 +600,7 @@ .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 = 1, // XXX for now };
@@ -609,7 +609,7 @@ .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 = 1, // XXX for now };
@@ -618,7 +618,7 @@ .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 = 1, // XXX for now };
hw/vga.c +23 -1
@@ -36,6 +36,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 ,
@@ -2219,10 +2224,20 @@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 + +if (size != s->vram_size) +fprintf (stderr,"vga map with size %x != %x\n" , size, s->vram_size); } s->map_addr = addr; - s->map_end = addr +VGA_RAM_SIZE ; + s->map_end = addr + s->vram_size;vga_dirty_log_start (s); }
@@ -2469,6 +2484,12 @@if (!d)return -1 ; s = &d->vga_state; + +if ( vga_ram_size >16 *1024 *1024 ) + { +fprintf (stderr,"The stdvga/VBE device model currently has no use for more than 16 Megs of vram. Video ram reduced 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);
@@ -2483,6 +2504,7 @@ 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
hw/vga_int.h +32 -29
68 lines not on this page · raw message
vl.c +17 -3
@@ -178,7 +178,7 @@to store the VM snapshots */ DriveInfo drives_table[MAX_DRIVES +1 ];int nb_drives; -static int vga_ram_size; +static int vga_ram_size =4 *1024 *1024 ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;DisplayState display_state;int nographic;
@@ -3872,6 +3872,7 @@ " use -soundhw all to enable all of them\n"#endif "-vga [std|cirrus|vmware]\n" +"-videoram set amount of memory available to virtual video adapter\n" " select video card type\n" "-localtime set the real time clock to local time [default=utc]\n" "-full-screen start in full screen\n"
@@ -4058,6 +4059,7 @@ QEMU_OPTION_localtime, QEMU_OPTION_g, QEMU_OPTION_vga, + QEMU_OPTION_videoram, QEMU_OPTION_echr, QEMU_OPTION_monitor, QEMU_OPTION_serial,
@@ -4167,6 +4169,7 @@#endif { "localtime", 0, QEMU_OPTION_localtime }, { "vga", HAS_ARG, QEMU_OPTION_vga }, + { "videoram", HAS_ARG, QEMU_OPTION_videoram }, { "echr", HAS_ARG, QEMU_OPTION_echr }, { "monitor", HAS_ARG, QEMU_OPTION_monitor }, { "serial", HAS_ARG, QEMU_OPTION_serial },
@@ -4551,7 +4554,6 @@ 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 ;
@@ -4908,6 +4910,13 @@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 ; + } +break ;case QEMU_OPTION_g: {const char *p;
@@ -5320,7 +5329,12 @@exit (1 );/* init the memory */ - phys_ram_size = machine->ram_require & ~RAMSIZE_FIXED ; + +#ifdef TARGET_SPARC + vga_ram_size += (1024 *1024 ); +#endif + + phys_ram_size = (machine->ram_require + vga_ram_size) & ~RAMSIZE_FIXED ;if (machine->ram_require &RAMSIZE_FIXED ) {if (ram_size >0 ) {
vl.c line 5335
Quoted 3 lines · On Friday 09 January 2009 12:45:47 Trolle Selander wrote:
vl.c +3
-0+#ifdef TARGET_SPARC + vga_ram_size += (1024 * 1024); +#endif
This looks pretty bogus.
Quoted 5 lines
hw/vga.c +3
-0+if ( vga_ram_size >16 *1024 *1024 ) + { + fprintf(stderr,"The stdvga/VBE device model currently has no usefor more than 16 Megs of vram. Video ram reduced to 16M. \n"); +
vga_ram_size= 16*1024*1024;
I'm pretty sure this is wrong. VBE alows arbritary sized virtual framebuffers.
Paul
Quoted 10 lines · Paul Brook
vl.c line 5335
Quoted 4 lines · On Friday 09 January 2009 12:45:47 Trolle Selander wrote:
vl.c +3
-0+#ifdef TARGET_SPARC + vga_ram_size += (1024 *1024 ); +#endif This looks pretty bogus.
Possibly. The previous static definition added one meg to the default VGA_RAM_SIZE if TARGET_SPARC was set, and I merely wanted to retain that behavior. If someone who is familiar with the SPARC target and knows the reason for the added meg of ram in the previous code can assure that this won't be needed with the configurabe ram patch, I'll be happy to drop that bit.
Quoted 9 lines
Quoted 5 lines
hw/vga.c +3
-0+if ( vga_ram_size >16 *1024 *1024 ) + { + fprintf(stderr,"The stdvga/VBE device model currently has no usefor more than 16 Megs of vram. Video ram reduced to 16M. \n"); +
vga_ram_size= 16*1024*1024;I'm pretty sure this is wrong. VBE alows arbritary sized virtual framebuffers.
Paul
VBE does, but the stdvga/VBE device model currently cannot _make use_ of more, since there highest resolution provided is 2560x1600x32 = 16Megs. The features required to make use of VRAM that is not used for the framebuffer itself are not there, either, and hence any additional memory would just be wasted. Anyone who would want to add features to the stdvga device or to the VBE bios can easily remove or change this check.
-- Trolle
Quoted 15 lines · Trolle Selander
Quoted 13 lines · Paul Brook
vl.c line 5335
Quoted 5 lines · On Friday 09 January 2009 12:45:47 Trolle Selander wrote:
vl.c +3
-0+#ifdef TARGET_SPARC + vga_ram_size += (1024 *1024 ); +#endif This looks pretty bogus.
Quoted 6 lines
Possibly. The previous static definition added one meg to the default
VGA_RAM_SIZEifTARGET_SPARCwas set, and I merely wanted to retain that behavior. If someone who is familiar with the SPARC target and knows the reason for the added meg of ram in the previous code can assure that this won't be needed with the configurabe ram patch, I'll be happy to drop that bit.
In 24 bit mode, TCX uses a 32 bit framebuffer, 32 bit control plane (selects whether 24 bit mode or 8 bit mode is used for each pixel) and there is still the 8 bit framebuffer, all full screen (1024x768) size. This translates to 4 + 4 + 1 MB.
I think the -videoram switch should be disabled for targets with fixed framebuffer hardware in machine description or with:
#if !defined(TARGET_SPARC) || defined(TARGET_SPARC64)
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · Paul Brook
Quoted 11 lines
Quoted 4 lines
I'm pretty sure this is wrong. VBE alows arbritary sized virtual framebuffers.
VBE does, but the stdvga/VBE device model currently cannot
_makeuse_of more, since there highest resolution provided is 2560x1600x32 = 16Megs. The features required to make use of VRAM that is not used for the framebuffer itself are not there, either, and hence any additional memory would just be wasted. Anyone who would want to add features to the stdvga device or to the VBE bios can easily remove or change this check.
Quoted 5 lines
Are you sure? I haven't actually tried it, but it looks like it should all just work.
Paul
It's not a matter of it not "working", it's a matter of the extra vram not being in any way _usable_ to a guest OS or to the emulated device without additional code in the stdvga device or implentation of VBE/AF functions in vgabios. Moreover, most of the things that extra "off-screen" vram would be useful for on real hardware are not helpful in an emulated device. For example, in a real card you may want to store pixmaps, fonts, etc in off-screen vram for fast copy to avoid having to move it over a potentially "slow" bus between system ram and frambuffer ram, but in an emulated device, vram and system ram are of course all really system ram, and copies are no faster or slower, although implementing "emulation" of on-card system ram and mechanisms to copy and cache over the emulated PCI bus would add additional complexity that would only make things _slower_.
Trying hard to think up a use for more than 16 Megs in the current case, I could think of adding horizontally doubled resolutions to provide vm screens that span Xinerama multi-monitor displays without needing to emulate multi-display inside the actual VM, but I think such use cases will be rather rare, and in case someone DOES want it, all that's needed is to add those resolutions to vbetable-gen and bump the vram limit in the code to the appropriate number (say 32M for a dual 2560x1600 display).
-- Trolle
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 7 lines · Paul Brook
Quoted 2 lines
Trying hard to think up a use for more than 16 Megs in the current case,
I'm pretty sure the current device allows the guest to do page flipping (using an oversize virtual framebuffer).
Paul
I could have sworn I checked that at some point and found that it didn't, but looking at the vgabios code now it looks like it's all implemented. That definitely bumps the useable limit to 32 Megs even in the current case. Thanks for catching this, I'll add it to the fix list.
-- Trolle
Quoted 7 lines · Trolle Selander
Quoted 6 lines · Paul Brook
Quoted 2 lines
Trying hard to think up a use for more than 16 Megs in the current case,
I'm pretty sure the current device allows the guest to do page flipping (using an oversize virtual framebuffer).
Quoted 6 lines
Quoted 2 lines
Paul
I could have sworn I checked that at some point and found that it didn't, but looking at the vgabios code now it looks like it's all implemented. That definitely bumps the useable limit to 32 Megs even in the current case. Thanks for catching this, I'll add it to the fix list.
For games _triple_ buffering is a common technique when there's enough RAM.
With double buffering, after you flip away from screen 0 to screen 1, you have to pause until the next vsync before it's safe to draw a new image on screen 0.
With triple buffering, this pause isn't required which makes games (etc.) able to run at a higher average frame rate.
(More buffers can smooth the average further, which is more useful when playing video than games, because it adds latency but hides individual frame drawing time spikes. But it's not that useful. Triple buffering is relatively common though.)
So there's a use for 3 screens in the virtual framebuffer - 48 MB?
-- Jamie
Quoted 7 lines · Trolle Selander
These patches are "extracted" from a patch-set I made for Xen. Any xen-specific parts have been removed. The patches do away with the statically defined
VGA_RAM_SIZE and provides a new -videoram option to enable setting the amount of video ram available to the VM. Shrinking default video ram used to 4 Megs (which is all that the default Cirrus card can use, anyway - previously, there's been a "waste" of 4 megs with the statically defined 8 Megs), but allowing users to specify up to 16 Megs of vram, to support the very high resolutions such as 2560x1600x32 that are available on today's high-end displays. The vgabios patch is needed for this to work, both for the variable size video ram, and to add the new resolutions. The defines for the high resolution and wide-screen modes were taken from what is already in qemu-kvm, so getting this into qemu mainline should get qemu/kvm & xen "in sync" in this regard.Special thanks to Stefano Stabellini for comments & constructive criticism, and some save/restore fixes on the Xen version of this patch-set.
I'll brace myself for reports of how this patch breaks all the non-x86 architectures that qemu emulates... :)
vl.c line 184
Quoted 8 lines
vl.c +1
-1@@ -178,7 +178,7 @@to store the VM snapshots */ DriveInfo drives_table[MAX_DRIVES +1 ];int nb_drives; -static int vga_ram_size; +static int vga_ram_size =4 *1024 *1024 ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;DisplayState display_state;int nographic;
You're changing the default, which will break existing setups.
Signature · 1 line
error compiling committee.c: too many arguments to function
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Trolle Selander
These patches are "extracted" from a patch-set I made for Xen. Any xen-specific parts have been removed. The patches do away with the statically defined
VGA_RAM_SIZE and provides a new -videoram option to enable setting the amount of video ram available to the VM. Shrinking default video ram used to 4 Megs (which is all that the default Cirrus card can use, anyway - previously, there's been a "waste" of 4 megs with the statically defined 8 Megs), but allowing users to specify up to 16 Megs of vram, to support the very high resolutions such as 2560x1600x32 that are available on today's high-end displays. The vgabios patch is needed for this to work, both for the variable size video ram, and to add the new resolutions. The defines for the high resolution and wide-screen modes were taken from what is already in qemu-kvm, so getting this into qemu mainline should get qemu/kvm & xen "in sync" in this regard.Special thanks to Stefano Stabellini for comments & constructive criticism, and some save/restore fixes on the Xen version of this patch-set.
Quoted 13 lines
vl.c line 184
Quoted 10 lines
I'll brace myself for reports of how this patch breaks all the non-x86 architectures that qemu emulates... :)
vl.c +1
-1@@ -178,7 +178,7 @@to store the VM snapshots */ DriveInfo drives_table[MAX_DRIVES +1 ];int nb_drives; -static int vga_ram_size; +static int vga_ram_size =4 *1024 *1024 ;enum vga_retrace_method vga_retrace_method =VGA_RETRACE_DUMB ;DisplayState display_state;int nographic;You're changing the default, which will break existing setups.
My bad. That was actually a small xen "leftover", where the previous default for stdvga didn't matter, since VBE had never been enabled and the 8 megs allocated for it by default had never actually been used, so it was "safe" to break the default there. The probably shouldn't be a "global" default now anyway, but a separate default per emulated card - current 4 for Cirrus, and 8 for stdvga & vmware. I suppose it would be possible to also add the ability to set cirrus down to 2 megs for cirrus too - pretty much everything is already in the code to emulate the 2 meg model anyway. All things considered, I consider it rather encouraging that no one has found anything other than memory defaults & limits to remark on so far. :)
-- Trolle
RFC PATCH 1/1 Variable video ram size option - revised
In reply to Avi KivityHi all,
This is an updated version of the patch after the suggestions/discussion on the list. It also includes different handling of how the -vga option is handled internally, replacing the multiple independent-yet-mutually-exclusive xxx_vga_enabled variables with one vgahw_model variable, and also includes the -vga none option added by Stefano in the time since my last version of this patch. Further comments & testing welcome. :)
-- Trolle
hw/cirrus_vga.c +16 -3
@@ -3297,6 +3297,12 @@ 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, vga_ram_base, vga_ram_offset, vga_ram_size);cirrus_init_common (s,CIRRUS_ID_CLGD5430 ,0 );
@@ -3324,10 +3330,10 @@ s->map_addr = s->map_end =0 ; s->lfb_addr = addr &TARGET_PAGE_MASK ; - s->lfb_end = ((addr +VGA_RAM_SIZE ) +TARGET_PAGE_SIZE -1 ) &TARGET_PAGE_MASK ; + s->lfb_end = ((addr + s->vram_size) +TARGET_PAGE_SIZE -1 ) &TARGET_PAGE_MASK ;/* account for overflow */ -if (s->lfb_end < addr +VGA_RAM_SIZE ) - s->lfb_end = addr +VGA_RAM_SIZE ; +if (s->lfb_end < addr + s->vram_size) + s->lfb_end = addr + s->vram_size; } static void cirrus_pci_mmio_map(PCIDevice *d, int region_num,
@@ -3365,6 +3371,13 @@/* 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, vga_ram_base, vga_ram_offset, vga_ram_size);cirrus_init_common (s, device_id,1 );
hw/mips_jazz.c +2 -2
@@ -293,7 +293,7 @@ .name = "magnum", .desc = "MIPS Magnum", .init = mips_magnum_init, - .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = MAGNUM_BIOS_SIZE, .nodisk_ok = 1, .use_scsi = 1, };
@@ -302,7 +302,7 @@ .name = "pica61", .desc = "Acer Pica 61", .init = mips_pica61_init, - .ram_require = MAGNUM_BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = MAGNUM_BIOS_SIZE, .nodisk_ok = 1, .use_scsi = 1, };
hw/mips_malta.c +1 -1
@@ -943,6 +943,6 @@ .name = "malta", .desc = "MIPS Malta Core LV", .init = mips_malta_init, - .ram_require = VGA_RAM_SIZE + BIOS_SIZE, + .ram_require = BIOS_SIZE, .nodisk_ok = 1, };
hw/mips_mipssim.c +1 -1
@@ -184,6 +184,6 @@ .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, };
hw/mips_r4k.c +1 -1
@@ -275,6 +275,6 @@ .name = "mips", .desc = "mips r4k platform", .init = mips_r4k_init, - .ram_require = VGA_RAM_SIZE + BIOS_SIZE, + .ram_require = BIOS_SIZE, .nodisk_ok = 1, };
hw/pc.c +50 -44
121 lines not on this page · raw message
hw/pc.h +0 -6
@@ -126,12 +126,6 @@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 (uint8_t *vga_ram_base,unsigned long vga_ram_offset,int vga_ram_size); int pci_vga_init(PCIBus *bus, uint8_t *vga_ram_base,
hw/ppc_chrp.c +1 -1
@@ -334,6 +334,6 @@ .name = "mac99", .desc = "Mac99 based PowerMAC", .init = ppc_core99_init, - .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = BIOS_SIZE, .max_cpus = MAX_CPUS, };
hw/ppc_oldworld.c +1 -1
@@ -383,6 +383,6 @@ .name = "g3beige", .desc = "Heathrow based PowerMAC", .init = ppc_heathrow_init, - .ram_require = BIOS_SIZE + VGA_BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = BIOS_SIZE + VGA_BIOS_SIZE, .max_cpus = MAX_CPUS, };
hw/ppc_prep.c +1 -1
@@ -760,6 +760,6 @@ .name = "prep", .desc = "PowerPC PREP platform", .init = ppc_prep_init, - .ram_require = BIOS_SIZE + VGA_RAM_SIZE, + .ram_require = BIOS_SIZE, .max_cpus = MAX_CPUS, };
hw/sun4u.c +3 -3
@@ -644,7 +644,7 @@ .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 = 1, // XXX for now };
@@ -653,7 +653,7 @@ .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 = 1, // XXX for now };
@@ -662,7 +662,7 @@ .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 = 1, // XXX for now };
hw/vga.c +17 -1
@@ -36,6 +36,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 ,
@@ -2246,10 +2251,20 @@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 + +if (size != s->vram_size) +fprintf (stderr,"vga map with size %x != %x\n" , size, s->vram_size); } s->map_addr = addr; - s->map_end = addr +VGA_RAM_SIZE ; + s->map_end = addr + s->vram_size;vga_dirty_log_start (s); }
@@ -2509,6 +2524,7 @@ 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
hw/vga_int.h +32 -29
68 lines not on this page · raw message
sysemu.h +5 -3
@@ -81,10 +81,12 @@/* SLIRP */ void do_info_slirp (void ); +typedef enum { +VGAHW_NONE ,VGAHW_CIRRUS ,VGAHW_STD ,VGAHW_VMWARE +}VGAHardwareModel ; + +extern VGAHardwareModel vgahw_model;extern int bios_size; -extern int cirrus_vga_enabled; -extern int std_vga_enabled; -extern int vmsvga_enabled;extern int graphic_width;extern int graphic_height;extern int graphic_depth;
vl.c +42 -15
109 lines not on this page · raw message
Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised
Quoted 16 lines · Trolle Selander
Hi all,
This is an updated version of the patch after the suggestions/discussion on the list. It also includes different handling of how the -vga option is handled internally, replacing the multiple independent-yet-mutually-exclusive
xxx_vga_enabledvariables with onevgahw_modelvariable, and also includes the -vga none option added by Stefano in the time since my last version of this patch. Further comments & testing welcome. :)vl.c +0
-0@@ -4933,6 +4930,13 @@case QEMU_OPTION_vga:select_vgahw (optarg);break ;
vl.c line 4942
Quoted 10 lines
vl.c +7
-0+case QEMU_OPTION_videoram: + { +char *ptr; + vga_ram_size =strtol (optarg,&ptr,10 ); + vga_ram_size *=1024 *1024 ; + } +break ;case QEMU_OPTION_g: {const char *p;
Rather than adding more add hoc extra parameters for VGA tunables, we should just make -vga work like the other generic device args, accepting a optional list comma separated values following it
eg
-vga cirrus,ram=32
Regards,
Daniel
Signature · 4 lines
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :| |: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
Re: [Qemu-devel] [PATCH] [RFC] Variable video ram size option - revised
Quoted 29 lines · Daniel P. Berrange
Quoted 13 lines · Trolle Selander
Hi all,
This is an updated version of the patch after the suggestions/discussion on the list. It also includes different handling of how the -vga option is handled internally, replacing the multiple independent-yet-mutually-exclusive
xxx_vga_enabledvariables with onevgahw_modelvariable, and also includes the -vga none option added by Stefano in the time since my last version of this patch. Further comments & testing welcome. :)vl.c +0
-0@@ -4933,6 +4930,13 @@case QEMU_OPTION_vga:select_vgahw (optarg);break ;vl.c line 4942
Quoted 10 lines
vl.c +7
-0+case QEMU_OPTION_videoram: + { +char *ptr; + vga_ram_size =strtol (optarg,&ptr,10 ); + vga_ram_size *=1024 *1024 ; + } +break ;case QEMU_OPTION_g: {const char *p;Rather than adding more add hoc extra parameters for VGA tunables, we should just make -vga work like the other generic device args, accepting a optional list comma separated values following it
Quoted 4 lines
eg
-vga cirrus,ram=32
Agreed.
Regards,
Anthony Liguori
Quoted 3 lines
Regards,
Daniel
[Qemu-devel] Re: [PATCH] [RFC] Variable video ram size option - revised
In reply to Trolle SelanderQuoted 8 lines · Trolle Selander
Hi all,
This is an updated version of the patch after the suggestions/discussion on the list. It also includes different handling of how the -vga option is handled internally, replacing the multiple independent-yet-mutually-exclusive
xxx_vga_enabledvariables with onevgahw_modelvariable, and also includes the -vga none option added by Stefano in the time since my last version of this patch. Further comments & testing welcome. :)-- Trolle
Signed-off-by Trolle Selander <[email protected]>
Forgot to include the vgabios patch - it remains the same as for the previous version of this patch, but I'll attach it to this thread as well to make things easier.
-- Trolle
vbe.c +12 -6
@@ -38,8 +38,6 @@#include "vbe.h" #include "vbetables.h" -#define VBE_TOTAL_VIDEO_MEMORY_DIV_64K (VBE_DISPI_TOTAL_VIDEO_MEMORY_MB*1024/64) -// The current OEM Software Revision of this VBE Bios #define VBE_OEM_SOFTWARE_REV 0x0002;
@@ -821,7 +819,8 @@ vbe_info_block.VideoModePtr_Off=DI +34 ;// VBE Total Memory (in 64b blocks) - vbe_info_block.TotalMemory =VBE_TOTAL_VIDEO_MEMORY_DIV_64K ; +outw (VBE_DISPI_IOPORT_INDEX ,VBE_DISPI_INDEX_VIDEO_MEMORY_64K ); + vbe_info_block.TotalMemory =inw (VBE_DISPI_IOPORT_DATA );if (vbe2_info) {
@@ -846,7 +845,8 @@ do { if ((cur_info->info.XResolution <= dispi_get_max_xres()) && - (cur_info->info.BitsPerPixel <= dispi_get_max_bpp())) { + (cur_info->info.BitsPerPixel <= dispi_get_max_bpp()) && + (cur_info->info.XResolution * cur_info->info.XResolution * cur_info->info.BitsPerPixel <= vbe_info_block.TotalMemory << 19 )) { #ifdef DEBUG printf("VBE found mode %x => %x\n", cur_info->mode,cur_mode); #endif
@@ -855,7 +855,7 @@ cur_ptr+=2 ; }else {#ifdef DEBUG -printf ("VBE mode %x (xres=%x / bpp=%02x) not supported by display\n" , cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel); +printf ("VBE mode %x (xres=%x / bpp=%02x) not supported \n" , cur_info->mode,cur_info->info.XResolution,cur_info->info.BitsPerPixel);#endif } cur_info++;
@@ -913,7 +913,13 @@ info.WinFuncPtr =0xC0000000UL ; *(Bit16u *)&(info.WinFuncPtr) = (Bit16u)(dispi_set_bank_farcall); } - +outw (VBE_DISPI_IOPORT_INDEX ,VBE_DISPI_INDEX_LFB_ADDRESS_H ); + info.PhysBasePtr =inw (VBE_DISPI_IOPORT_DATA ); + info.PhysBasePtr = info.PhysBasePtr <<16 ; +#if 0 +outw (VBE_DISPI_IOPORT_INDEX ,VBE_DISPI_INDEX_LFB_ADDRESS_L ); + info.PhysBasePtr |=inw (VBE_DISPI_IOPORT_DATA ); +#endif result =0x4f ; }else
vbe.h +33 -31
72 lines not on this page · raw message
vbetables-gen.c +31 -10
57 lines not on this page · raw message
Binary files vgabios-orig/VGABIOS-lgpl-latest.bin and vgabios/VGABIOS-lgpl-latest.bin differ
Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.bin and vgabios/VGABIOS-lgpl-latest.cirrus.bin differ Binary files vgabios-orig/VGABIOS-lgpl-latest.cirrus.debug.bin and vgabios/VGABIOS-lgpl-latest.cirrus.debug.bin differ Binary files vgabios-orig/VGABIOS-lgpl-latest.debug.bin and vgabios/VGABIOS-lgpl-latest.debug.bin differ