Skip to contentSkip to conversation

stdvga improvements

PATCH New Stefano Stabellini 1 participant 1 message Jan 13, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 stdvga improvements

This patch is the "stdvga improvements" patch to xen-unstable without any change to hvmloader (they are not needed any more).
It also moves the xc_hvm_build special pages top address from 0x100000 to 0xff000, to leave more room for the videoram.

tools/firmware/vgabios/vbe.c +12 -6
diff -r 7c788d90f39b tools/firmware/vgabios/vbe.c
@@ -37,8 +37,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
tools/firmware/vgabios/vbe.h +33 -31

72 lines not on this page · raw message

tools/firmware/vgabios/vbetables-gen.c +31 -10

57 lines not on this page · raw message

tools/firmware/vgabios/vgabios.c +3 -3
diff -r 7c788d90f39b tools/firmware/vgabios/vgabios.c
@@ -3811,9 +3811,9 @@
         for (i=0; i<format_width; i++) {
           nibble = (arg >> (4 * digit)) & 0x000f;
           if (nibble <= 9)
-            outb(0x0500, nibble + '0');
+            outb(0xe9, nibble + '0');
           else
-            outb(0x0500, (nibble - 10) + 'A');
+            outb(0xe9, (nibble - 10) + 'A');
           digit--;
           }
         in_format = 0;
@@ -3823,7 +3823,7 @@
       //  }
       }
     else {
-      outb(0x0500, c);
+      outb(0xe9, c);
       }
     s ++;
     }
tools/libxc/xc_hvm_build.c +1 -1
diff -r 7c788d90f39b tools/libxc/xc_hvm_build.c
@@ -28,7 +28,7 @@
 #define SPECIALPAGE_IDENT_PT 3
 #define SPECIALPAGE_SHINFO   4
 #define NR_SPECIAL_PAGES     5
-#define special_pfn(x) (0x100000u - NR_SPECIAL_PAGES + (x))
+#define special_pfn(x) (0xff000u - NR_SPECIAL_PAGES + (x))
 
 static void build_hvm_info(void *hvm_info_page, uint64_t mem_size)
 {
tools/python/xen/xend/XendConfig.py +1 -0
diff -r 7c788d90f39b tools/python/xen/xend/XendConfig.py
@@ -149,6 +149,7 @@
     'opengl': int,
     'soundhw': str,
     'stdvga': int,
+    'videoram': int,
     'usb': int,
     'usbdevice': str,
     'hpet': int,
tools/python/xen/xend/image.py +9 -4
diff -r 7c788d90f39b tools/python/xen/xend/image.py
@@ -264,6 +264,10 @@
             # skip vnc init if nographic is set
             ret.append('-nographic')
             return ret
+
+        vram = str(vmConfig['platform'].get('videoram',4))
+        ret.append('-videoram')
+        ret.append(vram)
 
         vnc_config = {}
         has_vnc = int(vmConfig['platform'].get('vnc', 0)) != 0
@@ -833,6 +837,7 @@
     def configure(self, vmConfig):
         HVMImageHandler.configure(self, vmConfig)
         self.vhpt = int(vmConfig['platform'].get('vhpt',  0))
+        self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024
 
     def buildDomain(self):
         xc.nvram_init(self.vm.getName(), self.vm.getDomid())
@@ -847,8 +852,8 @@
         # buffer io page, buffer pio page and memmap info page
         extra_pages = 1024 + 5
         mem_kb += extra_pages * page_kb
-        # Add 8 MiB overhead for QEMU's video RAM.
-        return mem_kb + 8192
+        mem_kb += self.vramsize
+        return mem_kb
 
     def getRequiredInitialReservation(self):
         return self.vm.getMemoryTarget()
@@ -882,6 +887,7 @@
     def configure(self, vmConfig):
         HVMImageHandler.configure(self, vmConfig)
         self.pae = int(vmConfig['platform'].get('pae',  0))
+        self.vramsize = int(vmConfig['platform'].get('videoram',4)) * 1024
 
     def buildDomain(self):
         xc.hvm_set_param(self.vm.getDomid(), HVM_PARAM_PAE_ENABLED, self.pae)
@@ -890,8 +896,7 @@
         return rc
 
     def getRequiredAvailableMemory(self, mem_kb):
-        # Add 8 MiB overhead for QEMU's video RAM.
-        return mem_kb + 8192
+        return mem_kb + self.vramsize
 
     def getRequiredInitialReservation(self):
         return self.vm.getMemoryTarget()
tools/python/xen/xm/create.py +4 -4
diff -r 7c788d90f39b tools/python/xen/xm/create.py
@@ -526,9 +526,9 @@
           use="""Try to find an unused port for the VNC server.
           Only valid when vnc=1.""")
 
-gopts.var('videoram', val='',
-          fn=set_value, default=None,
-          use="""Maximum amount of videoram PV guest can allocate
+gopts.var('videoram', val='MEMORY',
+          fn=set_int, default=4,
+          use="""Maximum amount of videoram a guest can allocate
           for frame buffer.""")
 
 gopts.var('sdl', val='',
@@ -884,7 +884,7 @@
     """Create the config for HVM devices.
     """
     args = [ 'device_model', 'pae', 'vcpus', 'boot', 'fda', 'fdb', 'timer_mode',
-             'localtime', 'serial', 'stdvga', 'isa', 'nographic', 'soundhw',
+             'localtime', 'serial', 'stdvga', 'videoram', 'isa', 'nographic', 'soundhw',
              'vnc', 'vncdisplay', 'vncunused', 'vncconsole', 'vnclisten',
              'sdl', 'display', 'xauthority', 'rtc_timeoffset', 'monitor',
              'acpi', 'apic', 'usb', 'usbdevice', 'keymap', 'pci', 'hpet',